akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
//const int MOD = (int) 1e9 + 7;
const int MOD = 998244353;
const int FFTMOD = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

const int maxn = 1e6 + 5;
int fac[maxn];
int ifac[maxn];

int binom(int a, int b) {
    return mult(fac[b], mult(ifac[a], ifac[b - a]));
}

void chemthan() {
    fac[0] = 1; FOR(i, 1, maxn) fac[i] = mult(fac[i - 1], i);
    FOR(i, 0, maxn) ifac[i] = inv(fac[i]);
    int n; long long a, b, k; cin >> n >> a >> b >> k;
    int res = 0;
    FOR(i, 0, n + 1) {
        long long xz = i;
        long long yz = k - xz * a;
        if (yz < 0) continue;
        if (yz % b) continue;
        yz /= b;
        if (yz > n) continue;
        addmod(res, mult(binom(xz, n), binom(yz, n)));
    }
    cout << res << "\n";
}

int main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 8064
#include<stdio.h>
#define N 8
#define WHITE 1
#define BLACK -1
 
int map[N][N];

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];


void outprint(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(map[i][j]==BLACK) {
	if(row[i]!=j)return;
      }
    }
  }


  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j){printf("Q");}
      else printf(".");
    }
    printf("\n");
    
  }

}



void initialize(){
  int i,j;
  
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      map[i][j]=WHITE;
    }
  }
  
  for(i=0;i<N;i++){row[i]=WHITE;col[i]=WHITE;}
  for(i=0;i<2*N-1;i++){dpos[i]=WHITE;dneg[i]=WHITE;}
  
}



void insert(int j){
  if(j==N){
    outprint();
    return; }

  int i;
  
  for(i=0;i<N;i++){
    if(col[i]==BLACK || dpos[i+j]==BLACK || dneg[j-i+N-1]==BLACK){continue; }
    row[j]=i;
    col[i]=dpos[j+i]=dneg[j-i+N-1]=BLACK;
    insert(j+1);
    row[j]=col[i]=dpos[j+i]=dneg[j-i+N-1]=WHITE;
  }

}


int main(){
  int number;
  int i,j;
  int tate,yoko;
  
  scanf("%d",&number);
  for(i=0;i<number;i++) {
    scanf("%d%d",&tate,&yoko);
    map[tate][yoko]=BLACK;
  }
  /*
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      printf("%d ",map[i][j]);
    }
    printf("\n");
  }
  */
  
  insert(0);  

  return 0;
}



Measured memory_bytes: 2112
import Data.List

fold_blue::[String]->[(String,Int)]
fold_blue = (map (\ ls -> (head ls,length ls) )).group.sort

check_red::[(String,Int)]->[String]->[(String,Int)]
check_red dat []      =dat
check_red dat (s:rest)= check_red (modify s dat) rest

modify::String->[(String,Int)]->[(String,Int)]
modify s [] = []
modify s ((t,v):rest) = if s == t then ((t,v-1):rest) else (t,v):(modify s rest)

solver::[String]->[String]->Int
solver blue_dat red_dat = let ls = ("",0):check_red (fold_blue blue_dat) red_dat in
                          maximum (map snd ls)

n_get::Int->IO [String]
n_get 0 = return []
n_get n = do
  d<-getLine
  rest<-n_get (n-1)
  return (d:rest)

main::IO()
main=do
  nc<-getLine
  let n=read nc
  blue<-n_get n
  mc<-getLine
  let m=read mc
  red<-n_get m
  print (solver blue red)

Measured memory_bytes: 636
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
    string a,b;
    cin>>a>>b;
    int al=a.size(),bl=b.size();
    //cout<<al<<" "<<bl<<"\n";
    vector<vector<int>>dp(al+1, vector<int>(bl+1,0));
    for(int i=1;i<=al;i++){
        for(int j=1;j<=bl;j++){
            //cout<<a[i-1]<<b[j-1]<<" ";
            if(a[i-1]==b[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
                //cout<<dp[i][j];
            }
            else
                dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
            }
    }
    int i=al,j=bl;
    string ans="";
    while(1){
        if(i==0 || j==0)
            break;

        else if(dp[i-1][j]==dp[i][j])
            i--;
        else if(dp[i][j-1]==dp[i][j])
            j--;
        else{
            ans=a[i-1]+ans;
            i--;j--;
         }
    }
    cout<<ans;
}


Measured memory_bytes: 35584
def solve(n, x, t):
    if n % x == 0:
        return t * (n // x)
    else:
        return t * (n // x + 1)


def main():
    n, x, t = map(int, input().split())
    res = solve(n, x, t)
    print(res)


def test():
    assert solve(20, 12, 6) == 12
    assert solve(1000, 1, 1000) == 1000000


if __name__ == "__main__":
    test()
    main()


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

const ll mod = 998244353;
template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}
ll cnt[100010];
int main(){
  int n;
  cin >> n;
  int mx = 0;
  rep(i,n) {
    int d;
    cin >> d;
    if (i == 0 && d != 0) {
      cout << 0 << endl;
      return 0;
    }
    cnt[d]++;
    mx = max(mx,d);
  }
  ll res = 1;
  if (cnt[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < mx; i++) {
    (res *= mod_pow(cnt[i],cnt[i+1],mod)) %= mod;
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 1024
from collections import deque
n = int(input())
s = [list(map(int, list(input()))) for _ in range(n)]
bord = [[] for _ in range(n)]
for i in range(n-1):
    for j in range(i+1, n):
        if s[i][j]==1:
            bord[i].append(j)
            bord[j].append(i)

result = []
for i in range(n):
    ch = True
    visit = [-1 for _ in range(n)]
    visit[i] = 1
    q = deque([i])
    while q:
        x = q.popleft()
        for y in bord[x]:
            if visit[y]<0:
                visit[y] = visit[x]+1
                q.append(y)
            elif (visit[y] == visit[x]+1) or (visit[y]==visit[x]-1):
                continue
            else:
                ch = False
                break
    if ch:
        result.append(max(visit))
    else:
        result = [-1]
        break
print(max(result))


Measured memory_bytes: 4076
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
    int h, w;
    scanf("%d %d", &h, &w);

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            char s[10];
            scanf("%s", s);
            if (strcmp(s, "snuke") == 0) {
                printf("%c%d\n", j + 'A', i + 1);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
int main(){
  int a[5000],b[5000],n,m,i,j,k,max=0,c;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  for(i=0;i<m;i++)scanf("%d",&b[i]);
  for(i=0;i<m;i++){
    k=i;
    c=0;
    for(j=0;j<n;j++){
      if(a[j]==b[k]){
	k++;
	c++;
      }
    }
    if(max<c)max=c;
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 636
nums = Array.new
nums << $_.to_i while gets
nums.sort!
num_max = 0
results = Array.new
while true
  target = nums.select {|x| x == nums[0]}
  temp_max = target.size
  if num_max < temp_max
    results.clear
    results << target.first
    num_max, temp_max = temp_max, 0
  elsif temp_max == num_max
    results << target.first
  end
  nums = nums.slice!(target.size,(nums.size-target.size))
  break if nums.size == 0
end

0.upto(results.size-1) {|p| puts results[p]}

Measured memory_bytes: 6136
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<numeric>
#include<cmath>

#define forf(i, a, b, c) for(int i=a; i<b; i=i+c)
#define forb(i, a, b, c) for(int i=a; i>=b; i=i-c)

typedef long long ll;

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	forf(i, 0, n, 1){
		cin >> h[i];
	}

	vector<int> dp(n);
	dp[0] = 0;
	forf(i, 1, n, 1){
		dp[i] = dp[i-1] + abs(h[i] -h[i-1]);
		if(i >= 2){
			dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
		}
	}
	cout << dp.back() << "\n";

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i == n-1) {
      ans += p[i]/2;
    } else {
      ans += p[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque


N, M = map(int, input().split())
to = [[] for _ in range(N)]

for i in range(M):
    A, B = map(int, input().split())
    to[A-1].append(B-1)
    to[B-1].append(A-1)

route = deque([0])
dist = [0]*N
prev = [-1]*N

while route:
    v = route.popleft()
    for u in to[v]:
        if dist[u]: continue
        dist[u] = dist[v]+1
        prev[u] = v
        route.append(u)

print("Yes")
for pre in prev[1:]:
    print(pre+1)

Measured memory_bytes: 35436
import java.util.Scanner;
class Main
{
public static void main(String args[])
{
Scanner scan=new Scanner(System.in);

while(true)
{
int count[]=new int[10];
int n=scan.nextInt();
if(n==0)break;
	for(int i=0;i<n;i++)
	{
	int kind=scan.nextInt();
	count[kind]++;
	}
	for(int i=0;i<10;i++)
	{
		for(int j=0;j<count[i];j++)
		{
		System.out.print("*");
		}
		if(count[i]==0)System.out.println("-");
		System.out.println();
	}
}
}
}

Measured memory_bytes: 54012
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 10000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
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;}

ll n, a[200005], subsum, ans = INF, allsum;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    rep(i, 0, n) {
        cin >> a[i];
        allsum += a[i];
    }
    rep(i, 0, n) {
        subsum += a[i];
        if (i + 1 < n) 
            ans = min(ans, abs(subsum-(allsum-subsum)));
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
const int maxN = 2*10e5 + 5;


//树状数组

int main() {
	int x;
	scanf("%d",&x);
	if(x==3 || x== 5 || x== 7)
	{
		puts("YES");	
	} 
	else
	{
		puts("NO");
	}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int n;cin >> n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    vector<int> ord(n);
    iota(ALL(ord),0);
    sort(ALL(ord),[&](int x,int y){
        return a[x] < a[y];
    });
    sort(ALL(a));
    rep(i,n){
        if(ord[n-1] == i)cout << a[n-2] << endl;
        else cout << a[n-1] << endl;
    }
    return 0;
}

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

int main(){
	int n,r;
	while((cin >> n)&&(cin >> r)&&(n!=0)&&(r!=0)){
		int a[256];
		int cnt=n;
		for(int i=0;i<n;i++){
			a[i] = cnt;
			cnt--;
			//cout << "a[" << i << "]" << a[i] << endl;
		}
		int p,c;
		//cout << endl;
		for(int i=0;i<r;i++){
			cin >> p;
			cin >> c;
			int b[50];
			//cout << p << endl;
			//cout << c << endl;
			//cout << endl;
			if(n!=c){
				for(int j=0;j<p-1;j++){
					b[j+c] = a[j];
				}
				for(int j=0;j<c;j++){
					b[j] = a[p+j-1];	
				}
				for(int j=0;j<p+c-1;j++){
					a[j] = b[j];	
					//cout << "a[" << j << "]" << a[j] << endl;
				//	cout << "b[" << j << "]" << b[j] << endl;
				}
			}
		}
		cout << a[0] << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int n;
int a[100];
int main() {
  cin >> n;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  
  int mn = INF;
  int sp = 0;
  for (int i = 0; i < n - 1; ++i) {
    sp += a[i];
    mn = min(mn, abs(sum - 2 * sp));
  }
  cout << mn << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
const int MAX = 1000000;
const int MOD = 1000000007;
 
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll modPow(ll a, ll n, ll p) {
  if (n == 0) return 1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}
ll choose(ll n, ll r, ll mod){
    ll mul = 1, div = 1;
    for(ll i = 0; i < r; i++){
        mul *= n - i;
        div *= i + 1;
        mul %= mod;
        div %= mod;
    }   
    return mul * modPow(div, mod - 2, mod) % mod;
}
 
int main(){
  int n;
  cin >> n;
  vector<double>a(n);
  rep(i, 0, n)cin >> a[i];
  sort(a.begin(),a.end());
  double p = a[0];
  rep(i, 1, n){
    p = (p+a[i])/2;
  }
  cout << fixed << setprecision(10) << p << endl;
}

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

#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
#define input freopen("input.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define fast_io ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
#define fix cout << fixed << setprecision(15);
//#define left left228
//#define right right228
//#define next next228
#define rank rank228
//#define prev prev228
#define y1 y1228
#define dout if(debug) cout
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int> ;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int> ;
using vll = vector<ll> ;
using vpii = vector<pii> ;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
const int mod = 1e9 + 7;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a-b) < 1e-9; }
inline bool IF(int a, int b, int c) { return (a >= b && a <= c); }
inline bool IFS(int a, int b, int c) { return (a > b && a < c); }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//typedef pair<int, int> pt;
//#define x first
//#define y second
//ifstream cin("input.txt");
//ofstream cout("output.txt");
/*
sort(a, a + n, [&](pair<pt, int> a, pair<pt, int> b){if (a.x.x != b.x.x)
        return a.x.x < b.x.x; return a.x.y > b.x.y;});
for(int c : s)
for(int &i : a) cin >> i;
for(int c = 'a'; c <= 'z'; ++c)
vector<vector<ll>> dp(n, vector<ll>(n+2));
__int128;
char 0 = int 48;
char c = cin;
int h = (int)c - 48;
*/

/*char memory[(int)1e8];

char memorypos;

inline void * operator new(size_t n){
    char * ret = memory + memorypos;
    memorypos += n;
    return (void *)ret;
}

inline void operator delete(void *){}
*/

int dp[nv];

int a[nv];

int inline solve() {
    //input;//,output;
    //fix;
    fast_io;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    fill(dp, dp + n, inf);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i] - a[i + 1]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]));
    }
    cout << dp[n - 1];
    return 0;
}

int32_t main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}
/*
6
2 1 6 3 4 5
2 1 3 4 5 6
6 0
1 7 8 2 4 6
 * */

Measured memory_bytes: 1024
import itertools
N = int(input())
a = list(itertools.permutations(range(1, N+1)))

s = []
for i in a:
  ans = ""
  for j in i:
    ans+=str(j)
  s.append(ans)

P = "".join(list(input().split()))
Q = "".join(list(input().split()))
ans = abs((s.index(P)+1)-(s.index(Q)+1))
print(ans)


Measured memory_bytes: 10868
import math
l = list(input())
N = len(l)
for i in range(math.floor((N+1)/4)):
  if l[i] == l[N- 1 - i] and l[i] == l[int((N-3)/2 - i)] and l[int((N-3)/2 - i)] == l[int((N+1)/2 + i)]:
    continue
  else:
    print('No')
    exit()
print('Yes')

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

#define rep( i, n ) for( int i = 0; i < ( n ); i++ )
#define PI 3.14159265
typedef long long ll;

int main( void ) {

    string w;
    cin >> w;
    string t;
    int    cnt = 0;
    while( cin >> t ) {
        if( t == "END_OF_TEXT" ) break;
        for( int i = 0; i < t.length(); i++) t.at(i) = tolower( t.at(i) );
        if( t == w ) cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3208
package main

import (
  "fmt"
)

func main() {
  var N, M int
  fmt.Scan(&N, &M)
  C := make([][]int, N)
  P := make([]int, N)
  for i := 0; i < N; i++ {
    P[i] = 0
  }
  for i := 0; i < N - 1 + M; i++ {
    var a, b int
    fmt.Scan(&a, &b)
    C[a - 1] = append(C[a - 1], b - 1)
    P[b - 1] -= 1
  }
  Q := make([]int, N)
  for i := 0; i < N; i++ {
    if P[i] == 0 {
      Q[0] = i
      break
    }
  }
  pos := 0
  que := 1
  for ; pos < que; {
    q := Q[pos]
    pos += 1
    for _, c := range C[q] {
      P[c] += 1
      if P[c] == 0 {
        P[c] = q + 1
        Q[que] = c
        que += 1
      }
    }
  }
  for _, p := range P {
    fmt.Println(p)
  }
}


Measured memory_bytes: 9728
def main():
    X=int(input())
    if 400<=X<=599:
        print(8)
    elif 600<=X<=799:
        print(7)
    elif 800<=X<=999:
        print(6)
    elif 1000<=X<=1199:
        print(5)
    elif 1200<=X<=1399:
        print(4)
    elif 1400<=X<=1599:
        print(3)
    elif 1600<=X<=1799:
        print(2)
    else:
        print(1)
if __name__=='__main__':
    main()

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
  int paSize = printArray.size();
  for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
  if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N;

signed main() {
  cin >> N;
  int cnt = 0;
  rep (i, N) {
    int a;
    cin >> a;
    if (a%2 == 0) cnt++;
  }

  puts(cnt==N?"second":"first");

  return 0;
}


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

int main() {
   char c;
   cin >> c;
   char ans = (c - 'a' + 1) % 26 + 'a';
   cout << ans << endl;
   return 0;
}


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

int main() {
  int X,Y,Z,K;
  cin >> X >> Y >> Z >> K;
  
  /*X = 1000;
  Y = 1000;
  Z = 1000;
  K = 3000;*/
  
  vector<long> A(X),B(Y),C(Z);
  for (int i=0; i<X; i++) {
    cin >> A[i];
  }
  for (int i=0; i<Y; i++) {
    cin >> B[i];
  }
  for (int i=0; i<Z; i++) {
    cin >> C[i];
  }
  
  /*for (int i=0; i<X; i++) {
    A[i] = i*3;
  }
  for (int i=0; i<Y; i++) {
    B[i] = i*i*4+334;
  }
  for (int i=0; i<Z; i++) {
    C[i] = i*i*i*2+33333333;
  }*/
  
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  sort(C.begin(),C.end());
  reverse(C.begin(),C.end());
  vector<long> value(K+Z,0);
  long noK = 0;
  for (int i=0; i<X; i++) {
    if (A[i]+B[0]+C[0] <= noK) {
      break;
    }
    for (int j=0; j<Y; j++) {
      if (A[i]+B[j]+C[0] <= noK) {
        break;
      }
      for (int k=0; k<Z; k++) {
        if (A[i]+B[j]+C[k] <= noK) {
          break;
        }
        value[K+k] = A[i]+B[j]+C[k];
      }
      sort(value.begin(),value.end());
      reverse(value.begin(),value.end());
      noK = value[K-1];
    }
  }
  for (int i=0; i<K; i++) {
    cout << value[i] << endl;
  }
}

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

using namespace std;
typedef long long ll;

int main() {

    string S;
    cin >> S;

    vector<ll> members; //項

    int length = S.length();

    for (int bit = 0; bit < (1 << length - 1); bit++)  {
        int current_index = 0;
        
        for (int i = 0; i < length - 1; i++) {
            if (bit & 1 << i) {
                int previous_index = current_index;
                current_index = i + 1;
                members.push_back(stoll(S.substr(previous_index, current_index - previous_index)));
            }             
        }

    members.push_back(stoll(S.substr(current_index, S.length() - current_index)));
    }

    cout << accumulate(members.begin(), members.end(), 0LL) << endl;

    return 0;
}
  



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

using namespace std;

int is_submask(int mask, int submask)
{
    return ((mask&submask) == submask);
}

int main()
{
    int no_of_boxes, no_of_keys;
    cin >> no_of_boxes >> no_of_keys;

    vector <long long> cost(no_of_keys + 1, 0);
    vector <int> no_of_openable_boxes(no_of_keys + 1, 0);
    vector <long long> mask(no_of_keys + 1, 0);

    for(int i = 1; i <= no_of_keys; i++)
    {
        cin >> cost[i] >> no_of_openable_boxes[i];

        for(int j = 1; j <= no_of_openable_boxes[i]; j++)
        {
            int key;
            cin >> key;

            key--;
            mask[i] |= (1 << key);
        }
    }

    long long oo = 1e12;
    int complete_mask = (1LL << no_of_boxes) - 1;
    vector <long long> minimum_cost(complete_mask + 1, oo);
    minimum_cost[0] = 0;

    for(int i = 1; i <= no_of_keys; i++)
    {
        for(int m = 0; m <= complete_mask; m++)
        {
            if(is_submask(m,mask[i]))
            {
                for(int sub_m = 0; sub_m <= complete_mask; sub_m++)
                {
                    if(is_submask(mask[i],sub_m))
                    {
                        minimum_cost[m] = min(minimum_cost[m], minimum_cost[m^sub_m] + cost[i]);
                    }
                }

            }
        }
    }

    cout << (minimum_cost[complete_mask] == oo ? -1 : minimum_cost[complete_mask]) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int i,pasta,drink,input;
	pasta=0;
	drink=0;
	scanf("%d",&pasta);
	for(i=0;i<2;i++){
		scanf("%d",&input);
		if(pasta>input)pasta=input;
	}
	scanf("%d",&drink);
	scanf("%d",&input);
	if(drink>input)drink=input;
	printf("%d\n",pasta+drink-50);
return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  int i,n,a;
  double d=0,ans;

  cin >> n;

  rep(i, n){
      cin >> a;
      d += (double)(1.0/a);
  }

  ans = (double)(1.0/d);

  cout << fixed << setprecision(10) << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try(Scanner scan = new Scanner(System.in);){
			int A = Integer.parseInt(scan.next());
			int B = Integer.parseInt(scan.next());
			int max = 0;
			if(A == B) {
				max = 2 * A;
			}else if(A > B) {
				max = 2 * A - 1;
			}else {
				max = 2 * B - 1;
			}
			System.out.println(max);
		}
	}
}


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

typedef long long int ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ar array
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7;
const ll inf = 2e9 + 5;
double PI = 3.14159265358979323846;

const int mxn = 3e5 + 7;
vi row(mxn, 0);
vi col(mxn, 0);

void solve() {

    int n, m, k;
    cin >> n >> m >> k;
    vector<pi> targets;
    for (int i = 0; i < k; i++) {
        int x, y;
        cin >> x >> y;
        targets.pb({x, y});
        row[x]++; col[y]++;
    }
    int ans = 0;
    int R, C;
    R = C = 0;
    for (int i = 0; i < mxn; i++) {
        R = max(R, row[i]);
        C = max(C, col[i]);
    }
    int nR, nC;
    nR = nC = 0;
    for (int i = 0; i < mxn; i++) {
        if (row[i] == R)nR++;
        if (col[i] == C)nC++;
    }
    ans = R + C;
    /*
    *
    *
    *
    *
    Now the answer is R+C unless there is an target at (i,j)
    coz we are counting it twice
    what we can do is if we find some (i,j) where row[i] = R and
    col[j] = C and there is no target at (i,j);
    To check if there exists such (i,j) count all the possible (i,j)
    where there is a target and row[i] = R and col[j] = C and if that is 
    less than nR*nC then it exits and ans remain same or else ans = ans-1
    *
    *
    *
    *
    */

    int cnt = 0;
    for(auto p : targets){
        if(row[p.F] == R and col[p.S] == C){
            ++cnt;
        }
    }
    if(cnt == nR*nC){
        ans -= 1;
    }
    cout << ans << endl;

}

int32_t main()
{
    IOS
    // int T; cin >> T; while (T--)
    solve();
    return 0;
}


Measured memory_bytes: 9780
n = int(input())
dp = list(map(int, input().split()))
for i in range(n - 1):
    a = list(map(int, input().split()))
    nex = [0, 0, 0]
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            nex[k] = max(nex[k], dp[j] + a[k])
    dp = nex
print(max(dp))


Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.lang.Math;
import java.util.Arrays;
import java.util.HashMap;
import java.util.ArrayDeque;

public class Main {
    static class Tree {
        public int parent = -1;
        public HashMap<Integer, Boolean> children = new HashMap<Integer, Boolean>();
    }

	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		String s = reader.next();
		String t = reader.next();
		int N = s.length();
		int M = t.length();
		
		long[][] table = new long[N][26];
		for(int i=0; i<N; i++) {
		    for(int j=0; j<26; j++) {
		        table[i][j] = Long.MAX_VALUE;
		    }
		}
		for (int i=0; i<N; i++) {
		    int alp = s.charAt(i) - 'a';
		    int j = (N+i-1)%N;
		    while (true) {
		        table[j][alp] = (N+i-j)%N;
		        if (table[j][alp] == 0) table[j][alp] = N;
		        if (i == j || s.charAt(i) == s.charAt(j)) break;
		        j = (N+j-1)%N;
		    }
		}
		
		long ans = -1;
		for (int i=0; i<N; i++) {
		    if (t.charAt(0) == s.charAt(i)) {
		        ans = i+1;
		        break;
		    }
		}
		if (ans == -1) {
		    System.out.println(ans);
		    return;
		}
		
		for (int i=1; i<M; i++) {
		    if (table[(int)((ans-1)%(long)N)][t.charAt(i)-'a'] == Long.MAX_VALUE) {
		        System.out.println(-1);
		        return;
		    }
		    ans += table[(int)((ans-1)%(long)N)][t.charAt(i)-'a'];
		}
		System.out.println(ans);
	}
	
	public static void solver() {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 54356
#include<bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define vpii vector<pair<int,int> >
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back   
#define PB pop_back
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;

void solve(){
    int b[100000] = {0};
    int n, k, ans = 0, cnt = 0;
    cin>>n;
    for(int x = 1; x <= sqrt(n); x++){
        for(int y = 1; y <= sqrt(n); y++){
            for(int z = 1; z <= sqrt(n); z++){
                cnt = (x + y)*(x + y) + (z + y)*(z + y) + (x + z)*(x + z);
                cnt /= 2;
                if(cnt < 100000)b[cnt]++;
            }
        }
    }
    ff(i,n)cout<<b[i]<<endl;
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  string s;
  int n;
  cin >> n;
  cin >> s;
  vi w(n+1,0),b(n+1,0);
  rep(i,n) w[i+1] = w[i]+(s[i] != '.');
  int numB = 0;
  rep(i,n) numB+=(s[i] != '#');
  if(numB == 0 || numB ==n){
    cout<<0<<endl;
    return 0;
  }
  b[0] = numB;
  rep(i,n){
    b[i+1] = b[i]-(s[i] != '#');
  }
  // srep(i,1,n+1){
  //   cout<< w[i]<<" ";
  // }
  // cout<<endl;
  // srep(i,0,n){
  //   cout<< b[i]<<" ";
  // }
  // cout<<endl;
  int ans = (int)1e9;
  srep(i,1,n+1){
    mins(ans,w[i]+b[i-1] - (s[i] == '#'));
  }
  mins(ans,n-numB);
  mins(ans,numB);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2180
s = input()

end = len(s) - 1
half = int(len(s) / 2) - 1
flag = True
while end != 1:
    end -= 2
    half -= 1
    start = 0
    flag = True
    for i in range(half+1, end):
        if s[i] != s[start]:
            flag = False
            break
        start += 1
    if flag == True:
        print(end+1)
        exit()




Measured memory_bytes: 9052
#include <iostream>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
	long long ans = 0;
	unsigned long long a, b, c, k;

	// input
	cin >> a >> b >> c >> k;

	// calc
	
	if ( a >= k ) {
		ans = k;
	} else {
		ans = a;
		k -= a;
		if ( b < k ) {
			k -= b;
			ans -= k;
		}
	}

	// output
	cout << ans;
	cout << endl;

	return 0;
}


Measured memory_bytes: 3676
#include<stdio.h>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b){
		if(b<c){
			printf("Yes\n");
		}else{printf("No\n");
		}
	}else{
		printf("No\n");	
	}
	return 0;
}

Measured memory_bytes: 580
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

#define MAX_V 1000

int V;
vector<int> G[MAX_V]; // グラフの隣接リスト表現
vector<int> rG[MAX_V];// 辺の向きを逆にしたグラフ
vector<int> vs;       // 帰りがけ順の並び
bool used[MAX_V];     // すでに調べたか
int cmp[MAX_V];       // 属する強連結成分のトポロジカル順序

// from から to への辺を張る関数
void add_edge(int from, int to){
	G[from].push_back(to);
	rG[to].push_back(from);
}

void dfs(int v){
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		if(!used[G[v][i]]){
			dfs(G[v][i]);
		}
	}
	vs.push_back(v);
}

void rdfs(int v, int k){
	used[v] = true;
	cmp[v] = k;
	for(int i = 0; i < rG[v].size(); i++){
		if(!used[rG[v][i]]){
			rdfs(rG[v][i], k);
		}
	}
}

// 強連結成分分解を行う関数、返り値は強連結成分の個数
int scc(){
	memset(used, 0, sizeof(used));
	vs.clear();
	for(int v = 0; v < V; v++){
		if(!used[v]){
			dfs(v);
		}
	}
	memset(used, 0, sizeof(used));
	int k = 0;
	for(int i = vs.size() - 1; i >= 0; i--){
		if(!used[vs[i]]){
			rdfs(vs[i], k++);
		}
	}
	return k;
}

int main(){
	
	while(true){
		cin >> V;
		if(V == 0){
			break;
		}
		
		double p[200], p_m[200];
		for(int i = 0; i < V; i++){
			G[i].clear();
			rG[i].clear();
			p_m[i] = 1;
		}
		for(int i = 0; i < V; i++){
			int m;
			cin >> p[i] >> m;
			for(int j = 0; j < m; j++){
				int num;
				cin >> num;
				add_edge(i, num - 1);
			}
		}
		
		int cnt = scc();
		
		bool flag[200] = {};
		for(int i = 0; i < V; i++){
			p_m[cmp[i]] *= p[i];
			for(int j = 0; j < G[i].size(); j++){
				if(cmp[i] != cmp[G[i][j]]){
					flag[cmp[G[i][j]]] = true;
				}
			}
		}
		
		double ans = 1;
		for(int i = 0; i < cnt; i++){
			if(!flag[i]){
				ans *= (1 - p_m[i]);
			}
		}
		printf("%.9f\n", ans);
	}
	
	return 0;
}


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

int main() {
  int n, m, sum = 0;
  cin >> n >> m;
  rep(i, m) {
    int x;
    cin >> x;
    sum += x;
  }
  if (sum > n) cout << -1 << endl;
  else cout << n - sum << endl;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

class UnionFind {
  //UnionFindは0-indexed。
  
  vector<int> parent;
  vector<int> rank;
  
  public:
  
  UnionFind(int N);
  int root(int x);
  void unite(int x, int y);
  bool isUnited(int x, int y);
  int getRank(int x);
  int getUnion(int N);
};

UnionFind::UnionFind(int N):parent(N),rank(N,1){
  for(int i=0; i<N; i++){parent[i]=i;}
}
  
int UnionFind::root(int x){
  if(parent[x] == x) return x;
  return root(parent[x]);
  /*parent[x] = parent[parent[x]];
  if(parent[x]!=parent[parent[x]]) rank[x]-=1;*/
}
  
void UnionFind::unite(int x, int y) { // xとyの木を併合
  int rx = root(x); //xの根をrx
  int ry = root(y); //yの根をry
  if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
  
  if(rank[x] >= rank[y]){parent[ry] = rx; rank[y]+=1;}//大きい木に小さい木が併合される
  else{parent[rx] = ry; rank[x]+=1;}//根に直接辺を張る
}
  
bool UnionFind::isUnited(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
  int rx = root(x);
  int ry = root(y);
  parent[x]=rx; parent[y]=ry;rank[x]=2;rank[y]=2;
  return rx == ry;
}

int UnionFind::getRank(int x){
  return rank[x];
}

int UnionFind::getUnion(int N){
  set<int> st;
  for(int i=0; i<N; i++){
    st.insert(root(i));
  }
  return st.size();
}

int main()
{
  const ll ELE = 0;
  
  //input
  //cinを忘れないようにしよう！！
  int N, M; cin >> N >> M;
  vector<ll> x(M), y(M), z(M);
  for(int i=0; i<M; i++){ cin >> x[i] >> y[i] >> z[i]; }

  //main
  //UnionFindは0-indexed。
  UnionFind uf(N);
  
  for(int i=0; i<M; i++){ uf.unite(x[i]-1,y[i]-1); }
  int ans = uf.getUnion(N);
  
  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9+7;  
using  p = pair<int,int>;
using  v = vector<int>;

ll acc(ll i){
   if(i==1) return 1;
   return i*acc(i-1)%INF;
}


int main(){
  int n;
  cin >> n;
  auto a = vector<int>(n,0);
  for (int i = 0; i < n; i++)
  {
     cin >> a[i];
  }
  cout << *max_element(a.begin(),a.end())-*min_element(a.begin(),a.end());
  
}
  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    long long int a,b;
    cin>>a>>b;
    long long int ans=0;
    long long int x=a*b;

    if(a<b){
        int tmp = a;
        a = b;
        b = tmp;
    }

    long long int r = a%b;
    while(r!=0){
        a = b;
        b = r;
        r = a%b;
    }
    ans = x/b;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		while (!s.equals("")) {
			Character c = s.charAt(0);
			int count = 0;
			for (int i = 0; i < s.length(); i++) {
				if (s.charAt(i) == c.charValue()) {
					count++;
				}
			}
			if (count % 2 == 1) {
				System.out.println("No");
				sc.close();
				return;
			}
			s = s.replaceAll(c.toString(), "");
		}

		System.out.println("Yes");
		sc.close();
	}
}



Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] c = s.toCharArray();
        int zero = 0;
        int one = 0;
        for (int i = 0; i < s.length(); i++) {
            if(c[i] == '0') {
                zero++;
            }else{ 
                one++;
            }
        }
        int ans = Math.min(zero, one) * 2;
        System.out.println(ans);
    }
}


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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(m);
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int x;
            cin >> x;
            x--;
            v[x]++;
        }
    }
    int count = 0;
    for (int i = 0; i < m; i++)
        if (v[i] == n)count++;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
def judge_status_summary():
    N = int(input())
    res = {"AC":0,"WA":0,"TLE":0,"RE":0}
    for i in range(N):
        res[input()] += 1
    
    for k in res:
        print("{} x {}".format(k,res[k]))
        
judge_status_summary()

Measured memory_bytes: 9108
#include <algorithm>
#include <climits>
#include <iostream>
#include <iomanip>
#include <random>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using std::cin;
using std::cerr;
using std::cout;
using std::endl;
using std::make_pair;
using std::pair;
using std::stack;
using std::string;
using std::unordered_map;
using std::unordered_set;
using std::vector;
using std::lower_bound;
using std::upper_bound;

int main(int argc, char* argv[]) {
  string s;
  cin >> s;
  cout << ((s[0] != s[1] || s[0] != s[2]) ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) cin >> s[i];
	cout << string(w+2, '#') << endl;;
	rep(i, h) cout << "#" << s[i] <<"#" << endl;
	cout << string(w+2, '#') << endl;;
	return 0;
}

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

int dp[101][100001];
int val[100];
int weight[100];

long long maxValue(int val[], int weight[], int capacity, int n)
{
	if(n<0)
		return 0;

	if(dp[n][capacity]!=-1)
	{
		return dp[n][capacity];
	}

	if(capacity-weight[n]<0)
		return dp[n][capacity] = maxValue(val, weight, capacity,n-1);

	return dp[n][capacity] = max( maxValue(val, weight, capacity,n-1), val[n] + maxValue(val, weight, capacity-weight[n], n-1));
}



int32_t main()
{
	int N,W;
	cin >> N >> W;
	vector<int> w,v;

	for(int i=0; i<101; i++)
	{
		for(int j=0; j< 100001; j++)
		{
			dp[i][j]=-1;	
		}
	}

	for(int i=0;i<N;i++)
	{
		cin >> weight[i] >> val[i];
	}
	cout << maxValue(val,weight,W,N-1);
	
	return 0;
}

Measured memory_bytes: 82524
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);
long long dp[100005][4];

int main() {
  string S;
  cin >> S;
  long long mod = 1e9+7;

  dp[0][0] = 1;

  rep(i, S.length()) {

    if (S[i] == '?') {
      rep(j, 4) dp[i+1][j] = 3 * dp[i][j];
    } else {
      rep(j, 4) dp[i+1][j] = dp[i][j];
    }
    //rep(j, 4) dp[i+1][j] %= mod;

    if (S[i] == 'A') {
      dp[i+1][1] += dp[i][0];
    } else if (S[i] == 'B') {
      dp[i+1][2] += dp[i][1];
    } else if (S[i] == 'C') {
      dp[i+1][3] += dp[i][2];
    } else {
      rep(j, 3) dp[i+1][j+1] += dp[i][j];
    }

    rep(j, 4) dp[i+1][j] %= mod;

  }

  cout << dp[S.length()][3] << endl;

  return 0;
}

Measured memory_bytes: 3712