akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

int A, B, C, D, E, F;

bool canAB[3001];
bool canCD[3001];

int main() {
	cin >> A >> B >> C >> D >> E >> F;
	canAB[0] = true;
	for (int i = 0; i <= F; i++) {
		if (canAB[i]) {
			if (i + A * 100 <= F)canAB[i + A * 100] = true;
			if (i + B * 100 <= F)canAB[i + B * 100] = true;
		}
	}
	canCD[0] = true;
	for (int i = 0; i <= F; i++) {
		if (canCD[i]) {
			if (i + C <= F)canCD[i + C] = true;
			if (i + D <= F)canCD[i + D] = true;
		}
	}
	int ansa = 0, ansb = 0;
	double per = 0;
	for (double i = 0; i <= F; i++) {
		if (!canAB[(int)i])continue;
		for (double j = F; j >= 0; j--) {
			if (canCD[(int)j] && F >= i + j && E >= j * 100 / i) {
				if (per < j * 100 / (i + j)) {
					per = j * 100 / (i + j);
					ansa = i + j;
					ansb = j;
				}
				break;
			}
		}
	}
	if (ansa != 0) {
		cout << ansa << " " << ansb << endl;
	}
	else cout << A * 100 << " " << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int w[10], k[10];

int main(){

	rep(i, 10)cin >> w[i];
	rep(i, 10)cin >> k[i];

	sort(w, w + 10);
	sort(k, k + 10);

	cout << w[9] + w[8] + w[7] << " " << k[9] + k[8] + k[7] << endl;

	return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	private static int n=sc.nextInt();
	private static int[] x=new int[n];
	private static int[] y=new int[n];
	public static void main (String[] args){
		for(int i=0;i<n;i++) x[i]=sc.nextInt();
		for(int i=0;i<n;i++) y[i]=sc.nextInt();
		System.out.println(cal(1));
		System.out.println(cal(2));
		System.out.println(cal(3));
		System.out.println(calf());
	}
	private static double cal(int k){
		double sum=0;
		for(int i=0;i<n;i++){
			sum=sum+Math.abs(Math.pow(x[i]-y[i],k));
		}
		return Math.pow(sum,1.0/k);
	}
	private static double calf(){
		double currentMax=Math.abs(x[0]-y[0]);
		for(int i=1;i<n;i++){
			currentMax=Math.max(Math.abs(x[i]-y[i]),currentMax);
		}
		return currentMax;
	}
}

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

using namespace std;

using ll = long long;

int main(){

    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll moves = min(k, x / d);
    k -= moves;
    x -= (moves * d);
    if(k % 2 == 0){
        cout << x;
    }else cout << abs(x - d);
    return 0;
}


Measured memory_bytes: 3600
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):

    all_sum = sum(A)
    od_sum =sum([A[i*2] for i in range((N+1)//2)])
    a = []
    a1 = (od_sum - all_sum//2)*2
    pre = a1
    a.append(a1)
    for x in range(0,N-1):
        t = (A[x] - pre//2)*2
        a.append(t)
        pre = t

    print(*a)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 22372
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,k;
  cin >> a >>b >>k;
  FOR(i,a,b+1){
      if (i<a+k || b-k<i)cout << i << endl;
  }
}


Measured memory_bytes: 256
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
ll A[200001],B[200001];
int main(){
	int N;
	scan(N);
	vll xmin,xmax;
	rep(i,N){
		scan(A[i]>>B[i]);
		xmin.push_back(A[i]);
		xmax.push_back(B[i]);
	}
	sort(ALL(xmin));
	sort(ALL(xmax));
	ll ans;
	if(N%2){
		ans=xmax[N/2]-xmin[N/2]+1;
	}
	else{
		ans=xmax[N/2-1]+xmax[N/2]-(xmin[N/2-1]+xmin[N/2])+1;
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 9760
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		A solver = new A();
		solver.solve(1, in, out);
		out.close();
	}

	static class A {
		public void solve(int testNumber, Scanner in, PrintWriter out) {
			String input = in.next();
			boolean result = false;
			for (int i = 0; i < input.length() - 1; i++) {
				if (input.charAt(i) != input.charAt(i + 1)) {
					result = true;
					break;
				}
			}

			if (result) {
				out.println("Yes");
			} else {
				out.println("No");
			}
		}

	}
}



Measured memory_bytes: 22996
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Collections;
import java.util.Arrays;
import java.lang.Math;
import java.util.PriorityQueue;
import java.util.Comparator;
import java.util.ArrayDeque;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int N = reader.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		for(int i=0; i<N; i++) {
		    A[i] = reader.nextInt();
		}
		for(int i=0; i<N; i++) {
		    B[i] = reader.nextInt();
		}
		solver(N, A, B);
	}
	
	public static void solver(int N, int[] A, int[] B) {
		// write logic
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		for(int i=0; i<N; i++) {
		    q.add(i);
		}

		long ans = 0;
		while(!q.isEmpty()) {
		    int idx = q.poll();
		    if (B[idx] == A[idx]) continue;

	        int dif = B[(N+idx-1)%N]+B[(N+idx+1)%N];
	        int loop = (B[idx]-A[idx])/dif;
	        ans += loop;
	        B[idx] -= dif*loop;
	        if (loop > 0) {
	            q.add((N+idx-1)%N);
	            q.add((N+idx+1)%N);
	        }
		}
		boolean valid = true;
		for(int i=0; i<N; i++) {
		    if (A[i] != B[i]) valid = false;
		}
		if (valid) System.out.println(ans);
		else System.out.println(-1);
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 54184
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>

using namespace std;



int main(){
    string s;
    int k;
    cin >> k;
    cin >> s;
    if(k >= s.size()){
        cout << s << endl;
        return 0;
    }
    else{
        for(int i=0;i<k;i++){
            cout << s[i];
        }
        cout << "..." << endl;
        return 0;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
inline int lowbit(int x){return x & (-x);}
int n , p[200004];
int tr[200004];
void add(int x){
	for(int i=x;i<=n;i+=lowbit(i))tr[i]++;
}
int ask(int x){
	int ans=0;
	for(int i=x;i;i-=lowbit(i))ans+=tr[i];
	return ans;
}
int main(){
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	for(int i=1;i<=n;i++){
		add(p[i]);
		int v = ask(p[i]-1);
		if(v == 0) ++ ans;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int findSumOfDigits(int n){
    int sum = 0;
    while (n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
int main() {
    int N;
    cin >> N;
    int sum = 0;
    sum = findSumOfDigits(N);

    if(N % sum ==0){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  if(n==0) cout<<0<<endl;
  else{
    vector<bool> v;
    while(n!=0){
      if(n%2==0){
        v.push_back(false);
        n=n/(-2);
      }
      else{
        v.push_back(true);
        n=(n-1)/(-2);
      }
    }
    reverse(v.begin(),v.end());
    rep(i,0,v.size()){
      if(v[i]) cout<<1;
      else cout<<0;
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

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

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n; cin>>n;
    string s; cin>>s;
    int ans=0;
    for(int i=0;i<=n-3;i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
import fractions
gcd=a[0]
l=[]
r=[]
for i in range(n):
	gcd=fractions.gcd(gcd,a[i])
	l.append(gcd)
gcd=a[-1]
for i in range(n):
	gcd=fractions.gcd(gcd,a[-i-1])
	r.append(gcd)
x=list()
x.append((r[n-2]))
for i in range(n-2):
	x.append(fractions.gcd(l[i],r[n-i-3]))
x.append((l[n-2]))
print(max(x))

Measured memory_bytes: 14524
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			int m = sc.nextInt();
			if (n == 0 && k == 0 && m == 0)
				break;
			List<Integer> stones = new ArrayList<Integer>(0);
			for (int i = 1; i < n + 1; i++)
				stones.add(i);
			int pointer = m - 1;
			stones.remove(pointer);
			while (!(stones.size() == 1)) {
				pointer = (pointer + k - 1) % stones.size();
				stones.remove(pointer);
			}
			System.out.println(stones.get(0));
		}
		sc.close();
	}
}

Measured memory_bytes: 37848
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
num=[]
for i in range(m):
    num.append(list(map(int,input().split())))
num.sort(reverse=True,key=lambda x: x[1])
cnt=0
for i in range(n):
    if cnt==m:
        break
    if num[cnt][0]==0:
        cnt+=1
    if cnt==m:
        break
    if a[i]>=num[cnt][1]:
        break
    a[i]=num[cnt][1]
    num[cnt][0]-=1
print(sum(a))


Measured memory_bytes: 32932
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const llint mod=1000000007;
const llint big=1e17+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int a,b,c,d;cin>>a>>b>>c>>d;
	cout<<min(a,b)+min(c,d)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
const ll  big =1e7+2;
 ll n,m,k;
ll pref1[big],pref2[big];
ll bsfind(ll res){
  ll low=0,high=m,ans=0;
  while(low<=high){
    ll mid=(low+high)/2;
    if(pref2[mid]<=res){
        low=mid+1;
        ans=mid;
    }
    else{high=mid-1; }
  }

  return ans;
  }
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

ll ans=0,can;
cin>>n>>m>>k;
ll x;
cin>>x;
pref1[1]=x;
for(int i=2;i<=n;++i){
        ll x;cin>>x;
    pref1[i]=pref1[i-1]+x;

    }
ll y;cin>>y;
    pref2[1]=y;
for(int i=2;i<=m;++i){
        ll x;cin>>x;
    pref2[i]=pref2[i-1]+x;

    }
for(int i=0;i<=n;++i){
    ll rest=k-pref1[i];
    if(rest<0){
        break;
    }
 
    can=bsfind(rest);
    ans=max(ans,i+can);
    }




cout<<ans;
    return 0;
}

Measured memory_bytes: 6748
import java.util.*;
public class Main{
	public static void main(String[] args){
		//N枚のうちi枚目に文字列siにはM枚のうちi枚目に文字列ti
		//文字列一つ入力
		//青いカードにそれがあれば1円
		//赤いカードの時は1円失う
		//
		//手法
		//文字列の比較はequalsを使う
		//
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String si[] = new String[n];
		int money = 0;//高橋の財産
		int countp = 0;//+のカウント
		int countm = 0;//-のカウント
		int maxresultbox = 0;
		

		for (int i = 0;i < n;i++){//解釈
			si[i] = sc.next();
		}

		int m = sc.nextInt();		
		String ti[] = new String[m];
			
		for (int i = 0;i < m;i++){
			ti[i] = sc.next();
		}//文字列受け取り

		//青1文字目に対してsi同じ文字があるか文字チェック
		for (int i = 0;i < n;i++){//Nに対して
			countp = 0;
			countm = 0;
			for(int ii = 0;ii < n;ii++){//Nの配列の比較

				if(si[i].equals(si[ii])){//文字列の一致

					countp++;
					
				}
				
			}

			for(int ii = 0;ii < m;ii++){//Mの配列の比較

				if(si[i].equals(ti[ii])){

					countm++;
					
				}
				
			}
			maxresultbox = Math.max(maxresultbox,countp-countm);
			
		}

		for (int i = 0;i < m;i++){//Mに対して
			
			countp = 0;
			countm = 0;

			for(int ii = 0;ii < n;ii++){//Nの配列の比較

				if(ti[i].equals(si[ii])){

					countp++;
					
				}
				
			}

			for(int ii = 0;ii < m;ii++){//Mの配列の比較

				if(ti[i].equals(ti[ii])){

					countm++;
					
				}
				
			}
			maxresultbox = Math.max(maxresultbox,countp-countm);			
			
		}
		
		System.out.println(maxresultbox);

	}
	
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { 1, -1, 0, 0 };
static const int dy[] = { 0, 0, 1, -1 };

int W, H, a, b, ans;
VS mp;
string str;

int gcd( int m, int n ) {
	if ( n == 0 ) return m;
	return gcd( n, m % n );
}


int main() {
	while ( ~scanf("%d %d", &W, &H) && W && H ) {
		for ( int i = 0; i < W + 2; i++ ) {
			str += "#";
		}
		ans = 0;
		mp.resize( H + 2 );
		mp[ 0 ] = str;
		mp[ H + 1 ] = str;
		for ( int i = 1; i < H + 1; i++ ) {
			cin >> str;
			str = "#" + str + "#";
			mp[ i ] = str;
			for ( int j = 1; j < W + 2; j++ ) {
				if ( mp[ i ][ j ] == '@' ) {
					a = i;
					b = j;
				}
			}
		}
		queue<PII> q;
		q.push( PII( a, b ) );
		while ( q.size() ) {
			int y = q.front().first;
			int x = q.front().second;
			if ( mp[ y ][ x ] == '#' ) {
				q.pop();
				continue;
			}
			mp[ y ][ x ] = '#';
			ans++;
			q.pop();
			for ( int i = 0; i < 4; i++ ) {
				if ( mp[ y + dy[ i ] ][ x + dx[ i ] ] != '#' ) {
					q.push( PII( y + dy[ i ], x + dx[ i ] ) );
				}
			}
		}
		printf( "%d\n", ans );
		str.clear();
		mp.clear();
	}
	return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <vector>
using namespace std; 
int main()
{
	int a,b,k;
	cin >> a >> b>> k;
	
	for(int i=a;i<=b;i++){
	    if(i<a+k||i>b-k)
	    cout << i <<endl;
	}
	
	
	
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Eating Symbols Easy
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  string s;
  cin >> s;

  int k = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '+') k++;
    else k--;
  }

  printf("%d\n", k);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	int n, m;
	cin >> n >> m;
	int l = 0,r=1e5;
	rep(i, m) {
		int a, b; cin >> a >> b;
		l = max(l, a);
		r = min(r, b);
	}
	
	if (l <= r)cout << r-l + 1;
	else cout << 0;
	return 0;
}










Measured memory_bytes: 256
#include <stdio.h>

#define MAX 10000
int bubble(int *,int);

int main(){
  int seq[MAX],len,chk=1,temp;
  int i,cnt;


  scanf("%d",&len);
  for(i=0;i<len;i++) scanf("%d",&seq[i]);
  
  /*while(chk==1){
    chk=0;
    for(i=len-1;i>=1;--i){
      if(seq[i]<seq[i-1]){
	temp=seq[i];
	seq[i]=seq[i-1];
	seq[i-1]=temp;
	chk=1;
	cnt++;
      }
    }
  }
  */
  
  cnt=bubble(seq,len);
  
  for(i=0;i<len-1;i++) printf("%d ",seq[i]);
  printf("%d\n",seq[i]);
  printf("%d\n",cnt);
  
  return 0;
}
//kannsuuka
int bubble(int *A,int len){
  int i,chk,temp,cnt=0;

  chk=1;
  while(chk==1){
    chk=0;
    for(i=len-1;i>0;i--){
      if(A[i]<A[i-1]){
	temp=A[i];
	A[i]=A[i-1];
	A[i-1]=temp;
	chk=1;
	cnt++;
      }
    }     
  }
  return cnt;
}



Measured memory_bytes: 2112
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def S(): return sys.stdin.readline().rstrip()

N,K = MI()

black = [[0]*K for _ in range(K)]
white = [[0]*K for _ in range(K)]
for _ in range(N):
    x,y,c = map(str,S().split())
    x,y = int(x),int(y)
    if ((x//K + y//K) % 2 == 0 and c == 'B') or ((x//K + y//K) % 2 == 1 and c == 'W'):
        black[x % K][y % K] += 1
    else:
        white[x % K][y % K] += 1

black_accumulate = [[0]*(K+1)] + [[0]+black[i] for i in range(K)]  # black の2次元累積和
white_accumulate = [[0]*(K+1)] + [[0]+white[i] for i in range(K)]  # white の2次元累積和
for i in range(1,K+1):
    for j in range(1,K+1):
        black_accumulate[i][j] += black_accumulate[i][j-1]
        white_accumulate[i][j] += white_accumulate[i][j-1]
for i in range(1,K+1):
    for j in range(1,K+1):
        black_accumulate[i][j] += black_accumulate[i-1][j]
        white_accumulate[i][j] += white_accumulate[i-1][j]

def f(s,t,u,v):  # black の (s,t]×(u,v] の区間和
    return black_accumulate[t][v]-black_accumulate[t][u]-black_accumulate[s][v]+black_accumulate[s][u]
def g(s,t,u,v):  # white の (s,t]×(u,v] の区間和
    return white_accumulate[t][v]-white_accumulate[t][u]-white_accumulate[s][v]+white_accumulate[s][u]

ans = 0
for i in range(1,K+1):  # 区切る位置
    for j in range(1,K+1):  # 区切る位置
        ans = max(ans,f(0,i,0,j) + f(i,K,j,K) + g(0,i,j,K) + g(i,K,0,j))
        ans = max(ans,g(0,i,0,j) + g(i,K,j,K) + f(0,i,j,K) + f(i,K,0,j))
print(ans)


Measured memory_bytes: 103016
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;
	cin >> n;
	int l;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> l;
		a[i] = l;
	}
	sort(ALL(a));
	int x = a[0];
	int counter = 1;
	for(int i = 1; i < n; i++) {
		if (x < a[i]){
			counter++;
		}
		x = a[i];
		
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 256
// -------- START : snippet -------- //

#include <bits/stdc++.h>
using namespace std;

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

// -------- START : macro -------- //

#define ll long long
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define len(c) (ll)c.size()
#define all(v) (v).begin(),(v).end()
#define lb(v,x) (lower_bound(all(v),x)-v.begin())
#define ub(v,x) (upper_bound(all(v),x)-v.begin())
#define has(c,x) (c.find(x) != c.end())
#define uniq(v) v.erase(unique(all(v)),v.end())
#define bit(k) (1LL<<(k))
#define INF int(1e9)

template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

// -------- END : macro -------- //

// -------- START : debug macro -------- //

template<class T,class U> ostream& operator<<(ostream& ost, const pair<T,U> &p) { ost << "(" << p.first << ", " << p.second << ")"; return ost; }
#define ostream_container { ost << "{"; for(const auto &t : v) { if (&t != &*v.begin()) ost << ", "; ost << t; } ost << "}"; return ost; }
template<class T> ostream& operator<<(ostream &ost, const vector<T> &v) ostream_container
template<class T> ostream& operator<<(ostream &ost, const set<T> &v) ostream_container
template<class T,class U> ostream& operator<<(ostream &ost, const map<T,U> &v) ostream_container

template<class H> void recursive_debug(string s, H h) {
    cerr << "\033[33m" << s << " = " << h << endl << "\033[m";
}
template<class H,class... T> void recursive_debug(string s, H h, T... t) {
    int comma = s.find(',');
    cerr << "\033[33m" << s.substr(0,comma) << " = " << h << ", ";
    recursive_debug(s.substr(comma+1), t...);
}
#define debug(...) recursive_debug(#__VA_ARGS__, __VA_ARGS__)

// -------- END : debug macro -------- //

pair<ll, ll> product_2_5(ll x) {
    ll p2 = 0, p5 = 0;
    while (x % 2 == 0) {
        x /= 2;
        p2++;
    }
    while (x % 5 == 0) {
        x /= 5;
        p5++;
    }
    return {p2, p5};
}
// -------- END : snippet -------- //

int main(void) {
    ll n;
    cin >> n;
    map<pair<ll, ll>, ll> mp;
    ll res = 0;
    rep(i,n) {
        string s;
        cin >> s;
        int pos = s.find('.');
        pair<ll, ll> bunsi, bunbo;
        if (pos != -1) {
            bunbo = {s.size() - pos - 1, s.size() - pos -1};
            s.erase(pos, 1);
            bunsi = product_2_5(stoll(s));
        } else {
            bunsi = product_2_5(stoll(s));
        }
        pair<ll, ll> p25 = {bunsi.first - bunbo.first, bunsi.second - bunbo.second};
        for (auto itr : mp) {
            pair<ll, ll> mp25 = itr.first;
            if (mp25.first + p25.first >= 0 && mp25.second + p25.second >= 0) {
                res += itr.second;
            }
        }
        mp[p25]++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main (){
  int N;cin >> N;
  map<string,int>M;
  for(int i=1;i<=N;i+=1){
    string s;cin>>s;
    M[s]++;
  }
  cout<<"AC x "<<M["AC"]<<endl;
  cout<<"WA x "<<M["WA"]<<endl;
  cout<<"TLE x "<<M["TLE"]<<endl;
  cout<<"RE x "<<M["RE"]<<endl;
  return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// 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 );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N);

    ll c2 = 0;
    ll c4 = 0;
    REP(i, N){
        cin >> A[i];
        if(A[i]%2 == 0) c2++;
        if(A[i]%4 == 0) c4++;
    }

    c2 = c2-c4;
    ll K = N-c2;

    if(c2 == N){
        cout << "Yes" << endl;
        return 0;
    }
    if(c2 == 0){
        if(K/2 <= c4){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
        return 0;
    }
    if((K-1)/2 < c4){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4048
//#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

//#define int long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;
using namespace std;
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;
const int N = 2e5 + 123 ,mod1 =  1e9 + 7 , mod2 =  1100101;
int n , k , a[N];
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n >> k;
	for( int i = 1 ; i <= n; i++){
		cin >> a[i];
		if(a[i] == 0)
			k-- , n-- , i--;
	}
	a[n + 1] = 0;
	n++;
	sort(a + 1, a + 1 + n);
	int pos = 0;
	for(int i = 1 ; i <= n ;i++){
		if(a[i] == 0) 
			pos = i;
	}
	int ans = 1e9 + 123;
	for(int i = 0 ; i <= k ; i++){
	 	if(pos - i > 0 && pos + k - i <= n){
			ans = min(ans , min(abs(a[pos - i]) , a[pos + k - i]) + -1 * a[pos - i] + a[pos + k - i]);
	 	}
	}
	cout << ans;
	 	
	
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = Integer.parseInt(sc.next());
		int g = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		sc.close();

		int num = 100 * r + 10 * g + b;
		if(num % 4 == 0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<pair<int, int>, null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };
const ld eps = 1e-6;

const int N = 1007;


int main() {
	fastIO;
	int n, m, k;
	cin >> n >> m >> k;
	int grid[n][m];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			char c;
			cin >> c;
			grid[i][j] = c == '1';
		}
	}
	int ans = n+m-2;
	for (int i = 0; i < (1 << (n-1)); i++) {
		vector<int> cuts;
		for (int bit = 0; bit < n-1; bit++) {
			if (i & (1 << bit)) {
				cuts.push_back(bit);
			}
		}
		cuts.push_back(n-1);
		vector<int> blocks(cuts.size(), 0);
		int vcuts = 0;
		bool skip = 0;
		for (int j = 0; j < m; j++) {
			vector<int> cols;
			int ptr = 0, curr = 0, sum = 0;
			while(ptr < (int)cuts.size()) {
				sum += grid[curr][j];
				if (curr == cuts[ptr]) {
					ptr++;
					cols.push_back(sum);
					sum = 0;
				}
				curr++;
			}
			assert(cols.size() == blocks.size());
			bool newCut = 0, valid = 1;
			for (int r = 0; r < cols.size(); r++) {
				if (cols[r] > k) {
					valid = false;
					break;
				}
				if (cols[r]+blocks[r] > k) {
					newCut = 1;
					break;
				}
			}
			if (!valid) {
				skip = 1;
				break;
			}
			if (newCut) {
				vcuts++;
				blocks = cols;
			}
			else {
				for (int r = 0; r < cols.size(); r++) {
					blocks[r] += cols[r];
				}
			}
		}
		if (skip)
			continue;
		ans = min(ans, vcuts + __builtin_popcount(i));
	}
	cout << ans;


}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main implements Runnable {
	char[] s;
	int[] a,b;

	public void solve() {
		s = next().toCharArray();

		a = new int[26];
		b = new int[1111];

		for(int i = 0;i < s.length;i++){
			a[s[i]-'a']++;
		}

		for(int i = 0;i < 26;i++){
			b[a[i]]++;
		}

		for(int i = 999;i >= 0;i-=2){
			if(b[i] > 0){
				b[i]--;
				break;
			}
		}

		int m = 0;

		for(int i = 1;i <= 1000;i+=2){
			m += b[i];
		}

		if(m%2 == 0){
			out.println(m/2);
		}else{
			out.println(m/2+1);
		}
	}

	public static void main(String[] args) {
		new Thread(null, new Main(), "", 64 * 1024 * 1024).start();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	@Override
	public void run() {
		out.flush();
		new Main().solve();
		out.close();

	}
}

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

using namespace std;

#define lc (1 + (idx << 1))
#define rc (2 + (idx << 1))
#define md ((st + nd) >> 1)
#define fi first
#define se second
#define pb push_back
typedef long long ll;

const int N = 16;
int a[N][N];
ll dp[1<<N], b[1<<N];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for (int j = 1; j < (1 << n); j++) {
		for (int u = 0; u < n; u++) {
			if (j & (1 << u)) {
				for (int v = u + 1; v < n; v++) {
					if (j & (1 << v)) {
						b[j] += a[u][v];
					}
				}
			}
		}
	}
	//memset(dp, -1, sizeof dp);
	//dp[0] = 0;
	//for (int i = 1; i <= n; i++) {
		for (int j = 1; j < (1 << n); j++) {
			int hold = j;
			do {
				//if (dp[hold] != -1) {
					b[j] = max(b[j], b[hold] + b[j^hold]);
				//}
				--hold;
				hold &= j;
			} while (hold != j);
		}
	//}
	printf("%lld", b[(1<<n)-1]);
	return 0;
}
/*
3
0 10 20
10 0 -100
20 -100 0
*/
/*
2
0 -10
-10 0
*/
/*
4
0 1000000000 1000000000 1000000000
1000000000 0 1000000000 1000000000
1000000000 1000000000 0 -1
1000000000 1000000000 -1 0
*/
/*
16
0 5 -4 -5 -8 -4 7 2 -4 0 7 0 2 -3 7 7
5 0 8 -9 3 5 2 -7 2 -7 0 -1 -4 1 -1 9
-4 8 0 -9 8 9 3 1 4 9 6 6 -6 1 8 9
-5 -9 -9 0 -7 6 4 -1 9 -3 -5 0 1 2 -4 1
-8 3 8 -7 0 -5 -9 9 1 -9 -6 -3 -8 3 4 3
-4 5 9 6 -5 0 -6 1 -2 2 0 -5 -2 3 1 2
7 2 3 4 -9 -6 0 -2 -2 -9 -3 9 -2 9 2 -5
2 -7 1 -1 9 1 -2 0 -6 0 -6 6 4 -1 -7 8
-4 2 4 9 1 -2 -2 -6 0 8 -6 -2 -4 8 7 7
0 -7 9 -3 -9 2 -9 0 8 0 0 1 -3 3 -6 -6
7 0 6 -5 -6 0 -3 -6 -6 0 0 5 7 -1 -5 3
0 -1 6 0 -3 -5 9 6 -2 1 5 0 -2 7 -8 0
2 -4 -6 1 -8 -2 -2 4 -4 -3 7 -2 0 -9 7 1
-3 1 1 2 3 3 9 -1 8 3 -1 7 -9 0 -6 -8
7 -1 8 -4 4 1 2 -7 7 -6 -5 -8 7 -6 0 -9
7 9 9 1 3 2 -5 8 7 -6 3 0 1 -8 -9 0
*/


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
using namespace std;
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod (int)1e9+7
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout<<endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;

signed main() {
	int a, p;
	cin >> a >> p;
	p += a * 3;
	cout << p / 2 << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

S = readline().rstrip()
T = readline().rstrip()
ans = 0
for i in range(len(S)):
    if S[i] != T[i]:
        ans += 1
print(ans)


Measured memory_bytes: 9884
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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 int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
///////////////////////////////////////////////////////
int a,b,k,d,e;
cin >> a >> b >> k;
if(b-a+1>=2*k){
	int i=a;
while(i<a+k){
	cout << i << endl;
    i++;
}

int j=b-k+1;
while(j<b+1){
	cout << j << endl;
	j++;
}
}
else{
	while(a<b+1){
		cout << a << endl;
		a++;
	}
}
///////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#include<cctype>
#define ll long long
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b&&a!=c || a==c&&a!=b || b==c && b!= a){
        cout << "Yes" << endl;

    }else{
    cout << "No"<<endl;
    }


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0;i<n;i++)
typedef long long int ll;

int main(){

    int n;
    string s[3];

    cin >> n >> s[0] >> s[1] >> s[2];
    int ans=0;
    for(int i=0;i<n;i++){
        if(s[0][i]==s[1][i]&&s[0][i]==s[2][i]) continue;
        else if(s[0][i]!=s[2][i]&&s[0][i]!=s[1][i]&&s[1][i]!=s[2][i]) ans+=2;
        else ans++;
    }

    cout  << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    #入力をとる
    n,a,b,c = map(int,input().split())
    moto = [int(input()) for i in range(n)]

    take = []
    take.append(a)
    take.append(b)
    take.append(c)

    mp = 10000000000
    pt= []
    #全探索
    for i in range(2**(2*n)):
        pt = []
        for j in range(n):
            if (i >> j*2)&1:
                if (i >> j*2+1)&1:
                    pt.append(3)
                else:
                    pt.append(1)
            else:
                if (i >> j*2+1)&1:
                    pt.append(2)
                else:
                    pt.append(0)       

        #keisan
        mp_tmp = 0
        all_used = True
        for k in range(3):
            if pt.count(k) == 0:
                all_used = False
                break

            sum_tmp = 0
            mp_tmp += (pt.count(k) - 1)*10
            for l in range(n):
                if pt[l] == k:
                    sum_tmp += moto[l]
            
            mp_tmp += abs(sum_tmp-take[k])

        if all_used == True:
            mp = min(mp_tmp, mp)
    print(mp)

main()

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		String str2 = sc.next();
		int Count = 0;
		for(int i = 0; i < str.length(); i++) {
			if(str.charAt(i) == str2.charAt(i)) {
				Count++;
			}
		}
		System.out.println(Count);
	}
}

Measured memory_bytes: 23380
sx,sy,tx,ty=[int(i) for i in input().split()]
ans="U"*(ty-sy)
ans+="R"*(tx-sx)
ans+="D"*(ty-sy)
ans+="L"*(tx-sx+1)
ans+="U"*(ty-sy+1)
ans+="R"*(tx-sx+1)
ans+="DR"
ans+="D"*(ty-sy+1)
ans+="L"*(tx-sx+1)
ans+="U"
print(ans)

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

int main() {
    int k;
    int x;

    cin >> k >> x;

    int all = k*2-1;
    int array[all];

    int num = k - 1;
    int cnt = 0;
    for (int i = 1; i <= num; i++) {
        array[cnt] = x - i;
        cnt++;
    }
    for (int i = 1; i <= num; i++) {
        array[cnt] = x + i;
        cnt++;
    }

    array[cnt] = x;

    std::sort(array, array + all);

    for (int i = 0; i < all-1; i++) {
        cout << array[i] << " ";
    }
    cout << array[all-1];
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (H, W, D): (usize, usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let A: Vec<Vec<usize>> = {
        let mut A = vec![];
        for _ in 0..H {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            A.push(
                line.split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect()
            );
        }
        A
    };
    let Q: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let (L, R): (Vec<usize>, Vec<usize>) = {
        let (mut L, mut R) = (vec![], vec![]);
        for _ in 0..Q {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            L.push(iter.next().unwrap().parse().unwrap());
            R.push(iter.next().unwrap().parse().unwrap());
        }
        (L, R)
    };

    let N = H * W;
    let mut X = vec![0; N + 1];
    let mut Y = vec![0; N + 1];
    for i in 0..H {
        for j in 0..W {
            let a = A[i][j];
            X[a] = j as i64;
            Y[a] = i as i64;
        }
    }
    let mut dp = vec![0; N + 1];
    for i in (D + 1)..(N + 1) { dp[i] = dp[i - D] + (X[i] - X[i - D]).abs() + (Y[i] - Y[i - D]).abs(); }

    let ans = (0..Q)
        .map(|i| (dp[R[i]] - dp[L[i]]).to_string())
        .collect::<Vec<_>>()
        .join("\n");

    println!("{}", ans);
}

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

const int mod = 1000000007;

long long solve(long long m, long long n) {
    if (n == 1) {
        return m % mod;
    }
    long long t = solve(m, n/2);
    if (n % 2 == 0) {
        return (t * t) % mod;
    }
    return (((t * t) % mod) * m) % mod;
}

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

    int m, n;
    cin >> m >> n;

    cout << solve(m, n) << endl;
}


Measured memory_bytes: 3176