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

#ifndef _WIN32
    #define getchar getchar_unlocked
#endif

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

typedef long long int LLI;
typedef unsigned long long int LLU;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<int> vi;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr<<*sdbg++;
  cerr<<"="<<h<<",";
  _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MX = 100007;
int x[MX];
inline int odl(int a, int b){
	return abs(x[a] - x[b]);
}

int32_t main()
{
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &x[i]);
	LLI sumo = 0;
	for(int i = 0; i <= n; ++i){
		sumo += odl(i, i != n ? i + 1 : 0);
	}
	for(int i = 1; i <= n; ++i){
		LLI pom = sumo;
		pom -= odl(i - 1, i); pom -= odl(i, i != n ? i + 1 : 0);
		pom += odl(i - 1, i != n ? i + 1 : 0);
		printf("%lld\n", pom);
	}
}


Measured memory_bytes: 1664
/**
 *    Author:  Oak_limy
 *    Created: 2020-09-19 21:09:39
**/
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define up upper_bound
using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
       if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
    char c = getchar(); int w = 1; int x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
    x *= w;
    return x;
}
inline ll readll() {
    char c = getchar(); ll w = 1; ll x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
    x *= w;
    return x;
}
void fl(string name){
    freopen((name+".in").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
          dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
#define MAXN 110
struct node{
    ll x,y;
}a[MAXN];
ll n;
int main(){
    cin>>n;
    rp(i,1,n){
        cin>>a[i].x>>a[i].y;
    }
    ll flag=0;
    rp(i,1,n-2){
        if(a[i].x==a[i].y&&a[i+1].x==a[i+1].y&&a[i+2].x==a[i+2].y){
            flag++;
            //break;
        }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}
/* stuff to remember
    * int overflow, array bounds
    * special cases (n=1? n=0?)
    * do something instead of nothing and stay organized
    * USE STATIC ARRAYS
    * DEFINING ARRAYS BEFORE main()
    * DO NOT DEFINE ARRAYS IN main()
    * USE INT INSTEAD OF LL,NOTICE THE MLE
*/

Measured memory_bytes: 3616
def solve():
    n=int(input())
    r=range
    a=list(map(int, input().split()))
    q=int(input())

    d={}
    s=0
    for i in r(n):
        cu=a[i]

        if d.get(cu, None):
            d[cu]+=1
        else:
            d[cu]=1
        
        s+=cu
    
    for _ in r(q):
        bi, ci = map(int, input().split())
        diff=ci-bi

        if d.get(ci, None):
            d[ci]+=d.get(bi, 0)
        else:
            d[ci]=d.get(bi, 0)

        s+=diff * d.get(bi, 0)
        print(s)

        if d.get(bi, None):
            d[bi]=0


if __name__ == '__main__':
    t=1
    for _ in range(t):
        solve()


Measured memory_bytes: 20844
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;
using namespace std;

#define mod 1000000007
#define INF 1000000000
#define LLINF 2000000000000000000LL

#define SIZE 100000

struct P{
    typedef double Type;
    
    Type x,y;
    
    P(Type X,Type Y){
        x = X;
        y = Y;
    }
    
    bool operator< (const P &B) const{
        return x==B.x ? y < B.y : x < B.x;
    }
};

/* ConvexHull(??????) */

bool ccw(P &base,P &A,P &B){
    //??´???????????????????????????
    return (A.x-base.x)*(B.y-base.y) - (A.y-base.y)*(B.x-base.x) >= 0; //double?????? -EPS
    
    //??´?????????????????????
    //return (A.x-base.x)*(B.y-base.y) - (A.y-base.y)*(B.x-base.x) > 0; //double?????? EPS
}

vector<P> ConvexHull(vector<P> s){
    vector<P> g;
    int n = (int)s.size();
    
    if(n<3) return s;
    
    sort(s.begin(),s.end());
    
    for(int i=0;i<n;i++){
        for(int m = (int)g.size();m>=2 && ccw(g[m-2],g[m-1],s[i]); m--){
            g.pop_back();
        }
        g.push_back(s[i]);
    }
    
    int upper_n = g.size();
    
    for(int i=n-2;i>=0;i--){
        for(int m = (int)g.size();m>upper_n && ccw(g[m-2],g[m-1],s[i]); m--){
            g.pop_back();
        }
        g.push_back(s[i]);
    }
    
    reverse(g.begin(),g.end());
    g.pop_back();
    
    return g;
}

int calc(int n){
    //int n;
    double x,y;
    vector<P> point;
    vector<P> ans;
    
    //scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%lf,%lf",&x,&y);
        point.push_back(P(x,y));
    }
    
    ans = ConvexHull(point);
    int m = (int)ans.size();
    
    
    printf("%d\n",n-m);
    
    return 0;
}

int main(){
    int n;
    
    while(1){
        scanf("%d",&n);
        if(n==0) break;
        calc(n);
    }
}

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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll n;
  string s;
  cin >> n >> s;
  auto convert = [&](char c) { return (char)('A' + (c - 'A' + n) % 26); };
  rep(i, s.size()) cout << convert(s[i]);
  cout << endl;
  return 0;
}


Measured memory_bytes: 3552
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
bool solve(void){
	int n,m,H,K,i,j;cin>>n>>m>>H>>K;
	if(n==0){return false;}
	vector<vector<tuple<int,int,int,int>>>go(n);
	for(i=0;i<m;i++){
		int a,b,c,h,r;cin>>a>>b>>c>>h>>r;a--;b--;r--;
		go[a].pub(mt(b,c,h,r));
		go[b].pub(mt(a,c,h,r));
	}
	int S,T;cin>>S>>T;S--;T--;
	int P;cin>>P;
	vector<int>pass(1<<K,mod);
	pass[0]=0;
	while(P--){
		int l,d,g=0;cin>>l>>d;
		while(l--){int k;cin>>k;k--;g+=(1<<k);}
		for(i=0;i<(1<<K);i++){mineq(pass[i|g],pass[i]+d);}
	}
	int ans=mod;
	for(int bi=0;bi<(1<<K);bi++){
		vector<vector<int>>dist(n,vector<int>(H+1,mod));
		dist[S][0]=0;
		priority_queue<tuple<int,int,int>,vector<tuple<int,int,int>>,greater<tuple<int,int,int>>>que;
		que.push(mt(0,S,0));
		while(que.size()){
			int nc,b,t;
			tie(nc,b,t)=que.top();
			que.pop();
			//cerr<<nc<<' '<<b<<' '<<t<<endl;
			if(dist[b][t]<nc){continue;}
			for(auto it:go[b]){
				int a,gc,h,r;
				tie(a,gc,h,r)=it;
				if(bi&(1<<r)){gc=0;}
				if(t+h<=H&&mineq(dist[a][t+h],nc+gc)){que.push(mt(nc+gc,a,t+h));}
			}
		}
		for(i=0;i<=H;i++){mineq(ans,pass[bi]+dist[T][i]);}
	}
	if(ans==mod){ans=-1;}
	//cerr<<"ans=";
	cout<<ans<<endl;
	return true;
}
int main(void){
	
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	while(solve()){}
	return 0;
}
//24*256*100


Measured memory_bytes: 3276
import math

n, c, k =map(int, input().split())
t = list(int(input()) for _ in range(n))

t.sort()

ans = 0
tm = 0
passenger = 0

for i in range(n):
    if passenger == 0 or t[i] > tm + k or passenger == c:
        tm = t[i]
        passenger = 1
        ans += 1
    else:
        passenger += 1

print(ans)


Measured memory_bytes: 13168
#include<iostream>
#include<cstdio>
#define N 110000
using namespace std;
int n,c,k;
int t[N];
int main()
{
    cin>>n>>c>>k;
    for(int i=1;i<=n;i++)cin>>t[i];
    sort(t+1,t+n+1);
    
    int cnt=0;
    int time=-100;
    int st=0;
    
    for(int i=1;i<=n;i++)
    {
        if(st<c&&time>=t[i])
        {
            st++;
        }
        else
        {
            cnt++;
            st=1;
            time=t[i]+k;
        }
    }
    cout<<cnt;
}


Measured memory_bytes: 888
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def main():
    _ = INT()
    V = LIST()
    C = LIST()

    ans = 0
    for v, c in zip(V, C):
        ans += max(v - c, 0)

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
def main():
    a = [[] for i in range(3)]

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

    n = int(input())

    for i in range(n):
        c = int(input())
        for j in range(3):
            for k in range(3):
                if a[j][k] == c:
                    a[j][k] = -1

    ans = "No"
    for i in range(3):
        if a[i][0] == -1 and a[i][1] == -1 and a[i][2] == -1:
            ans = "Yes"
            break
        if a[0][i] == -1 and a[1][i] == -1 and a[2][i] == -1:
            ans = "Yes"
            break

    if a[0][0] == -1 and a[1][1] == -1 and a[2][2] == -1:
        ans = "Yes"
    if a[0][2] == -1 and a[1][1] == -1 and a[2][0] == -1:
        ans = "Yes"

    print(ans)

main()

Measured memory_bytes: 38256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    H,W,M = LI()
    t = [LI() for _ in range(M)]

    hmax = [0] * (H+1)
    wmax = [0] * (W+1)

    for x,y in t:
        hmax[x] += 1
        wmax[y] += 1

    ans = 0

    hm = max(hmax)
    wm = max(wmax)

    xcnt = 0
    ycnt = 0
    for x in range(H+1):
        if hmax[x] == hm:
            xcnt += 1
    for y in range(W+1):
        if wmax[y] == wm:
            ycnt += 1

    cnt = 0
    for x,y in t:
        if hmax[x] == hm and wmax[y] == wm:
            cnt += 1
    if xcnt *  ycnt - cnt:
        print(hm + wm)
    else:
        print(hm+wm-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 126384
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
vector<ll>adj[100005];
bool visit[100005];
ll power(ll x, ll y,ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        ll w=(p*p)%z;
        if(y%2==0)
         return w;
        else
        return (x*w)%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
/*
ll dfs(ll x,vector<ll>&a)
{
    visit[x]=true;
    ll m=a[x-1];
    for(auto it=adj[x].begin();it!=adj[x].end();it++)
    {
        if(visit[*it]==false)
        {
            m=min(m,dfs(*it,a));
        }
        
    }
    return m;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll k;
    cin>>k;
    for(int i=0;i<k;i++)
    cout<<"ACL";}
    
    
    
    
    
    
   

Measured memory_bytes: 5928
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;
const int MOD = 1000000007;

const ll INF = 1001001001001;

int main(){
    int n;cin>>n;
    
    vector<ll> a(n),b(n);
    
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    
    if(n%2){
        cout << (b[n/2]-a[n/2])+1 << endl;
        return 0;
    }else{
        double diff;
        diff = ((b[n/2]+b[n/2-1])/2.0 - (a[n/2]+a[n/2-1])/2.0)*2+1;
        cout << (int)diff << endl;
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
template <typename T>
inline void read(T &x) {
	x = 0;
	char ch = 0;
	bool sign = false;
	while (ch < '0' || '9' < ch) sign |= ch == '-', ch = getchar();
	while ('0' <= ch && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	x = sign ? -x : x;
}
template <typename T>
inline void print(T x) {
	static char outp[64];
	if (!x) { putchar('0'); return; }
	if (x < 0) putchar('-'), x = -x;
	int tot = 0;
	while (x) outp[tot++] = x % 10 + '0', x /= 10;
	while (tot) putchar(outp[--tot]);
}
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rt register int
#define all(it) it.begin(), it.end()
#define rep(it, f, e) for (rt it = f; it <= e; ++it)
#define per(it, f, e) for (rt it = f; it >= e; --it)
const int MAXN = 2e5 + 10;
const int Sz = MAXN << 2; // (1 << 19) + 10;
vector<pii> bck[MAXN];
struct Node {
	#define lson (root << 1)
	#define rson (root << 1 | 1)
	#define mid ((tree[root].lt + tree[root].rg) >> 1)
	struct Point {
		int lt, rg;
		ll mn, vl;
	}	tree[Sz];
	inline void build(int root, int l, int r) {
		tree[root].lt = l;
		tree[root].rg = r;
		if (l == r) return;
		build(lson, l, mid);
		build(rson, mid + 1, r);
	}
	inline void change(int root, int x, ll p) {
		if (tree[root].lt == tree[root].rg) {
			tree[root].vl = p;
			tree[root].mn = p;
			return;
		}
		pushdown(root);
		if (x <= mid) change(lson, x, p);
		else change(rson, x, p);
		update(root);
	}
	inline void pushdown(int root) {
		tree[lson].vl += tree[root].vl;
		tree[lson].mn += tree[root].vl;
		tree[rson].vl += tree[root].vl;
		tree[rson].mn += tree[root].vl;
		tree[root].vl = 0;
	}
	inline void update(int root) {
		tree[root].mn = min(tree[lson].mn, tree[rson].mn);
	}
	inline void plus(int root, int l, int r, ll p) {
		if (l <= tree[root].lt && r >= tree[root].rg) {
			tree[root].vl += p;
			tree[root].mn += p;
			return;
		}
		pushdown(root);
		if (l <= mid) plus(lson, l, r, p);
		if (r > mid) plus(rson, l, r, p);
		update(root);
	}
	inline ll query(int root, int l, int r) {
		if (l <= tree[root].lt && r >= tree[root].rg) {
			return tree[root].mn;
		}
		ll ret = 1e18;
		pushdown(root);
		if (l <= mid) ret = min(ret, query(lson, l, r));
		if (r > mid) ret = min(ret, query(rson, l, r));
		return ret;
	}
	#undef lson
	#undef rson
	#undef mid
}	Tree;
int main() {
	int l, n;
	read(l), read(n);
	ll s = 0;
	rep (i, 1, n) {
		int u, v, e;
		read(u), read(v), read(e);
		bck[v].pb(mp(u, e));
		s += e;
	}
	Tree.build(1, 0, l);
	rep (i, 1, l) {
		ll d = Tree.query(1, 0, i - 1);
		Tree.change(1, i, d);
		for (auto t : bck[i]) {
			Tree.plus(1, 0, t.fst - 1, t.sed);
		}
	}
	print(s - Tree.query(1, 0, l)), puts("");
	return 0;
}

Measured memory_bytes: 25856
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
using namespace std;


int main(){
    int H,W;
    cin >> H >> W;
    vector<string>field;
    string st(W+2,'.');
    field.push_back(st);
    for(int i=0; i<H; i++){
        string s;
        cin >> s;
        s = "." + s + ".";
        field.push_back(s);
    }
    field.push_back(st);
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(field[i][j]=='#') continue;
            int tmp=0;
            for(int k=-1;k<=1;k++){
                for(int l=-1;l<=1;l++){
                    if(k!=0 | l!=0){
                        if(field[i+k][j+l]=='#') tmp+=1;
                    }
                }

            }
            field[i][j]=to_string(tmp)[0];
        }
    }
    for(auto itr = field.begin()+ 1;itr!=field.end() -1;itr++) cout << (*itr).substr(1,W) <<"\n";
}

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

int main() {
    int64_t N, A, B;
    cin >> N >> A >> B;

    int64_t n1 = N / (A + B) * A;
    int64_t n2 = min(N % (A + B), A);
    cout << (A != 0 ? (n1 + n2) : 0) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,d=0;//taoyandejie meiweidejie meiweidedu
	scanf("%d %d %d",&a,&b,&c);
	

	if(c>a || c>b){

	while(c>0){	
		d++;
		if(b>0){
			d++;
			c--;
			b--;
			continue;
		}
		if(b==0){
			if(a>0){
				c--;
				
				a--;
				continue;
			}
			if(a==0){
				break;
			}
		}
	}

	}
	else if(c<b || c==b){
		d=c+b;
	}
	
	
	
	printf("%d",d);
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static int a;
        static int b;
        static int coins;

        static void Main(string[] args)
        {
            //[summary]A - Buttons
            var line = ReadLine();
            a = line[0];
            b = line[1];

            PushButton();
            PushButton();

            Console.WriteLine(coins);
        }

        static void PushButton()
        {
            if (a > b)
            {
                coins += a;
                a--;
            }
            else
            {
                coins += b;
                b--;
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
import java.util.*;
public class Main {
	//0323 start
	
	
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		int dataset = sc.nextInt();
		while(dataset-- > 0){
			int [][] data = new int[8][32];
			for(int i = 0; i < 8; i++){
				long num = Long.parseLong(sc.next(), 16);
				data[i] = parse(num);
			}
			String s = sc.next();
			int [] n9 = parse(Long.parseLong(s, 16));
			//System.out.println(Arrays.toString(n9));
			
			int [] res = new int[32];
			int prev = 0;
			for(int i = 0 ; i < 32; i++){
				int sum = prev;
				for(int j = 0; j < 8; j++){
					sum+= data[j][i];
				}
				//System.out.println("i = " + i + " sum = " + sum +  " prev = " + prev);
				if(sum % 2 == n9[i]){
					res[i] = 0;
					prev = sum / 2;
				}
				else{
					res[i] = 1;
					sum = prev;
					for(int j = 0 ; j < 8; j++){
						sum += (data[j][i] + 1) % 2; 
					}
					prev = sum / 2;
				}
			}
			
			StringBuilder sb = new StringBuilder();
			for(int i = 0; i < 32; i++){
				sb.append(res[i]);
			}
			sb.reverse();
			long ans = Long.parseLong(sb.toString(), 2);
			System.out.println(Long.toHexString(ans));
			
		}
	}

	private int[] parse(long num) {
		StringBuilder s = new StringBuilder(Long.toBinaryString(num));
		s.reverse();
		int [] res = new int[32];
		for(int i = 0; i < s.length(); i++){
			res[i] = s.charAt(i) - '0';
		}
		return res;
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	char a, b;
	cin >> a >> b;
	if (a < b)cout << "<" << endl;
	else if (a == b)cout << "=" << endl;
	else cout << ">" << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			int s = sc.nextInt();
			int g = sc.nextInt();
			int m = sc.nextInt();
			
			int[][] map = new int[m+1][n+1];
			
			String t;
			for(int i=1;i<=m;i++){
				t = sc.next();
				for(int j=1;j<n;j++){
					map[i][j] = t.codePointAt(j-1)-48;
				}
			}
			
			int x;
			boolean flag = false;
			for(int i=0;i<=m;i++){
				for(int j=1;j<n;j++){
					if(map[i][j-1]==0 && map[i][j]==0 && map[i][j+1]==0){
						map[i][j] = 1;
						x = s;
						for(int k=1;k<=m;k++){
							if(map[k][x-1]==1) x--;
							else if(map[k][x]==1) x++;
						}
						if(x==g){
							if(i==0) System.out.println(0);
							else System.out.println(i + " " + j);
							flag = true;
							i = m+1;
							j = n;
						}else{
							map[i][j] = 0;
						}
					}
				}
			}
			if(flag==false) System.out.println(1);
		}	
	}	
}

Measured memory_bytes: 20808
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int n;
    int m;
 
   cin >> n >> m;
  
  
string l;
int k=0;
  
string a[n];
  
  
 while(cin>>l){
        a[k] = l;
       
        k++;
    }

  
  // cout << n << endl;
  // cout << m << endl;
  
  for(int i = 0;i<n;i++){
    
      cout << a[i] << endl;
      cout << a[i] << endl;
   }
  
  return 0;
}

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

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

lol lcm(lol a, lol b){
    lol q1=min(a,b),q2=max(a,b);
    a=q1,b=q2;
    return (a*(b/(gcd(a,b))));
}
              
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lol n,a;
    cin >> n;
    lol ans=-n;
    for(lol i=0; i<n; i++){
        cin >> a;
        ans+=a;
    }
    cout << ans;
    return 0;
}

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

int main(){
  int N;
  long long count = 0,total = 0;
  cin >> N;
  vector<long long> A(N);
  for(int i= 0;i<N;i++)
    cin >> A.at(i);
  for(int i= 0;i<N;i++)
    if(A.at(i)<0)count++;
  for(int i= 0;i<N;i++)
    if(A.at(i)==0)count = 0;
  for(int i= 0;i<N;i++)
    A.at(i) = abs(A.at(i));
  for(int i= 0;i<N;i++)
    total += A.at(i);
  sort(A.begin(),A.end());
  if(count%2== 1) cout << total - 2*A.at(0) << endl;
  else cout << total << endl;
}

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

// 2つの整数の場合
long long GetGreatestCommonDivisor(long long a, long long b)
{
	long long m = a;
	long long n = b;
	long long temp;
	while (m % n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

int main() {

	ll n; cin >> n;
	vector<ll> a(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	// 3つ以上の整数の場合
	long long gcd = a[0];
	for (int i = 1; i < n; i++) {
		gcd = GetGreatestCommonDivisor(gcd, a[i]);
	}	
	cout << gcd << endl;
	return 0;
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
#define vpp vector<pair<ll,ll>>
#define ff first
#define ss second
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;

ll dp[100005];
int main()
{
    rkc;
    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    fl(i,1,n+1)cin>>a[i];
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    fl(i,3,n+1)
    {   
        dp[i]=dp[i-1]+abs(a[i-1]-a[i]);
        fl(j,2,k+1)if(i-j>0)
            dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
    }
    cout<<dp[n];
}

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

typedef long long LL;
using namespace std;

void read(int &v){int k=0,l=1;char ch;ch=getchar();while (ch>'9' || ch<'0'){if (ch=='-') l=-1;ch=getchar();}while (ch>='0' && ch<='9') k=k*10+ch-'0',ch=getchar();v=l*k;}
void print(int v){if (v<0) putchar('-'),v=-v;if (v>9) print(v/10);putchar(v%10+'0');}
int max(int a, int b) { return a>b ? a: b;}
int min(int a, int b) { return a<b ? a: b;}

static int n;

int main() {
    read(n);
    vector<int> a(n);
    for (int i = 0; i < n; ++i )
        cin >> a[i];
    LL tmp = 0;
    for(int i = 0; i < n; ++i ) {
        if(i % 2 == 0)
            tmp += a[i];
        else
            tmp -= a[i];
    }
    print(tmp);
    for(int i = 0; i < n - 1; ++i ){
        tmp = (a[i] - (tmp >> 1)) << 1;
        cout << ' ' << tmp;
    }
}

Measured memory_bytes: 1664
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var K = one[1];
  var list = nextIntArray();
  list.sort(function(a,b){
  	return b - a;
  });
  var output = 0;
  for(var i = 0; i < K; i++){
    output += list[i];
  }
  myout(output);
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200010
#define lim9 1000000010

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

int main() {
    ll x;
    cin >> x;
    ll c = 100;
    ll i = 0;
    while(true) {
        c *= 1.01;
        ++i;
        if (c >= x) {
            out(i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
A, V = tuple(int(c) for c in input().split(' '))
B, W = tuple(int(c) for c in input().split(' '))
T = int(input())

delta = V - W

if A == B:
  print('YES')
  exit()
elif delta <= 0:
  print('NO')
  exit()
else:
  d = abs(A-B)
  time = d / delta
  if time <= T:
    print('YES')
  else:
    print('NO')
  

Measured memory_bytes: 9192
import java.util.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	int N,M;
	final int	MAX1=1000001,
				MAX2=1001,
				INF=1<<29;
	boolean[][] isPrime;
	int[][] number,dp1,dp2;
	int[] xp,yp;
	void init(){
		isPrime = new boolean[MAX2][MAX2];
		number = new int[MAX2][MAX2];
		for(int i=0; i<MAX2; ++i)for(int j=0; j<MAX2; ++j)	number[i][j]=INF;
		xp=new int[MAX1];
		yp=new int[MAX1];
		int x=500,y=500;
		int lim=1,cnt=0,two=0,v=0;
		final int[] vx={1,0,-1,0},vy={0,-1,0,1};
		for(int i=1; i<MAX1; ++i){
//			System.out.println(i+"="+x+","+y);
			xp[i]=x;	yp[i]=y;
			number[x][y]=i;
			x+=vx[v];	y+=vy[v];
			++cnt;
			if(cnt>=lim){
				cnt=0;
				v=(v+1)%4;
				++two;
				if(two>=2){
					two=0;
					++lim;
				}
			}
		}
		dp1=new int[MAX2][MAX2];
		dp2=new int[MAX2][MAX2];
		
		for(int i=0; i<MAX2; ++i)for(int j=0; j<MAX2; ++j)	isPrime[i][j]=true;
		isPrime[xp[0]][yp[0]]=isPrime[xp[1]][yp[1]]=false;
		for(int i=2; i*i<MAX1; ++i)if(isPrime[xp[i]][yp[i]])for(int j=i+i; j<MAX1; j+=i)	isPrime[xp[j]][yp[j]]=false;
		
		while(true){
			M=sc.nextInt();
			N=sc.nextInt();
			if((N|M)==0)	break;
			solve();
		}
	}

	void solve(){
		int sx=xp[N],sy=yp[N];
		for(int x=0; x<MAX2; ++x)for(int y=sy; y<MAX2; ++y){
			dp1[x][y]=-INF;
			dp2[x][y]=0;
		}
		
		dp1[sx][sy]=(isPrime[sx][sy]? 1: 0);
		dp2[sx][sy]=(isPrime[sx][sy]? number[sx][sy]: 0);
		int ans1=(isPrime[sx][sy]? 1: 0),ans2=(isPrime[sx][sy]? number[sx][sy]: 0);
		
		for(int y=sy; y<MAX2-1; ++y)for(int x=0; x<MAX2; ++x)if(number[x][y]<=M && dp1[x][y]>(-INF)){
//			System.out.println(x+","+y+" "+number[x][y]+" "+isPrime[x][y]+" "+dp1[x][y]);
			for(int i=-1; i<=1; ++i){
				int nx=x+i,ny=y+1;
				if(!(0<=nx&&nx<MAX2 && 0<=ny&&ny<MAX2))	continue;
				if(number[nx][ny]>M)	continue;
				if(dp1[nx][ny] < dp1[x][y]+(isPrime[nx][ny]? 1: 0)){
					dp1[nx][ny]=dp1[x][y]+(isPrime[nx][ny]? 1: 0);
					dp2[nx][ny]=(isPrime[nx][ny]? number[nx][ny]: dp2[x][y]);
					// TODO
//					System.out.println(nx+","+ny+" "+number[nx][ny]+" "+isPrime[nx][ny]+" "+dp1[nx][ny]);
				}else if(dp1[nx][ny] == dp1[x][y]+(isPrime[nx][ny]? 1: 0)){
					if(dp2[nx][ny] < (isPrime[nx][ny]? number[nx][ny]: dp2[x][y])){
						dp1[nx][ny]=dp1[x][y]+(isPrime[nx][ny]? 1: 0);
						dp2[nx][ny]=(isPrime[nx][ny]? number[nx][ny]: dp2[x][y]);
						// TODO
//						System.out.println(nx+","+ny+" "+number[nx][ny]+" "+isPrime[nx][ny]+" "+dp1[nx][ny]);
					}
				}
				if(ans1 < dp1[nx][ny]){
					ans1=dp1[nx][ny];
					ans2=dp2[nx][ny];
				}else if(ans1==dp1[nx][ny] && ans2<dp2[nx][ny]){
					ans2=dp2[nx][ny];
				}
			}
		}
		System.out.println(ans1+" "+ans2);		
	}
}

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

int main()
{
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    vector<int> B(400);
    rep(i, 400)
    {
        B[i] = (i + 1) * (i + 1);
    }
    rep(i, N)
    {
        rep(j, D)
        {
            cin >> X[i][j];
        }
    }
    int sum = 0;
    int count = 0;
    rep(i, N)
    {
        sum = 0;
        int m = i + 1;
        while (m < N)
        {

            rep(j, D)
            {
                sum += (abs(X[i][j] - X[m][j]) * abs(X[i][j] - X[m][j]));
            }

            rep(k, 400)
            {
                if (B[k] == sum)
                {
                    count++;
                    break;
                }
            }
            sum = 0;
            m++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    string S; cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    } else cout << "No" << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

using namespace std;

using ll = long long;
constexpr ll MOD = 998244353;

int n, k;
ll dp[100010][310][2];
vector<int> sub(100010, 1);
vector<vector<int>> g(100010);

void rec(int cur, int pre)
{
    dp[cur][0][0] = dp[cur][1][1] = 1;
    int ma = min(k, 1);
    for (auto v : g[cur])
    {
        if (v == pre)
            continue;
        rec(v, cur);
        sub[cur] += sub[v];
        int s = min(k, sub[v]);
        vector<ll> nxt0(min(k, ma + sub[v]) + 1, 0), nxt1(min(k, ma + sub[v]) + 1, 0);
        for (int i = 0; i <= ma; i++)
        {
            for (int j = 0; j <= s; j++)
            {
                if (i + j > k)
                    break;
                ll sum = (dp[v][j][0] + dp[v][j][1]) * dp[cur][i][0] % MOD;
                nxt0[i + j] = (nxt0[i + j] + sum);
                if (nxt0[i + j] >= MOD)
                    nxt0[i + j] -= MOD;
            }
            for (int j = 0; j <= s; j++)
            {
                if (i + j > k)
                    break;
                ll sum = (dp[v][j][0] + dp[v][j][1]) * dp[cur][i][1] % MOD;
                nxt1[i + j] = (nxt1[i + j] + sum);
                if (nxt1[i + j] >= MOD)
                    nxt1[i + j] -= MOD;
            }
            for (int j = 1; j <= s; j++)
            {
                if (i + j - 1 > k)
                    break;
                ll sum = dp[v][j][1] * dp[cur][i][1] % MOD;
                nxt1[i + j - 1] = (nxt1[i + j - 1] + sum);
                if (nxt1[i + j - 1] >= MOD)
                    nxt1[i + j - 1] -= MOD;
            }
        }
        ma = min(k, ma + sub[v]);
        for (int i = 0; i <= ma; i++)
        {
            dp[cur][i][0] = nxt0[i];
            dp[cur][i][1] = nxt1[i];
        }
    }
}

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

    cin >> n >> k;
    for (int i = 0; i < n - 1; i++)
    {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    rec(0, -1);
    cout << (dp[0][k][0] + dp[0][k][1]) % MOD << endl;
}



Measured memory_bytes: 503420
import java.util.*;
public class Main {
  
  private static long X = 1000000007;
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    long[][] memo = new long[N+1][N+1];
//    for (int i = 0; i <= N; i++) {
//      for (int j = 0; j <= N; j++) {
//        memo[i][j] = -1;
//      }
//    }
    for (int i = 1; i <= K; i++) {
      if (N-K+1 >= i) {
        long count = (comb(N-K+1, i, memo) * comb(K-1, i-1, memo)) % X;
        System.out.println(count);
      } else {
        System.out.println(0);
      }
    }
  }
  
  private static long comb(int n, int r, long[][] memo) {

    if (r == n || r == 0) {
      return 1;
    }

    if (memo[n][r] != 0) {
      return memo[n][r];
    }

    memo[n][r] = (comb(n-1, r-1, memo) + comb(n-1, r, memo)) % X;
    
    return memo[n][r];
  }
}


Measured memory_bytes: 82644
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  string s;
  cin>>s;
  if(s[1]==s[0]&&s[1]==s[2]){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
bool jishojun_hikaku(string x, string y) {
    for(int i = 0; i < x.size(); i++) {
        if(x.at(i)<y.at(i)) return true;
    }
    return false;
}

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    vector<int> P(N);
    for(int i = 0; i < N; i++) {
        cin >> S.at(i) >> P.at(i);
        P.at(i) *= -1;
    }
    
    vector<pair<string, int>> restaurant(N), copy_restaurant(N);
    for(int i = 0; i < N; i++) {
        restaurant.at(i) = make_pair(S.at(i), P.at(i));
        copy_restaurant.at(i) = make_pair(S.at(i), P.at(i));
    }
    sort(copy_restaurant.begin(), copy_restaurant.end());
    
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            if(restaurant.at(j)==copy_restaurant.at(i)) cout << j+1 << endl;
        }
    }
    
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.*;
class Main
{
	static ArrayList<Integer> adj[];
	static int dpi[],dpo[],vis[];
	static int ans;
	public static void main (String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int i;
		int n=sc.nextInt(); int m=sc.nextInt();
		dpi=new int[n]; dpo=new int[n];
		adj=new ArrayList[n]; ans=0;
		for(i=0;i<n;i++)
			adj[i]=new ArrayList();
		for(i=0;i<m;i++) 
		{
			int u=sc.nextInt()-1; int v=sc.nextInt()-1;
			adj[u].add(v); 
		}
		vis=new int[n];
		for(i=0;i<n;i++)
		{
			if(vis[i]==0)
				dfs(i,-1,0);
		}
		Arrays.fill(vis, 0);
		for(i=0;i<n;i++)
		{
			if(vis[i]==0)
				dfs(i,-1,0);
		}
		for(i=0;i<n;i++)
			if(dpi[i]+dpo[i]>ans)
				ans=dpi[i]+dpo[i];
		System.out.println(ans);
	}
	public static void dfs(int v,int p,int l)
	{
		vis[v]=1;
		dpi[v]=Math.max(dpi[v], l);
		if(p!=-1)
		{
			dpo[p]=Math.max(dpo[p], 1+dpo[v]);
			dpi[v]=Math.max(dpi[v], dpi[p]+1);
		}
		for(int node:adj[v])
		{
			if(vis[node]==0)
			{
				dfs(node,v,l+1);
				dpo[v]=Math.max(dpo[v], 1+dpo[node]);
			}
			else
			{
				dpi[node]=Math.max(dpi[node], dpi[v]+1);
				dpo[v]=Math.max(dpo[node]+1, dpo[v]);
			}
		}
		
	}
} 

Measured memory_bytes: 77500
#include <bits/stdc++.h>
#define INF 100000000
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)


int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    if (k < a) a -= k;
    else if(a + b > k){b -= (k - a), a = 0;
    }
    else {a = 0; b = 0;
    }
    cout << a << '\t' << b << '\n';
}

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

#define mp make_pair
typedef long long ll;
typedef pair<int,int>pii;
const int N = 3e5;
vector<int>graph[N+100];
int dist[N+100];

int main()
{
	int n,m,s,t;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		graph[u].push_back(v+n);
		graph[u+n].push_back(v+2*n);
		graph[u+2*n].push_back(v);
	}
	scanf("%d%d",&s,&t);
	queue<int>q;
	memset(dist,-1,sizeof dist);
	dist[s] = 0;
	q.push(s);
	while(!q.empty())
	{
		int u = q.front();
		q.pop();
		for(auto it:graph[u])
		{
			if(dist[it]==-1){
				dist[it] = dist[u]+1;
				q.push(it);
			}
		}
	}
	if(dist[t]==-1){
		printf("-1\n");
	}
	else printf("%d\n",dist[t]/3);
}


Measured memory_bytes: 17792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>

using namespace std;

#define ll long long
#define MOD 1000000007
#define rep(i, n) for(int i = 0;i < n;i++)


int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n)
    {
        cin >> d[i];
    }
    int N;
    N = (n*(n-1))/2;
    ll ans = 0;

    rep(i,n)
    {
        for (int j = i+1; j < n; j++)
        {
            ans+=d[i]*d[j];
        }
    }

    cout <<  ans<< endl;
}


Measured memory_bytes: 256
S = input()

S = reversed(S)

x, tot = 1, 0
cnt = [0] * 2019
ans = 0

for (i, s) in enumerate(S):
    cnt[tot] += 1
    tot += int(s)*x
    tot %= 2019
    ans += cnt[tot]
    x = x * 10 % 2019

print(ans)


Measured memory_bytes: 9276
#54a
A,B = map(int, input().split())

if A==B:
    print("Draw")
elif A==1 or B==1:
    if A==1:
        print("Alice")
    else:
        print("Bob")
else:
    if A > B:
        print("Alice")
    elif A < B:
        print("Bob")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for (int i = 1; i <= n; ++i) {
        int power = i;
        int cnt = 0;
        while (power < k) {
            power *= 2;
            cnt++;
        }
        ans += pow(0.5, cnt);;
    }
    ans /= n;
    cout << fixed << setprecision(15) << ans << endl;
}

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

using namespace std;
int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	
	int ans = 0;
	for (int i = 0; i < s.size() / 2; i++) {
		if (s[i] != s[s.size()-1-i]) {
			ans += 1;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
k = I()
s = S()
if len(s) <= k:
    print(s)
else:
    print(s[0:k] + '...')

Measured memory_bytes: 68540
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

int main(){
  long long n,m,Q;
  cin >> n >> m >> Q;
  long long l[m],r[m];
  long long p[Q],q[Q];
  for(int i=0;i<m;i++){
    cin >> l[i] >> r[i];
  }
  for(int i=0;i<Q;i++){
    cin >> p[i] >> q[i];
  }

  long long count_1[n+1][n+1];
  long long dp[n+1][n+1];
  long long count_2[n+1];
  for(int i=0;i<n+1;i++){
    count_2[i] = 0;
    for(int j=0;j<n+1;j++){
      count_1[i][j] = 0;
      dp[i][j] = 0;
    }
  }

  for(int i=0;i<m;i++){
    count_1[l[i]][r[i]] += 1;
  }

  for(int i=n;i>=2;i--){
    for(int j=1;j<n+1;j++){
      count_1[i-1][j] += count_1[i][j];
    }
  }

  for(int i=0;i<m;i++){
    count_2[l[i]] += 1;
  }

  dp[1][n] = m;
  for(int i=2;i<n+1;i++){
    dp[i][n] = dp[i-1][n] - count_2[i-1];
  }
  for(int i=1;i<n+1;i++){
    for(int j=n-1;j>=1;j--){
      dp[i][j] = dp[i][j+1] - count_1[i][j+1];
    }
  }
  for(int i=0;i<Q;i++){
    cout << dp[p[i]][q[i]] << endl;
  }


  return 0;
}


Measured memory_bytes: 9472
N,W = map(int,input().split())
item = [list(map(int,input().split())) for i in range(N)]

dp = [[0] * (W + 1)  for i in range(N + 1)]

for i in range(N):
  value = item[i][0]
  weight = item[i][1]
  for w in range(W + 1):
    if item[i][1] <= w:
      dp[i + 1][w] = max(dp[i][w - weight] + value,dp[i][w])
    #大事
    else:
      dp[i + 1][w] = dp[i][w]

print(dp[N][W])


Measured memory_bytes: 41884
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
    int keytw;
    Node *next,*prev;
};

Node *nil;

Node* listSearch(int keytw){
    Node *curtw = nil->next;
    while(curtw != nil && curtw->keytw != keytw){
        curtw = curtw->next;
    }
    return curtw;
}

void init(){
    nil = (Node*)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    Node *cur = nil->next;
    int isftw=0;
    while(1){
        if(cur==nil)break;
        if(isftw++ > 0)printf(" ");
        printf("%d",cur->keytw);
        cur=cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t){
    if(t==nil)return;
    t->prev->next=t->next;
    t->next->prev=t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int keytw){

    deleteNode(listSearch(keytw));
}

void insert(int keytw){
    Node *x=(Node *)malloc(sizeof(Node));
    x->keytw=keytw;

    x->next=nil->next;
    nil->next->prev=x;
    nil->next=x;
    x->prev=nil;
}

int main(){
    int keytw,n,i;
    int size=0;
    char comtw[20];
    int np=0, nd=0;
    scanf("%d",&n);
    init();
    for(i=0;i<n;i++){
        scanf("%s%d",comtw,&keytw);
        if(comtw[0]=='i'){insert(keytw);np++;size++;}
        else if(comtw[0]=='d'){
            if(strlen(comtw)>6){
                if(comtw[6]=='F')deleteFirst();
                else if(comtw[6]=='L')deleteLast();
            }else{
                deleteKey(keytw);nd++;
            }
            size--;
        }
    }

    printList();

    return 0;
}




Measured memory_bytes: 33936