akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    long int a[n];
    int i;
    for(i=0;i<n;i++) {
        cin>>a[i];
    }
    int count=0;
    int ans=INT_MIN;
    for(i=0;i<n-1;i++) {
        if(a[i]>=a[i+1]) {
            count++;
        }
        else {
            count=0;
        }
        ans=max(ans,count);
    }
    if(n>1)
        cout<<ans<<"\n";
    else
        cout<<0<<"\n";
    return 0;
}


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

int main(){
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double pi = 3.141592653589793238;
  double ans = sqrt(a * a + b * b - 2 * a * b * cos((h * 30 - m * 5.5) * M_PI / 180));
  printf("%4.10f", ans);
}


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

long long l,r,ans = INT_MAX,m = 2019;

long long mod(int a,int b)
{
	long long ans=0;
    a = a % m;
    b = b % m;
    while(b > 0)
	{
        if(b & 1) ans = ( ans + a ) % m;
        a = (a + a) % m;
        b = b >> 1;
    }
	return ans;
}

int main()
{
	cin >> l >> r;
	if(l <= 2019 && r >= 2019)
	{ 
		cout << 0;
		return 0;
	}
//	l %= m;
//	r %= m; 
	for(long long i = l;i <= r;i++)
		for(long long j = l;j < i;j++)
		{
			ans = min(ans,mod(i % m,j % m));
			if(ans == 0)
			{
				cout << ans;
				return 0;
			}
		}
	cout << ans; 
	return 0; 
} 

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

int main(){
    string a,b;
    cin >> a >> b;
    bool frag=true;

    for(int i=0;i<a.size();i++){
        if(a.at(i)==b.at(i)){
        }
        else{
            frag=false;
        }
    }
    if(frag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
#include <stdio.h>

int main()
{
  double a,b,c,d,e,f,t;
  while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF){
    t=a*e-b*d;
    printf("%.3lf %.3lf\n",(e*c-b*f)/t+0.0,(a*f-d*c)/t+0.0);
  }
  return 0;
}

Measured memory_bytes: 652
L,R=map(int,input().split())
MOD=2019
if R-L>=MOD:
  print(0)
else:
  ans=MOD
  for _a in range(L,R+1):
    a=_a%MOD
    if a==0:
      print(0)
      exit(0)
    for b in range(_a+1,R+1):
      b%=MOD
      if b==0:
        print(0)
        exit(0)
      ans=min(ans,(a*b)%MOD)
  print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
import java.lang.Math;

public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String inputN = scanner.nextLine();
		
		int n = Integer.parseInt(inputN);
		
		// 桁数
		int pow = (int)Math.log10(n) + 1;
		
		int oddPow = 0;
		for(int i=1;i<pow;i+=2){
			oddPow += pow10(i-1) * 9;
		}
		
		if(pow%2 != 0){
			oddPow += n - pow10(pow-1) + 1;
		}
		
		System.out.println(oddPow);
	}
	
	// 10のn乗
	public static int pow10(int n){
		int val = 1;
		for(int i=0;i<n;i++){
			val *= 10;
		}
		return val;
	}
}

Measured memory_bytes: 23252
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int integral(int x)
{
	int i, sum = 0;
	for(i=x; i<=600-x; i+=x){
		sum += x*i*i;
	}
	return sum;
}


int main()
{
	int d;
	
	while(scanf("%d", &d) != EOF){
		printf("%d\n", integral(d));
	}

	return 0;

}

Measured memory_bytes: 596
#include <iostream>
#include <stdio.h>
using namespace std;
#define max_t 24 * 60 * 60

int main(){
    int n;
    while( cin >> n, n ){
        int list[max_t] = {};
        while( n-- ){
            int d_h, d_m, d_s;      // the departure time
            int a_h, a_m, a_s;      // the arrival time
            //cin >> d_h >> ":" >> d_m >> ":" >> d_s;
            //cin >> a_h >> ":" >> a_m >> ":" >> a_s;
            scanf("%d:%d:%d", &d_h, &d_m, &d_s );
            scanf("%d:%d:%d", &a_h, &a_m, &a_s );
            int s, e;
            s = d_h * 60 * 60 + d_m * 60 + d_s;
            e = a_h * 60 * 60 + a_m * 60 + a_s;
            //cout << s << " " << e << endl;
            for( int i = s; i < e; i++ ){
                list[i]++;
            }
        }
        int max = 0;
        for( int i = 0; i < max_t; i++ ){
            if( max < list[i] ) max = list[i];
        }
        cout << max << endl;
    }
}

Measured memory_bytes: 1584
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int num = n;
    long total = 0;
    while(num != 0) {
      total += (num % 10);
      num /= 10;
    }
    if (n % total == 0) System.out.println("Yes");
    else System.out.println("No");
  }
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    int N, M;
    cin >> N >> M;

    int a, b;
    vector<pair<int, int>> vt(N);

    for(int i = 0; i < N; i++){
        cin >> a >> b;
        vt[i] = make_pair(a, b);
    }

    sort(vt.begin(), vt.end(), [](pair<int, int> ta, pair<int, int> tb){
        if(ta.first == tb.first){
            return ta.second > tb.second;
        }
        return ta.first < tb.first;
        }
    );

    
    int ind = 0;
    priority_queue<int> pq;
    ll ans = 0;
    for(int i = 1; i <= M; i++){
        for(int j = ind; j < vt.size() && vt[j].first <= i; j++){
            pq.push(vt[j].second);
            ind++;
        }

        if(!pq.empty()){
            ans += pq.top();
            pq.pop();
        }
    }

    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 1660
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
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 LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int p,q,r;
    
    cin >> p >> q >> r;
    
    if (p >= q && p >= r){
    
    cout << q+r << endl;
    
    }else if (q >= p && q >= r){
    
    cout << p+r << endl;
    
    }else{
    
    cout << p+q << endl;
    
    
    }

    
/////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABCK = GetLongNumArray();
            var A = ABCK[0];
            var B = ABCK[1];
            var C = ABCK[2];
            var K = ABCK[3];
            long max = 0;

            if (A <= K)
            {
                max = A;
                K = K - A;
            }
            else
            {
                max = K;
                Console.WriteLine(max);
                return;
            }

            if (B <= K)
            {
                K = K - B;
            }
            else
            {
                Console.WriteLine(max);
                return;
            }

            if (K != 0)
            {
                max = max - K;
                Console.WriteLine(max);
                return;
            }

            Console.WriteLine(max);



            //for (int i = 0; i < ABCK[3]; i++)
            //{
            //    if (A != 0)
            //    {
            //        max++;
            //        A = A - 1;
            //        continue;
            //    }

            //    if (B != 0)
            //    {
            //        B = B - 1;
            //        continue;
            //    }

            //    if (C != 0)
            //    {
            //        max--;
            //        C = C - 1;
            //        continue;
            //    }
            //}

            //Console.WriteLine(max);
        }

        private static long[] GetLongNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => long.Parse(x)).ToArray();
        }

        private static long GetLongNum()
        {
            return long.Parse(Console.ReadLine());
        }

        private static string[] GetStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static string GetString()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 28168
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;
typedef long long lint;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep0(i,n) rep(i,0,n)

int main(void){
	ios::sync_with_stdio(false);
	string S, T;
	cin >> S >> T;
	int a;
	a = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == T[i]) a++;
	}
	cout << a;
	return 0;
}

////sort Ｎ個の配列a
//sort(a, a + N); //昇順
//sort(a, a + N, greater<int>()); //降順
//
////最大公約数（ユークリッドの互除法利用）
//int gcd(int a, int b) {
//	if (a == 0) return b;
//	if (b == 0) return a;
//	int m = max(a, b);
//	int n = min(a, b);
//	if (m%n == 0) return n;
//	else return gcd(n, m%n);
//
//}
//
////最小公倍数
//int lca(int a, int b) {
//	if (a == 0) return 0;
//	if (b == 0) return 0;
//	return a * b / gcm(a, b);
//}
//
////n^k(整数)
//int pow_int(int n, int k) {
//	int re = 1;
//	for (int i = 0; i < k; i++) re *= n;
//	return re;
//}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int a, b, c, x, i, j, k, ans=0;
    scanf("%d %d %d %d", &a, &b, &c, &x);
    
    for(k=c; k>=0; k--) {
        for(j=b; j>=0; j--) {
            for(i=a; i>=0; i--) {
                if(500*i+100*j+50*k==x)
                    ans++;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void){
	char s[2];
	scanf("%s",&s);
	if( s[0] =='9'){
		printf("Yes");
		return 0;
	}
	if(s[1]=='9'){
		printf("Yes");
		return 0;
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
m=input()
s=list(m)
a=[]
n=len(s)
j=0
while (j<n):
    x=0
    if s[j] == 'R':
        y=j+1
        for k in range (j,n):
            y=k+1
            if s[k]=='S':
                y=k+1
                break
            else:
                x+=1
        a.append(x)
        j=y

    else:
        j+=1

a.sort(reverse=True)
if len(a)==0:
    print (0)
else:
    print(a[0])


Measured memory_bytes: 9068
def binarySearch(A, key):
    left = 0
    right = len(A)

    while left < right:
        mid = (left + right) / 2
        if A[mid] == key:
            return True
        elif key < A[mid]:
            right = mid
        else:
            left = mid + 1 

    return False


n = int(raw_input())
S = map(int, raw_input().split())

q = int(raw_input())
T = map(int, raw_input().split())

ans = 0

for i in T:
    if binarySearch(S, i):
        ans += 1

print ans

Measured memory_bytes: 14916
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

void preParse(int u) {
  if (u == NIL) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u) {
  if (u == NIL) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u) {
  if (u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main() {
  int i, v, l, r, root;
  scanf("%d", &n);
  for (i = 0; i < n; i ++) {
    T[i].p = NIL;
  }

  for (i = 0; i < n; i ++) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if (l != NIL) T[l].p = v;
    if (r != NIL) T[r].p = v;
  }

  for (i = 0; i < n; i ++) if (T[i].p == NIL) root = i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			int[] table = new int[3];
			int len = s.length;
			for (int i = 0; i < len; i++) {
				table[s[i]-'a']++;
			}

			for (int k = 0; k < 3; k++) {
				// a,c,b,a,c,b, ...
				int[] tmptable = Arrays.copyOf(table, 3);
				for (int i = 0; i < len; i++) {
					if (i % 3 == 0) {
						tmptable[k%3]--;
					} else if (i % 3 == 1) {
						tmptable[(k+2)%3]--;
					} else if (i % 3 == 2) {
						tmptable[(k+1)%3]--;
					}
				}
				if (check(tmptable)) {
					out.println("YES");
					return;
				}

				// a,b,c,a,b,c, ...
				tmptable = Arrays.copyOf(table, 3);
				for (int i = 0; i < len; i++) {
					if (i % 3 == 0) {
						tmptable[k%3]--;
					} else if (i % 3 == 1) {
						tmptable[(k+1)%3]--;
					} else if (i % 3 == 2) {
						tmptable[(k+2)%3]--;
					}
				}
				if (check(tmptable)) {
					out.println("YES");
					return;
				}
			}
			out.println("NO");

		}
		static boolean check(int[] table) {
			boolean ret = true;
			for (int i = 0; i < table.length-1; i++) {
				if (table[i] == 0) {
					continue;
				} else {
					ret = false;
				}
			}
			return ret;
		}
	}


	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 23252
import numpy as np

Product_Num, Limit_of_the_weight = map(int, input().split())

dp = np.zeros(Limit_of_the_weight + 1)

for i in range(Product_Num):
    w, v = map(int, input().split())
    dp[w:] = np.maximum(dp[:-w] + v, dp[w:])

print(int(np.max(dp)))


Measured memory_bytes: 15472
n,m=map(int,input().split())
a=[input() for _ in '1'*n]
b=[input() for _ in '1'*m]
for i in range(n-m+1):
	for j in range(n-m+1):
		c=[a[i+k][j:j+m]for k in range(m)]
		if b==c:print('Yes');exit()
print('No')

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

int main()
{
    int x, y, s;
    int sumx, sumy; 

    while(1)
    {
        cin >> x >> y >> s;
        if ((x == 0) && (y == 0) && (s == 0)) {
            break;
        }
        int max=0;

        for (int i = 1; i < s; i++) {
            for (int j = i; j < s; j++) {
                sumx = (i*(100+x)/100) + (j*(100+x)/100);
                if (s == sumx) {
                    sumy = (i*(100+y)/100) + (j*(100+y)/100);
                    if (sumy > max) {
                        max = sumy;
                    }
                }
            }
        }
         
        cout << max << endl;
        
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
 
#define ff first
#define ss second
#define mp make_pair
 
using namespace std;
 
typedef long long ll;

const int MOD = 1e9+7;
int v[55][55];
int n;

void add(int &a, int b) {
    a += b;
    if(a >= MOD) a-= MOD;
}

void mult(int a[55][55], int b[55][55]) {
    int c[55][55];
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++) {
            c[i][j] = 0;
            for(int k = 0; k < n; k++)
                add(c[i][j], ((ll)a[i][k]*b[k][j])%MOD);
	}
    
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            a[i][j] = c[i][j];
}

void pot(int a[55][55], ll b) {
    int r[55][55];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++)
            r[i][j] = 0;
        r[i][i] = 1;
    }
    
    while(b) {
        if(b&1) mult(r, a);
        mult(a,a);
        b/=2;
    }
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            a[i][j] = r[i][j];
}

int main() {
    ll k;
	scanf("%d%lld", &n, &k);
  	
  	for(int i = 0; i < n; i++)
      for(int j = 0; j < n; j++)
      	scanf("%d", &v[i][j]);
 
	pot(v, k);
	
	int ans = 0;
	for(int i = 0; i < n; i++)
      for(int j = 0; j < n; j++)
          add(ans, v[i][j]);
    
    printf("%d\n", ans);
	
    return 0;
}

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

int main() {
  double x,h;
  while(true) {
    cin>>x>>h;
    if(!x) break;
    cout.precision(11);
    cout<<showpoint<<x*x+2*x*sqrt(x*x/4+h*h)<<endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <cstdio>
#include <vector>
#include <set>
#include <string>
#include <iostream>


int main ()
{
    int H, A;
    int cnt = 0;

    scanf("%d %d", &H, &A);

    while(H>0)
    {
        H = H - A;
        cnt += 1;
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a%b);
}

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int A, P;
    cin >> A >> P;

    int s = P + A * 3;

    cout << s / 2 << endl;
    
}


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

long calc_gcd(long x, long y){
    if(y == 0) return x;
    return calc_gcd(y, x % y);
}

int main(){
    long long n; cin >> n;
    vector<long long>A(n);
    for(int i=0;i<n;i++){
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    //要素がすべて同じ値の時
    long ans = 0;
    for(int i=0;i<n;i++){
        ans = calc_gcd(ans, A.at(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

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

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

ll solve(){
  int hoge;cin >> hoge >> hoge;
  string s,t;cin >> s >> t;
  if(s.length()>t.length())swap(s,t);
  ll l = lcm(s.length(),t.length());

  map<int,char> mp;
  ll m;
  m = l/t.length();
  rep(i,t.length()){
    mp[m*i] = t[i];
  }
  m = l/s.length();
  rep(i,s.length()){
    if(mp.count(m*i)){
      if(mp[m*i] != s[i]) return -1;
    }
  }
  return l;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cout << solve() << endl;
  return 0;
}


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

int main()
{
    string seq;
    int m, i, h, len;

    while(1){
        cin >> seq;
        if(seq == "-") break;
        len = 0;
        for(i = 0; seq[i]; i++) len++;
        cin >> m;
        for(i = 0; i < m; i++){
            cin >> h;
            seq = seq.substr(h, len - h) + seq.substr(0, h);
        }
        cout << seq << endl;
    };

    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
	int n;
	cin >> n;
	int a;
	int ans = 35;
	for (int i = 0; i < n; i++) {
		cin >> a;
		int cnt = 0;
		while (a % 2 == 0) {
			cnt++;
			a >>= 1;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,n,k,ans=0;
    cin>>k>>n;
    int a[n];
    for(i=0;i<n;i++){cin>>a[i];}
    sort(a,a+n);
    ans=k-a[n-1]+a[0];
    for(i=1;i<n;i++){
        ans=max(ans,a[i]-a[i-1]);
    }cout<<k-ans;
    return 0;
}

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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

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

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod =  1e9 + 7;
const int N = 1e5;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
*/

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}



int main()
{
	#ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif
   	ll n,k;
   	cin>>n>>k;
   	ll arr[105] = {0};
   	for(int i=1;i<=n;i++)cin>>arr[i];

   	ll dp[100005] = {0};
   	dp[0] = 0;

   	for(int i=1;i<=k;i++)
   	{
   		for(int j=1;j<=n;j++)
   		{
   			if(i-arr[j] >= 0)
   			{
   				dp[i] = (!dp[i-arr[j]]) || dp[i];
   			}
   		}
   	}

   	if(dp[k]==1)cout << "First\n";
   	else cout << "Second\n";
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
CSF = [list(map(int, input().split())) for _ in range(n - 1)]

for i in range(n):
    ans = 0
    for c, s, f in CSF[i:]:
        if ans < s:
            ans = s
        elif ans % f != 0:
            ans += f - ans % f
        ans += c
    print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ss second
#define ff first
#define pii pair<int,int> 
#define mp make_pair()
#define ll long long
int main(){
	io
    ll int l,r;
  	cin>>l>>r;
  	
  	if(r-l>=2019){
  		cout<<0;	
  	}
  	else{
  		vector<int> arr;
  		for(ll int i=l;i<=r;i++){
  			arr.pb(i%2019);
  		}
  		vector<int> ans; 
  		for(int i=0;i<arr.size();i++){
  			for(int j=i+1;j<arr.size();j++){
  				ans.pb((arr[i]*arr[j])%2019);
  			}
  		}
  		sort(ans.begin(),ans.end());
  		cout<<ans[0];
  	}
  	
}

Measured memory_bytes: 8940
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

#define reps(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reps(i, 0, n) 

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

bool C(int m, int n, int book[], int w)
{
	int dan = 1;
	int now = 0;
	rep(i, n){
		if(now+book[i] <= w)
			now += book[i];
		else if(book[i] <= w){
			now = book[i];
			++dan;
		}
		else
			return false;
	}
	return dan <= m;	
}

int main()
{
	int m, n;
	while(scanf("%d", &m), m){
		scanf("%d", &n);
		
		int book[100];
		rep(i, n)
			scanf("%d", &book[i]);
		
		int left = 0, right = 1500000;
		while(right-left>1){
			int mid = (left + right)/2;
			if(C(m, n, book, mid))
				right = mid;
			else
				left = mid;
		}
		printf("%d\n", right);
	}
	return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll a, b,c,d;
    string S, T;
    cin >> S >> T;
    //cin >> a>>b>>c>>d;
    string answer;

    if (S < T) cout << "<" << endl;
    else if (S > T) cout << ">" << endl;
    else cout << "=" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define EPS (1e-8)
using namespace std;
typedef complex<double> point;

vector<point> CrossPoints_CC(point a,double ra,point b,double rb){
  vector<point> res;
  b-=a;
  double d= ( norm(b) + ra*ra - rb*rb ) / ( 2.0 * abs(b)  );
  double  c = sqrt( ra*ra - d*d );

  res.push_back(point(d,c));
  res.push_back(point(d,-c));  
  for(int i=0;i<(int)res.size();i++)res[i]=res[i]*b/abs(b)+a;
  return res;
}


int main(){
  point c1,c2;
  double a,b,r1,r2;
  cin>>a>>b>>r1;
  c1=point(a,b);
  cin>>a>>b>>r2;
  c2=point(a,b);
  vector<point> ans=CrossPoints_CC(c1,r1,c2,r2);
  if(ans[0].real()>ans[1].real())swap(ans[0],ans[1]);
  if(ans[0].real()==ans[1].real())
    if(ans[0].imag()>ans[1].imag())swap(ans[0],ans[1]);
  for(int i=0;i<2;i++){
    if(i)cout<<' ';
    printf("%.8f %.8f",ans[i].real(),ans[i].imag());
  }
  cout<<endl;
  return 0;
}

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

const int maxn=5005;
const int mod=1e9+7;
int n,a,b;
int f[maxn][maxn],sum[maxn],sf[maxn][maxn];

void Add(int &a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}

int main(){
	scanf("%d%d%d",&n,&a,&b);
	int ans=1;
	for(int i=1;i<=n;i++)ans=2LL*ans%mod;
	if(a<b)swap(a,b);
	f[0][0]=sf[0][0]=sum[0]=1;
	for(int i=1;i<=n;i++){
		sum[i]=sum[i-1];
		for(int j=0;j<=i&&j<a;j++){
			if(j==0){
				f[i][j]=(i<b);
				if(i>=2)Add(f[i][j],(sum[i-2]-(i-b-1<0?0:sum[i-b-1])+mod)%mod);
			}
			else{
				f[i][j]=f[i-1][j-1];
				if(i==j&&i>=b)Add(f[i][j],1);
				if(j>=b+1)Add(f[i][j],sf[i-j][j-(b+1)]);
			} 
			sf[i-j][j]=(!j?0:sf[i-j][j-1]);
			Add(sf[i-j][j],f[i][j]);
			if(j+1<a)Add(sum[i],f[i][j]);
		}
	}
	for(int i=0;i<a;i++)ans=(ans+mod-f[n][i])%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 137400
#include<iostream>
#include<string>
using namespace std;
int main() {

	int n, ans = 0;
	string a, b, c;
	cin >> n >> a >> b >> c;

	for (int i = 0; i != n; i++) {
		if (a.substr(i, 1) == b.substr(i, 1) && b.substr(i, 1) == c.substr(i, 1)) {
			//全てi番目が同じ
		}
		else {
			if (a.substr(i, 1) != b.substr(i, 1) && b.substr(i, 1) == c.substr(i, 1)) {
				ans++;
			}
			else {
				if (a.substr(i, 1) == b.substr(i, 1) && b.substr(i, 1) != c.substr(i, 1)) {
					ans++;
				}
				else {
					if (a.substr(i, 1) != b.substr(i, 1) && a.substr(i, 1) == c.substr(i, 1)) {
						ans++;
					}
					else {
						ans += 2;
					}
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;

signed main()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
	
  	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
  cin>>n;
  vector<int> v(n);
    for (int i=0;i<n;++i)
      cin>>v[i];
  int dp[n+1];
  dp[0]=0;
 	dp[1]=abs(v[1]-v[0]);
  for (int i=2;i<n;++i)
  {
    dp[i]=min(abs(v[i]-v[i-1])+dp[i-1],abs(v[i]-v[i-2])+dp[i-2]);
  }
  cout<<dp[n-1]<<endl;


}


Measured memory_bytes: 4716
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nl = readln.split.to!(int[]);
    auto N = nl[0];
    auto L = nl[1];
    
    int s, e = int.max;
    foreach (i; 0..N) {
        s += L+i;
        if (abs(L+i) < abs(e)) e = L+i;
    }
    writeln(s - e);
}

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

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  for (int i=0; i < K; i++) {
    if (i%2 == 0){
      if (A%2 == 1) {
        A--;
      }
      B += A/2;
      A -= A/2;
    } else {
      if (B%2 == 1) {
        B--;
      }
      A += B/2;
      B -= B/2;
    }
  }
  cout << A << " " << B << endl;
  return 0;
}


Measured memory_bytes: 256
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}


void solve();

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

void solve(){
    ll h,w,k;cin>>h>>w>>k;
    vector<string> c(h);
    rep(i,h)cin>>c[i];

    ll ans=0;
    rep(i,1<<h)rep(j,1<<w){
        ll cnt=0;
        rep(p,h)rep(q,w){
            if(c[p][q]=='.'||i>>p&1||j>>q&1)continue;
            cnt++;
        }
        if(cnt==k)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define inputSpeed() ios_base::sync_with_stdio(0),cin.tie(0)
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...);}
#define MOD 998244353

ll mPower(ll b, ll e) {
	ll ans = 1;
	while (e) {
		if (e&1) ans = (ans * b) % MOD;
		b = (b * b) % MOD;
		e >>= 1;
	}
	return ans;
}

int main () {
	inputSpeed();

	int N, S;
	cin >> N >> S;
	int A[N+5];
	for (int i = 0; i < N; i++) cin >> A[i];

	ll dp[N+5][S+5];
	ll inv2 = mPower(2, MOD-2);

	memset(dp, 0, sizeof(dp));
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= S; j++) {
			if (!i) {
				if (j) dp[i][j] = 0;
				else dp[i][j] = mPower(2, N);
			} else {
				dp[i][j] = (dp[i][j] + dp[i-1][j]) % MOD; // Same result from before
				if (j-A[i-1] >= 0) dp[i][j] = (dp[i][j] + ((dp[i-1][j-A[i-1]] * inv2) % MOD)) % MOD;
			}
		}
	}

	printf("%lld\n", dp[N][S]);
}


Measured memory_bytes: 74216
def main():
    H, W, K = list(map(int, input().split()))
    S = [input() for _ in range(H)]

    m = 10 * 1000
    for h in range(2 ** (H - 1)):
        T = []
        s = [0]
        c = 0
        for i in range(H - 1):
            if h & (1 << i):
                T.append(s)
                s = [i + 1]
                c += 1
            else:
                s.append(i + 1)
        T.append(s)
        C = [0] * len(T)
        CC = [0] * len(T)
        fail = False
        for w in range(W):
            split = False
            for i, t in enumerate(T):
                cc = 0
                for j in t:
                    if S[j][w] == '1':
                        cc += 1
                CC[i] = cc
                if C[i] + CC[i] > K:
                    split = True
            if split:
                for i in range(len(C)):
                    C[i] = CC[i]
                    if C[i] > K:
                        fail = True
                c += 1
            else:
                for i in range(len(C)):
                    C[i] += CC[i]
        if not fail:
            m = min(c, m)
    return m

print(main())


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

long long int gcd( long long int a, long long int b ) {
  return b ? gcd( b, a % b ) : a ;
}
long long int lcm( long long int m, long long int n ) {
  if ( m == 0 || n == 0 ) return 0;
  return ( ( m / gcd( m, n ) ) * n );
}

int main() {

  while( true ) {

    long long int n;
    cin >> n;
    if ( n == 0 ) break;

    vector< long long int > p, q, r, b;
    for ( long long int i = 0; i < n; i++ ) {
      long long int in_p, in_q, in_r, in_b;
      cin >> in_p >> in_q >> in_r >> in_b;
      p.push_back( in_p );
      q.push_back( in_q );
      r.push_back( in_r );
      b.push_back( in_b );
    }

    for ( long long int i = 0; i < n; i++ ) {
      for ( long long int j = 0; j < n; j++ ) {

	if ( r[j] <= 0 && b[j] <= 0 ) {

	  if ( r[j] == 0 ) {
	    r[j] = 1;
	  }else {
	    r[j] = -r[j];
	  }
	  long long int r2 = r[j] * p[j];
	  if ( b[j] == 0 ) {
	    b[j] = 1;
	  }else {
	    b[j] = -b[j];
	  }
	  long long int b2 = b[j] * q[j];
	  long long int h = lcm( r2, b2 ) / p[j] + lcm( r2, b2 ) / q[j];

	  r[j] = n + 2;
	  b[j] = n + 2;

	  for ( long long int k = 0; k < n; k++ ) {
	    if ( i == n - 1 ) {
	      cout << h << endl;
	      break;
	    }
	    if ( r[k] == j + 1 ) {
	      r[k] = -h;
	      break;
	    }
	    if ( b[k] == j + 1 ) {
	      b[k] = -h;
	      break;
	    }
	  }
	  break;

	}

      }
    }

  }

  return 0;

}

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

using namespace std;

using ll = long long;

constexpr ll INF = 1e17;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<int> ids(n);
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i1, int i2){
        return a[i1] > a[i2];
    });

    vector< vector<ll> > dp(n + 1, vector<ll>(n + 1, -INF));
    dp[0][0] = 0;
    for (int ii = 0; ii < n; ++ii) {
        int i = ids[ii];
        for (int j = 0; j <= ii; ++j) {
            if (dp[ii][j] < 0) continue;
            dp[ii + 1][j + 1] =  max(dp[ii + 1][j + 1], dp[ii][j] + abs(i - j) * a[i]);
            dp[ii + 1][j] = max(dp[ii + 1][j], dp[ii][j] + abs(n - 1 - (ii - j) - i) * a[i]);
        }
    }
    
    ll ans = 0;
    for (int i = 0; i <= n; ++i) {
        ans = max(ans, dp[n][i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 34616
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<stack>
#define pi 3.141592653589
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
#define fi first
#define se second
using namespace std;

int dx[8] = { 0,1,0,-1,-1,1,-1,1 };
int dy[8] = { 1,0,-1,0,1,1,-1,-1 };



int main() {

	string s;

	cin >> s;
	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
	

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	final static String EVENT_HIT = "HIT";
	final static String EVENT_HOMERUN = "HOMERUN";
	// final static String EVENT_OUT = "OUT";

	static Main main = new Main();

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String event = "";

		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			Inning inning = main.new Inning(0);
			while ((event = br.readLine()) != null) {
				if (event.equals(EVENT_HIT)) {
					inning.singleHit();
				} else if (event.equals(EVENT_HOMERUN)) {
					inning.homeRun();
				} else {
					inning.out();
					if (inning.outs == 3) {
						System.out.println(inning.run);
						break;
					}
				}
			}
		}
	}

	class Inning {

		int diamond;
		int outs;
		int run;

		Inning(int run) {
			diamond = 0;
			outs = 0;
			this.run = run;
		}

		void singleHit() {
			diamond <<= 1;
			diamond |= 1;
			if ((diamond & 8) > 0) {
				run++;
				diamond &= 7;
			}
		}

		void homeRun() {
			diamond <<= 3;
			if ((diamond & 32) > 0)
				run++;
			if ((diamond & 16) > 0)
				run++;
			if ((diamond & 8) > 0)
				run++;
			run++;
			diamond = 0;
		}

		void out() {
			outs++;
		}
	}
}

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

typedef long long ll;
ll K, X, Y;
vector<pair<ll, ll>> R;
ll CX, CY;

ll dist_x() { return abs(X - CX); }
ll dist_y() { return abs(Y - CY); }
ll dist() { return dist_x() + dist_y(); }
void update_cx(ll dx) { CX += (X - CX > 0 ? 1 : -1) * dx; }
void update_cy(ll dy) { CY += (Y - CY > 0 ? 1 : -1) * dy; }
void approach(ll dx = min(dist_x(), K)) {
  update_cx(dx);
  update_cy(K - dx);
  R.push_back(make_pair(CX, CY));
}
void finalize() {
  ll d = dist();
  assert(d % 2 == 0);
  if (dist_x() < d / 2) {
    ll dy = d / 2 - dist_x();
    approach(K - dy);
  } else {
    ll dx = d / 2 - dist_y();
    approach(dx);
  }
  assert(dist() == K);
  approach(dist_x());
}
void solve() {
  if (K % 2 == 0 && dist() % 2 != 0) {
    cout << -1 << endl;
    return;
  }
  if (dist() == K) {
    cout << 1 << endl;
    cout << X << " " << Y << endl;
    return;
  }
  if (K % 2 == 1 && dist() % 2 == 1) approach();
  while (dist() > 2 * K) {
    approach();
    if (K % 2 == 1) approach();
  }
  finalize();
  cout << R.size() << endl;
  for (auto xy : R) {
    cout << xy.first << " " << xy.second << endl;
  }
}
int main() {
  cin >> K >> X >> Y;
  solve();
  return 0;
}


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

int main()
{
  int n, x,a=0; cin >> n >>x;
  
  vector<int> m(n);

  int ans=0;  
  for (int i=0; i<n; i++) {
    cin >> m.at(i);
    ans += m[i];   
  }
  
  sort (m.begin(), m.end());
  int ress = n + (x-ans)/m[0];
  
  cout << ress  << endl;
}

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

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    char f = s[0];
    int cnt = 0;
    int it = 0;
    while(cnt < k){
        if(it == n) break;
        while(s[it] == f) it++;
        while(s[it] != f){
            if(it == n) break;
            s[it] = f;
            it++;
        }
        cnt++;
    }
    int ans = 0;
    rep(i,n){
        if(s[i] == 'L'){
            if(i == 0) continue;
            if(s[i] == s[i - 1]) ans++;
        }else{
            if(i == n-1) continue;
            if(s[i] == s[i + 1]) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int a[200000];
int main()
{
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            for(int k=1;k<=n;k++)
    {
        ans+=(__gcd(__gcd(i,j),k));
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

typedef struct state{
	int id;
	int solved;
	int pena;
};


int compare(const void *a, const void *b){
	state *ta = (state*)a;
	state *tb = (state*)b;
	if (ta->solved != tb->solved){
		return - ta->solved + tb->solved;
	}
	else if (ta->pena != tb->pena){
		return ta->pena - tb->pena;
	}
	return ta->id - tb->id;
}

int main(void){
	int t, p, r, tid, pid, time;
	string judge;
	state st[50];
	int missed[50][10];
	while (true){
		cin >> t >> p >> r;

		if (t == 0 && p == 0 && r == 0){
			break;
		}
		for (int i = 0; i < t; i++){
			st[i].id = i + 1;
			st[i].solved = 0;
			st[i].pena = 0;
			for (int j = 0; j < p; j++){
				missed[i][j] = 0;
			}
		}


		for (int i = 0; i < r; i++){
			cin >> tid >> pid >> time;
			tid--;
			pid--;
			cin >> judge;
			if (judge == "CORRECT"){
				st[tid].pena += time + 1200 * missed[tid][pid];
				st[tid].solved++;
			}
			else{
				missed[tid][pid]++;
			}
		}

		qsort(st, t, sizeof(state), compare);

		for (int i = 0; i < t; i++){
			cout << st[i].id << " " << st[i].solved << " " << st[i].pena << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1228
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		long x = 0;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			x ^= A[i];
		}
		for(int i = 0; i < N; i++)
			System.out.print((A[i] ^ x) + " ");
	}

}

Measured memory_bytes: 61088
#include<stdio.h>
int main(void){
    int n,m,a[200],i,sum=0;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    int cnt=0;
    for(i=0;i<n;i++){
        if((float)a[i]>=(float)sum/(4*(float)m)){
            cnt++;
        }
    }
    if(cnt>=m){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
/**
*    created: 05.07.2020 17:15:07
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    bint n;
    cin >> n;

    auto lcm = [&] (bint a, bint b) {
        bint ret = a * b / __gcd(a,b);
        return ret;
    };

    bint ans = 1;
    rep(i,n) {
        int t;
        cin >> t;
        ans = lcm(ans,t);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3764
a, b, c = gets.chomp.split.map(&:to_i)
d = gets.chomp.split.map(&:to_i)
sum = 0
ans = 0
a.times do |hoge|
    i = gets.chomp.split.map(&:to_i)
    b.times do |huga|
        sum += d[huga] * i[huga]
    end
    sum += c
    ans += 1 if sum > 0
    sum = 0
end
puts ans 
    

Measured memory_bytes: 1788
use std::io::*;//Not mine.
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let s:String = read();
    if(s == "A"){
        println!("T");
    }
    else if(s == "T"){
        println!("A");
    }
    else if(s == "G"){
        println!("C");
    }
    else {
        println!("G");
    }
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  int x = N * A;

  if (x < B) {
    cout << x << endl;
  }
  
  if (x > B) {
    cout << B << endl;
  }

  if (x == B) {
    cout << x << endl;
  }
}


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

int main() {
  int x;
  cin >> x;
  int a=x%10;
  int b=((x-a)/10)%10;
  int c=((x-(a+10*b))/100)%10;
  int d=(x-(a+10*b+100*c))/1000;
  
  if ((a==b&&b==c)||(b==c&&c==d)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256