akhauriyash/Code-Regression huggingface dataset:
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline char nc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int Scan(){
    char ch=nc();int sum=0, f=1;
    if (ch=='-') f=-1, ch=nc();
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum*f;
}
const int N=100005;
//Code begin....

LL sum=0, dp[N][2];
int dep[N];
VI E[N], G[N];
bool flag=false;

void dfs(int x, int fa){
    dep[x]=dep[fa]+1;
    for (auto i=E[x].begin(); i!=E[x].end(); ++i) {
        if (*i==fa) continue;
        if (dep[*i]==0) {
            G[x].pb(*i);
            dfs(*i,x);
            dp[x][0]+=dp[*i][1];
            dp[x][1]+=dp[*i][0]+1;
        }
        else if ((dep[*i]+dep[x])%2==0) flag=true;
    }
    sum+=dp[x][1];
    for (auto i=G[x].begin(); i!=G[x].end(); ++i) {
        sum+=(dp[*i][0]+1)*(dp[x][0]-dp[*i][1]);
    }
}
int main ()
{
    int n, m, u, v;
    scanf("%d%d",&n,&m);
    FOR(i,1,m) scanf("%d%d",&u,&v), E[u].pb(v), E[v].pb(u);
    dfs(1,0);
    if (flag) printf("%lld\n",(LL)n*(n-1)/2-m);
    else printf("%lld\n",sum-m);
    return 0;
}


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

int main(){
	int X,Y;
	cin >> X>> Y;
	long long ans =0;
	if(X==3){
		ans += 100000;
	}
	else if(X==2){
		ans+=200000;
	}
	else if(X==1){
		ans+=300000;
	}
	if(Y==3){
		ans += 100000;
	}
	else if(Y==2){
		ans+=200000;
	}
	else if(Y==1){
		ans+=300000;
	}
	if(X==1&&Y==1){
		ans+=400000;
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)

int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N, K, R, S, P;
	string T;
	cin >> N >> K >> R >> S >> P >> T;

	ll score = 0;
	vector<char> history(N);
	vector<bool> fix(N, false);

	unordered_map<char, int> points = {{'r', R}, {'s', S}, {'p', P}};
	unordered_map<char, char> kachi = {{'r', 'p'}, {'s', 'r'}, {'p', 's'}};
	char te;
	for (size_t i = 0; i < N; i++)
	{
		if (i < K)
		{
			te = kachi[T[i]];
			fix[i] = true;
			score += points[te];
		}
		else
		{
			if (fix[i - K] == true && history[i - K] == kachi[T[i]])
			{
				te = T[i];
			}
			else
			{
				te = kachi[T[i]];
				fix[i] = true;
				score += points[te];
			}
		}

		history[i] = te;
	}
	cout << score << endl;
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int factrial(int n) {
  int k, ret;

  ret = 1;
  for (k = n; k > 1; k--)
    ret *= k;
  return ret;
}

int rank(int *array, int n) {
  int i, j, w, ret;

  ret = 0;
  for (i = 0; i < n; i++) {
    w = array[i];
    for (j = 0; j < i; j++)
      if (array[j] < array[i])
        w--;
    ret += (w - 1) * factrial(n - i - 1);
  }
  return ret + 1;
}

int main() {
  int N, i, a, b, result;
  int P[8], Q[8];

  scanf("%d", &N);
  for (i = 0; i < N; i++)
    scanf(" %d", &P[i]);
  for (i = 0; i < N; i++)
    scanf(" %d", &Q[i]);
  a = rank(P, N);
  b = rank(Q, N); 
  result = a - b;
  if (result < 0)
    result = - result;
  printf("%d\n", result);
  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
const int inf = 1 << 28;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};

template<typename T> inline void chmin(T& t, T f){if(t > f)t = f;}

int w, h;

inline bool inrect(int x, int y){
    return 0 <= x && x < h && 0 <= y && y < w;
}

int dfs(vector<vector<int> >& board, int x, int y, int n){
    if(n == 0)return inf;
    int res = inf;
    rep(k, 4){
        for(int nx = x + dx[k], ny = y + dy[k]; inrect(nx, ny); nx += dx[k], ny += dy[k]){
            if(board[nx][ny] == 1){
                if(x == nx - dx[k] && y == ny - dy[k])break;
                board[nx][ny] = 0;
                chmin(res, dfs(board, nx - dx[k], ny - dy[k], n - 1) + 1);
                board[nx][ny] = 1;
                break;
            }
            if(board[nx][ny] == 3)return 1;
        }
    }
    return res;
}

int main(){
    while(cin >> w >> h, w|h){
        int sx = -1, sy = -1;
        vector<vector<int> > board(h, vector<int>(w));
        rep(i, h)rep(j, w){
            cin >> board[i][j];
            if(board[i][j] == 2)sx = i, sy = j;
        }
        int ans = dfs(board, sx, sy, 10);
        cout << (ans == inf? -1: ans) << '\n';
    }
    return 0;
}

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

int main() {
    
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    int count=0;
    bool check=true;
    while(check){
        check=false;
        for(int i=N-1;i>0;i--){
            if(A.at(i-1)>A.at(i)){
                swap(A.at(i-1),A.at(i));
                     count++;
                check=true;
                     }
                     
            }
        }
    for(int i=0;i<N-1;i++){
        cout<<A.at(i)<<" ";
    }
    cout<<A.at(N-1)<<endl;
    cout<<count<<endl;
    
    }



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

// --------------------------------------------------------------------------------
#define fastio	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve_main()
{
   	int n,m;cin>>n>>m;
   	if(n==m)cout<<"Yes";
   	else	cout<<"No";
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("/home/suryakant/input.txt","r",stdin);
 //        freopen("/home/suryakant/output.txt","w",stdout);
 //    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

Measured memory_bytes: 3636
//============================================================================
// Name        : rough.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
using namespace std;



int main() {

	int n;
	cin>>n;

	int divisors[n+1];
	divisors[0]=0;

	long long sum[n+1];
	sum[0]=0;

	for(int i=1;i<=n;i++)
	{
		int d=0;
		int j=1;
		for( j=1;j*j<i;j++)
		{
			if(i%j==0)
				d++;
		}

		d*=2;
		if(j*j==i)
			d++;

		divisors[i]=d;
	}

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

	cout<<sum[n-1];

}


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

int main()
{
    int n, k, d, ad, ans(0);

    cin >> n >> k;

    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        a.at(i) = 1;
    }
    for (int i = 0; i < k; i++)
    {
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            cin >> ad;
            a.at(ad - 1) = 0;
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (a.at(i) != 0)
            ans++;
    }
    cout << ans << endl;
}

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

int main() {
	int i, minv, n, maxp, tmp;
	cin >> n;
	cin >> minv >> tmp;
	maxp = tmp - minv;
	minv = min(minv, tmp);
	for (i = 0; i < n - 2; i++) {
		cin >> tmp;
		maxp = max(maxp, tmp - minv);
		minv = min(minv, tmp);
	}
	cout << maxp << endl;
	return 0;
}

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

int main()
{
    string ans = "No";
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    cout << 'A' << s2.at(0) << 'C' << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

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

    if(n == 2) {
        cout << -1 << endl;
        return 0;
    }

    if(n == 3) {
        cout << "aa.\n";
        cout << "..a\n";
        cout << "..a\n";
        return 0;
    }

    vector<vector<string>> v(8);
    v[4] = {"aabc", "ddbc", "bcaa", "bcdd"};
    v[5] = {"aabba", "bcc.a", "b..cb", "a..cb", "abbaa"};
    v[6] = {"aabc..", "ddbc..", "..aabc", "..ddbc", "bc..aa", "bc..dd"};
    v[7] = {"aabbcc.", "dd.dd.a", "..d..da", "..d..db", "dd.dd.b", "..d..dc", "..d..dc"};

    ll idx = 0;
    vector<string> ans(n, string(n, '.'));
    REP(i, (n-4)/4) {
        dump(i);
        REP(j, 4) REP(k, 4) {
            ans[idx+j][idx+k] = v[4][k][j];
        }
        idx += 4;
    }
    ll t = (n%4)+4;
    dump(t);
    REP(j, t) REP(k, t) {
        ans[idx+j][idx+k] = v[t][j][k];
    }

    REP(i, n) cout << ans[i] << "\n";
    cout << flush;

    return 0;
}

Measured memory_bytes: 2304
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var str=Arr[0];
Arr.shift();
Arr.shift();
Arr.forEach(function(v){
   var arr=v.split(" ");
   var ab=arr[0];
   var a=arr[1]-0;
   var b=arr[2]-0;
   if(ab==="print")console.log(str.slice(a,b+1));
   if(ab==="reverse")str=str.slice(0,a)+str.slice(a,b+1).split("").reverse().join("")+str.slice(b+1);
   if(ab==="replace")str=str.slice(0,a)+arr[3]+str.slice(b+1);
});

Measured memory_bytes: 7908
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <functional>
#include <random>
using namespace std;

const int MOD = 998244353;
const int INF = 999999999;

long long fac[300005], finv[300005], inv[300005];

void COMinit() {
	fac[0] = 1, fac[1] = 1, finv[0] = 1, finv[1] = 1, inv[1] = 1;
	for (int i = 2; i < 300005; ++i) {
		fac[i] = fac[i - 1] * i%MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

//calc
long long COM(long long n, long long k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	COMinit();
	long long a, b, c, d, ans = 0;
	cin >> a >> b >> c >> d;
	for (int i = 1; i <= a; ++i) {
		if ((d - i * b) % c == 0 && (d - i * b) / c <= a) { ans += COM(a, i)*COM(a, (d - i * b) / c); ans %= MOD; }
	}
	cout << max(ans % MOD, (long long)1) << endl;
}

Measured memory_bytes: 7296
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;

int n = 0, m = 0;
int e_a[10010], e_b[10010];

int main() {
	scanf("%d", &n);
	if (n % 2 == 0) {
		for (int i = 1; i <= n; i++) {
			for (int j = i+1; j <= n; j++) {
				if (n-i+1 != j) {
					++ m;
					e_a[m] = i;
					e_b[m] = j;
				}
			}
		}
	} else {
		for (int i = 1; i <= n; i++) {
			for (int j = i+1; j <= n; j++) {
				if (j == n) {
					if (i != n/2 || j != n/2+1) {
						++ m;
						e_a[m] = i;
						e_b[m] = j;
					}
					continue;
				}
				if (n-i != j) {
					++ m;
					e_a[m] = i;
					e_b[m] = j;
				}
			}
		}
	}
	printf("%d\n", m);
	for (int i = 1; i <= m; i++) printf("%d %d\n", e_a[i], e_b[i]);
	return 0;
}

Measured memory_bytes: 256
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
void solve() {
    int cnt = 0;
    string s, t;
    cin >> s >> t;
    forn(i, sz(s)) {
        cnt += (s[i] != t[i]);
    }
    cout << cnt;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3812
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 = INT()
A = LIST()

A.insert(0, 0)
A.append(0)

total = sum([abs(A[i]-A[i-1]) for i in range(1, N+2)])
for i in range(1, N+1):
	print(total - abs(A[i]-A[i-1]) - abs(A[i]-A[i+1]) + abs(A[i+1]-A[i-1]))





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

#define mp make_pair
#define pb push_back
#define ll long long int
#define sd(x) scanf("%lld",&x)
#define inf 1000000000000000000
#define pll pair<ll,ll>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define bits(x) __builtin_popcountll(x)
#define ld long double
#define test() ll test; cin>>test; while(test--)
#define fi first
#define se second


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


inline ll GCD(ll x, ll y) {
    if(x<y) swap(x,y);
    if(x==0) return y;
    if(y==0) return x;
    return GCD(x%y,y);
}

ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}

ll power(ll x, ll n, ll mod) {
    ll res = 1;
    x %= mod;
    while(n) {
        if(n&1) {
            res = ((res*x)%mod+mod)%mod;
        }
        x = ((x*x)%mod+mod)%mod;
        n>>=1;
    }

    return res;
}

const int MAXN = 2e5+5;



int main() {
    fastio;

    ll N,X,M;
    cin>>N>>X>>M;

   
    vector<ll> cnt(M+1,0);
    vector<ll> pre(MAXN,0);
    pre[1] = X;
     pre[0]=0;
    N--;
    ll sum = X;
    cnt[X] = 1;
    for(ll i=2;N>0;i++,N--) {
        X = ((X*X)%M+M)%M;
        if(cnt[X]>0) {
            ll kitne = i-cnt[X];
            ll dum = pre[i-1]-pre[cnt[X]-1];
            ll tim = N/kitne;
            sum += dum*tim;
            ll md = N%kitne;
            dum = pre[cnt[X]-1+md]-pre[cnt[X]-1];
            sum += dum;
            break;
        } else {
            cnt[X] = i;
            pre[i] = pre[i-1]+X;
            sum += X;
        }
    }
    

    cout<<sum<<endl;
}




Measured memory_bytes: 5584
//shara's here
//私は私は大きい男の子
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAAAAADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
#include <bits/stdc++.h>
using namespace std;
typedef string s;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 + 10;
const ll MINF = -(1e18 + 10);
#if defined(BANYANYA)
#include "/home/xsharawi/Desktop/cpp/debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define ins insert
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
int main(){
	ll x;
	cin>>x;
	if(x%2==0)cout<<x/2<<endl;
	else cout<<((x/2)+1)<<endl;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	





return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int sum = 0;

		for (int i = 1; i <= N; i++) {
			sum += i;
		}

		System.out.println(sum);
	}
}


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

using namespace std;

int findMinCost(int a[], int n, int k){
    
  int dp[n];
  for(int i=0; i<n; i++){
      dp[i] = INT_MAX;
  }
  
  dp[0] = 0;
  
  
	for(int i=0; i<n; i++){
    	for(int j=i+1; j<=i+k; j++){
        	if(j<n){
            	dp[j] = min(dp[j], dp[i] + abs(a[j]-a[i]));
            }
        }
    }
  
  return dp[n-1];
}

int main(){
	int n,k;
  	cin>>n>>k;
  	int a[n];
  	
  for(int i=0; i <n; i++){
  	cin>>a[i];
  }
  
  cout<<findMinCost(a,n,k);
}


Measured memory_bytes: 4348
#include<cstdio>
#include<cstring>
#include<algorithm>
const int maxn=1e5+10;
int n;
char s[maxn];
void judge()
{
    if(s[1]=='0' || s[n]=='1')
    {
        printf("-1\n");
        return;
    }
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='1' && s[n-i]=='0')
        {
            printf("-1\n");
            return;
        }
    }
    int root=1;
    for(int i=2;i<=n;i++)
    {
        printf("%d %d\n",root,i);
        if(s[i-1]=='1') root=i;
    }
}
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    judge();
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
#include<numeric>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef long long Int;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef list<int> lii;
typedef list<ll> lil;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5
#define MOD 1000000007
int main(){
	int n;
	cin>>n;
	vi a(n);rep(i,n) cin>>a[i];
	int ai=0;
	rep(i,n) ai+=pow(-1,i)*a[i];
	
	rep(i,n){
		cout<<ai<<endl;
		ai=2*a[i]-ai;
	}
}








Measured memory_bytes: 1664
N,K = map(int,input().split())
t = []#i / 分母
j = 0
for i in range(N,0,-1):
    while i * (2**j) < K:
        j += 1
    t.append((i,j))

ansU = 0
ansD = (2**j)*N
for i,n in t:
    ansU += 2**(j-n)
print(round(ansU/ansD,10))


Measured memory_bytes: 13416
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
ll n;
cin>>n;
vector<ll> vec(n+1,0);
for(ll i=1;i<=n;i++){
cin>>vec[i];
}
map<ll,ll> map;
std::map<ll,ll> ::iterator it;
ll ans=0;
for(ll i=1;i<=n;i++){
it=map.find(i-vec[i]);
if(it!=map.end()){
ans+=map[i-vec[i]];
}
map[i+vec[i]]++;
}
cout<<ans<<endl;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n,x; cin >> n >> x;
  int cnt = 1;
  int d = 0;
  rep(i,n){
    int l; cin >> l;
    d+=l;
    if(d<=x) cnt++;
    else break;
  }
  /*vector<int> l(n);
  rep(i,n) cin >> l[i];

  int d = 0;
  int cnt = 0;
  rep(i,n){
    if(d<=x) cnt++;
    d+=l[i];
    }*/
  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 3632
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ARangeFlipFindRoute {
public:

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int h, w; cin >> h >> w;
      vector<vector<bool>> mat(h, vector<bool>(w));
      rep(i, h) rep(j, w) {
        char c; cin >> c;
        mat[i][j] = (c == '.');
      }

      vector<vector<int>> dp(h, vector<int>(w, INT_MAX/2));
      if (mat[0][0] == true) {
        dp[0][0] = 0;
      } else {
        dp[0][0] = 1;
      }
      deque<pair<P, int>> que;
      que.emplace_back(make_pair(P(0, 0), dp[0][0]));
      vector<P> vec = {P(0,1),P(1,0)};

      while(!que.empty()) {
        auto p = que.front(); que.pop_front();
        auto i = p.first.first;
        auto j = p.first.second;
        auto c = p.second;
        if (dp[i][j] > c) continue;
        for(auto e: vec) {
          auto i2 = i+e.first;
          auto j2 = j+e.second;
          if (i2 < 0 || i2 >= h || j2 < 0 || j2 >= w) continue;
          if (mat[i][j] && (!mat[i2][j2])) {
            if (dp[i2][j2] > c+1) {
              //debug(i2, j2, c+1);
              dp[i2][j2] = c+1;
              que.emplace_back(make_pair(P(i2, j2), c+1));
            }
          } else {
            if (dp[i2][j2] > c) {
              //debug(i2, j2, c);
              dp[i2][j2] = c;
              que.emplace_front(make_pair(P(i2, j2), c));
            }
          }
        }
      }

      cout << dp[h-1][w-1] << endl;

    }
};

signed main() {
  ARangeFlipFindRoute solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 384
n,m = map(int,input().split())
a = list(map(int,input().split()))
check = {};ios = [a[0]%m]*n
for i in range(n-1):
    ios[i+1] = (a[i+1] + ios[i])%m
    check[ios[i]] = 0
check[ios[n-1]] = 0
for i in range(len(ios)):
    check[ios[i]%m] += 1
ans = 0
for i in range(n):
    num = check[ios[i]];check[ios[i]] = 'finish'
    if num == 'finish':continue
    if ios[i] % m == 0:ans += num
    ans += (num * (num - 1))//2
print(ans)

Measured memory_bytes: 14732
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v(1,1);
  for (ll i = 2; n >= i * i; ++i) {
		if(!(n % i)){
      v.pb(i);
	  }
  }
  if(v.size()==1)v.pb(n);
  return v;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  ll n,m;cin>>n>>m;
  vector<int> a(n);rep(i,n)cin>>a[i];
  
  ll tmp = 0;
  rep(i,n){
    for(int j = i+1;j < n;++j){
      tmp += a[i] > a[j];
      tmp %= INF;
    }
  }
  
  
  ll cnt = 0;
  rep(i,n){
    rep(j,n){
      if(i != j && a[i] > a[j]){
        cnt++;
        cnt %= INF;
      }
    }
  }

  ll ans = ((tmp * m) % INF + (cnt * (((m*(m - 1)) / 2) % INF)) % INF) % INF;
  print(ans%INF);
  return 0;
} 

Measured memory_bytes: 256
fun main(arr: Array<String>) {
    val (n,x) = readLine()!!.split(" ").map { it.toInt() }
    val l = readLine()!!.split(" ").map { it.toInt() }
    var currnt = 0
    var ans = 1
    for(i in l) {
        currnt += i
        if(currnt > x) {
            break
        }
        ans++
    }
    println(ans)
}


Measured memory_bytes: 36492
#include<bits/stdc++.h>
using namespace std;
#define Fastread ios_base::sync_with_stdio(false);
int main()
{
    Fastread;
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    if(a==b){
        cout<<"Draw"<<endl;
    }
    else if(a==1 || b==1){
        if(a==1){
            cout<<"Alice"<<endl;
        }
        else{
            cout<<"Bob"<<endl;
        }
    }
    else if(a > b){
        cout<<"Alice"<<endl;
    }
    else{
        cout<<"Bob"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3612
#include<stdio.h>
#define MAX 100
#define NIL -1
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define INF (1<<21)

int G[MAX][MAX],c[MAX],p[MAX],d[MAX],n;
void dijkstra(){
  int i,u,min;
  for(i=0;i<n;i++){
    c[i]=WHITE;
    p[i]=NIL;
    d[i]=INF;
  }
  d[0]=0;
  c[0]=GRAY;
  while(1){
    min=INF;
    u=NIL;
    for(i=0;i<n;i++){
      if(c[i]!=BLACK && d[i]<min){
        min=d[i];
        u=i;
      }
    }
    if(u==NIL) break;
    c[u]=BLACK;
    for(i=0;i<n;i++){
      if(c[i]!=BLACK && G[u][i]!=NIL){
	if(d[u]+G[u][i]<d[i]){
	  d[i]=G[u][i]+d[u];
	  p[i]=u;
	  c[i]=GRAY;
	}
      }
    }
  }
  /*for(i=0;i<n;i++){
    if(p[i]!=NIL) count+=G[i][p[i]];
  }
  return count;*/
}
  int main(){
    int i,j,a,w,k,l;
    scanf("%d",&n);
    for(i=0;i<n;i++){
      for(j=0;j<n;j++) G[i][j]=NIL;
    }
  for(i=0;i<n;i++){
    scanf("%d %d",&k,&j);
    for(l=0;l<j;l++){
      scanf("%d %d",&a,&w);
      G[k][a]=w;
    }
  }
  dijkstra();
  for(i=0;i<n;i++){
    printf("%d ",i);
    if(d[i]!=INF) printf("%d\n",d[i]);
    else printf("%d\n",NIL);
  }
  return 0;
}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vpp vector<pair<long long,long long>>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define d0(x) cout<<(x)<<" "
#define c1(x) cin>>(x)
#define c2(x,y) cin>>(x)>>(y)
#define c3(x,y,z) cin>>(x)>>(y)>>(z)
#define c4(w,x,y,z) cin>>(w)>>(x)>>(y)>>(z)
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define fo(i,a,b) for(int i=a;i<b;i++)
#define alld(c) (c).rbegin(),(c).rend()
#define alli(c) (c).begin(),(c).end()
#define ll long long
const int M=1e9+7;
const double pyi=3.14159265358979323846;

vector<int> adj[200005]; 

int main()
{
	int n;
	sfi(n);

	fo(i,2,n+1)
	{
		int a;
		cin>>a;

		adj[i].pb(a);
		adj[a].pb(i);

	}

	d1(adj[1].size());

	fo(i,2,n+1)
	{
		d1(adj[i].size()-1);
	}
	return 0;
}

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

using namespace std;

#define PB push_back
#define f first
#define s second

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

const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)2e5+1;

void setIO(string name)
{
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}

int dp[MAXN], mx[MAXN];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //setIO("");
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    for(int i=n-1; i>=0; i--)
    {
        if(s[i] == 'x')
        {
            dp[i] = mx[i+1];
        }
        else
        {
            dp[i] = 1 + mx[min(n, i+c+1)];
        }
        mx[i] = max(dp[i], mx[i+1]);
    }
//    for(int i=0; i<n; i++)
//    {
//        cout << dp[i] << " " << mx[i] << "\n";
//    }
    deque<int> d;
    int num_left = k;
    int ind = 0;
    while(num_left)
    {
        for(int i=ind; i<n; i++)
        {
            if(s[i] == 'o' && dp[i] >= num_left)
                d.push_back(i);
            else if(mx[i] < num_left)
            {
                ind = i;
                break;
            }
        }
        if(d.size() == 1)
        {
            cout << d[0]+1 << "\n";
        }
        if(d.size())
        {
            ind = max(ind, d[0] + c + 1);
        }
        int prev = d[0];
        while(!d.empty() && prev + c >= d[0])
        {
            d.pop_front();
        }
        num_left--;
    }



    return 0;
}


Measured memory_bytes: 3348
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
    };

    let mut graph: Vec<Vec<usize>> = vec![Vec::new(); n];
    let mut dp: Vec<usize> = vec![std::usize::MAX; n];
    for _ in 0..m {
        input! {
            x: usize,
            y: usize
        };
        graph[x - 1].push(y - 1);
    }

    let mut result = 0;
    for i in 0..n {
        result = std::cmp::max(result, f(i, &graph, &mut dp));
    }

    println!("{}", result);
}

fn f(node: usize, graph: &Vec<Vec<usize>>, dp: &mut Vec<usize>) -> usize {
    if dp[node] < std::usize::MAX {
        return dp[node];
    }
    let mut res = 0;

    for &next in graph[node].iter() {
        res = std::cmp::max(res, f(next, graph, dp) + 1)
    }
    dp[node] = res;
    res
}


Measured memory_bytes: 11996
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    char s;cin>>s;
    if(0<=s-'a'&&s-'a'<=26)cout<<'a'<<endl;
    else cout<<'A'<<endl;
}

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

int main(){

   int W,H;
   cin>>W>>H;

   int x,y,r;
   cin>>x>>y>>r;

   if( x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H ) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e4 + 5, maxp = 1e9 - maxn;
int n, a[maxn], b[maxn], p[maxn];
int main() {
	scanf("%d", &n);
	int x = maxp / (n - 1);
	a[1] = maxn, b[n] = maxn;
	for(int i = 1; i < n; ++ i)
		a[i + 1] = a[i] + x, b[n - i] = b[n - i + 1] + x;
	for(int i = 1; i <= n; ++ i)
		scanf("%d", &p[i]), a[p[i]] -= n - i;
	for(int i = 1; i <= n; ++ i)
		printf("%d ", a[i]);
	puts("");
	for(int i = 1; i <= n; ++ i)
		printf("%d ", b[i]);
	puts("");
}

Measured memory_bytes: 3964
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    x, n = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    if n == 0:
        print(x)
    else:
        P = list(map(int, input().split()))
        P.sort()
        #B = [i for i in range(102)]

        if x not in P:
            print(x)
        else:
            xindex = P.index(x)

            for j in range(1,100):
                if xindex - j >= 0:
                    if P[xindex - j] != x-j:
                        print(x-j)
                        break
                else:
                    print(x-j)
                    break
                if xindex + j <= n-1:
                    if P[xindex + j] != x+j:
                        print(x+j)
                        break
                else:
                    print(x+j)
                    break

resolve()

Measured memory_bytes: 62084
puts ("1\n"..gets).map{n=gets.to_i
n<2?"#\n":n<3?"##\n# \n":(a=[?#*n+?\n]+(2..n).map{?#+" "*(n-2)+"#\n"}
c=i=j=n-1
d=[[1,0],[0,-1],[-1,0],[0,1]]
(c=0;(x,y),_=d.rotate!;(c+=1;a[i+=x][j+=y]=?#)while a[i+x*2][j+y*2]<?#)while c>1
a*"")}*?\n

Measured memory_bytes: 6108
n,m = map(int, input().split())
l = [tuple(map(int, input().split())) for _ in range(n)]

l.sort()

drink_cnt = 0
ans = 0
for cost, cnt in l:
    if drink_cnt + cnt <= m:
        ans += cost * cnt
        drink_cnt += cnt
        if drink_cnt == m:
            break
    else:
        ans += cost * (m - drink_cnt)
        break

print(ans)

Measured memory_bytes: 16988
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
ll test[1234][1234];
signed main() {
	ll n = 0, m = 0, k, l, cnt = 0, z = 0; cin >> n;
	vector<ll>v(n);
	for (int h = 0; h < n; h++) {
		cin >> v[h];
	}
	sort(v.begin(), v.end());
	cout << v[n / 2] - v[n / 2 - 1] << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 1024
def gcd(a, b)
  b == 0 ? a : gcd(b, a % b)
end

gets
A = gets.chomp.split(/ /).map(&:to_i)
lcm = 1
A.each do |i|
  lcm = i * lcm / gcd(i, lcm)
end
puts A.inject(0){|a,b| a + lcm / b} % (10 ** 9 + 7)


Measured memory_bytes: 90508
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


int main(){
  
  string s,t;
  cin>>s;
  cin>>t;
  int ans=0;
  REP(i,3){
    if(s[i]==t[i])ans++;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[100001];
int b[100001];
int f[100001];
bool flag[100001];
int ans[2][100001];
int ans2[2][100001];
int ra[100001]; 

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		a[i]--;
		ra[a[i]]=i;
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
		b[i]--;
		flag[b[i]]=true;
	}
	for(int i=0;i<n;i++){
		f[a[i]]=b[i];
	}
	for(int i=0;i<n;i++){
		ans[0][f[i]]=1;
		ans[1][f[i]]=1;
	}
	bool ft=true;
	for(int i=0;i<n;i++){
		if(ans[0][i]==0)ans[0][i]=2;
		if(ans[1][i]==0)ans[1][i]=1;
		if(ans[0][i]!=ans[1][i])ft=false;
	}
	if(ft){
		puts("Yes");
		return 0;
	}
	puts("No");
	for(int i=0;i<n;i++){
		printf("%d%c",ans[0][a[i]],i+1==n?'\n':' ');
	}
	for(int i=0;i<n;i++){
		printf("%d%c",ans[1][a[i]],i+1==n?'\n':' ');
	}
	return 0;
}


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

using ll = long long;
const int N = 2e5+10;

int n, p;
char s[N];
ll dp[6][N];
ll h[N];

int main () {
  scanf("%d %d %s", &n, &p, s + 1);
  if(p < 6) {
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++) {
      dp[0][i]++;
      for(int j = 0; j < p; j++) {
        dp[(j * 10 + s[i] - '0') % p][i] += dp[j][i - 1];
      }
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++)
      ans += dp[0][i];
    printf("%lld\n", ans - n);
    return 0;
  }
  h[0] = 1;
  ll ans = 0, cur = 0, ten = 1;
  for(int i = n; i > 0; i--) {
    cur = cur + (s[i] - '0') * ten;
    cur %= p;
    ten = ten * 10ll % p;
    ans += h[cur];
    h[cur]++;
  }
  printf("%lld\n", ans);
  return 0;
}

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

using namespace std;

int main() {
    string input;
    cin >> input;
    for (int i = 0; i < input.size(); i++) {
        if (i % 2 == 1) { //even
            if (input[i] == 'R') {
                cout << "No";
                return 0;
            }
        }
        else {
            if (input[i] == 'L') {
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
}


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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (ll i = a; i >= b; i--)
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           (a)*(a)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)

int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<max(max(a*c,a*d),max(b*c,b*d));
    }
    return 0;
}


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

/*  define  */
#define rep(i,j) for(int i=0;i<j;i++)
#define loop(i,j,z) for(int i=j;i<z;i++)
#define min(a,b) (a>b)?b:a
/*  using namespace  */
using namespace std;
using ll = long long;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }
int main(void)
{
	ll N,K;
	ll right,left;

	cin>>N>>K;
	int position;// 要素番号

	vector<ll> x(N+5);
	loop(i,1,N+1){
		cin>>x[i];
		if(x[i]==1)position=i;
	}
	position=min(position,N-position+1);
	printf("%d",(K==N)?1:(N-2)/(K-1)+1);
}


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

const int maxn = 100010, P = 1000000007;
int n, a[maxn], lst[maxn], fact[maxn], finv[maxn];

int qp(int x, int y) {
    int z = 1;
    for (; y; y >>= 1, x = 1LL * x * x % P) {
        if (y & 1) z = 1LL * z * x % P;
    }
    return z;
}

int C(int x, int y) {
    if (x < y) return 0;
    return 1LL * fact[x] * finv[y] % P * finv[x - y] % P;
}

int main() {
    scanf("%d", &n), n++;
    int p1, p2;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        if (lst[a[i]]) p1 = lst[a[i]], p2 = i;
        lst[a[i]] = i;
    }
    for (int i = fact[0] = finv[0] = 1; i <= n; i++) {
        fact[i] = 1LL * i * fact[i - 1] % P;
        finv[i] = qp(fact[i], P - 2);
    }
    for (int i = 1; i <= n; i++) {
        printf("%d\n", (C(n, i) - C(n - (p2 - p1) - 1, i - 1) + P) % P);
    }
    return 0;
}

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

int main()
{
	int x, y, s;
	while (scanf("%d %d %d", &x, &y, &s), x + y + s){
		P maxi = P(0, 0);
		for (int i = 1; i < s; i++){
			int a = i;
			int ax = a * (100 + x) / 100;
			int bx = s - ax;
			
			for (int j = 1; j < s; j++){
				int b = j;
				if (j * (100 + x) / 100 == bx){
					int ay = a * (100 + y) / 100;
					int by = b * (100 + y) / 100;
					//printf("%d %d %d %d\n", ay, by, a, b);
					maxi = max(maxi, P(ay + by, a + b));
				}
			}
		}
		
		cout << maxi.first << endl;
	}
	
	return 0;
}

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

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

	int n;
	string s;

	cin >> n;
	cin >> s;

	int res = 0;
	for(int i=1;i<s.length();i++)
	{
		string x = s.substr(0,i);
		string y = s.substr(i);

		int cnt = 0;
		set <char> S1,S2;

		for(int j=0;j<x.length();j++)
		{
			S1.insert(x[j]);
		}
		for(int j=0;j<y.length();j++)
		{
			S2.insert(y[j]);
		}

		for(auto it : S2)
		{
			if(S1.find(it)!=S1.end())
			{
				cnt++;
			}
		}

		res = max(res,cnt);
	}

	cout << res << '\n';
	
	return 0;	
}

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

int main() {
  int num;
  cin >> num;
  rep(i, 3) {
    if (num % 10 == 7) {cout << "Yes" << endl; return 0;}
    else num /= 10;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=10000;

int main(){
	int D;
	cin>>D;
	if(D==22)cout<<"Christmas Eve Eve Eve";
	if(D==23)cout<<"Christmas Eve Eve";
	if(D==24)cout<<"Christmas Eve";
	if(D==25)cout<<"Christmas";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        scan.close();

        if (n % 1000 == 0) {
            System.out.println(0);
            return;
        }

        System.out.println(1000 - (n % 1000));
    }
}


Measured memory_bytes: 35784