akhauriyash/Code-Regression huggingface dataset:
from itertools import combinations
import sys


def get_ngram(n, s):
    return [''.join(s[i:i+n]) for i in range(len(s)-n+1)]


def main():
    S = input()
    chars = {'A', 'C', 'G', 'T'}

    for i in range(len(S), -1, -1):
        for c in get_ngram(i, S):
            if set(c) <= chars:
                print(i)
                sys.exit()


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
# coding:utf-8
n = int(input())
a = list(map(int, input().split()))
a[0:0] = [0]
# print(a)
ans = [0] * n

for i in range(1, n):
    # print(i)
    num = a[i]
    ans[num - 1] += 1
    # print(num, num - 1)

for item in ans:
    print(item)


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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  int k;
  cin >> k;
  int a, b;
  cin >> a >> b;
  for (int i = k; i <= b; i += k) {
    if (i >= a) {
      cout << "OK\n";
      return 0;
    }
  }
  cout << "NG\n";
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

struct test{
    signed short mid;
    signed short fin;
    signed short re;
    unsigned char eval;
};
unsigned char evaluate(signed short mid, signed short fin, signed short re);
int main(){
    struct test test[50];
    unsigned short i;
    short unsigned count = 0;
    for(i = 0;i < 50;i++){
        scanf("%d %d %d", &test[i].mid, &test[i].fin, &test[i].re);
        if(test[i].mid == -1 && test[i].fin == -1 && test[i].re == -1){
            break;
        }
        test[i].eval = evaluate(test[i].mid, test[i].fin, test[i].re);
        count++;
    }
    for(i = 0;i < count;i++){
        printf("%c\n", test[i].eval);
    }
    return 0;
}

unsigned char evaluate(signed short mid, signed short fin, signed short re){
    signed short sum;
    unsigned char result;
    sum = mid + fin;
    if(mid == -1 || fin == -1){
        result = 'F';
    }
    else if(sum >= 80){
        result = 'A';
    }
    else if(sum >= 65){
        result = 'B';
    }
    else if(sum >= 50){
        result = 'C';
    }
    else if(sum >= 30){
        if(re >= 50){
            result = 'C';
        }
        else{
            result = 'D';
        }
    }
    else{
        result = 'F';
    }
    return result;
}


Measured memory_bytes: 2096
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N, A, B, C, D = MAP()
S = input()

if 1 <= S[A:max(C, D)].count("##"):
	print("No")
elif C < D:
	print("Yes")
else:
	if 1 <= S[B-2:D+1].count("..."):
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 10936
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)

print(ans)


Measured memory_bytes: 134276
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define in1(n) cin>>n;
#define in2(n, k) cin>>n>>k;
#define in3(n, k, s) cin>>n>>k>>s;
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (int i = j; i < k; i += in)
#define rloop(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define inar(n, a) \
    rep(i, n)\
        cin>>a[i];
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)\
{\
return (a.second < b.second);\
}
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast  \
    ios_base::sync_with_stdio(false);\
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

int solve (string s, string t)
{
    int sum = 0;
    rep(i, s.length()) if(s[i] != t[i]) sum +=1;
    return sum;
}

int main()
{
    fast
    string s, t;
    in2(s, t)
    int mn = INT_MAX;
    for(int i = 0; i <= (s.length()-t.length()); i++)
    {
        mn = min(mn, solve(s.substr(i, t.length()), t));
    }
    cout<<mn;
    return 0;
}

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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 200005;

int n, ans, a[N];

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n), ans = 1;
  for (int i = 1, x; i <= n; ++i) {
    Read(x), a[x] = i;
  }
  for (int i = 1, c = 0; i <= n; ++i) {
    if (a[i] > a[i - 1]) {
      CheckMax(ans, ++c);
    } else {
      c = 1;
    }
  }
  printf("%d\n", n - ans);
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 1024
def to_xy(str, target)
  str.chars.each_with_index do |s, i|
    if target == s.to_i
      x = i%4
      y = i < 4 ? 0 : 1
      return x, y, i
    end
  end
end

def move_zero(str, mx, my)
  zx, zy, zi = to_xy(str, 0)
  (1..7).each do |i|
    sx, sy, si = to_xy(str, i)
    if (zx + mx) == sx and (zy + my) == sy
      ns = str.dup
      ns[zi], ns[si] = ns[si], ns[zi]
      return ns
    end
  end
end

rule = Struct.new('Rule', :can_move?, :move)
rules = [
    rule.new(lambda { |str| x, _, _ = to_xy(str, 0); x <= 2 }, lambda { |str| move_zero(str,  1,  0) }),
    rule.new(lambda { |str| _, y, _ = to_xy(str, 0); y == 0 }, lambda { |str| move_zero(str,  0,  1) }),
    rule.new(lambda { |str| x, _, _ = to_xy(str, 0); x >= 1 }, lambda { |str| move_zero(str, -1,  0) }),
    rule.new(lambda { |str| _, y, _ = to_xy(str, 0); y == 1 }, lambda { |str| move_zero(str,  0, -1) })
]

goal = '01234567'
map_list = [goal]
answers = {goal => 0}
loop do
  search_map = map_list.shift
  break unless search_map
  rules.each do |rule|
    next unless rule.can_move?.call(search_map)
    next_map = rule.move.call(search_map)
    next if answers[next_map]
    answers[next_map.to_s] = answers[search_map] + 1
    map_list.push(next_map)
  end
end

while s = gets
  puts answers[s.chomp.split.join]
end

Measured memory_bytes: 9536
#include <stdio.h>
int main(void){
    int m,f,r;
    while(1){
        scanf("%d%d%d",&m,&f,&r);
        if(m == -1 && f== -1 && r == -1)break;
        if(m==-1||f==-1){
            printf("F\n");
        }else if((m+f)>=80){
            printf("A\n");
        }else if((m+f)<80&&(m+f)>=65){
            printf("B\n");
        }else if((m+f)<65&&(m+f)>=50){
            printf("C\n");
        }else if((m+f)<50&&(m+f)>=30&&r>=50){       
            printf("C\n");
        }else if((m+f)<50&&(m+f)>=30&&r<50){       
            printf("D\n");
        }else if((m+f)<30){       
            printf("F\n");   }}   
    return 0;
}



Measured memory_bytes: 2056
from collections import Counter
n=int(input())
a=[]
b=[]
for i in range(n):
    a.append(input())
m=int(input())
for i in range(m):
    b.append(input())
an=Counter(a)
bn=Counter(b)

count=0
for i in an:
    c=an[i]-bn.get(i,0)
    if c>count:
        count=c
print(count)

Measured memory_bytes: 3444
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[200001],ans,L;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    a[n]=0;
    if(a[0]!=0){cout<<-1<<endl;return 0;}
    reverse(a,a+n+1);
    for(int i=1;i<=n;i++){
        if(a[i-1]>a[i]+1){cout<<-1<<endl;return 0;}
        else if(a[i-1]!=a[i]+1)ans+=a[i];
    }
    cout<<ans<<endl;
}


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

int main(){
	int n;
	cin>>n;
	
	vector<pair<int,int> > ans;
	int p=(n%2==0)?n:n-1;//対の数.
	for(int i=1;i<=n;++i){
		for(int j=i+1;j<=n;++j){
			if(j!=p){
				ans.push_back(make_pair(i,j));
			}
		}
		p--;//point.
	}
	
	cout<<ans.size()<<endl;
	REP(i,ans.size()){
		cout<<ans[i].first<<' '<<ans[i].second<<endl;
	}
}//agc032_b.復習.解答解説参考.

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n;
  while(cin>>n,n) {
    char c[n][n];
    REP(i,n)
      REP(j,n)
      cin >> c[j][i];
    int dp[n][n];
    memset(dp,0,sizeof(dp));
    int ans = 0;
    REP(y,n) {
      REP(x,n) {
        if (c[x][y] == '.') {
          if (x>0&&y>0&&dp[x-1][y-1]>0) {
            int i=0;
            for(;i<dp[x-1][y-1];i++)
              if (c[x][y-i-1] == '*' || c[x-i-1][y] == '*')
                break;
            dp[x][y] = i+1;
          } else
            dp[x][y] = 1;
        }
        ans = max(ans,dp[x][y]);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
bool vis[2000006];
vector<int> ans;
void dfs(int u,vector<int> adj[])
{
    vis[u]=true;
ans.push_back(u);
    for(int i=0;i<adj[u].size();i++)
    {
        if(vis[adj[u][i]]==false)
        {
            dfs(adj[u][i],adj);
        }
        else
        {
            ans.push_back(adj[u][i]);
            return;
        }
    }

}
int main() {
    long long int n;
    long long int k;
    cin>>n>>k;
    vector<int> adj[n+1];
    for(int i=1;i<=n;i++)
    {
        int data;
        cin>>data;
        adj[i].push_back(data);
    }
    memset(vis,false,sizeof(vis));
    int count=0;
    dfs(1,adj);
     n=ans.size();int index=-1;
    for(int i=0;i<n-1;i++){
if(ans[i]==ans[n-1])
{
    index=i;break;
}
    }
    ans.pop_back();
    
    long long int before=index;
    long long int repeat=n-index-1;
    if(k<=before)cout<<ans[k]<<endl;
    else {
        k=k-index;
        long long int rem=k%(repeat);
        cout<<ans[(index+rem)];
    }
}


Measured memory_bytes: 26128
#include<stdio.h>
int main()
{
    int x0,y0,x1,y1,x2,y2,x3,y3,m1,m2,i,n,t;
    scanf("%d",&t);
    for(i=0;i<t;i++){
        scanf("%d%d%d%d%d%d%d%d",&x0,&y0,&x1,&y1,&x2,&y2,&x3,&y3);
        if(((y1-y0)*(x3-x2))-((y3-y2)*(x1-x0))==0)
            printf("2\n");
        else if(((y1-y0)*(y3-y2))+((x3-x2)*(x1-x0))==0)
            printf("1\n");
        else
            printf("0\n");
    }
    return 0;
}



Measured memory_bytes: 2140
import sys
L = []
for l in sys.stdin:
    L.append(l)
X, N = map(int, L[0].split())
p_N_list = map(int, L[1].split())

def calc_sub(n):
    return n - X

sub =  map(calc_sub, p_N_list)
abs_sort = sorted(sub, key=abs)

num = 0
check = 1
while(check):
  if (- num) not in abs_sort:
    print(X - num)
    check = 0
  elif num not in abs_sort:
    print(X + num)
    check = 0
  else:
    num += 1

Measured memory_bytes: 9208
#!/usr/bin/env python3
from collections import deque
h, w = map(int, input().split())
s = []
a = 0
for _ in range(h):
    s.append(list(input()))
mx = [1,-1,0,0]
my = [0,0,1,-1]
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            d = [[-1 for a in range(w)] for b in range(h)]
            d[i][j] = 0
            q = deque([(j,i)])
            while q:
                x, y = q.popleft()
                for c in range(4):
                    new_x = x + mx[c]
                    new_y = y + my[c]
                    if 0<=new_x<=w-1 and 0<=new_y<=h-1 and s[new_y][new_x] != "#" and d[new_y][new_x] < 0:
                        q.append((new_x,new_y))
                        d[new_y][new_x] = d[y][x] + 1
                        a = max(a, d[new_y][new_x])
                        
print(a)

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    string s; 
    cin >> s;
    ll L = s.size();

    vector<ll> A(L);

    ll ans = 0;
    for(int i=L-1; i>=0; i--){
        if(s[i]=='A'){
            ll count = 0;
            FOR(j, i+1, L){
                if(s[j]=='A'){
                    count += A[j];
                    break;
                }
                else if(s[j]=='B' && s[j+1]=='C'){
                    count++;
                    j++;
                }
                else{
                    break;
                }
            }
            A[i] = count;
            ans += count;
        }
    }

    // vprint(A);
    p(ans);

    return 0;
}

Measured memory_bytes: 2196
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
void solve()
{
	string s;
	cin>>s;
	int n=s.length();
	if(s[n-1]=='2'|| s[n-1]=='5' || s[n-1]=='4' || s[n-1]=='7'|| s[n-1]=='9')
		cout<<"hon";
	else if(s[n-1]=='3')
		cout<<"bon";
	else
		cout<<"pon";
}
signed main()
{
	fastio;
	solve();
}












Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n, t; cin >> n >> t;
	
	int mi = 1 << 30;
	for(int i = 0; i < n; i++) {
		int a, b; cin >> a >> b;
		
		if(b <= t) mi = std::min(mi, a);
	}
	
	if(mi == 1 << 30) cout << "TLE" << endl;
	else cout << mi << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, n, a);
    Sort(a);
    int m = (int)a.size();
    Unique(a);
    int ans = (int)a.size();
    if((ans + m) % 2) ans --;
    Cout(ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<'\n'
using namespace std;


int main() {
	SPEED;
	//freopen("in.txt", "r", stdin);
	int n; cin >> n;
	stack< int> ans;
	while(n){
		ans.push(abs(n) % 2);
		n -= ans.top();
		n /= (-2);
	}
	if(len(ans) == 0) print(0);
	else while(!ans.empty()){
		cout << ans.top();
		ans.pop();
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int main(void){
    int day,work,sum=0,t,ans;
    cin>>day>>work;
    for(int i=0;i<work;i++){
        cin>>t;
        sum+=t;
    }
    ans=day-sum;
    if(ans>=0){
        cout<<ans<<endl;
    }else{
        cout<<-1<<endl;
    }
    return 0;
}


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

int main(){
    int a[3];
    for(int i = 0; i < 3; i++)  cin >> a[i];
    sort(a, a+3);
    cout << a[0] + a[1] + a[2] * 10 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;


int main(){
    

    string s;
    cin >> s;
    if(s == "SUN")
        print(7);
    if(s == "MON")
        print(6);
    if(s == "TUE")
        print(5);
    if(s == "WED")
        print(4);
    if(s == "THU")
        print(3);
    if(s == "FRI")
        print(2);
    if(s == "SAT")
        print(1);
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<stack>
#include<vector>
#define maxn 10000000
typedef long long ll;
using namespace std;
int main()
{
	char s[maxn];
	scanf("%s",s);
	int l;
	l=strlen(s);
	for(int i=0;i<l;i++)
	{
		if(s[i] == 'h' && s[i+1] == 'i')
		{
			i++;
		}else{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
def parent(i)
  i/2
end

def left(i)
  i*2
end

def right(i)
  i*2 + 1
end

def extract(i)
  l = left(i)
  r = right(i)
  h = A.length

  # printf "extract %d\n",i
  # p A
  # printf "l %d  r %d  h %d\n",l,r,h

  if l < h && A[l] > A[i]
    @largest = l
  else
    @largest = i
  end

  if r < h && A[r] > A[@largest]
    @largest = r
  end

  if @largest != i
    A[i], A[@largest] = A[@largest], A[i]
    extract(@largest)
  end
end

def insert(i)
  @parent = parent(i)
  if @parent == 0
    return
  end

  if A[i] > A[@parent]
    A[i], A[@parent] = A[@parent], A[i]
    insert(@parent)
  end
end

A = Array.new
A << 0

until (str=gets.chomp) == "end"
  # p A
  if str == "extract"
    puts A[1]
    A[1] = A.pop
    extract(1)
  else
    str = str.split(" ")
    A << str[1].to_i
    insert(A.length-1)
  end
end



Measured memory_bytes: 14816
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
-- import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace

solve :: Int -> Int -> Int -> Int
solve bigA bigB bigC = bigB + min (bigA + bigB + 1) bigC

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bigA,bs_bigB,bs_bigC]:remLines1 = remLines0
      bigA = readBInt bs_bigA
      bigB = readBInt bs_bigB
      bigC = readBInt bs_bigC
  in solve bigA bigB bigC

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
  string s;
  cin>>s;
  ll n=s.length();
  set<char>st;
  for(int i=0;i<n;i++)
  {
    st.insert(s[i]);
  }
  if(st.size()==n)
    cout<<"yes"<<endl;
  else
    cout<<"no"<<endl;
    
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;



int main()
{
    int a,b;
    cin >> a >> b;
    int ans = 0;
    
    if(a==1 && b == 1){
        cout << 1000000;
        return 0;
    }else{
        if(a == 1) ans += 300000;
        if(b == 1) ans += 300000;
        if(a == 2) ans += 200000;
        if(b == 2) ans += 200000;
        if(a == 3) ans += 100000;
        if(b == 3) ans += 100000;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A_list = [0]*N
B_list = [0]*N
for i in range(N):
    A_list[i],B_list[i] = map(int,input().split())

A_list.sort()
B_list.sort()

if N%2 == 1:
    print(B_list[(N-1)//2] - A_list[(N-1)//2] + 1)
else:
    big = (B_list[N//2] + B_list[N//2-1])/2
    small = (A_list[N//2] + A_list[N//2-1])/2
    print(int((big-small)*2 + 1))

Measured memory_bytes: 25352
#include<bits/stdc++.h>
#include<iostream>
#include <iomanip>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
//#define mpr make_pair
#define gap ' '
#define abs(x) ((x)>0?(x):-(x))
#define INF 1e18
#define mod 1000000007
#define inf 1e9
ll powr(ll m,ll n)
{
    if(m==1)
        return 1;
    if(n==0)
        return 1;
    if(n==1)
        return m%mod;
    if(n%2)
    {
        ll te=powr(m,n/2);
        return (((te*te)%mod)*(m%mod))%mod;
    }
    else
    {
        ll te=powr(m,n/2);
        return (te*te)%mod;
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tc=1;
    //cin>>tc;
    int cs=0;
    while(tc--)
    {
      int n,x,t;
      cin>>n>>x>>t;
      int ne=n/x;
      if(n%x!=0) ne++;
      cout<<ne*t;
    }
}


Measured memory_bytes: 3608
#coding:utf-8
import itertools
n = int(input())
p = list(map(int, input().split()))
ans = 0
q = itertools.accumulate(p, min)
q = list(q)

for i in range(n):
    if p[i] <= q[i]:
        ans += 1
#print(list(q))
print(ans)


Measured memory_bytes: 25124
#include<bits/stdc++.h>
   
using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;
   
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n,q;
  cin >> n >> q;
  string s;
  cin >> s;

  vector<int> cum(n+5);

  reps(i,n){
    if(s[i-1] == 'A' && s[i] == 'C'){
      cum[i+1]++;
    }
    cum[i+1] += cum[i];
  }

  rep(i,q){
    int l,r;
    cin >> l >> r;
    cout << cum[r] - cum[l] << '\n';
  }

  return 0;
}

Measured memory_bytes: 1872
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
vector<int> G[100000];

int A[100000];
bool bad = false;
void dfs(int x, int d) {
  if (A[x] == -1) A[x] = d;
  else {
    if (A[x] != d) bad = true;
    return;
  }
  for (int t : G[x]) dfs(t, d^1);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].pb(b);
    G[b].pb(a);
  }
  rep(i, N) A[i] = -1;
  dfs(0, 0);
  long long m = 0;
  if (bad) m = (1LL*N*(N-1))/2;
  else {
    int a = 0;
    rep(i, N) if (A[i] == 0) a++;
    int b = N-a;
    m = 1LL*a*b;
  }
  cout << max(m-M, 0LL) << "\n";
  return 0;
}


Measured memory_bytes: 6528
class segmentTreeOR():
    initValue = 0
    dat = []
    lenTreeList = -1
    depthTreeList = 0
    lenOriginalList = -1

    def __init__(self):
        pass

    def load(self, l):
        # len(l)個よりも大きい2の二乗を得る
        self.lenOriginalList = len(l)
        self.lenTreeList = 2 ** (len(l) - 1).bit_length()  # len 5 なら 2^3 = 8
        self.depthTreeList = (len(l) - 1).bit_length()  # 木の段数(0 origin)
        self.dat = [self.initValue] * (self.lenTreeList * 2)
        # 値のロード
        for i in range(len(l)):
            self.dat[self.lenTreeList - 1 + i] = l[i]
        self.build()

    def build(self):
        for i in range(self.lenTreeList - 2, -1, -1):
            self.dat[i] = self.dat[2 * i + 1] | self.dat[2 * i + 2]

    def setValue(self, i, a):
        """
        set a to list[i]
        """
        # print("setValue: {0}, {1}".format(i, a))
        nodeId = (self.lenTreeList - 1) + i
        # print(" first nodeId: {0}".format(nodeId))
        self.dat[nodeId] = a
        while nodeId != 0:
            nodeId = (nodeId - 1) // 2
            # print(" next nodeId: {0}".format(nodeId))
            self.dat[nodeId] = self.dat[nodeId * 2 + 1] | self.dat[nodeId * 2 + 2]

    def querySub(self, a, b, nodeId, l, r):
        """
        [a,b) 区間の親クエリに対するノードnodeへ[l, r)の探索をデリゲート
        区間については、dataの添え字は0,1,2,3,4としたときに、
        [0,3)なら0,1,2の結果を返す
        """
        # print("querySub: a={0}, b={1}, nodeId={2}, l={3}, r={4}".format(a, b, nodeId, l, r))
        if (r <= a or b <= l):
            return self.initValue
        if a <= l and r <= b:
            return self.dat[nodeId]
        resLeft = self.querySub(a, b, 2 * nodeId + 1, l, (l + r) // 2)
        resRight = self.querySub(a, b, 2 * nodeId + 2, (l + r) // 2, r)
        return resLeft | resRight

    def query(self, a, b):
        return self.querySub(a, b, 0, 0, self.lenTreeList)

# https://yottagin.com/?p=2808
def count_ones_by_bin(num):
    bin_num = bin(num)[2:]
    count = 0
    for i in bin_num:
        count += int(i)
    return count

n = int(input())
s = input()
sl = list(s)
sl = list(map(lambda x: ord(x) - ord("a"), sl))

l = list(map(lambda x: 1 << x, sl))

st = segmentTreeOR()
st.load(l)

q = int(input())
for _ in range(q):
    ty, x, y = input().split()
    x = int(x)
    if ty == "1":
        nind = ord(y[0]) - ord("a") # 置き換えるindex
        st.setValue(x-1, 1 << nind)
    elif ty == "2":
        x = int(x) - 1
        y = int(y)
        res = 0
        cnt = st.query(x, y)
        print(count_ones_by_bin(cnt))
    else:
        print("error")

Measured memory_bytes: 122876
#include <iostream>

using namespace std;

long long gcd(long long a, long long b);
long long lcm(long long a, long long b);

int main()
{
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	a--;

	long long ans = b - b / c - b / d + b / lcm(c, d);
	ans -= a - a / c - a / d + a / lcm(c, d);

	cout << ans << endl;

	return 0;
}

long long gcd(long long a, long long b)
{
	if (a < b) {
		long long t = a;
		a = b;
		b = t;
	}

	long long r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

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

Measured memory_bytes: 384
#pragma region Include
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << endl
template <class T>
using VV = vector<vector<T>>;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;
#pragma endregion

vi state;

bool dfs_two(const vvi& G, int v, bool color) {
  state[v] = color;
  for (int i = 0; i < G.size(); ++i) {
    if (G[i][v] == 1) {
      if (state[i] != -1) {
        if (state[i] == color)
          return false;
        else
          continue;
      }
      if (!dfs_two(G, i, !color)) return false;
    }
  }
  return true;
}

int main() {
  int N;
  cin >> N;
  vvi G;
  resize(G, N, N);
  char tmp;
  rep(i, N) rep(j, N) {
    cin >> tmp;
    G[i][j] = tmp - '0';
    if (i != j && tmp == '0') {
      G[i][j] = INF;
    }
  }

  state.assign(N, -1);
  bool pos = dfs_two(G, 0, 0);
  if (!pos) {
    cout << "-1" << endl;
    return 0;
  }

  vvi d = G;
  rep(k, N) rep(i, N) rep(j, N) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

  // cout << G << endl;
  // cout << d << endl;

  pii maxind = mp(-1, -1);
  int m = -1;
  rep(i, N) rep(j, N) if (m < d[i][j]) {
    m = d[i][j];
    maxind = mp(i, j);
  }

  cout << m + 1 << endl;

  return 0;
}

Measured memory_bytes: 640
//_Krenil_Bhikadiya_

#include<bits/stdc++.h>
#define MAX_SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define max(a,b) (a<b?b:a) 
#define min(a,b) (a>b?b:a) 
#define ll long long
#define ld long double
#define llu unsigned long long int
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define umap unordered_map
#define uset unordered_set
#define rep(i,a,n) for(int i=(int)a;i<(int)n;i++)
#define rev(i,n,a) for(int i=(int)n;i>=(int)a;i--)
#define pb push_back
#define ff first
#define ss second
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define endl "\n"
const int INF  = 1e9;
const llu INFM = 1e18;
const int mod  = INF+7;
using namespace std;


int gcd(int A,int B)
{
	if(A==0) return B;

	return gcd(B%A,A);
}

int lcm(int A,int B)
{
	return ( A*B / gcd(A,B) );
}

ll mod_pwr(ll A,ll B,ll P)
{
	ll RES = 1; A %= P;

	while(B>0)
	{
		if(B&1) RES = RES * A % P;
		A = A * A % P;
		B >>= 1;
	}

	return RES;
}

llu pwr(llu A,llu B)
{
	llu RES=1;

	while(B>0)
	{
		if(B&1) RES*=A;
		A=A*A;
		B>>=1;
	}

	return RES;
}

ll modInv(ll A,ll M)
{
	return mod_pwr(A,M-2,M);
}

bool isPrime(int N)
{
	if(N==1) return false;

	for(int i=2;i*i<=N;i++)
	{
		if(N%i==0) return false;
	}

	return true;
}

ll dp[101][100001];

int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	MAX_SPEED
	
	int test=1; //cin>>test;
	while(test--)
	{
		string S,T; cin>>S>>T;

		int N=sz(S), M=sz(T);

		int dp[N+1][M+1];

		vector<char> V;

		memset(dp,0,sizeof dp);

		rep(i,1,N+1)
		{
			rep(j,1,M+1)
			{
				if(S[i-1]==T[j-1])
				{
					dp[i][j]=1+dp[i-1][j-1];
				} 
				else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}

		int i=N,j=M;
		while(i>0 and j>0)
		{
			if(S[i-1]==T[j-1]) V.pb(S[i-1]),i--,j--;
			else
			{
				if(dp[i][j-1]>dp[i-1][j]) j--;
				else i--;
			}
		}

		reverse(all(V));
		for(auto X:V) cout<<X; cout<<endl;
	}
}

Measured memory_bytes: 38848
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;


int main(){
        int q;
        cin >>q;
        rep(i,q){
                string x,y;
                cin >> x >>y;
                vector<vector<int>> dp(x.size()+1,vector<int>(y.size()+1,0));
                
                for(int i=1;i<=x.size();i++){
                        for(int j=1;j<=y.size();j++){
                                if(x.at(i-1) == y.at(j-1)) dp.at(i).at(j) = dp.at(i-1).at(j-1) + 1;
                                else dp.at(i).at(j) = max(dp.at(i-1).at(j),dp.at(i).at(j-1));
                        }
                }
                
                cout << dp.at(x.size()).at(y.size()) << endl;
        }

        return 0;
}



Measured memory_bytes: 6868
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 1e3 + 17;
ll cnt, lnt, mn = N, mx, a[N], n, m ,k, x , y, z;
pair<ll,ll>pr[N];
vector<ll>v,v2,v3;
map<ll,ll>mp;
bool used[N], t1, t2;
vector<string>sv;

int main()
{
    string s;
    cin >> n >> m >> s;
    vector<ll>hi(n);
    for(ll i = 0; i < s.size() - 1; i ++)
    {
        if(s[i] == 'A' and s[i+1] == 'C')
        {
            hi[i+1] = hi[i] + 1;
        }
        else
        {
            hi[i+1] = hi[i];
        }
    }
    for(ll i = 0; i < m; i ++)
    {
        cin >> x >> y;
        cout << hi[y - 1] - hi[x - 1] << endl;
    }
}


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

int main() {
  int a, b, k; cin >> a >> b >> k;
  int c = a % b;
  while (c) {
    a = b; b = c; c = a % b;
  }
  vector<int> ans;
  for (int i=b; i>0; --i) {
    if (b % i == 0) ans.push_back(i);
  }
  cout << ans[k-1] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
 
using namespace std;
 
#define REP(i, n) for(int i=0; i<n; i++)
 
struct edge{
    int to, dist, t;
};
 
typedef pair<int, pair<int, int> > pii; // thief, edge, money
 
int INF = 10e8;
int n, m, l;

int thief[101][101];
 
int main(){
    while(1){
        cin >> n >> m >> l;

        if(n==0) break;
 
        vector<edge> g[101];
        REP(i, m){
            int a, b, d, e;
            cin >> a >> b >> d >> e;
            edge ae;
            ae.to = b;
            ae.dist = d;
            ae.t = e;
            g[a].push_back(ae);
            edge be;
            be.to = a;
            be.dist = d;
            be.t = e;
            g[b].push_back(be);
        }
 
        priority_queue<pii, vector<pii>, greater<pii> > que;
        REP(i, n+1){
            REP(j, l+1){
                thief[i][j] = INF;
            }
        }
        thief[1][l] = 0;
        pii init = make_pair(0, make_pair(1, l));
        que.push(init);
 
        while(!que.empty()){
            pii p = que.top();
            que.pop();
 
            int v = p.second.first;
            int m = p.second.second;
            if(thief[v][m]<p.first) continue;
            REP(i, g[v].size()){
                edge e = g[v][i];
                if(thief[e.to][m] > thief[v][m] + e.t){
                    thief[e.to][m] = thief[v][m] + e.t;
                    que.push(pii(make_pair(thief[e.to][m], make_pair(e.to, m))));
                }
                if(m >= e.dist && thief[e.to][m-e.dist] > thief[v][m]){
                    thief[e.to][m-e.dist] = thief[v][m];
                    que.push(pii(make_pair(thief[e.to][m-e.dist], make_pair(e.to, m-e.dist))));
                }
            }
        }
        /*
        REP(i, n+1){
            REP(j, c+1){
                cout << dis[i][j] << " ";
            }
            cout << endl;
        }
        */
        int output = INF;
        REP(i, l+1){
            output = min(output, thief[n][i]);
        }
        cout << output << endl;
    }
}

Measured memory_bytes: 3460
// Distance.c
// ２点 P1(x1, y1), P2(x2, y2) の距離を求めるプログラムを作成せよ。
// 【入力】
// x1, y1, x2, y2 （実数）が空白区切りで与えられます。
// 【出力】
// P1とP2の距離を実数で１行に出力して下さい。0.0001以下の誤差があってもよいものとします。
// 【例】
// 入力１：
// 0 0 1 1
// 出力１:
// 1.41421356
#include<stdio.h>
#include<math.h>

int main( void) {
  double x1, y1, x2, y2;

  scanf( "%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

  printf( "%.8lf\n", sqrt( pow( fabs(x1-x2), 2) + pow( fabs(y1-y2),2)));

  return 0;
}



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

bool cmp(int a,int b)
{
	return a<b;
}

int main(void)
{
	int n;
	cin>>n;
	int p[n];
	int a[n]={0};
	int di=0;
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
		a[i]=p[i];
	}
	sort(a,a+n,cmp);
	for(int i=0;i<n;i++)
	{
		if(a[i]!=p[i])
		di++;
	}
	if(di==0 || di==2)
	cout<<"YES\n";
	else
	cout<<"NO\n";
}


Measured memory_bytes: 256
L, R = map(int,input().split())
if R-L>=2018:
    print(0)
else:
    lst = [i%2019 for i in range(L,R+1)]
    lst = set(lst)
    lst = list(lst)
    N = len(lst)
    ans = 10**8
    for i in range(N-1):
        for j in range(i+1,N):
            if ans>(lst[i]*lst[j])%2019:
                ans = (lst[i]*lst[j])%2019
    print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {if(a < b) {a= b;return 1;}return 0;}
template <class T> inline bool chmin(T &a, T b) {if(a > b) {a= b;return 1;}return 0;}
ll mod= 1e9 + 7;


int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans=a*100+b*10+c;
  if(ans%4==0){cout << "YES" << endl;}else{cout << "NO" << endl;}
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <math.h>
#define SQ(a) ((a) * (a))

int main(void)
{
	int n;
	double Ax, Ay, Bx, By, Cx, Cy;
	double A, B, C;
	double cosA, cosB, cosC;
	double sinA, sinB, sinC;
	double sin2A, sin2B, sin2C;
	double GaisinX, GaisinY, radius;
	
	scanf("%d", &n);
	
	while (n-- != 0){
	
		scanf("%lf%lf%lf%lf%lf%lf", &Ax, &Ay, &Bx, &By, &Cx, &Cy);
		
		A = sqrt(SQ(Bx - Cx) + SQ(By - Cy));
		B = sqrt(SQ(Cx - Ax) + SQ(Cy - Ay));
		C = sqrt(SQ(Ax - Bx) + SQ(Ay - By));
		
		cosA = (SQ(B) + SQ(C) - SQ(A)) / (2 * B * C);
		cosB = (SQ(C) + SQ(A) - SQ(B)) / (2 * C * A);
		cosC = (SQ(A) + SQ(B) - SQ(C)) / (2 * A * B);
		
		sinA = sqrt(1 - SQ(cosA));
		sinB = sqrt(1 - SQ(cosB));
		sinC = sqrt(1 - SQ(cosC));
		
		sin2A = 2 * sinA * cosA;
		sin2B = 2 * sinB * cosB;
		sin2C = 2 * sinC * cosC;
		
		GaisinX = (Ax * sin2A + Bx * sin2B + Cx * sin2C) / (sin2A + sin2B + sin2C);
		GaisinY = (Ay * sin2A + By * sin2B + Cy * sin2C) / (sin2A + sin2B + sin2C);
		
		radius = A / (2 * sinA);
		
		printf("%.3f %.3f %.3f\n",GaisinX, GaisinY, radius);
	}
	return (0);
}

Measured memory_bytes: 0