akhauriyash/Code-Regression huggingface dataset:
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ld> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
ld EPS=1e-4;
// cout << "Case #" << index << " :IMPOSSIBLE";

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n;
    cin>>n;
    V vec(n);
    rep(i,n)cin>>vec[i];
    rep(i,n)vec[i]*=1000000000+1e-5;
    map<P,ll> mp;
    rep(i,n){
       // cout<<(ll)vec[i]<<endl;
        ll reg2=0;
        while((ll)vec[i]%2==0){
            vec[i]/=2;
            reg2++;
        }
        ll reg5=0;
        while((ll)vec[i]%5==0){
            vec[i]/=5;
            reg5++;
        }
        
        if(reg2>18){
            reg2=18;
        }
        if(reg5>18){
            reg5=18;
        }
        mp[{reg2,reg5}]++;
        //cout<<reg2<<" "<<reg5<<endl;
    }
    ll res=0;
    rep(i,19){
        rep(j,19){
            rep(k,19){
                rep(l,19){
                    if(!(i+k>=18&&j+l>=18)){
                        continue;
                    }
                    if(i==k&&j==l&&mp[{i,j}]>=1){
                        res+=(mp[{i,j}])*(mp[{i,j}]-1);
                        if(mp[{i,j}]*mp[{k,l}]>=1){
                         //   cout<<"same"<<i<<" "<<j<<" "<<k<<" "<<l<<endl;
                        }
                    }else if(!(i==k&&j==l)){
                        res+=mp[{i,j}]*mp[{k,l}];
                        if(mp[{i,j}]*mp[{k,l}]>=1){
                         ///  cout<<"diff "<<i<<" "<<j<<" "<<k<<" "<<l<<endl;
                        }
                    }
                }
            }
        }
    }
    cout<<res/2<<endl;
}


Measured memory_bytes: 6316
/*
 AUTHOR : ANSHU BABU RAJPUT
 
    JAI MAA SARASWATI
    OM NAMAH SHIVAY
    JAI SHRI KRISHNA
    JAI SHRI RAM
    BHARAT MATA KI JAI
 
    #PKMKB	
    #CKMKB
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define int  long long 
#define endl    ("\n")
#define ff       first
#define ss      second
#define pb   push_back
#define pf  push_front
#define ppb   pop_back
#define ppf  pop_front
#define mp   make_pair
#define mod 1000000007
 
#define L(x)    x.length()
#define B(x)     x.begin()
#define E(x)       x.end()
#define F(x)     x.front()
#define SZ(x)     x.size()
#define CLR(x)   x.clear()
 
#define all(x)                      x.begin(),x.end()
#define sortD(x) sort(x.begin(),x.end(),greater<int>)
#define rev(x)             reverse(x.begin(),x.end())
 
#define intV vector<int>
 
#define PI          (3.141592653589)
#define PMAX     priority_queue<int>
#define PMIN             priority_queue<int,vi,greater<int>>
#define setbits(x)                   __builtin_popcountll(x)
#define zrobits(x)                        __builtin_ctzll(x)
 
#define KING(i, n) for (int(i) = 0; (i) < n; (i)++)
#define MAHAKAL(i, n) for (int(i) = n-1; (i) >= 0; (i)--)
 
#define Anshu        int t; cin>>t; while(t--)
#define SITARAM(n,type) type* input=new type[n]
 
mt19937                          rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void ViLiFY_KiNG()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt","w",stderr);
#endif
}
 
int32_t main()
{
    ViLiFY_KiNG();
    int a,b;
  cin>>a>>b;
  cout<<a*b<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin >> s;
    
    int l;
    l = s.length();
    string ans;
    for(int i=0;i<l;i++){
        if(s[i] == '0' || s[i] == '1'){
            ans += s[i];
        }else{
            if(!ans.empty())
                ans.pop_back();
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val N = readLine()!!.toLong()

    val list753 = listOf("7", "5", "3")
    val maxDigits = Math.log10(N.toDouble()).toInt() + 1

    var count = 0L
    var set = hashSetOf<Long>()
    list753.forEach { a ->

        list753.forEach { b ->

            list753.forEach { c ->

                list753.forEach { d ->

                    list753.forEach { e ->

                        list753.forEach { f ->

                            list753.forEach { g ->

                                list753.forEach { h ->
                                    list753.forEach { i ->
                                        list753.forEach { j ->
                                            val s = a + b + c + d + e + f + g + h + i + j
                                            (3..9).forEach {
                                                val sub = s.take(it)
                                                val numericSub = sub.toLong()
                                                if (!set.contains(numericSub) && numericSub <= N && sub.contains("7") && sub.contains("5") && sub.contains("3")) {
                                                    count++
                                                    set.add(numericSub)
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    println(count)
}

Measured memory_bytes: 61540
#!/usr/bin/env python3


def main():
    n = int(input())
    v = list(map(int, input().split()))
    c = list(map(int, input().split()))
    result = 0
    for i in range(n):
        if v[i] > c[i]:
            result += v[i]
            result -= c[i]
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <functional>
const int INF =1e5;
const int MOD = 1e9 + 7;
using namespace std;
typedef pair<int,int> P;
typedef long long lint;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define all(x) (x).begin(),(x).end()

int main(){
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int count=0;
    int temp=0;
    for(int i=a;i>=0;i--){
        if(x>=(500*i)){
            temp+=(500*i);
        }else{
            continue;
        }
        for(int j=b;j>=0;j--){
            if(x>=temp+(100*j)){
                temp+=(100*j);
            }else{
                continue;
            }
            if(((x-temp)/50)<=c){
                count++;
            }
            temp=(500*i);
            
        }
        temp=0;
    }

    cout<<count<<endl;
    return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan=new Scanner(System.in);
		int d=scan.nextInt();
		if(d==25) {
			System.out.println("Christmas");
		}
		else if(d==24) {
			System.out.println("Christmas Eve");
		}
		else if(d==23) {
			System.out.println("Christmas Eve Eve");
		}
		else if(d==22) {
			System.out.println("Christmas Eve Eve Eve");
		}
	}

}


Measured memory_bytes: 35676
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};


int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);

    ll a,b,c,d,m,n,maxi=0,f=0,g=0,mini=INF,sum=0;
    ll k;
    string str,stra;
    ll l[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
    cin>>n;
    cout<<l[n-1]<<endl;

    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
long get(int a,int b,int c,int d)
{
	long ret=a*1000000000L+b*1000000L+c*1000L+d;
	ret=min(ret,b*1000000000L+c*1000000L+d*1000L+a);
	ret=min(ret,c*1000000000L+d*1000000L+a*1000L+b);
	ret=min(ret,d*1000000000L+a*1000000L+b*1000L+c);
	return ret;
}
map<long,set<int> >M;
int a[400],b[400],c[400],d[400];
int N;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		M[get(a[i],b[i],c[i],d[i])].insert(i);
	}
	long ans=0;
	for(int i=0;i<N;i++)
	{
		for(int j=i+1;j<N;j++)
		{
			for(int r=0;r<4;r++)
			{
				swap(a[j],b[j]);
				swap(b[j],c[j]);
				swap(c[j],d[j]);
				long t[4]={
					get(b[i],a[i],b[j],a[j]),
					get(a[i],d[i],c[j],b[j]),
					get(d[i],c[i],d[j],c[j]),
					get(c[i],b[i],a[j],d[j]),
				};
				int cc[4]={1,1,1,1};
				for(int I=0;I<4;I++)for(int J=I+1;J<4;J++)
				{
					if(t[I]==t[J])cc[I]+=cc[J],cc[J]=0;
				}
				long now=1;
				for(int k=0;k<4;k++)
				{
					if(cc[k]==0)continue;
					if(M.find(t[k])==M.end())
					{
						now=0;
						break;
					}
					int C=M[t[k]].size();
					if(M[t[k]].find(i)!=M[t[k]].end())C--;
					if(M[t[k]].find(j)!=M[t[k]].end())C--;
					int L=1;
					if(t[k]==t[k]%1000*1001001001L)L=4;
					else if(t[k]==t[k]%1000000*1000001L)L=2;
					for(int l=0;l<cc[k];l++)
					{
						now=now*(C-l)*L;
					}
				}
				ans+=now;
			}
		}
	}
	cout<<ans/3<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main()
{
    double x;
    cin>>x;
    double cnt=0;
    int64_t sum = 100;

    while(sum<x)
    {
        sum = sum+ sum*0.01;
        cnt++;     
    }
  
  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 3776
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin >> a >>b;
  cout << max({a+b,a-b,a*b}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
  int a, b;
  int ans;
  cin >> a >> b;
  if ((a+b) % 2 != 0){
  	ans = (a+b)/2+1;
  }else{
    ans = (a+b)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/* Author : A110011 - 00:19 "CodeIn Hard Way" */

#include<bits/stdc++.h>

#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x
typedef long long int ll;

using namespace std;


int solve(int i,int n,int k,vector<int> &res, vector<int> &dp){
        
    if(i==n-1){
        return 0;
    }
    
    
    if(dp[i]!=-1){
        return dp[i];
    }
    
    int ans =INT_MAX;
    
    for(int j=i+1;j<min(n,i+k+1);j++ ){
         ans=min(ans,abs(res[j]-res[i])+solve(j,n,k,res,dp));
    }
    return dp[i]=ans;
    //return 0;
}

int main(){

	// For fast I/O.
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif */
    
   
    int n,k;
    cin>>n>>k;
    
    vector<int> res;
    
    
    for(int i=0;i<n;i++){
        int val;
        cin>>val;
        res.push_back(val);
    }
    
    
    vector<int> dp(n,-1);
    
    cout<<solve(0,n,k,res,dp)<<endl;
   



return 0; 
}


Measured memory_bytes: 10488
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter
from itertools import accumulate

n,m = li()
a = list(li())

acum = list(accumulate(a))
acum = [acumi%m for acumi in acum]

cnt = Counter(acum)

ans = cnt[0]
for k,v in cnt.items():
    ans += v*(v-1)//2
    
print(ans)

Measured memory_bytes: 17796
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    if(a>9||b>9){
      System.out.println(-1);
    }else{
      System.out.println(a*b);
    }
  }
}


Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
    template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    ll n, k;
    cin >> n >> k;
    vector<ll> a = inp(n);

    // ループを見る

    vector<bool> visited(n, false);

    visited[0] = true;

    int cur = 0;
    int loop = 0;
    vector<int> num(n, 0);
    bool end = false;

    int ans = 0;

    rep(i, k) {
        cur = a[cur] - 1;
        if (visited[cur]) {
            loop = i + 1;
            break;
        }
        visited[cur] = true;
        num[cur] = i + 1;
        if (i == k - 1) {
            end = true;
            ans = cur + 1;
        }
    }

    if (end) {
        Cout(ans);
        return 0;
    }

    loop -= num[cur];
    k -= num[cur];
    k %= loop;
    rep(i, k) {
        cur = a[cur] - 1;
    }

    Cout(cur + 1);

    return 0;
}


Measured memory_bytes: 5636
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    ll N, x;
    cin >> N >> x;
    
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    
    vector<vector<int>> b(N, vector<int>(N, 0));
    ll ans = 1LL << 62;
    for(ll k = 0; k < N; k++) {
        ll sum = 0;
        for(int i = 0; i < N; i++) {
            if (k == 0) {
                b[i][k] = A[i];
            } else {
                b[i][k] = min(b[(i + N - 1) % N][(k + N - 1) % N], A[i]);
            }
            sum += b[i][k];
        }
        ans = min(ans, sum + k * x);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;

int main()
{
  string s;
  cin >> s;
  if (s == "RRR")
  {
    cout << 3 << endl;
  }
  else if (s == "RRS" || s == "SRR")
  {
    cout << 2 << endl;
  }
  else if (s == "SSS")
  {
    cout << 0 << endl;
  }
  else
  {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3596
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ll  long long
#define ull unsigned long long 
#define ff first 
#define ss second
#define eb(x) emplace_back(x)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define testcase(t) int t;cin>>t;while(t--)
#define mp(x,y) make_pair(x,y)
#define in(x) insert(x)
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<=(b);i++)
#define nrep(i,a,b)  for (__typeof((b)) i=(b);i>=(a);i--)
#define PI 3.14159265358979323846
#define SP(x) setprecision(x)
#define reflex ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define M 998244353
#define sz(a) (int)a.size()
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(x) x.resize(distance(x.begin(), unique(all(x))))
#define mem(arr,val) memset(arr,val,sizeof(arr)) //For "0" and "-1"                  
#define inp0(a,n) rep(i,0,n-1) cin>>a[i];
#define inp1(a,n) rep(i,1,n) cin>>a[i]; 
#define prll(x) printf("%lld",x)
#define nth_ele(v,n) nth_element(v.begin(), v.begin()+n ,v.end())//O(N)
#define DEBUG(x) cerr << (#x) << ": " << (x) << endl
#define DEBUGV(x) for(auto IT:x) cout<<IT.ff<<" "<<IT.ss<<endl; cout<<endl;
#define minheap priority_queue <int, vector<int>, greater<int>>
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll gcd(ll n1, ll n2){if(n2!=0) return gcd(n2, n1%n2);else return n1;}
ll powerM(ll a,ll b){if(b==0) return 1LL;  if(b==1) return a%M; ll x=powerM(a,b/2)%M; if(b&1){return ((((a%M)*(x%M))%M)*(x%M))%M;}return ((x%M)*(x%M))%M;}
ll power(ll a,ll b){if(b==0) return 1;  if(b==1) return a; ll x=power(a,b/2); if(b&1){return ((((a)*(x)))*(x));}return ((x)*(x));}
 
const ll INF = (ll)2e18+77; 
const int SIZE = 100005;

signed main(){
    int n;
    cin>>n;
    int rr = n%10;
    if(rr==3){
        cout<<"bon\n";
    }  
    else if(rr==0 || rr==1 || rr==6||rr==8){
        cout<<"pon\n";
    }  
        
    else cout<<"hon\n"; 
} 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#define DEBUG

using namespace std;
struct node {
    int id, point;
} node[1<<18];
int n, a[131073];

void add(int id, int x)
{
    id=n-1+id;
    node[id].point+=x;

    while (id>0) {
        id=(id-1)/2;
        int c1=2*id+1, c2=2*id+2;
        if (node[c1].point>=node[c2].point)
            node[id]=node[c1];
        else
            node[id]=node[c2];
    }
}

void print()
{
#ifdef DEBUG
    int k=1;
    int x=0;
    while (true) {
        for(int i=0;i<k;++i) printf("(%d %d)", node[x+i].id, node[x+i].point);
        puts("");
        x+=k;
        k<<=1;
        if (x>=n) break;
    }
    puts("");
#endif
}

int main()
{
    int m, r, l;
    scanf("%d%d%d", &m, &r, &l);
    n=1;
    while (n<m) n<<=1;
    for(int i=0;i<m;++i) node[n-1+i].id=i;

    int pt=0;
    for(int i=0;i<r;++i) {
        int d, t, x;
        scanf("%d%d%d", &d, &t, &x);

        if (pt<t) {
            int id=node[0].id;
            a[id]+=t-pt;
        }
        add(d-1, x);
        print();
        pt=t;
    }
    print();
    a[node[0].id]+=l-pt;
#ifdef DEBUG
    for(int i=0;i<n;++i) printf("%d ", a[i]); puts("");
#endif
    printf("%d\n", 1+(max_element(a, a+n)-a));
}

Measured memory_bytes: 3168
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, = map(int, input().split())
S = [ord(v) - ord("a") for v in input().strip()]
N, = map(int, input().split())

for i in range(len(S)):
    c = 26 - S[i]
    if S[i] == 0:
        continue
    if c <= N:
        N -= c
        S[i] = 0

S[-1] += N % 26

print("".join([chr(ord("a") + v) for v in S]))

Measured memory_bytes: 5084
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>-
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define clr(a,x) memset(a,x,sizeof(a))
#define input(x) freopen(x".in","r",stdin)
#define output(x) freopen(x".in"",w",stdout)
#define file(x) input(x),output(x)
using namespace std;

const int N=400005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x+=y;if(x>=mod) x-=mod;}
inline void read(int &x){
	x=0;char ch=getchar();
	while(ch>'9'||ch<'0') ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
}

int n,m,A,B,a[N];
ll sum[N],dp[N][2];
struct front{
	ll c[N];
	void clear(){for(int i=1;i<=n;i++) c[i]=1ll<<60;}
	void ch(int x,ll y){
		while(x<=n) gmin(c[x],y),x+=x&-x;
	}
	ll get(int x){
		ll ans=1ll<<60;
		while(x) gmin(ans,c[x]),x-=x&-x;
		return ans;
	}
}fr[2];
struct back{
	ll c[N];
	void clear(){for(int i=1;i<=n;i++) c[i]=1ll<<60;}
	void ch(int x,ll y){
		while(x) gmin(c[x],y),x-=x&-x;
	}
	ll get(int x){
		ll ans=1ll<<60;
		while(x<=n) gmin(ans,c[x]),x+=x&-x;
		return ans;
	}
}bk[2];

int main(){
	scanf("%d%d%d%d",&n,&m,&A,&B);
	for(int i=1;i<=m;i++) scanf("%d",&a[i]);
	for(int i=2;i<=m;i++) sum[i]=sum[i-1]+abs(a[i]-a[i-1]);
	for(int j=0;j<2;j++) fr[j].clear(),bk[j].clear();
	fr[0].ch(B,-B+abs(a[1]-A)),fr[1].ch(A,-A+abs(a[1]-B));
	bk[0].ch(B,B+abs(a[1]-A)),bk[1].ch(A,A+abs(a[1]-B));
	for(int i=1;i<m;i++){
		for(int j=0;j<2;j++){
			dp[i][j]=min(fr[j^1].get(a[i+1])+a[i+1]+sum[i],bk[j^1].get(a[i+1])-a[i+1]+sum[i]);
			fr[j].ch(a[i],dp[i][j]-a[i]-sum[i+1]);bk[j].ch(a[i],dp[i][j]+a[i]-sum[i+1]);
		}
//		printf("%d %d\n",dp[i][0],dp[i][1]);
	}
	ll ans=sum[m]+min(abs(a[1]-A),abs(a[1]-B));
	for(int i=1;i<m;i++)
		for(int j=0;j<2;j++)
			gmin(ans,sum[m]-sum[i+1]+dp[i][j^1]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 20352
from sys import setrecursionlimit
setrecursionlimit(10 ** 8)

n, k = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for j in range(n - 1)]
p = 10 ** 9 + 7

E = [[] for i in range(n + 1)]

for a, b in A:
    E[a].append(b)
    E[b].append(a)

visited = [False] * (n + 1)

def dfs(i, f, s):
    if visited[i]:
        return 1
    b = f + s
    visited[i] = True
    
    res = k - b
    s = f
    f = 1
    for v in E[i]:
        if visited[v]:
            continue
        res *= dfs(v, f, s)
        res %= p
        s += 1

    return res if res > 0 else 0

print(dfs(1, 0, 0) % p)


Measured memory_bytes: 99872
n=int(input())
s=input()
count=0
for i in range(10):
  left=s.find('0')
  if left>=0:
    mid=s[left+1:].find('0')
    if mid>=0:
      right=s[left+mid+2:].find(str(i))
      if right>=0:
        count+=1

for i in range(10,100):
  left=s.find('0')
  if left>=0:
    mid=s[left+1:].find(str(i)[0])
    if mid>=0:
      right=s[left+mid+2:].find(str(i)[1])
      if right>=0:
        count+=1

for i in range(100,1000):
  left=s.find(str(i)[0])
  if left>=0:
    mid=s[left+1:].find(str(i)[1])
    if mid>=0:
      right=s[left+mid+2:].find(str(i)[2])
      if right>=0:
        count+=1
print(count)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,n,s) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define rall(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;
int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void printpair(vector<pair<ll, ll>> vp)
{
  cout<<'['<<endl;
  rep(i,0,vp.size())
  {
    pair<ll, ll> p=vp[i];
    cout<<'{'<<p.first<<','<<p.second<<'}'<<endl;
  }
  cout<<'}'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
const long long INF = 1e12;
//------------------------------------------------------------
ll N;
void solve()
{
    cin >> N;
    set<ll> set;

    rep(i,0,N)
    {
      ll num;
      cin >>num;
      set.insert(num);
    }

    print(set.size());

    return;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;

int main(){
    int N,i=1,count=0;
    cin>>N;
    int a[N];
    for(int i=1;i<=N;++i)cin>>a[i];

        while(i<=N){
            if(a[i]%2==1)count++;
            i+=2;
        }
    cout<<count;
}

Measured memory_bytes: 3160
#include <iostream>
using namespace std;
#define h for(int i = 1; i < 14; i++)
int S[14], H[14], C[14], D[14];
int main() {
	int a, x;
	char y;
	cin >> a;
	for (int i = 0; i < a; i++) {
	    cin >> y >> x;
	    if (y == 'S') S[x]++;
	    if (y == 'H') H[x]++;
	    if (y == 'C') C[x]++;
	    if (y == 'D') D[x]++;
	}
	h {
	    if (S[i] == 0) cout << "S " << i << endl;
	}
	h {
	    if (H[i] == 0) cout << "H " << i << endl;
	}
	h {
	    if (C[i] == 0) cout << "C " << i << endl;
	}
	h {
	    if (D[i] == 0) cout << "D " << i << endl;
	}
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>

using namespace std;

typedef long long ll;

const ll prime = 10000000000 + 7;

/*
vector<int> z_algorithm(const string& s) {
	vector<int> prefix(s.size());
	for (int i = 1, j = 0; i < s.size(); i++)
	{
		if (i + prefix[i - j] < j + prefix[j]) {
			prefix[i] = prefix[i - j];
		}
	}
}
*/

struct UnionFind {
	vector<ll> par;
	vector<ll> rank;

	UnionFind(ll n) {
		par = vector<ll>(n);
		rank = vector<ll>(n);
		for (ll i = 0; i < n; i++)
		{
			par[i] = i;
			rank[i] = 0;
		}
	}

	ll root(ll x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return root(par[x]);
		}
	}

	bool is_same(ll x, ll y) {
		return (root(x) == root(y));
	}

	void connect(ll x, ll y) {
		if (!is_same(x, y)) {
			ll x1, y1;
			x1 = root(x);
			y1 = root(y);
			if (rank[x1] < rank[y1]) {
				par[x1] = y1;
			}
			else if (rank[x1] > rank[y1]) {
				par[y1] = x1;
			}
			else {
				par[x1] = y1;
				rank[y1]++;
			}
		}
	}
};

int main() {

	ll a, b;
	cin >> a >> b;
	if (1 <= min(a, b) and max(a, b) <= 9) {
		cout << (a * b) << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 888
h, w, k = map(int, input().split())
ar = [list(map(int, input())) for _ in range(h)]

ans = None
for i in range(2**(h - 1)):
    t = 0
    to_add = [0]
    for a in range(h - 1):
        if i & (2**a):
            t += 1
        to_add.append(t)
    n_h = t
    n_w = 0
    zz = [0 for _ in range(n_h + 1)]
    cnts = zz.copy()
    is_new = True
    is_fail = False
    for x in range(w):
        is_over = False
        for y in range(h):
            z = to_add[y]
            cnts[z] += ar[y][x]
            if cnts[z] > k:
                is_over = True
                break
        if is_over:
            n_w += 1
            if ans is not None and ans <= n_h + n_w:
                break
            cnts = zz.copy()
            for y in range(h):
                z = to_add[y]
                cnts[z] += ar[y][x]
                if cnts[z] > k:
                    is_fail = True
                    break
            if is_fail:
                break
    if not is_fail and (ans is None or ans > n_h + n_w):
        ans = n_h + n_w
print(ans)


Measured memory_bytes: 3188
program abc
	implicit none
	integer :: i,j,n,m,y
	integer :: aij(3,3)=0,xij(3,3)=0
	integer :: bn(10)=0
    
	do i = 1, 3
		read(*,*) (aij(i,j),j=1,3)
	enddo 
	read(*,*) n
	do m = 1, n
		read(*,*) bn(m)
		do i = 1, 3
		do j = 1, 3
			if(bn(m) == aij(i,j)) then
				xij(i,j) = 1
			endif
		enddo
		enddo
	enddo

	y = 0

	if(xij(1,1) + xij(1,2) + xij(1,3) == 3) y = 1
	if(xij(2,1) + xij(2,2) + xij(2,3) == 3) y = 1
	if(xij(3,1) + xij(3,2) + xij(3,3) == 3) y = 1 

	if(xij(1,1) + xij(2,1) + xij(3,1) == 3) y = 1
	if(xij(1,2) + xij(2,2) + xij(3,2) == 3) y = 1
	if(xij(1,3) + xij(2,3) + xij(3,3) == 3) y = 1

	if(xij(1,1) + xij(2,2) + xij(3,3) == 3) y = 1
	if(xij(3,1) + xij(2,2) + xij(1,3) == 3) y = 1

	if(y == 1) then
    		write(*,*) 'Yes'
	else
    		write(*,*) 'No'
	endif

end program abc

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int A = 0;
  int Z = 0;
  
  for(int i = 0; i < str.size(); i++) {
    if(str.at(i) == 'A') {
      break;
    }
    A++;
  }
  for(int i = str.size() - 1; i >= 0; i--) {
    if(str.at(i) == 'Z') {
      break;
    }
    Z++;
  }
  int res = (str.size() - Z) - A;
  
  cout << res << endl;
}


Measured memory_bytes: 640
n = gets.to_i
input = gets.chomp.split(' ').map { |v| v.to_i }
t = input[0]
a = input[1]
h = gets.chomp.split(' ').map { |v| v.to_i }

min_diff = (a - (t - h[0] * 0.006)).abs
min_idx = 0
(1...h.length).each { |i|
  diff = (a - (t - h[i] * 0.006)).abs
  if diff < min_diff
    min_diff = diff
    min_idx = i
  end
}

puts min_idx+1

Measured memory_bytes: 1788
import numpy as np

n = int(input())
arr = np.array([[int(x) for x in input().split()] for _ in range(n)])
med_a = np.median(arr[:, 0])
med_b = np.median(arr[:, 1])

if n % 2 == 0:
    print(int(med_b * 2 - med_a * 2 + 1))
else:
    print(int(med_b - med_a + 1))


Measured memory_bytes: 63408
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int A = sc.nextInt();
    
    if(X < A){
      System.out.println(0);
    }else{
      System.out.println(10);
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b;
    cin >> a >> b;
    
    if (b % a == 0)cout << a+b << endl;
    else cout << b-a << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;

int main(){
    int A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;

    int sum=0;
    int half = C*2;
    int ab = A+B;
    if(half<ab)
        if(X>Y){
            sum+= half * Y;
            if(A>half)
                sum+=half*(X-Y);
            else
                sum+=A*(X-Y);
        }else{
            sum+=half * X;
            if(B>half)
                sum+=half*(Y-X);
            else
                sum+=B*(Y-X);
        }

    else
        sum+=A*X+B*Y;


    cout<<sum;
}


Measured memory_bytes: 256
public class Hello {
    public static void Main()
    { 
        string [] inputs = System.Console.ReadLine().Split(' ');
        int a = int.Parse(inputs[0]);
        int b = int.Parse(inputs[1]);
        int c = (a * b);
        int d = (a + b) * 2;
        System.Console.WriteLine(c + " " + d);
    }
} 


Measured memory_bytes: 9156
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 100000001;
const int MAX_V = 201;
struct edge {
	int to;
	int cost;
	int step;
	edge(int _to, int _cost) {
		to = _to;
		cost = _cost;
	}
};
vector<edge> e[MAX_V];
//int d[202][8];
int t[202][202];
int best[202];
int R[9];
//void dik(int start,int r) {
//	for (size_t i = 0; i < 202; i++)
//	{
//		best[i] = INF;
//	}
//	best[start] = 0;
//	d[start][0] = 0;
//
//	queue<vector<int>> q;
//	q.push({start,0,0});
//	bool visited[201];
//	while (!q.empty())
//	{
//		vector<int> p = q.front();
//		q.pop();
//		int pos = p[0];
//		int cos = p[1];
//		int ste = p[2];
//		if (best[pos] < cos) continue;
//
//		for (size_t i = 0; i < e[pos].size(); i++)
//		{
//			edge nex = e[pos][i];
//			int ns = ste + 1;
//			if (best[nex.to] > cos + nex.cost) {
//				best[nex.to] = cos + nex.cost;
//
//				d[start][ns] = min(d[start][ns] ,cos + nex.cost);
//				q.push({ nex.to, best[nex.to],ns });
//			}
//		}
//	}
//}
bool use[9];
int r;
int rec(int deep,int v,int cost) {
	if (deep == r - 1) {
		return cost;
	}

	int res = INF;
	for (size_t i = 0; i < r; i++)
	{
		int to = R[i];
		if (!use[i] && t[v][to] < INF) {
			use[i] = true;
		 	res = min(rec(deep + 1,to, cost + t[v][to]),res);
			use[i] = false;
		}
	}
	return res;
}

void joisinostravel() {
	int n, m;
	cin >> n >> m >> r;

	for (size_t i = 0;i < r; i++)
	{
		cin >> R[i];
	}

	for (int i = 0; i < 202; i++)
	{
		for (int j = 0; j < 202; j++)
		{
			t[i][j] = INF;
		}
	}


	for (size_t i = 0; i < m; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;
		t[a][b] = c;
		t[b][a] = c;
		//e[a].push_back(edge(b, c));
		//e[b].push_back(edge(a, c));
	}

	for (size_t i = 1; i <= n; i++)
	{
		for (size_t f = 1; f <= n; f++)
		{
			for (size_t to = 1; to <= n; to++)
			{
				if (f == to) continue;

				t[f][to] = min(t[f][to], t[f][i] + t[i][to]);
			}
		}
	}

	int best = INF;

	for (size_t i = 0; i < r; i++)
	{
		use[i] = true;
		best = min(best, rec(0,R[i], 0));
		use[i] = false;
	}
	cout << best << endl;
}

int main() {
	joisinostravel();
	return 0;
}



Measured memory_bytes: 384
import sys
input=sys.stdin.readline

def grid(y,x,mp):
    mod=10**9+7
    dp=[[0]*x for _ in range(y)]
    dp[0][0]=1
    for h in range(y):
        for w in range(x):
            if mp[h][w]=='.':
                if 1<=h<y and 1<=w<x:
                    dp[h][w]=((dp[h][w-1]+dp[h-1][w])%mod)
                elif h==0 and 1<=w<x:
                    dp[h][w]=(dp[h][w-1]%mod)
                elif 1<=h<y and w==0:
                    dp[h][w]=(dp[h-1][w]%mod)
    return dp[y-1][x-1]


H,W=map(int,input().split())
mp=[list(input()) for _ in range(H)]
print(grid(H,W,mp))

Measured memory_bytes: 56076
arr = Array.new(4){Array.new(3,10 ** 10)}
gets.to_i.times do
  b, f, r, v = gets.split(" ").map(&:to_i)
  arr[b - 1][f - 1] += v * 10 ** (r - 1)
end
arr.each_with_index{|item, idx|
  item.each{|i|puts " " + i.to_s.split(//)[1..-1].reverse.join(" ")}
  puts "#" * 20 if idx != arr.length - 1
  }
  

Measured memory_bytes: 6124
#include <stdio.h>

int main()
{
    int value[100];
    int i,num;
    int max,min,tmp;

    scanf("%d",&num);
    scanf("%d",&value[0]);
    max = value[0];
    min = value[0];

    for(i=1;i<num;i++){
        scanf("%d",&value[i]);
        if(value[i] < min){
            min = value[i];
        }else if(value[i] > max){
            max = value[i];
        }
    }

    printf("%d",max-min);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;
#define rep(i,s,e) for(int i = (s); i < (e); ++i)
#define per(i,s,e) for(int i = (s)-1; i >= e; --i)

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<typename T, size_t N, typename U>
void Fill(T (&a)[N], const U&v){
    std::fill((U*)a,(U*)(a+N),v);
}

int main(){
  int a, b; cin >> a >> b;
  cout << max(0,a-2*b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        if (a % 2 == 0 && (a % 3 != 0 && a % 5 != 0)) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define FORD(i,a,b) for(int i = (a); i >= (b); i--)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define M_PI 3.14159265358979323846
template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
	while (*sdbg != ',')cerr << *sdbg++; cerr << '=' << h << ','; _dbg(sdbg + 1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
	os << "["; for (auto& vv : V) os << vv << ","; os << "]";
	return os;
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
	return os << "(" << P.st << "," << P.nd << ")";
}


#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif

int32_t main(int32_t argc, char ** argv) {
	ios_base::sync_with_stdio(0);
	int h, w;
	cin >> h >> w;
	vector<int> co(26);
	REP(i, h) {
		string s;
		cin >> s;
		for (char c : s) {
			co[c - 'a']++;
		}
	}
	bool needSingle = 0;
	int needPairs = 0;
	int needQuads = 0;
	if ((h & 1) && (w & 1)) {
		needSingle = 1;
		REP(i, 26) {
			if (co[i] & 1) {
				co[i]--;
				needSingle = 0;
				break;
			}
		}
	}
	
	if (h & 1) {
		h--;
		needPairs += w / 2;
	}
	if (w & 1) {
		w--;
		needPairs += h / 2;
	}
	needQuads = h / 2 * w / 2;
	REP(i, 26) {
		int chop = min(needQuads, co[i] / 4);
		co[i] -= chop * 4;
		needQuads -= chop;
		chop = min(needPairs, co[i] / 2);
		co[i] -= chop * 2;
		needPairs -= chop;
	}
	if (needPairs || needQuads || needSingle) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
	return 0;
no:
	cout << "No";
}

Measured memory_bytes: 256
import java.util.*;

//クラス名をMainに変える
public class Main{
	public static void main(String[] args) {

		// input
		Scanner scan = new Scanner(System.in);
		String sa = scan.next();
		String sb = scan.next();
		String sc = scan.next();

		scan.close();

		char[] SequenceA = sa.toCharArray();
		char[] SequenceB = sb.toCharArray();
		char[] SequenceC = sc.toCharArray();

		char player = 'a';
		int discardcardA = 0;
		int discardcardB = 0;
		int discardcardC = 0;

		char res = 'd';

		boolean flag = true;
		do {
			// update
			if (player == 'a') {

				if (SequenceA.length == discardcardA) {
					res = 'A';
					flag = false;
				} else {

					player = SequenceA[discardcardA];
					discardcardA++;
				}
			} else if (player == 'b') {
				if (SequenceB.length == discardcardB) {
					res = 'B';
					flag = false;
				} else {

					player = SequenceB[discardcardB];
					discardcardB++;
				}
			} else if (player == 'c') {
				if (SequenceC.length == discardcardC) {
					res = 'C';
					flag = false;
				} else {

					player = SequenceC[discardcardC];
					discardcardC++;
				}
			}
		} while (flag == true);

		// output
		System.out.println(res);
	}
}

Measured memory_bytes: 9428
#include<bits/stdc++.h>
using namespace std;
int h,w;
long long ans=0;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
bool vis[405][405];
char a[405][405];
pair<int,int> dfs(int x,int y)
{
    pair<int,int>v;
    if(a[x][y]=='.') v.second=1,v.first=0;
    else v.second=0,v.first=1;
    for(int i=0;i<4;i++)
    {
        int xx=x+dx[i];
        int yy=y+dy[i];
        if(xx<1||xx>h||yy<1||yy>w||vis[xx][yy]||a[xx][yy]==a[x][y]) continue;
        vis[xx][yy]=true;
        pair<int,int>t=dfs(xx,yy);
        v.first+=t.first;
        v.second+=t.second;
    }
    return v;
}
int main()
{
    scanf("%d%d",&h,&w);
    for(int i=1;i<=h;i++) scanf("%s",a[i]+1);
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
        {
            if(vis[i][j]) continue;
            vis[i][j]=true;
            pair<int,int>v=dfs(i,j);
            ans+=(long long)v.first*v.second;
        }
    printf("%lld\n",ans);
}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
#define all(x) x.begin(), x.end()

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    string S, T; cin >> S >> T;
    T.pop_back();
    if(S == T) cout << "Yes" << endl;
    else cout << "No" << endl;    

    return 0;
}



Measured memory_bytes: 3660
//41
#include<iostream>

using namespace std;

int w,h;
bool imap[50][50];

void ff(int y,int x){
  imap[y][x]=false;
  for(int i=-1;i<=1;i++){
    for(int j=-1;j<=1;j++){
      int ny=y+i,nx=x+j;
      if(0<=ny&&ny<h&&0<=nx&&nx<w&&imap[ny][nx]){
	ff(ny,nx);
      }
    }
  }
}

int main(){
  for(;cin>>w>>h,w|h;){
    fill_n(&imap[0][0],50*50,false);
    for(int y=0;y<h;y++){
      for(int x=0;x<w;x++){
	cin>>imap[y][x];
      }
    }
    int ans=0;
    for(int y=0;y<h;y++){
      for(int x=0;x<w;x++){
	if(imap[y][x]){
	  ans++;
	  ff(y,x);
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  long long ans=0,n,cnt=0;
  string s;
  cin >> s;
  n=s.size();
  for(int i=n-1;i>=0;i--){
    if(s[i]=='W'){
      cnt++;
    }else{
      ans+=cnt;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;
const int mod=1000000007;
const int inv2=(mod+1)/2;
int f[5010],g[5010];
char s[5010];

int main()
{
    #ifdef waltz
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n;scanf("%d",&n);
    scanf("%s",s+1);int m=strlen(s+1);
    memset(f,0,sizeof(f));f[1]=1;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=5001;j++) g[j]=((f[j-1]+f[j-1])%mod+f[j+1])%mod;
        g[1]=(g[1]+f[1])%mod;
        memcpy(f+1,g+1,5001*sizeof(int));
    }
    int ans=f[1+m];
    for (int i=1;i<=m;i++) ans=ll(ans)*inv2%mod;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#define SORT(v) sort(v.begin(), v.end())
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <algorithm>
#include <cstdarg>
#include <cstdio>
#include <numeric>

// #include "ane.cpp"

#define INF (int)1e9
#define INFLL (long long)1e18
#define NMAX 200
#define MMAX 200
#define MOD 100000
using namespace std;

// ??????????????¢??????????????¨db_printf()??????????????????
#define DEBUG

//
//  ???????????????
//

// ????????????????????¨????????¢???
typedef pair<int, int> p;
typedef long long ll;


// ???????????°??¨printf
void db_printf(const char* format, ...){
    #ifndef DEBUG
    return;
    #endif
    va_list arg;
    va_start(arg, format);
    vprintf(format, arg);  // ????????????????????????
    va_end(arg);
}

// n?¬??????????????????????????¬¬????????°???????????????????????¨???????????????????????????
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// Union-Find Tree
class UnionFindTree{
    struct node{
        int par;
    };
    std::vector<node> T;

    public:
    void init(int num){
        T.resize(num+1);    // ignore T[0]
        for (int i = 1; i <= num; ++i)
        {
            T[i].par = i;
        }
    }
    void unite(int x, int y){
        T[find(y)].par = find(x);
    }
    int find(int x){
        if (T[x].par == x) return x;
        else return T[x].par = find(T[x].par);
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

//
// ?????????????????????
//


ll N,M,K,A,B,C,D,E;
int dp[NMAX][MMAX] = {};
UnionFindTree uft;

static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

ll ans = 0;

void solve(){
    // ?§£?????¢?????´?????????
    uft.init(N);
    for (int i = 0; i < M; ++i)
    {
        int c,x,y;
        scanf("%d%d%d", &c,&x,&y);
        if (c)
        {
            printf("%d\n", (int)(uft.same(x, y)));
        }else{
            uft.unite(x, y);
        }
    }
}
void debug(){
    // ???????????°??¨??????
}
void answer(){
    // ?§£?????????
    // printf("%lld\n", ans);
}
int main(int argc, char const *argv[])
{
    // ??\??????????????????????????????

    // Fill(dp, -1);

    scanf("%lld%lld", &N,&M);
    solve();
    #ifdef DEBUG
    debug();
    #endif
    answer();

    return 0;
}

Measured memory_bytes: 3236