akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    vector<ll>a(3*n);
    for (ll i = 0; i < 3*n; ++i) {
        cin >>a[i];
    }
    priority_queue<ll>rque;
    priority_queue<ll,vector<ll>,greater<ll>>fque;
    vector<ll>b;
    ll f=0,r=0;
    for (ll i = 0; i < 3 * n; ++i) {
        if(i<n){
            fque.push(a[i]);
            f+=a[i];
        }
        else if(i<2*n)b.push_back(a[i]);
        else {
            rque.push(a[i]);
            r+=a[i];
        }
    }
    vector<ll>fsum(n+1,f);
    for (int i = 0; i < n; ++i) {
//        cout <<fque.top()<<" "<<b[i]<<endl;
        if(fque.top()<b[i]){
            fsum[i+1]=fsum[i]-fque.top()+b[i];
            fque.pop();
            fque.push(b[i]);
        }
        else fsum[i+1]=fsum[i];
    }
    reverse(all(b));
    vector<ll>rsum(n+1,r);
    for (int i = 0; i < n; ++i) {
        if(rque.top()>b[i]){
            rsum[i+1]=rsum[i]-rque.top()+b[i];
            rque.pop();
            rque.push(b[i]);
        }
        else rsum[i+1]=rsum[i];
    }
    reverse(all(rsum));
    ll ans=-INFll;
    for (int i = 0; i <=n; ++i) {
//        cout <<fsum[i]<<" "<<rsum[i]<<endl;
        ans=max(ans,fsum[i]-rsum[i]);
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 9560
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[][] count = new long[10][10];
        long ans = 0;

        // nまでの全ての数の先頭と末尾を取り出す
        for (int i = 1; i <= n; i++) {
            if (i % 10 == 0) {
                continue;
            }
            int j = i;
            while (j >= 10) {
                j /= 10;
            }
            count[j][i % 10]++;
        }
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= 9; j++) {
                ans += (count[i][j] * count[j][i]);
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
import sys

a = []
for i in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = [int(input()) for i in range(n)]

for i in range(3):
    cnt = 0
    for j in range(3):
        if a[i][j] in b:
            cnt += 1
    if cnt == 3:
        print("Yes")
        sys.exit()

for i in range(3):
    cnt = 0
    for j in range(3):
        if a[j][i] in b:
            cnt += 1
    if cnt == 3:
        print("Yes")
        sys.exit()
    
cnt = 0
for i in range(3):
    if a[i][i] in b:
        cnt += 1
if cnt == 3:
    print("Yes")
    sys.exit()

cnt = 0
for i in range(3):
    if a[i][2-i] in b:
        cnt += 1
if cnt == 3:
    print("Yes")
    sys.exit()

print("No")

Measured memory_bytes: 38384
/*
        Author  : Malisetti Samrat
        Date    : 09-02-2020  
        Problem : HARD CASH ("FEB LONG CHALLENGE")
*/

#pragma GCC optimize ("O3")

#pragma GCC optimize("Ofast")

/*
   *********************************************************
    Code_Blooded Human == @{{ samrat_12   [  0_0  ^_^  ] }}
   *********************************************************
*/
#include   <bits/stdc++.h>
#include   <algorithm>
#include   <queue>
#include   <list>
#include   <map>
#include   <math.h>
#include   <numeric>
#include   <iomanip>
using      namespace        std;
#define    endl             '\n'
#define    FAST             ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define    ipfile           ifstream cin ("input.txt");std::cin.rdbuf(std::cin.rdbuf())
#define    pb(x)            push_back(x)
#define    int              long long int
#define    ull              unsigned long long int
#define    db               long double
#define    mod              1000000007
#define    vll              vector<int>
#define    all(v)           v.begin(),v.end()
#define    GCD(m,n)         __gcd(m,n)
#define    LCM(m,n)         m*(n/GCD(m,n))
#define    REVVEC(v)        reverse(v.begin(),v.end())
#define    REVARR(a)        reverse(a,a+n)
#define    maxc(v)          max_element(all(v))
#define    minc(v)          min_element(all(v))
#define    inputarr(a,n)    for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define    outputarr(a,n)   for(int xxx=0;xxx<n;xxx++) cout<<a[xxx]<<" "
#define    rep(i,m, n)      for(int i = m; i < (n); ++i)
#define    sp               setprecison(10)
#define    sz(v)            v.size()

clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}

void TestCase2()
{
    set<int>s;
    
    int ele,n;
    cin>>n;
    rep(i,0,n){
    cin>>ele;s.insert(ele);}
    //cout<<s.size()<<endl;
    if(s.size()==n)
    cout<<"YES\n";
    else cout<<"NO\n";
    
}

void TestCase3()
{
    
    string s,t;
    cin>>s>>t;
    int s1,t1;
    cin>>s1>>t1;
    string str; cin>>str;
    if(str=="red")
    s1--;
    if(str=="blue") t1--;
    cout<<s1<<" "<<t1<<endl;
    
}

signed main() {
	    
	 FAST
    
   // int T; cin>>T; while(T -- > 0){
    
    //TestCase3();
    
    TestCase2();
    
    //}

	return 0;
}


Measured memory_bytes: 9600
#include <iostream>

using namespace std;

int main()
{
	int N;
	cin >> N;

	for (int a = 1; a <= 9; ++a) {
		if (N % a == 0 && N / a <= 9) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
N = int(input())
A = list(map(int,input().split()))
K = lcm_list(A)
L = K - 1
ans = 0
for i in range(N):
  ans += L % A[i]
print(ans)

Measured memory_bytes: 5560
def main():
	n = int(input())
	ans = ""
	while n!=0:
		rem = n%(-2)
		n= n//(-2)
		if rem<0:
			rem = rem+2
			n = n+1
		ans = ans + chr(rem + ord('0'))
	if ans =="":
		print(0)
		exit()
	print(ans[::-1])
if __name__ =="__main__":
	main()

Measured memory_bytes: 61976
#include<iostream>
#define DFF 1e-10
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    double p[4][2],ans;
    for(int i=0; i<4; i++) for(int j=0; j<2; j++) cin >>p[i][j];
    for(int i=0; i<2; i++) for(int j=0; j<2; j++) p[i*2+1][j]-=p[i*2][j];
    ans = p[1][0]*p[3][1]-p[1][1]*p[3][0];
    if(ans>-DFF && ans<DFF) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    vector<pair<ll,int>> ab(N);
    rep(i,N){
        cin >> A[i] >> B[i];
        ab[i].second = i;
        ab[i].first = A[i] + B[i];
    }
    sort(all(ab));
    ll a = 0;
    ll b = 0;
    
    for (int i = N-1; i>=0; i--) {
        a += A[ab[i].second];
        i--;
        if(i>=0) b += B[ab[i].second];
    }
    cout << a-b << endl;
    return 0;
}



Measured memory_bytes: 3456
let sentinel = 1000000001
let cnt = ref 0

let to_int_list str =
  Str.split (Str.regexp_string " ") str |> List.map int_of_string

let merge a l m r =
  let ni = m - l in
  let nj = r - m in
  let init_ary n p =
    Array.init (n + 1) (fun i -> if i = n then sentinel else a.(p + i))
  in
  let ai = init_ary ni l in
  let aj = init_ary nj m in
  let rec doit i j k =
    if k >= r then ()
    else begin
      incr cnt;
      if ai.(i) <= aj.(j) then (a.(k) <- ai.(i); doit (i + 1) j (k + 1))
      else (a.(k) <- aj.(j); doit i (j + 1) (k + 1))
    end
  in
  doit 0 0 l

let rec merge_sort a l r =
  if (l + 1) < r then begin
    let m = (l + r) / 2 in
    merge_sort a l m;
    merge_sort a m r;
    merge a l m r
  end

let () =
  let n = read_int () in
  let a = Array.of_list (to_int_list (read_line ())) in
  merge_sort a 0 n;
  Array.iteri (fun i e -> Printf.printf (if i = 0 then "%d" else " %d") e) a;
  print_newline ();
  Printf.printf "%d\n" !cnt

Measured memory_bytes: 78032
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
{
	long long int n,i,a[3][3];
	int f=0,colsum=0,rowsum=0,k,j;
	for(i=0;i<3;i++)
		for(j=0;j<3;j++)
			cin>>a[i][j];
	cin>>n;
	int b[n];
	for(i=0;i<n;i++)
		cin>>b[i];
	for(k=0;k<n;k++)
		{
			for(i=0;i<3;i++)
				{
					rowsum=0;
					for(j=0;j<3;j++)
						{
							if(a[i][j]==b[k])
								a[i][j]=-1;
								rowsum+=a[i][j];
						}
					if(rowsum==-3)
					{
						f=1;
						break;
					}
				}
		}

for(k=0;k<n;k++)
		{
			for(j=0;j<3;j++)
				{
					colsum=0;
					for(i=0;i<3;i++)
						{
							if(a[i][j]==b[k])
								a[i][j]=-1;
								colsum+=a[i][j];
						}
					if(colsum==-3)
					{
						f=1;
						break;
					}
				}
		}
	if(a[0][0]+a[1][1]+a[2][2]==-3)
		f=1;
		
	if(a[0][2]+a[1][1]+a[2][0]==-3)
		f=1;
	if(f==1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
		
		
}

Measured memory_bytes: 3520
N, M = map(int, input().split(' '))
if M == 0:
    if N == 1:
        print(0)
    else:
        print('1', '0' * (N - 1), sep='')
else:
    rst = [''] * N
    is_end = False
    for i in range(M):
        s, c = input().split(' ')
        idx = int(s) - 1
        if idx == 0 and N != 1 and c == '0':
            print(-1)
            is_end = True
            break
        elif rst[idx] == '':
            rst[idx] = c
        elif rst[idx] != c:
            print(-1)
            is_end = True
            break
    if not is_end:
        for i, j in enumerate(rst):
            if i == 0 and rst[i] == '':
                print('1', end='')
            elif rst[i] == '':
                print('0', end='')
            else:
                print(j, end='')

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  map<int, bool> m;
  while (n--)
  {
    int a;
    cin >> a;
    if (m[a] == true)
      m[a] = false;
    else
      m[a] = true;
  }
  int ans = 0;
  for (pair<int, bool> t : m)
    if (t.second == true)
      ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
from sys import stdin, setrecursionlimit
input = stdin.readline
setrecursionlimit(200000)
N, M = map(int, input().split())
# d = [0] * (N + 1)
adj = [[] for _ in range(N + 1)]
for _ in range(M):
    x, y = map(int, input().split())
    adj[x].append(y)
    # d[y] += 1

dp = [-1] * (N + 1)


def lp(x: 'int') -> 'int':
    if dp[x] >= 0:
        return dp[x]
    else:
        dp[x] = 0
        for y in adj[x]:
            dp[x] = max(dp[x], lp(y) + 1)
        return dp[x]


print(max(lp(i) for i in range(1, N + 1)))


Measured memory_bytes: 123056
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main( void )
{
  string s,t;
  int n=0;
  map<string,int> m;
  while( 1 ){
    cin>>s;
    if( cin.eof() ) break;
    if( m.find( s ) == m.end() ) m[s]=0;
    m[s]++;
    if( s.size() > n ){ t = s; n = s.size(); }
  }
  n=0;
  for( map<string,int>::iterator it = m.begin(); it != m.end(); ++it )
    if( it->second > n ) n = it->second;
  for( map<string,int>::iterator it = m.begin(); it != m.end(); ++it )
    if( it->second == n ) cout << it->first;
  cout << ' ' << t << endl;
  return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll N, K; cin >> N >> K;
	ll sum = 0;
	for (ll k = K; k <= N+1; k++) {
		ll a = (N+1)*(N)/2;
		ll b = (k)*(k-1)/2;
		ll r = N+1-k;
		ll bb = (r)*(r-1)/2;
		(sum += a-bb-b+1) %= mod;
	}
	cout << sum << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

int main(int argc, char** argv) {
  string s;
  cin >> s;

  int n = s.size();
  vector<int> diffs(n, 1);

  bool left_is_r = true;
  int the_most_left_r = 0;
  int the_most_left_l = -1;

  for (int i = 1; i < n; ++i) {
    if (left_is_r) {
      if (s[i] == 'R') {
        continue;
      } else { // s[i] == 'L'
        int diff = (i - the_most_left_r);
        for (int j = 0; j < diff; ++j) {
          diffs[i - (j + 1)] = j;
        }

        the_most_left_l = i;
        diffs[i] = - 1;
        left_is_r = false; // From now, left i L
      }
    } else { // left is L
      if (s[i] == 'R') {
        the_most_left_r = i;
        diffs[i] = 0;
        left_is_r = true;
      } else { // s[i] == 'L'
        diffs[i] = - (i - the_most_left_l) - 1;
      }
    }
  }

  // NOTE: Only for debug
  // cout << diffs[0];
  // for (int i = 1; i < n; ++i) {
  //   cout << " " << diffs[i];
  // }

  // ### input2
  // RRLLLLRLRRLL
  //
  // 1(R) 0(R) -1(L) -2(L) -3(L) -4(L) 0(R) -1(L) 1(R) 0(R) -1(L) -2(L)
  //
  // We calculate after the n.
  vector<int> cnts(n, 0);

  int trial = n + (n % 2); // If n is odd, + 1.

  for (int i = 0; i < n; ++i) {
    if (diffs[i] >= 0) { // R
      int idx = i + diffs[i];  // Base index
      if ((trial - diffs[i]) % 2 == 1) {
        cnts[idx + 1] += 1;
      } else {
        cnts[idx] += 1;
      }
    } else { // L
      int idx = i + diffs[i]; // Base index
      if ((trial + diffs[i]) % 2 == 1) {
        cnts[idx + 1] += 1;
      } else {
        cnts[idx] += 1;
      }
    }
  }

  cout << cnts[0];
  for (int i = 1; i < n; ++i) {
    cout << " " << cnts[i];
  }

  // vector<int> n_cnts(n, -1); // initialize with -1

  // int onemore = ((n % 2) == 1) ? 1 : 0;

  // for (int i = 0; i < n + onemore; ++i) {
  //   rep(j, n) { n_cnts[j] = cnts[j]; }  // Set

  //   rep(j, n) {
  //     if (s[j] == 'R') {
  //       n_cnts[j+1] += cnts[j];
  //       n_cnts[j] -= cnts[j];
  //     } else { // s[j] == 'L'
  //       n_cnts[j-1] += cnts[j];
  //       n_cnts[j] -= cnts[j];
  //     }
  //   }

  //   rep(j, n) { cnts[j] = n_cnts[j]; }  // Set
  // }

  // cout << cnts[0];
  // for (int i = 1; i < n; ++i) {
  //   cout << " " << cnts[i];
  // }
}


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

long f(int a, int d, int n) {
  return (long) n * (2 * a + (n - 1) * d) / 2;
}

int main() {
  int N, K, mod = 1e9 + 7;
  cin >> N >> K;
  long ans = 0;
  for (int k = K; k <= N + 1; k++) {
    long mi = f(0, 1, k);
    long mx = f(N - k + 1, 1, k);
    (ans += mx - mi + 1) %= mod;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3596
var
  n,m,i,j,s:longint;
  a:array[0..100,0..100] of char;
  p:boolean;
begin
  readln(n,m);
  for i:=1 to n do
  begin
    for j:=1 to m do read(a[i,j]);
    readln;
  end;
  for i:=1 to n do
  begin
    for j:=1 to m do
    begin
      p:=true;
      if a[i,j]='#' then begin write('#');p:=false; end;
      if p then
      begin
           s:=0;
           if a[i-1,j]='#' then s:=s+1;
           if a[i+1,j]='#' then s:=s+1;
           if a[i-1,j-1]='#' then s:=s+1;
           if a[i-1,j+1]='#' then s:=s+1;
           if a[i,j+1]='#' then s:=s+1;
           if a[i,j-1]='#' then s:=s+1;
           if a[i+1,j-1]='#' then s:=s+1;
           if a[i+1,j+1]='#' then s:=s+1;
           write(s);
      end;
    end;
    writeln;
  end;
end.

Measured memory_bytes: 128
import itertools

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())



dish = [A,B,C,D,E]

combination = list(itertools.permutations(dish))

ans = []
count = 0

for i in combination:
    time = 0
    for j in i:
        if count != 4:
            time = time + j
            if time % 10 != 0:
                while time % 10 != 0:
                    time = time + 1
            count = count+1
        elif count == 4:
            time = time + j
            count = 0
            ans.append(time)

print(min(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

using fint64 = int_fast64_t;
struct Combination {
	const int MAX = 5000010;
	const int MOD;
	vector<fint64> FAC;
	vector<fint64> INV;
	vector<fint64> FAC_INV;
	Combination(fint64 MOD) :
		MOD(MOD),
		FAC(vector<fint64>(MAX)),
		INV(vector<fint64>(MAX)),
		FAC_INV(vector<fint64>(MAX))
		{
			FAC[0] = INV[1] = FAC_INV[0] = 1;
			for(int i = 1; i < MAX; ++i) {
				FAC[i] = FAC[i - 1] * i % MOD;
				if(i > 1) INV[i] = MOD - INV[MOD % i] * (MOD / i) % MOD;
				FAC_INV[i] = FAC_INV[i - 1] * INV[i] % MOD;
			}
		}
	fint64 C(int n, int r) {
		if(n < 0 or r < 0 or n < r) return 0;
		return FAC[n] * FAC_INV[r] % MOD * FAC_INV[n - r] % MOD;
	}
	fint64 P(int n, int r) {
		if(n < 0 or r < 0 or n < r) return 0;
		return FAC[n] * FAC_INV[n - r] % MOD;
	}
	fint64 H(int n, int r) {
		if(r == 0) return 1;
		return C(n + r - 1, r);
	}
};

template<fint64 MOD>
struct ModInt {
	fint64 x;
	ModInt():x(0){}
	ModInt(fint64 x):
		x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
		{}
	// 負号
	ModInt operator -() const{
		return ModInt(-x);
	}
	// 加算
	ModInt &operator +=(const ModInt &rhs){
		x+=rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator +(const ModInt &rhs) const{
		return ModInt(*this)+=rhs;
	}
	// 減算
	ModInt &operator -=(const ModInt &rhs){
		x+=MOD-rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator -(const ModInt &rhs) const{
		return ModInt(*this)-=rhs;
	}
	// 乗算
	ModInt &operator *=(const ModInt &rhs){
		x*=rhs.x;
		if(x>=MOD) x%=MOD;
		return (*this);
	}
	ModInt operator *(const ModInt &rhs) const{
		return ModInt(*this)*=rhs;
	}
	// 除算
	ModInt &operator /=(const ModInt &rhs){
		(*this)*=rhs.inverse();
		return (*this);
	}
	ModInt operator /(const ModInt &rhs) const{
		return ModInt(*this)/=rhs;
	}
	// 等号
	bool operator ==(const ModInt &rhs){
		return x==rhs.x;
	}
	bool operator !=(const ModInt &rhs){
		return x!=rhs.x;
	}
	// 累乗
	ModInt pow(fint64 n) const{
		fint64 tmp=x;
		fint64 ret=1;
		while(n>0){
			if(n&1) ret=ret*tmp%MOD;
			tmp=tmp*tmp%MOD;
			n>>=1ll;
		}
		return ModInt(ret);
	}
	// 逆元
	ModInt inverse() const{
		fint64 a=x,b=MOD,s=1,t=0;
		while(b>0){
			fint64 u=a/b;
			a-=u*b;
			s-=u*t;
			swap(a,b);
			swap(s,t);
		}
		return ModInt(s);
	}
	// 入出力
	friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
		fint64 x; lhs>>x;
		rhs=ModInt<MOD>(x);
		return lhs;
	}
	friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
		return lhs<<rhs.x;
	}
};

using mint = ModInt<MOD>;
int main() {
	Combination com(MOD);
	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	mint ans = 0;
	for(int i = c1; i <= c2; ++i) {
		ans += com.C(r2 + i + 1, i + 1) - com.C(r1 + i, i + 1);
		// cerr << r2 + i + 1<< " " << i + 1 << '\n';
		// cerr << com.C(r2 + i + 1, i + 1) << '\n';
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 117376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			
			if(x == 0 && y == 0) {
				break;
			}
			else {
				if(x < y) {
					System.out.println(x + " " + y);
				}
				else{
					System.out.println(y + " " + x);
				}
			}
		}
		sc.close();
	}

}



Measured memory_bytes: 35284
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n; cin >> n;
    vector<int> c(n-1), s(n-1), f(n-1);
    rep(i, n-1) cin >> c[i] >> s[i] >> f[i];
    vector<int> ans(n, 0);
    rep(i, n-1) {
        int x = s[i] + c[i];
        for(int j=i+1;j<n-1;j++) {
            if(x > s[j]) {
                int num = (x-s[j]+f[j]-1)/f[j];
                x = s[j] + (num)*f[j] + c[j];
            } else {
                x = s[j] + c[j];
            }
        }
        ans[i] = x;
    }
    rep(i, n) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int L = Integer.parseInt(sc.next());
		int R = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());

		int ans1 = L / d;
		int ans2 = R / d;
		sc.close();

		if(L % d == 0) {
			int ans = ans2 - ans1  + 1;
			System.out.println(ans);
			return;
		}else {
			int ans = ans2 - ans1;
			System.out.println(ans);
			return;
		}

	}

}

Measured memory_bytes: 35468
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using U = unsigned int;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using std::cin; using std::cout;
using std::endl; using std::cerr;
using std::bitset; using std::map;
using std::queue; using std::priority_queue;
using std::set; using std::string;
using std::vector;
using std::pair; using std::make_pair;
using pii = std::pair<int, int>;
using pll = std::pair<LL, LL>;
#ifdef LOCAL
#include <ctime>
void displayTime() { cout << "Current time = " << clock() * 1e3 / CLOCKS_PER_SEC << "ms" << endl; }
#else
void displayTime() {}
#endif
#ifdef DEBUG
#define pass cerr << "[" << __FUNCTION__ << "] : line = " << __LINE__ << endl;
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n) { cerr << #a << " = {"; \
      for(int qwq = (st); qwq <= (n); ++qwq) cerr << a[qwq] << (qwq == n ? '}' : ',') << (qwq == n ? '\n' : ' '); }
#include <ctime>
class MyTimer {
  clock_t st;
public:
  MyTimer() { cerr << std::fixed << std::setprecision(0); reset(); }
  ~MyTimer() { report(); }
  void reset() { st = clock_t(); }
  void report() {  cerr << "Time consumed :" << (clock() - st) * 1e3 / CLOCKS_PER_SEC << endl; }
} myTimer;
#else
#define pass ;
#define display(x) ;
#define displaya(a, st, n) {}
class MyTimer {
public: void reset() {} void report() {}
} myTimer;
#endif

template<typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) { return a > b ? a = b, true : false; }
template<typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) { return a < b ? a = b, true : false; }
#ifdef QUICK_READ
char pool[1<<15|1],*it=pool+32768;
#define getchar() (it>=pool+32768?(pool[fread(pool,sizeof(char),1<<15,stdin)]=EOF,*((it=pool)++)):*(it++))
#endif
inline int readint() {
  int a = 0; char c = getchar(), p = 0;
  while(isspace(c)) c = getchar();
  if(c == '-') p = 1, c = getchar();
  while(isdigit(c)) a = a*10 + c - '0', c = getchar();
  return p ? -a : a;
}
inline LL readLL() {
  LL a = 0; char c = getchar(), p = 0;
  while(isspace(c)) c = getchar();
  if(c == '-') p = 1, c = getchar();
  while(isdigit(c)) a = a*10 + c - '0', c = getchar();
  return p ? -a : a;
}

const int maxN = 100000 + 233;
int n, v[maxN];

pii get(int st, int &t) {
	map<int, int> M; M.clear();
	int x = 0, y = 0;
	for(int i = st; i < n; i += 2) M[v[i]]++;
	t = -st;
	for(auto p : M) {
		if(p.second > x) y = x, x = p.second, t = p.first;
		else if(p.second > y) y = p.second;
	}
	return pii(x, y);
}

int main() {
  n = readint();
  for(int i = 0; i < n; ++i) v[i] = readint();
  int v1, v2;
  pii p1 = get(0, v1), p2 = get(1, v2);
  if(v1 != v2) cout << n - p1.first - p2.first << endl;
  else cout << n - p1.first - p2.first + std::min(p1.first - p1.second, p2.first - p2.second) << endl;
  return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PRINT(var) std::cout<<#var"= "<<var<<std::endl

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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


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

  int w,h,n,x,y,a;
  cin >> w;
  cin >> h;
  cin >> n;

  vector<vector <int> > field;
  field = vector<vector<int> >(w+1, vector<int>(h+1, 0)); //field[w+1][h+1]

  REP(i,n){
    cin >> x;
    cin >> y;
    cin >> a;

    switch (a)
    {
      case 1:
        FOR(j,1,h+1){
          FOR(k,1,x+1){

            field[k][j]=1;
          }
        }
        break;
      case 2:
        FOR(j,1,h+1){
          FOR(k,x+1,w+1){
            field[k][j]=1;
          }
        }
        break;
      case 3:
        FOR(j,1,y+1){
          FOR(k,1,w+1){
            field[k][j]=1;
          }
        }
        break;
      case 4:
        FOR(j,y+1,h+1){
          FOR(k,1,w+1){
            field[k][j]=1;
          }
        }
        break;
      default:
        break;
    }
  }

  int count=0;
  FOR(j,1,h+1){
    FOR(k,1,w+1){

      if(field[k][j]==0) count++;
    }

  }

  cout <<count <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
int const INF = 1001001001;


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

int N;
cin >> N;

vi dp(N+1, INF);
dp[0] = 0;

rrep(i,N) {
    for(int j = 0; pow(6,j) <= i; j++) {
        chmin(dp[i], dp[i - (int)pow(6,j)] + 1);
    }
    for(int j = 0; pow(9,j) <= i; j++) {
        chmin(dp[i], dp[i - (int)pow(9,j)] + 1);
    }
}
cout << dp[N] << endl;
return 0;
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;


public class Main {
	Scanner sc = new Scanner(System.in);
	
	void run(){
		int n = sc.nextInt();
		for(int i = 0; i < n; i++){
			ArrayList<Integer> sides = new ArrayList<Integer>();
			for(int j = 0; j < 3; j++){
				sides.add(sc.nextInt());
			}
			Collections.sort(sides, new Comparator<Integer>(){
				@Override
				public int compare(Integer a, Integer b) {
					return b-a;
				}
			});
			int a = sides.get(0);
			int b = sides.get(1);
			int c = sides.get(2);
			
			if(a * a == b * b + c * c)
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 23368
#!/usr/bin/env ruby

def fc(s, n, min, remain)
  # ???????????¶
  return 0 if n.zero? && !remain.zero?
  return 1 if n.zero? && remain.zero?

  # ?????????
  return 0 if min > remain

  # ?¶???????????????´???
  sum = 0
  (min+1).upto(9) do |k|
    sum += fc(s, n-1, k, remain - k) unless remain - k < 0
  end

  sum
end

while line = gets
  n, s = line.chomp!.split(' ').map(&:to_i)
  break if n.zero? && s.zero?
  puts fc(s, n, -1, s)

end

Measured memory_bytes: 8652
#include <stdio.h>
int main(void){
    int k,s,x,y,z,count=0;
    scanf("%d %d",&k,&s);
    for(x=0;x<=k;x++){
        for(y=0;y<=k;y++){
            z=s-x-y;
            if(0<=z&&z<=k) count++;
        }
    }
    printf("%d",count);
    return 0;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

vector<int> g[N];
vector<pair<int, int>> ve;
int ans = 0;

bool dfs(int u, int v, int par, pair<int, int> pp, ll vis)
{
  if(u == v) return true;
  bool f = false;
  for(auto x : g[u])
  {
    if(((1ll<<x)& vis) == 0)
    {
      pair<int, int> px = make_pair(min(x, u), max(x, u));
      if(x != par && px != pp)
          f = f | dfs(x, v, u, pp, vis | (1ll<<x));
    }
  }
  return f;
}

int main()
{
  int n,m;
  cin>>n>>m;
  rep(i, 0, m)
  {
    int a, b;
    cin>>a>>b;
    g[a].pb(b);
    g[b].pb(a);
    ve.pb({min(a, b), max(a, b)});
  }
  for(auto pp: ve)
  {
    int u = pp.f;
    int v = pp.s;
    ll vis = 1ll << u;
    if(dfs(u, v, -1, pp, vis))
      ans++;
  }
  cout<<(m- ans)<<endl;
}


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

int main(){
    string S,T;
    cin >> S >> T;

    int sl = S.length();
    int tl = T.length();

    int max=0;

    rep(i,sl-tl+1) {
        int count=0;
        rep(j,tl) {
            if(S.at(i+j)==T.at(j)){
                count+=1;
            }
        }

        if(count>max) {
            max = count;
        }
      	//cout << max << endl;
    }

    cout << tl - max << endl;
}

Measured memory_bytes: 3612
#include <sstream>
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<set>

using namespace std;


int main(int ac, char* av[]){
    int N, K;
    cin >> N >> K;
    vector<int> A;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        A.push_back(a);
    }
    for(int i=K;i<N;i++){
        if(A[i-K] < A[i]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    

    return 0;
}



Measured memory_bytes: 3848
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int d[n];
    rep(i, n) cin >> d[i];
    sort(d, d + n);
    cout << d[n / 2] - d[n / 2 - 1]  << endl;


}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <sstream>
#include <string>
using namespace std;
int main()
{
	string str;
	string item;
	vector<string> list;
	getline(cin, str);

	stringstream ss(str);
	while (getline(ss, item, ' ') && !item.empty()) {
		list.push_back(item);
	}
	int a = stoi(list[0].c_str());
	int b = stoi(list[1].c_str());

	if (a > b)
	{
		cout << "a > b" << endl;
	}
	else if (a < b)
	{
		cout << "a < b" << endl;
	}else{
		cout << "a == b" << endl;
	}
	return 0;
}

Measured memory_bytes: 3196
#include <stdio.h>
int main(void)
{
	 int a,i=1; 
	 while(1){
	    scanf("%d",&a); 
	    if (a == 0){ break; 
	      }
	    else{ 
	     printf("Case %d: %d\n" ,i,a); i++;
		 }
	 } 
	return 0;
 } 


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

map<int, int> prime_facter(ll n){
    map<int, int> res;
    for (ll i = 2; i*i <= n; i++){
        while (n%i == 0){
            ++res[i];
            n /= i;
        }
    }
    if (n != 1)res[n] = 1;
    return res;
}

int n;

int main(){
    cin >> n;
    map<int,int> m;
    FOR(i,1,n){
        map<int,int> buf = prime_facter(i+1);
        for(auto it = buf.begin();it != buf.end();it++){
            m[it->first] += it->second;
        }
    }
    ll ans = 0;
    vector<ll> v;
    for(auto it = m.begin();it != m.end();it++){
        // cout << it->first << " " << it->second << endl;
        v.push_back(it->second);
    }
    sort(ALL(v));
    reverse(ALL(v));
    ll num[5] = {};
    rep(i,v.size()){
        if(v[i] >= 74)num[0]++;
        if(v[i] >= 24)num[1]++;
        if(v[i] >= 14)num[2]++;
        if(v[i] >= 4)num[3]++;
        if(v[i] >= 2)num[4]++;
    }
    cout << num[0] + num[1] * (num[4] - 1) + num[2] * (num[3] - 1) + num[3] * (num[3] - 1) * (num[4] - 2) / 2 << endl;
}

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

int c[3][3];

/*int main(){
    for(int i=0;i<2;i++){
        for(int j=0;j<3;j++){
            int a;
            cin>>a;
            c[i][j]=a;
        }
    }
    if(c[0][0]==c[1][2]&&c[0][1]==c[1][1]&&c[0][2]==c[1][0]){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    return 0;
}*/
int n,ans=0;
int main(){
    cin>>n;
    for(int j=1;j<=n;j++){
        if(j*j<=n) ans=j*j;
        else break;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	while(cin >> n,n){
		deque<int> va;
		while(n){
			va.push_front(n%8);
			n=n/8;
		}
		for(int i=0;i<va.size();i++){
			if(va[i]==4)va[i]++;
			else if(va[i]==5)va[i]+=2;
			else if(va[i]==6)va[i]+=2;
			else if(va[i]==7)va[i]+=2;
			cout << va[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  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);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


map<pair<ll, ll>, P> mp;
int main() {
  int n;
  cin >> n;
  int zero = 0;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    if (x == 0 && y == 0) {
      zero++;
      continue;
    }
    ll g = gcd(x, y);
    x /= g;
    y /= g;
    if (y < 0) {
      x *= -1;
      y *= -1;
    }
    if (y == 0 && x < 0) {
      x *= -1;
      y *= -1;
    }
    bool rot = (x <= 0);
    if (rot) {
      ll tmp = x;
      x = y;
      y = -tmp;
    }
    if(rot)mp[{x,y}].fi++;
    else mp[{x,y}].se++;
  }

  mint ans = 1;
  for(auto p:mp){
    int s = p.se.fi;
    int t = p.se.se;
    mint now = 1;
    now+= mint(2).pow(s)-1;
    now+= mint(2).pow(t)-1;
    ans*=now;
  }

  ans-=1;
  ans+=zero;
  print(ans.x);
  return 0;
}



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

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String a = br.readLine();
		String b = br.readLine();
		
		String ans = solve(a,b);
		
		System.out.println(ans);
	}

	private static String solve(String a, String b) {
		
		int[][] lcs = getLcs(a,b);
		
		int n = a.length();
		int m = b.length();
		
		StringBuilder sb = new StringBuilder();
		
		while(n>0 && m>0) {
			if(a.charAt(n-1)==b.charAt(m-1)) {
				sb.append(a.charAt(n-1));
				n--;
				m--;
			}else {
				if(lcs[n][m-1]>lcs[n-1][m])
					m--;
				else
					n--;
			}
		}
		
		return sb.reverse().toString();
	}

	private static int[][] getLcs(String a, String b) {
		
		int[][] dp = new int[a.length()+1][b.length()+1];
		
		for (int i = 1; i < dp.length; i++) {
			for (int j = 1; j < dp[0].length; j++) {
				if(a.charAt(i-1)==b.charAt(j-1))
					dp[i][j] = 1+dp[i-1][j-1];
				else
					dp[i][j] = Math.max(dp[i][j-1], dp[i-1][j]);
			}
		}
		
		return dp;
	}
}

Measured memory_bytes: 80552
#include "bits/stdc++.h"

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define P pair<int, int>

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	ll ans = a[0];
	for(int i = 1; i < n; i++) {
		ans = gcd(ans, a[i]);
	}

	cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MAX (int)1e9 + 99
#define vi vector<int>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define MOD 998244353
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
#define set0(x) memset(x, 0, sizeof(x))
ll fastPowMod(ll a, ll p,ll mod){ if(p==0) return 1; ll z = fastPowMod(a,p/2,mod); z = (z*z)%mod; if(p%2) z = (z*a)%mod; return z; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}

vi graph[100001];
vi vis(100001, 0), dp(100001,0);
int check(int v)
{
    if(vis[v]) return dp[v];
    vis[v]=1;
    int ans=0;
    for(int i: graph[v])
    {
        ans = max(ans, check(i)+1);
    }
    dp[v] = ans;
    return dp[v];
}

void solve()
{
    int n,m;
    cin>>n>>m;
    rep(i,m)
    {
        int x,y;
        cin>>x>>y;
        graph[x].pb(y);

    }
    int ans=0;
    srep(i,1,n) ans=max(ans,check(i));
    cout<<ans;
}

int main()
{
    fastio;
    /*int t;
    cin>>t;
    
    rep(i,t)
    {*/
        solve();
        cout<<"\n";
    //}
    return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))


int main(){
    ll ans=1,n,k;
    cin >>n>>k;
    vector<ll> tree[n+1];
    int checked[n+1];
    for(int i=0;i<n-1;i++){
        ll a,b;
        cin >>a>>b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    for(int i=0;i<=n;i++){
        checked[i]=0;
    }
    queue<ll> q;
    q.push(1);
    while(!q.empty()){
        ll mul=k;
        ll kaku=0;
        ll now=q.front();
        q.pop();
        for(int i=0;i<tree[now].size();i++){//1段目
            ll F=tree[now][i];
            dbg cout <<"F is:"<<F<<endl;
            if(checked[F]==0){
                q.push(F);
                dbg cout <<"pushed:"<<F<<endl;
                continue;//未探索ならば
            }
            mul-=checked[F];
            kaku++;
            checked[F]++;

            /*
            for(int j=0;j< tree[F].size();j++){//2段目
                ll FF=tree[F][j];
                if(FF==now)continue;//戻ってくるな
                if(checked[FF])mul--;//探索済みならばかける数から引く
                //if(!checked[FF]);//未探索ならば無視
            }*/
        }
        dbg cout <<"multiply:"<<mul<<endl;
        ans=(ans*mul)%MAX;
        checked[now]=kaku+1;
    }

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 7668
#include<iostream>
using namespace std;
int main() {
  string s;
  cin >> s;
  int g = 0, p = 0;
  for (int i = 0;i < s.size();++ i) ++ (s[i] == 'g' ? g : p);
  if (s.size() & 1) -- g;
  cout << (g - p) / 2;
  return 0;
}

Measured memory_bytes: 512
ans=0
A=[]
B=[]
for _ in range(int(input())):
    i,j=map(int,input().split())
    A+=[i]
    B+=[j]
for a,b in zip(A[::-1],B[::-1]):    
    if (a+ans)%b:
        ans+=b-(a+ans)%b
print(ans)

Measured memory_bytes: 18512
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int arr[N] = {};
int main() {
    int n, x = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        x ^= arr[i];
    }
    for (int i = 1; i <= n; i++)
        cout << (x ^ arr[i]) << " \n"[i == n];
    return 0;
}

Measured memory_bytes: 4384
#include <cstdio>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <set>
 #include <map>
 #include <vector>
 #include <list>
 #include <algorithm>
 #include <cstring>
 #include <cmath>
 #include <string>
 #include <queue>
 #include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
 #include <cassert>
 #include <iomanip>        //do setprecision
 #include <ctime>
 #include <complex>
 using namespace std;

 #define FOR(i,b,e) for(int i=(b);i<(e);++i)
 #define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
 #define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
 #define REP(x, n) for(int x = 0; x < (n); ++x)

 #define ST first
 #define ND second
 #define PB push_back
 #define PF push_front
 #define MP make_pair
 #define LL long long
 #define ULL unsigned LL
 #define LD long double
 #define pii pair<int,int>
 #define pll pair<LL,LL>

 const double pi = 3.14159265358979323846264;
 const int mod=1000000007;


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

 long long lcm(long long a,long long b){
 	long long g=gcd(a,b);
 	return a/g*b;
 }


int main(){
	LL n,m;
	cin>>n>>m;
	LL ans=lcm(n,m);
	string s,t;
	cin>>s>>t;
	if(s[0]!=t[0]){
		cout<<-1<<endl;
		return 0;
	}
	map<LL,char> mp;
	LL nn=ans/n;
	LL mm=ans/m;
	FOR(i,1,n){
		mp[i*nn]=s[i];
	}
	FOR(i,1,m){
		if(mp[i*mm]==0){

		}else{
			if(mp[i*mm]!=t[i]){
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 10880
#include <set>
#include <cstdio>
int i,n,v[9999];main(){for(;scanf("%d",&n),n;){std::set<int>t;std::set<int>::iterator s,S;for(i=1;i<n;i++)v[i]=0,t.insert(i*i%n);for(s=t.begin();s!=t.end();s++)for(S=s;++S!=t.end();v[i>n/2?n-i:i]+=2)i=*S-*s;for(i=1;i<=n/2;i++)printf("%d\n",v[i]);}}

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

struct UnionFind {
	vector<int> d;
  	UnionFind(int n = 0): d(n, -1){}
  
  	int find(int x){
    	if(d[x] < 0) return x;
      	return d[x] = find(d[x]);
    }
  
  	bool unite(int x, int y){
    	x = find(x); y = find(y);
      	if(x == y) return false;
      	if(d[x] > d[y]) swap(x, y);
      	d[x] += d[y];
      	d[y] = x;
     	return true;
    }
  
  	bool same(int x, int y){ return find(x) == find(y);}
  	int size(int x) {return -d[find(x)];}
};

int deg[100005];
vector<int> to[100005];

int main(){
	int n, m, k;
  	cin >> n >> m >> k;
  	UnionFind uf(n);
  	rep(i, m){
    	int a, b;
      	cin >> a >> b;
      	--a; --b;
      	deg[a]++;
      	deg[b]++;
      	uf.unite(a, b);
    }
  	rep(i,k){
    	int a, b;
      	cin >> a >> b;
      	a--; b--;
      	to[a].push_back(b);
      	to[b].push_back(a);
    }
  	rep(i, n){
    	int ans = uf.size(i) - 1 - deg[i];
      	for(int u : to[i]){
        	if(uf.same(i, u)) ans--;
        }
      	cout << ans << " ";
    }
  	cout << endl;
}

Measured memory_bytes: 6784