akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

int main() {
  ll N;
  cin >> N;
  string S;
  cin >> S;

  ll n_R = 0;
  ll n_G = 0;
  ll n_B = 0;
  REP(i, N) {
    if (S[i] == 'R')
      n_R++;
    else if (S[i] == 'G')
      n_G++;
    else if (S[i] == 'B')
      n_B++;
  }

  ll ans = n_R * n_G * n_B;

  REP(i, N - 2) {
    for (ll j = 1; i + 2 * j < N; j++) {
      if (S[i] != S[i + j] && S[i] != S[i + 2 * j] && S[i + j] != S[i + 2 * j])
        ans--;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3604
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys

def main():
    A, B, C, K = map(int, input().split())
    if K<=A:
        print(K)
    elif K<=(A+B):
        print(A)
    elif K<=(A+B+C):
        print(A-(K-A-B))
    else:
        print(A-C)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9076
import numpy as np
import itertools

N, M, X = list(map(int, input().split()))
A = []
C = []
for i in range(N):
    _CA = list(map(int, input().split()))
    _C = _CA[0]
    _A = _CA[1:]
    A.append(_A)
    C.append(_C)

A = np.array(A)
C = np.array(C)
result = -2
A_sum = A.sum(axis=0)
if A_sum.min() < X:
    result = -1
else:
    n = np.array(list(range(N)))
    money_min = C.sum()
    for i in reversed(n + 1):
        is_enough = False
        comb = itertools.combinations(n, i)
        for _c in comb:
            c = np.array(_c)
            _A = A[c]
            _C = C[c]
            _score = _A.sum(axis=0)
            _money = _C.sum()
            if _score.min() >= X:
                is_enough = True
                if _money < money_min:
                    money_min = _money
        if not is_enough:
            break
    result = money_min
print(result)

Measured memory_bytes: 27336
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
//repマクロ定義
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//allマクロ定義
#define all(v) v.begin(),v.end()
using namespace std;

//global variable
int N;

//Recursive function
void dfs(string s,char mx){
  if(s.length()==N){
    printf("%s\n",s.c_str());
  }else{
    for(char c='a';c<=mx;c++){
      dfs(s+c,(c==mx) ? (char)(mx+1):mx);
    }
  }
}
int main()
{
  cin >> N;
  dfs("",'a');
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int x;
    cin >>x;

    if(x==2){
        cout << 2<< endl;
        return 0;
    }

    for (int i = x; true ; i++){
        
        bool f=true;
        for (int j = 2; j <= sqrt(x)+1; j++){
            if(i%j==0){
                f=false;
                break;
            }
        }

        if(f){
            ans = i;
            break;
        }
        
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  int a=(n/1000);
  int b=((n%1000)/100);
  int c=(((n%1000)%100)/10);
  int d=(((n%1000)%100)%10);
  
  if(b!=c){
    cout<<"No"<<endl;
  }
  else if ( a==b || c==d){
    cout<<"Yes"<<endl;
  }
  
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;

  if (x < r || W - r < x || y < r || H - r < y)
    cout << "No" << endl;
  else
      cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n,d; cin>>n>>d;
	int ans=n/(2*d+1)+ (n%(2*d+1)!=0);
	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())

def check(N,Y):
    for a in range(N + 1):
        for b in range(N - a + 1):
            c = N - b - a
            if a * 10000 + b * 5000 + c * 1000 == Y:
                return a, b, c

    return -1,-1,-1

a, b, c = check(N, Y)
print(a,b,c)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 0X3F3F3F3F;
const ll N = 1e5+7;
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS() std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

int main()
{
	IOS();
	int n;
	int a[200005];
	cin>>n;
	for(int i=0; i<n; i++) cin>>a[i];

	int k=1;
	for(int i=0; i<n; i++)
	{
		if(a[i]==k) 
		{
		//	flag=1;
			k++;
		}
	}
	cout<<(n-k+1==n?-1:n-k+1)<<endl;
	return 0;
}



Measured memory_bytes: 1024
'''input
3
10 40 70
20 50 80
30 60 90
'''
n=int(input())
arr=[list(map(int,input().split())) for i in range(n)]
dp=[[0,0,0] for i in range(n+1)]
for i in range(1,n+1):
	dp[i][0]=arr[i-1][0]+max(dp[i-1][1],dp[i-1][2])
	dp[i][1]=arr[i-1][1]+max(dp[i-1][2],dp[i-1][0])
	dp[i][2]=arr[i-1][2]+max(dp[i-1][1],dp[i-1][0])
print(max(dp[n]))



Measured memory_bytes: 47280
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
 int a,b,c,d;
 cin >>a>>b>>c>>d;
 if(a*b<c*d)
 cout<<c*d<<endl;
 else
 cout<<a*b<<endl;
  }


Measured memory_bytes: 256
"use strict";
function main(input) {
    const line = input.split("\n");
    const n = parseInt(line[0]);
    const p = line[1].split(" ").map(Number);
    let ans = 0;
    for (let i = 1; i < n - 1; i++) {
        if (p[i - 1] < p[i] && p[i] < p[i + 1]) ans++;
        else if (p[i + 1] < p[i] && p[i] < p[i - 1]) ans++;
    }
    console.log(ans);
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29676
#include<bits/stdc++.h>
using namespace std;
void test(int &N,vector<char> &atoz, vector<string> &words) {
  if(words.at(0).size() >= N) {
    return;
  }
  vector<string> wordst(0);
  vector<char> check(0);
  for(int i = 0; i < words.size(); i++) {
    //cout << "did_i" << endl;
    for(int j = 0; j < words.at(i).size(); j++) {
      //cout << "did_j" << endl;
      string s = words.at(i);
      bool judge = true;
      for(int k = 0; k < check.size(); k++) {
        //cout << "did_k" << endl;
        if(words.at(i).at(j) == check.at(k)) {
          judge = false;
        }
      }
      if(judge) {
        s += words.at(i).at(j);
        //cout << s << endl;
        wordst.push_back(s);
        check.push_back(words.at(i).at(j));
        /*for(int x = 0; x < check.size(); x++) {
          cout << check.at(x) << " ";
        }*/
        //cout << "check" << i << endl;
      } 
    }
  bool jj = false;
  for(int l = 0; l < atoz.size(); l++) {
    bool jjj = true;
    for(int m = 0; m < check.size(); m++) {
      if(atoz.at(l) == check.at(m)) {
        jjj = false;
      }
    }
    if(jjj) {
      string s = words.at(i) + atoz.at(l);
      /*if(i == 1) {
        cout << words.at(i) << "/" << atoz.at(l) << s << "s1" << endl;
      }*/
      //check.push_back(atoz.at(l));
      wordst.push_back(s);
      jj = true;
      break;
    }
    
    if(jj) {
      break;
    }
  }
  check = {};
  }
  words = wordst;
  wordst = {};
  
  test(N, atoz, words);
}
int main() {
  int N;
  cin >> N;
  string w = "a";
  //string atoz = abcdefghij;
  vector<char> atoz = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};
  vector<string> words(1, w);
  test(N, atoz, words);
  sort(words.begin(), words.end());
  for(int i = 0; i < words.size(); i++) {
    cout << words.at(i) << endl;
  }
}

Measured memory_bytes: 10648
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long K =  sc.nextLong();


        Queue<Long> q = new LinkedList<>();
        for (int i = 1; i <10 ; i++) {
            q.offer((long)i);
        }

        int count = 0;
        long result = 0;
        while(!q.isEmpty()){
            count++;
            result = q.remove();
            long mod =result%10;
            if(mod ==0 ){
                q.offer(result*10);
                q.offer(result*10+1);
            }else if(mod ==9){
                q.offer(result*10+8);
                q.offer(result*10+9);
            }else{
                q.offer(result*10+mod-1);
                q.offer(result*10+mod);
                q.offer(result*10+mod+1);
            }
            if(count==K){
                break;
            }
        }



        System.out.println(result);
    }



}


Measured memory_bytes: 36308
N = int(input())
A = list(map(int, input().split(' ')))
count_two = 0
for i in A:
    flag = 0
    while flag == 0:
        if i % 2 == 0:
            i = i // 2
            count_two += 1
        else:
            flag = 1

print(count_two)

Measured memory_bytes: 4148
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<string> s(n);
	vector<int> t(n);
	
	for(int i = 0; i < n; ++i) {
		cin >> s[i] >> t[i];	
	}
	
	string x;
	cin >> x;
	
	int st = 0;
	for(int i = 0; i < n; ++i) {
		if( s[i] == x ) {
			st = i;
			break;
		}
	}
	
	int ans = 0;
	for(int i = st + 1; i < n; ++i) {
		ans += t[i];
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>
#include <cmath>
#include <unordered_map>

using namespace std;

#define ll long long
#define MAX 100000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    ll x, k, d, m;
    cin >> x >> k >> d;
    x = abs(x);
    m = x / d;
    m = min(k, m);
    x -= m * d;
    k -= m;
    if (k & 1) {
        x = d - x;
    }
    cout << abs(x);

    return 0;
}


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

ll a, b;
ll func(ll x){
    return a*x/b - a*(x/b);
}

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

    ll n;
    cin >> a >> b >> n;

    if(n<b) cout << func(n) << endl;
    else cout << func(b-1) << endl;

    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int x;
	cin >> x;
	int cmax = 1;
	for(int i = 2; ; i++){
		if(pow(i, 2) > x) break;
		for(int j = 2; ; j++){
			int k = pow(i, j);
			if(k > x) break;
			cmax = max(cmax, k);
		}
	}
	cout << cmax << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rFOR(i, a, b) for(int i=b-1; i>=a; i--)
typedef long long ll;
using namespace std;

int main(void){
  int a[3];
  rep(i, 3){
    cin >> a[i];
  }
  sort(a, a+3);
  cout << abs(a[1]-a[0]) + abs(a[2]-a[1]) << endl;
  return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <ctime>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;
int main() {
	int m, n;
	cin >> m >> n;
	vector<int> sports;
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		sports.emplace_back(a);
	}
	int point[1001] = { 0 };
	for (int i = 0; i < m; i++) {
		cin >> a;
		for (int j = 0; j < n; j++) {
			if (sports[j] <= a) {
				point[j]++;
				break;
			}
		}
	}
	int ans = 0, maxl = 0;
	for (int i = 0; i < n; i++) {
		if (point[i] > maxl) {
			maxl = point[i];
			ans = i + 1;
		}
	}
	cout << ans << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

string O;

bool check(string s,string t) {
  int cur[2] = {0,0};
  bool phase = false;
  rep(i,(int)O.size()){
    if( !phase ) {
      if( cur[0] >= (int)s.size() ) return false;
      while( cur[0] < (int)s.size() && s[cur[0]] != O[i] ) ++cur[0];
      if( !( cur[0] < (int)s.size() && s[cur[0]] == O[i] ) ) return false;
      ++cur[0];
    } else {
      if( cur[1] >= (int)t.size() ) return false;
      while( cur[1] < (int)t.size() && t[cur[1]] != O[i] ) ++cur[1];
      if( !( cur[1] < (int)t.size() && t[cur[1]] == O[i] ) ) return false;
      ++cur[1];
    }
    phase = !phase;
  }
  return true;
}

void compute(string S,string T) {
  if( check(S,T) ) {
    puts("Yes");
    return;
  }
  if( check(T,S) ) {
    puts("Yes");
    return;
  }
  puts("No");
}

int main(){
  string s,t;
  cin >> s >> t;
  O = s;
  compute(s,t);
  return 0;
}

Measured memory_bytes: 3188
import math

n = int(input())
#a = int(input())
d,x = list(map(int,input().split(" ")))
#ls = list(input().split(" "))
#ls = list(map(int,input().split(" ")))
#a,b,c = list(input().split())
#string = input()
ls = [int(input()) for i in range(n)]

ans = x

for i in range(n):
  ans += (d-1) // ls[i] + 1
print(ans)

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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back`
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define PI         2*acos(0.0)
#define lb         lower_bound
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define spc(x)     cout<<fixed<<setprecision(x)

const   long long  cs=2e5+5;
const   long long  inf=1e18;
const   long long  mod=1e9+7;
void solve()
{
    int64_t t,n,m,a,b,c,d,e,i,j,k,x,y,cnt=0,cnt1=0;
    bool flag = false;   
    
    cin>>n>>d;
    int arr[n][d];
    for(i=0;i<n;i++)
    {
        for(j=0;j<d;j++)
        {
            cin>>arr[i][j];
        }
    }
    double xx=0.0;
    for(i=0;i<n-1;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=0;k<d;k++)
            {
                x=abs(arr[i][k]-arr[j][k]);
                x*=x;
                cnt+=x;
            }
            xx=sqrt(cnt);
            if(xx==(int)xx) cnt1++;
            cnt=0;
        }
    }
    cout<<cnt1<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main(void)
{
	int gyou, retu, you[101][101], i,j;

	scanf("%d %d", &gyou, &retu);

	for (i = 0; i < gyou; i++){
		for (j = 0; j < retu; j++) {
			scanf("%d", &you[i][j]);
		}
	}

	for (j = 0; j <= retu; j++) {//一番下初期化
		you[gyou][j] = 0;
	}

	for (i = 0; i <= gyou; i++) {//一番右初期化
		you[i][retu] = 0;
	}
		
	you[retu][gyou] = 0;

	for (i = 0; i < gyou; i++) {
		for (j = 0; j < retu; j++) {
			you[gyou][j] += you[i][j];//各列の合計
			you[i][retu] += you[i][j];//各行の合計
			you[gyou][retu] += you[i][j];//右下全体合計
		}
	}

	for (i = 0; i <= gyou; i++) {
		for (j = 0; j <= retu; j++) {
			if (j == retu) {
				printf("%d", you[i][j]);
			}
			else 
			{
				printf("%d ", you[i][j]);
			}
		}
		printf("\n");
	}
			
			return 0;
}


Measured memory_bytes: 2040
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s,a;
    cin >> s >> a;
    cout << s*s-a << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
ans=set()
b=set(range(1,m+1))
#print(b)
ans=ans.union(b)
for n in range(n):
  #print(ans)
  s=list(map(int,input().split()))
  ex=b - set(s[1:])
  ans=ans-ex
print(len(ans))



Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

ll daycount(ll y, ll m, ll d) {
	if (m == 1 || m == 2) {
		y--;
		m = 12 + m;
	}
	
	return 365*y + (y/4) - (y/100) + (y/400) + (306*(m+1)/10) + d - 429;
}

int main() {
	string str;
	while (cin >> str, str != "#") {
		stringstream ss;
		ss << str;
		
		ll y, m, d;
		ll b, ka, t, w, ki;
		
		if (count(ALL(str), '.') == 2) {
			ss >> y; ss.ignore();
			ss >> m; ss.ignore();
			ss >> d; ss.ignore();
			
			ll days = daycount(y, m, d) - daycount(2012, 12, 21);
			
			ki = days % 20; days /= 20;
			w = days % 18; days /= 18;
			t = days % 20; days /= 20;
			ka = days % 20; days /= 20;
			b = days % 13;
			
			printf("%lld.%lld.%lld.%lld.%lld\n", b, ka, t, w, ki);
		}
		else {
			ss >> b; ss.ignore();
			ss >> ka; ss.ignore();
			ss >> t; ss.ignore();
			ss >> w; ss.ignore();
			ss >> ki; ss.ignore();
			
			ll days = b; days *= 20;
			days += ka; days *= 20;
			days += t; days *= 18;
			days += w; days *= 20;
			days += ki;
			days += daycount(2012, 12, 21);
			
			ll l = 0, r = 1e8;
			while (r - l > 1) {
				 ll m = (l + r) / 2;
				 ll now = daycount(m, 1, 1);
				 if (now <= days) l = m;
				 else r = m;
			}
			y = l;
			
			l = 0, r = 13;
			while (r - l > 1) {
				 ll m = (l + r) / 2;
				 ll now = daycount(y, m, 1);
				 if (now <= days) l = m;
				 else r = m;
			}
			m = l;
			
			d = days - daycount(y, m, 1) + 1;
			
			printf("%lld.%lld.%lld\n", y, m, d);
		}
	}
	return 0;
}

Measured memory_bytes: 3288
import java.io.*;

public class Main {

	public static void main(String[] args) {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line;
			while((line=r.readLine())!=null){
				String[] vars = line.split(" ");
				String res = "";
				if (vars[0].indexOf('i')>=0){//intersection
					res = intersection(vars[1],vars[2]);
				} else {//union
					res = union(vars[1],vars[2]);
				}
				
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static String[] child(String a){//return left and right child
		String[] children = new String[2];
		int index = 1, level=0;
		while(true){
			if(a.charAt(index)=='('){
				level++;
			} else if (a.charAt(index)==')'){
				level--;
			} else if (a.charAt(index)==','&&level==0){
				children[0] = a.substring(1,index);
				children[1] = a.substring(index+1,a.length()-1);
				return children;
			}
			index++;
		}
	}
	
	public static String intersection(String a, String b){
		if(a.length()==0||b.length()==0){
			return "";
		} else {
			return "(" + intersection(child(a)[0],child(b)[0]) + "," + intersection(child(a)[1],child(b)[1]) + ")";
		}
	}
	
	public static String union(String a, String b){
		if(a.length()==0&&b.length()==0){
			return "";
		} else if (a.length()==0){
			return "(" + child(b)[0] + "," + child(b)[1] + ")"; 
		} else if (b.length()==0){
			return "(" + child(a)[0] + "," + child(a)[1] + ")";
		} else {
			return "(" + union(child(a)[0],child(b)[0]) + "," + union(child(a)[1],child(b)[1]) + ")";
		}
	}
}

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

int main() {
	string s;
	int a,b;
	cin >> a >> b;
	
	int c,d,e;
    c = a+b;
  	d = a-b;
    e = a*b;
  
  if(c>=d){
  	if(c>=e){
    	cout<<c<<endl;
    }
    else{
        cout<<e<<endl;
    }
  }
  else{
  	if(d>=e){
    	cout<<d<<endl;
    }
    else{
    	cout<<e<<endl;
    }
  }
  return 0;
}

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

int main(void)
{
    int n, i, ac, wa, tle, re;
    string s;
    ac = 0;
    wa = 0;
    tle = 0;
    re = 0;
    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> s;
        if (s.compare("AC") == 0)
            ac++;
        if (s.compare("WA") == 0)
            wa++;
        if (s.compare("TLE") == 0)
            tle++;
        if (s.compare("RE") == 0)
            re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}

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

import sys
sys.setrecursionlimit(300000)


def solve(A: int, B: int):
    ret = 0
    if 1 in [A, B] and 2 in [A, B]:
        ret = 3
    if 1 in [A, B] and 3 in [A, B]:
        ret = 2
    if 2 in [A, B] and 3 in [A, B]:
        ret = 1
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
int k,a,b;
cin>>k>>a>>b;
  int flg=0;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0)
    {
      flg=1;
      break;
    }
  }
  if(flg==1)
  {
    cout<<"OK";
  }
  else
  {
    cout<<"NG";
  }
}

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

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

  vector<int> s(N);
  int sum = 0;
  bool flag = false;
  for ( int i = 0; i < N; i++ ) {
    cin >> s[i];
    if ( s[i] % 10 ) flag = true;
    sum += s[i];
  }

  sort(s.begin(), s.end());

  if ( !flag ) {
    cout << 0 << endl;
  } else if ( sum % 10 ) {
    cout << sum << endl;
  } else {
    for ( int i = 0; i < N; i++ ) {
      if ( s[i] % 10 ) {	
	sum -= s[i];
	break;
      }      
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
// #define endl "\n"

int main(void) {
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    ll x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>; using vvi = vector<vector<int>>;
using vl = vector<ll>; using vvl = vector<vector<ll>>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
//#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}


signed main(){
  vvi gr(4);
  REP(i,3){
    int a,b;
    cin >> a >> b;
    a--; b--;
    gr[a].eb(b);
    gr[b].eb(a);
  }
  bool ans = true;
  REP(i,4){
    if(gr[i].size()>=3) ans = false;
  }
  cout << (ans?"YES":"NO") << endl;
}



Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] Args){
        Scanner scan = new Scanner(System.in);
        String S = scan.next();
        String T = scan.next();
        int hit = 0;
        for(int i = 0;i < 3;i++){
            if(S.charAt(i) == T.charAt(i)){
                hit++;
            }
        }
        System.out.println(hit);
        scan.close();
    }
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;
using namespace std;
long long h[10000010],x[10000010];

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

  int a,b;
  cin>>a>>b;

  if(a+b>=10) cout<<"error"<<'\n';
  else cout<<a+b<<'\n';
}


Measured memory_bytes: 256
# cook your dish here
n = int(input())
a = list(map(int,input().split()))
c = []
d = []

for i in range(n):
    if i %2 == 0:
        c.append(a[i])
    else:
        d.append(a[i])
c = c[::-1]

b = c + d
c = b[::-1]
ass = ''
for i in range(n):
    if n %2 == 0:
        ass += str(c[i]) + ' '
    else:
        ass += str(b[i]) + ' '
print(ass)

Measured memory_bytes: 26180
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <set>
#include <limits.h>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define rip(i,n,s) for (int i=(s);i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;

long long pow(long long n, long long p,long long k) {//n^k(mod p)
	if (k != 0) {
		if (p % 2==0) {
			long long x = pow(n, p, k / 2);
			return (long long)x*x%p;
		}
		else {
			long long x = pow(n, p, k - 1);
			return (long long)x*n%p;
		}
	}
	return 1;
}

long long rev(long long n, long long p) {//nの逆元
	return pow(n, p ,p - 2);
}

long long bino(long long n, long long m, long long p) {//nCm(mod p)
	long long me = 1;
	long long ans = 1;
	for (int i = 0;i < n + m;i++) {
		me = (long long)(i + 1) * ans % p;
		if (i == m - 1) {
			ans =(long long) rev(me,p) * ans%p;
		}
		if (i == m - n - 1) {
			ans = (long long)(rev(me, p))*ans%p;
		}
	}
	ans = (long long)(ans*me%p);
	return ans;
}

struct modint{
    long long num;
    long long p;
    modint () {
        num=0;
        p=1000000007;
    }
    modint(int x){
        p=1000000007;
        num=(long long) x%p;
    }
    modint (long long x){
        p = 1000000007;
        num = x%p;
    }
    modint operator+(const modint &other){
        modint ret;
        ret.p=p;
        ret.num=(num+other.num)%p;
        return ret;
    }
	modint operator+(const long long &other){
        modint ret;
        ret.p=p;
        ret.num=(num+(other%p))%p;
        return ret;
    }
    modint operator-(const modint &other){
        modint ret;
        ret.p=p;
        ret.num=(num-other.num+p)%p;
        return ret;
    }
    modint operator-(const long long &other){
        modint ret;
        ret.p=p;
        ret.num=(num-(other%p)+p)%p;
        return ret;
    }
    modint operator*(const modint &other){
        modint ret;
        ret.p=p;
        ret.num=(num*other.num)%p;
        return ret; 
    }
    modint operator*(const long long &other){
        modint ret;
        ret.p=p;
        ret.num=(num*(other%p))%p;
        return ret; 
    }
    modint operator/(const modint &other){
        modint ret;
        ret.p=p;
        ret.num=(num*rev(other.num,p))%p;
		return ret;
    }
    modint operator/(const long long &other){
        modint ret;
        ret.p=p;
        ret.num=(num*rev(other%p,p))%p;
		return ret;
    }
};

int main(){
    string s;
    int k;
    cin >> s >> k;
    int n=s.size();
    vector<vector<modint>> dp(n+1,vector<modint>(k));
    dp[n][0]=dp[n][0]+1;
    int no=0;
    for (int i=n-1;i>-1;i--){
        dp[i+1][no%k]=dp[i+1][no%k]-1;
        int x=s[n-i-1]-'0';
        rip(j,k,0){
            rip(l,10,0){
                dp[i][(j+l)%k]=dp[i+1][j]+dp[i][(j+l)%k];
            }
        }
        rip(j,x+1,0){
            dp[i][(j+no)%k]=dp[i][(j+no)%k]+1;
        }
        no+=x;
    }
    dp[0][0]=dp[0][0]-1;
    cout << dp[0][0].num << endl;
}

Measured memory_bytes: 16256
#include<stdio.h>
#define N 100
#define INF 1000000
#define W 0
#define G 1
#define B 2

int n,A[N][N];

void dijkstra();

int main(){
  int i,j,e,k,u,v,c;
  
  scanf("%d",&n);

  for(i=0;i<n;i++) {
    for(j=0;j<n;j++){
       A[i][j] = INF;
     
    }
  }
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&c);
      A[u][v]=c;
    }
  }
  dijkstra();
  
  return 0;
}

void dijkstra(){

  int i,j,min,u,dt[N],clr[N];

  for(i=0;i<n;i++){
    dt[i] =INF;
    clr[i] =W;

  }
  dt[0]=0;
  clr[0]=G;
  while(1){
    min=INF;
    u=-1;
    for(i=0;i<n;i++){
      if(min>dt[i]&&clr[i]!=B){
	u=i;
	min=dt[i];
      }
    }
    if(u==-1) break;
    clr[u]=B;
    for(j=0;j<n;j++){
      if(clr[j] !=B&&A[u][j] !=INF){
	if(dt[j]>dt[u]+A[u][j]){
	  dt[j]=dt[u]+A[u][j];
	  clr[j]=G;
	}
      }

    }
  }
  for(i=0;i<n;i++){
    printf("%d ",i);
    if(dt[i]==INF) printf("%d",-1);
    else printf("%d",dt[i]);
    printf("\n");

  }
}



Measured memory_bytes: 2044
open Batteries
let rec sum lst =
  match lst with
  | [] -> 0
  | first :: rest -> first + sum rest

let n, m = Scanf.sscanf (read_line()) "%d %d" (fun n m ->
  n, m
)

let a = read_line () |> String.split_on_char ' ' |> List.map int_of_string
let l = (float_of_int @@ sum a) /. (4. *. float_of_int m)
let foi x = float_of_int x

let rec ans lst =
  match lst with
  | [] -> 0
  | first :: rest ->
    if foi first < l then ans rest else 1 + ans rest

let _ = (
  if ans a < m then "No" else "Yes"
) |> print_endline



Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod ll(1e9+7)

ll power(ll x){
	ll temp=1;
	for(ll i=0;i<x;i++){
		temp=((temp%mod)*(2%mod))%mod;
	}
	return temp;
}

int main()
{
    ll i,n,a[1000000],status=0,temp=0,cou=0,ans;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    if(n==1 and a[0]==0)
    {
      cout<<1;
      return 0;
    }
    sort(a,a+n);
    if(n%2==0)
    {
        status=0;
    }
    else
    {
        status=1;
    }
    if(status==0)
    {
        if(a[0]==0)
        {
            cout<<0;
            return 0;
        }
        for(i=0;i<n;i++)
        {
            if(a[i]==a[i+1])
            {
                temp++;
                if(temp==1)
                {
                    cou++;
                }
            }
            else
            {
                temp=0;
            }
            if(temp>1)
            {
                cout<<0;
                return 0;
            }

        }
    }
    if(status==1)
    {
        if(a[0]!=0)
        {
          cout<<0;
          return 0;
        }
        if(a[0]==a[1])
        {
            cout<<0;
            return 0;
        }
        for(i=1;i<n;i++)
        {
            if(a[i]==a[i+1])
            {
                temp++;
                if(temp==1)
                {
                    cou++;
                }
            }
            else
            {
                temp=0;
            }
            if(temp>1)
            {
                cout<<0;
                return 0;
            }

        }
    }
    if(cou!=n/2)
    {
      cout<<0;
      return 0;
    }
    cou=power(cou);
    cout<<(cou)%mod;
    return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define ll  long long
#define pp pair<int,int>
#define ppn pair<pp,int>
#define F first
#define S second
#define N 1000005
#define mod 1000000007
#define pi 3.14159265358979323846

using namespace std;

int dp[1000001];
int main()
{


    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int a[n];
    map<int,int>m;
    for(int i=0; i<n; i++){
        cin>>a[i];
        dp[a[i]]++;
    }
    bool f = true;
    int ans =0;
    for(int i=2; i<1000001; i++){
        int c = 0;
        for(int j=1; j*i<1000001; j++){
            c+=dp[i*j];
        }
        if(c>1){
            f=false;
            //break;
        }
        ans = max(ans,c);
    }
    if(f)cout<<"pairwise coprime"<<endl;
    else cout<<(ans==n?"not coprime":"setwise coprime")<<endl;
}


Measured memory_bytes: 11456
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Heisei");
    } else {
        println!("TBD");
    }
}

fn main() {
    let s = read::<String>();
    yn(s <= "2019/04/30".to_string());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

int main() {
  int H,W;
  cin>>H>>W;
  int ch,cw,dh,dw;
  cin>>ch>>cw>>dh>>dw;
  ch--;cw--;dh--;dw--;
  vector<string>s(H);
  for(int i=0;i<H;i++){
    cin>>s[i];
  } 

  vector<int>X{0,0,-1,1};
  vector<int>Y{1,-1,0,0};

  queue<pair<int,int>>q;
  queue<pair<int,int>>warp;
  vector<vector<int>>seen(H,vector<int>(W,INF));
  seen[ch][cw]=0;
  q.push(make_pair(ch,cw));
  while(!q.empty()||!warp.empty()){
    if(!q.empty()){
      auto p=q.front();q.pop();
      int nowy=p.first;int nowx=p.second;
      warp.push(make_pair(nowy,nowx));
      for(int i=0;i<4;i++){
        int sy=nowy+Y[i],sx=nowx+X[i];
        if(sy<0||sy>=H||sx<0||sx>=W){continue;}
        if(s[sy][sx]=='#'){continue;}
        if(seen[sy][sx]!=INF){continue;}
        q.push(make_pair(sy,sx));
        warp.push(make_pair(sy,sx));
        seen[sy][sx]=seen[nowy][nowx];
      }
    }
    else{
      auto v=warp.front();warp.pop();
      int nowy=v.first;int nowx=v.second;
      for(int dy=-2;dy<=2;dy++){
        for(int dx=-2;dx<=2;dx++){
          int sy=nowy+dy,sx=nowx+dx;
          if(sy<0||sy>=H||sx<0||sx>=W){continue;}
          if(s[sy][sx]=='#'){continue;}
          if(seen[sy][sx]!=INF){continue;}
          seen[sy][sx]=seen[nowy][nowx]+1;
          q.push(make_pair(sy,sx));
        }
      }
    }
  }

  if(seen[dh][dw]==INF){cout<<-1<<endl;}
  else{cout<<seen[dh][dw]<<endl;}
  return 0;  
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int R, C; cin >> R >> C;
	int N; cin >> N;
	map<int, int> pts;
	auto toSeg = [&](int x, int y) -> int {
		if (x == 0) return y;
		else if (y == C) return C + x;
		else if (x == R) return C + R + (C - y);
		else if (y == 0) return C + R + C + (R - x);
		else return -1;
	};
	for (int i = 1; i <= N; i++) {
		int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
		int v1 = toSeg(x1, y1);
		int v2 = toSeg(x2, y2);
		if (v1 == -1 || v2 == -1) continue;
		if (v1 > v2) swap(v1, v2);
		pts[v1] = +i;
		pts[v2] = -i;
	}
	stack<int> st;
	for (auto it : pts) {
		if (it.second > 0) {
			st.push(it.second);
		} else {
			if (st.empty() || st.top() != -it.second) {
				cout << "NO" << '\n';
				exit(0);
			}
			st.pop();
		}
	}
	cout << "YES" << '\n';

	return 0;
}


Measured memory_bytes: 9856
import sys
sys.setrecursionlimit(10**9)

N = int(input())
A = [int(input()) for i in range(N-1)]
tree = [[] for i in range(N)]
for i, a in enumerate(A, 1):
  tree[a-1].append(i)

def calc_max_depth(node):
  children = tree[node]
  if children:
    depth = []
    for child in children:
      depth.append(calc_max_depth(child))
    depth.sort(reverse=True)
    return max([d+i for i, d in enumerate(depth, 1)])
  else:
    return 0

print(calc_max_depth(0))

Measured memory_bytes: 122920
n, x = list(map(int, input().split()))
children = list(map(int, input().split()))
children.sort()

ans = 0
for i in range(n):
	x = x - children[i]
	if i < n - 1:
		if x >= 0:
			ans += 1
	else:
		if x == 0:
			ans += 1

print(ans)

Measured memory_bytes: 9028
#include<stdio.h>

#define MAX(a,b) (a>b? a:b)

int memo[1010][1010];

int main(){
	int x,i,j,n;	scanf("%d",&n);
	char A[1010],B[1010];
	for(x=0;x<n;x++){
		for(i=0;i<200;i++)memo[0][i]=memo[i][0]=0;
		scanf("%s%s",A,B);

		for(i=0; A[i]!='\0'; i++){
			for(j=0; B[j]!='\0'; j++){
				if(A[i]==B[j])memo[i+1][j+1]=memo[i][j]+1;
				else memo[i+1][j+1]=MAX(memo[i][j+1],memo[i+1][j]);
			}
		}
		printf("%d\n",memo[i][j]);
	}


	return 0;
}



Measured memory_bytes: 5696
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

std::string s;
int dp[225816][2],t[225816],p[2][2]={{0,0},{2,1}};

int main(void){
	int n,i,ans;
	std::cin >> s;
	n = s.l_ength();
	if(s[0]!='P'){
		dp[0][1] = 1;
	}
	for(i=1; i<n; ++i){
		// D
		if(s[i]!='P'){
			dp[i][1] = std::max(dp[i][1],dp[i-1][0]+2);
			dp[i][1] = std::max(dp[i][1],dp[i-1][1]+1);
		}
		// P
		if(s[i]!='D'){
			dp[i][0] = std::max(dp[i][0],dp[i-1][0]);
			dp[i][0] = std::max(dp[i][0],dp[i-1][1]);
		}
	}
	ans = std::max(dp[n-1][0],dp[n-1][1]);
	if(s[n-1]!='?'){
		t[n-1] = (s[n-1]=='D');
	}else if(ans==dp[n-1][0]){
		t[n-1] = 0;
	}else{
		t[n-1] = 1;
	}
	for(i=(n-1); i>0; --i){
		if(s[i-1] != '?'){
			t[i-1] = (s[i-1]=='D');
			ans = dp[i-1][t[i-1]];
		}else if(dp[i][t[i]]==dp[i-1][0]){
			t[i-1] = 0;
		}else{
			t[i-1] = 1;
			ans -= p[t[i]][t[i-1]];
		}
	}
	for(i=0; i<n; ++i){
		std::cout << ((t[i])?'D':'P');
	}
	std::cout << std::endl;
	return 0;
}


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

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

using namespace std;

class union_find{
	int n;
	vector<int> p;
public:
	union_find(int n):n(n),p(n,-1){}
	int find(int u){ return p[u]<0?u:p[u]=find(p[u]); }
	void unite(int u,int v){
		u=find(u); v=find(v);
		if(u!=v){
			if(p[v]<p[u]) swap(u,v);
			p[u]+=p[v]; p[v]=u; n--;
		}
	}
	bool is_same(int u,int v){ return find(u)==find(v); }
	int size()const{ return n; }
	int size(int u){ return -p[find(u)]; }
};

int main(){
	int n,q; scanf("%d%d",&n,&q);
	union_find U(n);
	rep(_,q){
		int t,u,v; scanf("%d%d%d",&t,&u,&v);
		if(t==0) U.unite(u,v);
		else printf("%d\n",U.is_same(u,v));
	}

	return 0;
}


Measured memory_bytes: 4032
import java.util.Scanner;

class Main{
        public static void main(String[] args){
                Scanner scanner=new Scanner(System.in);
                int N=scanner.nextInt();
                boolean[] a=new boolean[N+1];
                for(int i=0;i<N;i++){
                        if(i+1==scanner.nextInt()){
                                a[i]=true;
                        }else{
                                a[i]=false;
                        }
                }

                int ans=0;
                int tmp=0;
                for(int i=0;i<N;i++){
                        if(a[i]){
                                a[i]=a[i+1]=false;
                                ans++;
                        }
                }

                System.out.println(ans);
        }
}

Measured memory_bytes: 50396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,c=0,cnt=0,d=0;
  bool f=true;
  cin>>n;
  vector<ll> s,t;
  ll a[n],b[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  for(int i=0;i<n;i++){
    int j=a[i]-b[i];
    if(j>0){
      t.push_back(j);
      c+=j;
    }else if(j<0){
      f=false;
      c+=j;
      d+=j;
      cnt++;
    }
  }
  if(f){
    cout<<0;
    return 0;
  }
  if(c<0){
    cout<<-1;
    return 0;
  }
  sort(t.begin(),t.end(),greater<ll>());
  for(int i=0;i<t.size();i++){
    d+=t[i];
    cnt++;
    if(d>=0) break;
  }
  cout<<cnt;
}

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

N, T = map(int, input().split())

imos = [0 for _ in range(T + 1)]

for _ in range(N):
    l, r = map(int, input().split())
    imos[l] += 1
    imos[r] -= 1

for i in range(T):
    imos[i + 1] += imos[i]

print(max(imos))


Measured memory_bytes: 9668
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

void solve();

int n;
int l[110];

int main() {
  cin >> n;
  rep(i, n) cin >> l[i];

  solve();

  return 0;
}

void solve() {

  sort(l, l+n, greater<int>());

  int max = l[0];
  int sum = 0;

  for(int i=1; i<n; ++i) {
    sum += l[i];
  }

  if(max<sum) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
                continue
            if L[i] + L[j] > L[k] and L[i] + L[k] > L[j] and L[j] + L[k] > L[i]:
                ans += 1
print(ans)

Measured memory_bytes: 68028
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	m := make(map[int]int)
	var a int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		as[i] = a
		m[a]++
	}

	sum := 0
	p := make(map[int]int)
	for a, c := range m {
		p[a] = c * (c - 1) / 2
		sum += p[a]
	}

	for i := 0; i < n; i++ {
		a := as[i]
		t := m[a] - 1
		c := t * (t - 1) / 2
		fmt.Println(sum - p[a] + c)
	}
}


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

signed main(){
  lint N; cin >> N;
  string s; cin >> s;
  lint cg = 0, cr  =0, cb = 0;
  for(lint i = 0; i < N; i++){
    if(s[i] == 'R') cr++;
    if(s[i] == 'G') cg++;
    if(s[i] == 'B') cb++;
  }
  lint ans = cg * cr * cb;
  for(lint i = 1; i <= N/2; i++){
    for(lint j = 0; j < N; j++){
      lint x = j, y = j + i, z = j + 2*i;
      if(y >= N || z >= N) continue;
      else if(s[x] != s[y] && s[y] != s[z] && s[x] != s[z]) ans--;
     }
  }
  cout << ans << endl;
}

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

bool f(int pos, vector<int>& v) {
  cout << pos << endl;
  string s;
  cin >> s;
  if (s == "Vacant")
    return true;
  if (s == "Male")
    v[pos] = 1;
  if (s == "Female")
    v[pos] = 2;
  return false;
}

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

  vector<int> v(n, 0);
  if (f(0, v)) {
    return 0;
  }
  if (f(n - 1, v)) {
    return 0;
  }

  int l = 0, r = n - 1;
  for (int i = 0; i < 20 - 2; ++i) {
    int h = l + (r - l) / 2;
    if (f(h, v)) {
      return 0;
    }

    if ((h - l) % 2 == 0 && v[h] != v[l]) {
      r = h;
    }
    if ((h - l) % 2 != 0 && v[h] == v[l]) {
      r = h;
    }
    if ((r - h) % 2 == 0 && v[r] != v[h]) {
      l = h;
    }
    if ((r - h) % 2 != 0 && v[r] == v[h]) {
      l = h;
    }
  }
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define int long long
void Digvijay()
{
    int d,t,s;
    cin>>d>>t>>s;
    double time = 1.0*d/s;
    if(time<=t)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _=1;
    //cin>>_;
    for(int __=1;__<=_;__++)
    {
        Digvijay();
    }
}



Measured memory_bytes: 3612