akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
}
int a[214514];
signed main(){
	ic(n)
	int ans=0;
	rep(0,i,n){
		cin>>a[i];
		a[i]-=i+1;
	}	
	sort(a,a+n);
	int b=(a[n/2]+a[(n-1)/2])/2;
	rep(0,i,n)ans+=abs(b-a[i]);
	c(ans)
}	

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    vector<pair<ll, ll>> lr(n);
    rep(i, n) {
        cin >> lr[i].first >> lr[i].second;
        lr[i].second++;
    }

    ll lmax = 0, rmin = (1 << 30);
    rep(i, n) {
        chmax(lmax, lr[i].first);
        chmin(rmin, lr[i].second);
    }

    multiset<ll> s, ss;
    vector<pair<ll, ll>> ab(n);
    rep(i, n) {
        ab[i].first  = max(0LL, lr[i].second - lmax);
        ab[i].second = max(0LL, rmin -  lr[i].first);

        // cout << " -- " << i << " " << ab[i].first << " " << ab[i].second << endl;
        s.insert(ab[i].first);
        ab[i].second *= -1;
    }

    ll ans = 0;
    rep(i, n) chmax(ans, max((ll)0, rmin - lmax) + lr[i].second - lr[i].first);
    // cout << ans << endl;

    sort(all(ab));
    rep(i, n - 1) {
        auto it = s.find(ab[i].first);
        if (it != s.end()) s.erase(it);
        ss.insert(-ab[i].second);
        // cout << s.size() << endl;
        chmax(ans, *ss.begin() + *s.begin());
        // cout << i << " " << -ab[i].second << " " << *s.begin() << " " << ans << endl;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8064
use std::io::*;
use std::str::FromStr;

fn main() {
	let a: char = read();
	let ans = if a >= 'a' { "a" } else { "A" };
println!("{}", ans);
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 2108
#include <iostream>

using namespace std;
typedef pair<int,int> P;//??°???????????° ?????????

P dp[32][32][32][32];//yl,yr,xl,xr
int U[32][32];//y,x
const P ZERO = P(0,0);

int U_sum[32][32];

int u_min;//??°?????????????¶???????????????????

P f(int yl, int yr, int xl, int xr){//xl<=xr, yl<=yr ???????????§??????????????¨
    if(dp[yl][yr][xl][xr]!=ZERO){
        return dp[yl][yr][xl][xr];
    }
    if(yl==yr&&xl==xr){
        return dp[yl][yr][xl][xr]=P(u_min<=U[yl][xl]?1:0,U[yl][xl]);            
    }

    int max_u=U_sum[yr][xr]-(yl?U_sum[yl-1][xr]:0)-(xl?U_sum[yr][xl-1]:0)+(xl&&yl?U_sum[yl-1][xl-1]:0);
    int max_d=(u_min<=max_u?1:0);

    //x?????????
    for(int x=xl;x<xr;x++){
        P pl=f(yl,yr,xl,x);
        P pr=f(yl,yr,x+1,xr);
        if(pl.first&&pr.first){
            int d=pl.first+pr.first;
            int u=min(pl.second,pr.second);
            if(d>max_d){
                max_d=d;
                max_u=u;
            }else if(d==max_d){
                max_u=max(max_u,u);
            }
        }
    }
    //y?????????
    for(int y=yl;y<yr;y++){
        P pl=f(yl,y,xl,xr);
        P pr=f(y+1,yr,xl,xr);
        if(pl.first&&pr.first){
            int d=pl.first+pr.first;
            int u=min(pl.second,pr.second);
            if(d>max_d){
                max_d=d;
                max_u=u;
            }else if(d==max_d){
                max_u=max(max_u,u);
            }
        }
    }
    return dp[yl][yr][xl][xr]=P(max_d,max_u);
}

int main(){
    int h,w,s;
    while(cin>>h>>w>>s,h){
        fill(dp[0][0][0],dp[32][0][0],ZERO);
        u_min=-s;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>U[i][j];
                u_min+=U[i][j];
            }
        }
        //?´????????????????
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                U_sum[i][j]=(j?U_sum[i][j-1]:0)+U[i][j];
            }
        }
        for(int i=1;i<h;i++){
            for(int j=0;j<w;j++){
                U_sum[i][j]+=U_sum[i-1][j];
            }
        }
        auto p = f(0,h-1,0,w-1);
        cout<<p.first<<' '<<p.second-u_min<<endl;
    }
    return 0;
}

Measured memory_bytes: 11224
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    int max_dist = 0;
    for(int i = 0; i < N - 1; i++){
        max_dist = max(max_dist, A[i + 1] - A[i]);
    }
    max_dist = max(max_dist, K - A.back() + A[0]);
    cout << K - max_dist << endl;
}


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

signed main () {
    int n, k;
    cin >> n >> k;
    int g = 0, m = 0, x;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        g = __gcd(g, x);
        m = max(m, x);
    }
    if (k > m || k % g)
        cout << "IMPOSSIBLE\n";
    else
        cout << "POSSIBLE\n";
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int H, W;
vector<vector<char>> S;

// 最長距離を返す
int bfs(int sy, int sx) {
    queue<pair<int, int>> Q;
    vector<vector<int>> searched(H + 1, vector<int>(W + 1, 0));
    vector<vector<int>> d(H + 1, vector<int>(W + 1, -1));

    Q.push(make_pair(sy, sx));
    searched[sy][sx] = 1;
    d[sy][sx] = 0;
    int longest = 0;

    while (!Q.empty()) {
        int qy = Q.front().first;
        int qx = Q.front().second;

        for (int i = 0; i < 4; ++i) {
            int ty = qy, tx = qx;
            if (i == 0) ty--;
            else if (i == 1) tx++;
            else if (i == 2) ty++;
            else if (i == 3) tx--;

            if (ty <= 0 || ty > H || tx <= 0 || tx > W) continue;

            if (searched[ty][tx] == 0) {
                searched[ty][tx] = 1;
                if (S[ty][tx] == '#') {
                    continue;
                }
                d[ty][tx] = d[qy][qx] + 1;
                longest = max(d[ty][tx], longest);
                Q.push(make_pair(ty, tx));
            }
        }

        searched[qy][qx] = 2;
        Q.pop();
    }

    return longest;
}

int main(void) {
    cin >> H >> W;
    S = vector<vector<char>>(H + 1, vector<char>(W + 1));

    REP(y, 1, H + 1) {
        string s;
        cin >> s;
        REP(x, 1, W + 1) {
            S[y][x] = s[x - 1];
        }
    }

    int longest = 0;
    // 全マスを対象にBFS
    for (int y = 1; y <= H; ++y) {
        for (int x = 1; x <= W; ++x) {
            if (S[y][x] == '#') continue;
            longest = max(longest, bfs(y, x));
        }
    }

    cout << longest << endl;
    return 0;
}

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

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

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


int main() {

    double L;
    cin>>L;

    double n=L/3;
    double z=L-n-n;

    double ans=n*n*z;

    cout<<fixed<<setprecision(10)<<ans<<endl;

}


Measured memory_bytes: 256
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define MAX_T 202
#define MAX_N 100

int main() {
#ifdef DEBUG

#endif
	char s[4];
	scanf("%c%c%c", &s[0], &s[1], &s[2]);

	int cnt = 0;
	int i;
	for (i = 0; i < 3; i++) {
		if (s[i] == '1')cnt++;
	}

	printf("%d\n", cnt);
}

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

int dp[100100][110];
int weight[100100], value[110];

#define passv(a,b) if(a < b) a = b

signed main(){
    int n,w;
    cin >> n >> w;
    for(int i = 0; i < n; i++){
        cin >> weight[i] >> value[i];
    }

    for(int i = 0; i < n; i++){
        for(int ww = 0; ww <= w; ww++){
            if(ww - weight[i] >= 0)
            passv(dp[ww][i + 1],dp[ww - weight[i]][i] + value[i]);
        passv(dp[ww][i + 1],dp[ww][i]);
        }
    }
    cout << dp[w][n] << endl;
}

Measured memory_bytes: 86016
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
def main():
    T = int(input())
    for _ in range(T):
        N, A, B, C, D = map(int, input().split())
        memo = {}

        def f(n):
            if n == 0:return 0
            if n == 1:return D
            if n in memo:return memo[n]

            ret = min(
                D * n,
                D * (n%2) + A + f(n//2),
                D * abs(n - (n+1)//2*2) + A + f((n+1)//2),
                D * (n%3) + B + f(n//3),
                D * abs(n - (n+2)//3*3) + B + f((n+2)//3),
                D * (n%5) + C + f(n//5),
                D * abs(n - (n+4)//5*5) + C + f((n+4)//5)
            )

            memo[n] = ret
            return ret
        print(f(N))
if __name__ == "__main__":
    main()

Measured memory_bytes: 11032
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
  ll n,m,q;
  cin>>n>>m>>q;
  vector<vector<ll>>v(n,vector<ll>(n));
  rep(i,m){
    ll l,r;
    cin>>l>>r;
    l--;r--;
    v[l][r]++;
  }
  vector<vector<ll>>sum(n+1,vector<ll>(n+1));
  rep(i,n){
    rep(j,n){
      sum[i+1][j+1]=sum[i+1][j]+sum[i][j+1]+v[i][j]-sum[i][j];//2次元累積和
    }
  }
  rep(i,q){
    ll x,y;
    cin>>x>>y;
    ll ans=sum[y][y]-sum[x-1][y]-sum[y][x-1]+sum[x-1][x-1];
    cout<<ans<<"\n";
  }
  return;
}
 
signed main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
  cout<<fixed<<setprecision(20);
	solve();
	return 0;
}

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

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

struct Happiness {
    int a;
    int b;
    int index;
};

bool cmp1(const Happiness& lhs, const Happiness& rhs) {
    int diff1 = lhs.a - rhs.b;
    int diff2 = rhs.a - lhs.b;
    if ( diff1 > diff2 ) return true;
    return false;
}

bool cmp2(const Happiness& lhs, const Happiness& rhs) {
    int diff1 = lhs.b - rhs.a;
    int diff2 = rhs.b - lhs.a;
    if ( diff1 > diff2 ) return true;
    return false;
}

class CDifferentStrokes {
public:
    void solve(istream& cin, ostream& cout) {
        ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
        cout.setf(ios::fixed); cout.precision(20);

        int n; cin >> n;
        vector<Happiness> A;
        vector<Happiness> B;
        for (int i = 0; i < n; ++i) {
            int a, b; cin >> a >> b;
            A.push_back({a, b, i});
            B.push_back({a, b, i});
        }

        sort(A.begin(), A.end(), cmp1);
        sort(B.begin(), B.end(), cmp2);

        set<int> visited; int aIndex = 0, bIndex = 0;
        long long ans = 0LL;
        while (aIndex < n && bIndex < n) {
            while (aIndex < n) {
                Happiness& h = A[aIndex];
                if (visited.find(h.index) != visited.end()) { aIndex++; continue; }
                ans += A[aIndex].a;
                aIndex++;
                visited.insert(h.index);
                break;
            }
            while (bIndex < n) {
                Happiness& h = B[bIndex];
                if (visited.find(h.index) != visited.end()) { bIndex++; continue; }
                ans -= B[bIndex].b;
                bIndex++;
                visited.insert(h.index);
                break;
            }
        }
        cout << ans << endl;
    }
};


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


Measured memory_bytes: 7340
#include <bits/stdc++.h>
#define mp make_pair
#define pii pair<int,int>
using namespace std;
typedef long long ll;
#define rint register int
const int maxn=100007;
const int inf=(1LL<<29);
int main(){
    cin.tie(0);ios_base::sync_with_stdio(false);
    char s[10];cin>>s+1;
    int x1=0,x2=0;
    if(s[1]=='0'&&(s[2]>='1'&&s[2]<='9')||s[1]=='1'&&(s[2]=='1'||s[2]=='2'||s[2]=='0')) x1=1;
    if(s[3]=='0'&&(s[4]>='1'&&s[4]<='9')||s[3]=='1'&&(s[4]=='1'||s[4]=='2'||s[4]=='0')) x2=1;
    if(x1&&x2){
        cout<<"AMBIGUOUS";
    }
    else if(x1){
        cout<<"MMYY";
    }
    else if(x2) cout<<"YYMM";
    else cout<<"NA";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    if(n>=1 && m>=1)
    cout<<(n*(n-1))/2 + ((m-1)*m)/2 <<endl;
    else if(n==0 && m==0)
    cout<<0<<endl;
    else if(n==0 && m>=1)
    cout<<((m-1)*m)/2 <<endl;
    else if(n>=1 && m==0)
    cout<<((n-1)*n)/2 <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), putchar(), scanf()
#include <stdbool.h>

#define MAT_N 15
const int INF = 100000000;

int
main(int argc, char **argv)
{
	int mat[MAT_N][MAT_N];
	int N;
	int x, y;
	int i;

	while (true)
	{
		scanf("%d", &N);
		if (N == 0)
			break;

		for (y = 0; y < N; ++y)
		{
			for (x = 0; x < N; ++x)
				mat[y][x] = INF;
		}

		x = (N + 1) / 2 - 1;
		y = x + 1;
		int n = 1;
		mat[y][x] = n++;

		while (n <= N * N)
		{
			y++;
			x++;
			if (x >= N)
				x = 0;

			if (y >= N)
				y = 0;

			for (i = 1; mat[y][x] != INF && i <= N * N; ++i)
			{
				x--;
				y++;
				if (x < 0)
					x = N - 1;

				if (y >= N)
					y = 0;
			}

			mat[y][x] = n++;
		}

		for (y = 0; y < N; ++y)
		{
			for (x = 0; x < N; ++x)
				printf("%4d", mat[y][x]);

			putchar('\n');
		}
	}

	return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
using namespace std;

#define max_n 1000
#define max_m 100
#define max_w 10000
#define max_h 1000
#define max_k 10000
#define max_l 10000
#define INF 9999999

typedef long long lint;



int main()
{
    int a,b;
    cin>>a>>b;
    if(a==1 || b==1){
        if(b==1 &&a==1){
            cout<<"Draw"<<endl;
        }else if(a==1){
            cout<<"Alice"<<endl;
        }else{
            cout<<"Bob"<<endl;
        }
    }else{
        if(a>b){
            cout<<"Alice"<<endl;
        }else if(a<b){
            cout<<"Bob"<<endl;
        }else{
            cout<<"Draw"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
N, M = [int(i) for i in input().split()]
R = [0 for _ in range(N)]
for _ in range(M):
    a, b = [int(i) for i in input().split()]
    R[a - 1] += 1
    R[b - 1] += 1
for i in range(N):
    print(R[i])


Measured memory_bytes: 9092
#!/usr/bin/env python3
import sys

def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    from itertools import groupby, product
    base_w = w[0]
    v_list = [[] for _ in range(4)]
    for ww, vv in zip(w, v):
        v_list[ww-base_w].append(vv)
    v_list = [sorted(vv, reverse=True) for vv in v_list]
    acc_v = [[0] for _ in range(4)]
    for i, vv in enumerate(v_list):
        for vvv in vv:
            acc_v[i].append(acc_v[i][-1] + vvv)
    ans = 0
    for i, j, k, l in product(*[range(len(a)) for a in acc_v]):
        if i * base_w + j * (base_w + 1) + k * (base_w + 2)+ l * (base_w + 3) > W:
            continue
        ans = max(ans, acc_v[0][i] + acc_v[1][j] + acc_v[2][k] + acc_v[3][l])
    return ans

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    print(solve(N, W, w, v))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 3064
#include <stdio.h>
int main(){
int n,m,l,i,j,k;
long c[100][100]={0};
scanf("%d %d %d",&n,&m,&l);
int A[n][m],b[m][l];



for(i=0;i<n;i++){
    for(j=0;j<m;j++){
     scanf("%d",&A[i][j]);
     }
    }

    for(j=0;j<m;j++){
     for(k=0;k<l;k++){

scanf("%d",&b[j][k]);} }



  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
     for(k=0;k<l;k++){
    c[i][k]+=A[i][j]*b[j][k];}}


  }



for(i=0;i<n;i++){
     for(k=0;k<l;k++){
        printf("%ld",c[i][k]);
        if(k<l-1){printf(" ");}
     }
     printf("\n");
}





return 0;




     }

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = unordered_set<int32_t>;
using setstr = unordered_set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;
    rep(i, n)
    {
        while (a[i] % 2 == 0)
        {
            ++ans;
            a[i] /= 2;
        }
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

int mask(int a){
	return (1LL<<a)-1;
}
int topbit(ll t){
	return t==0?-1:63-__builtin_clzll(t);
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int n;cin>>n;
	vi len(n),bit(n);
	rep(i,n){
		string s;cin>>s;
		len[i]=s.size();
		rep(j,s.size())
			bit[i]+=(s[j]-'0')<<j;
	}
	
	const int L=17;
	const int inf=LLONG_MAX/3;
	vc<int> dist(1<<L,inf);
	priority_queue<pi,vc<pi>,greater<pi>> pq;
	auto rc=[&](int a,int b,int c){
		dmp(a);
		dmp(b);
		dmp(c);
		int x=b+(1<<a);
		dmp(x);
		if(dist[x]>c){
			dist[x]=c;
			pq.emplace(c,x);
		}
	};
	
	rep(i,n)rep(j,n)if(i!=j){
		if(len[j]<len[i]&&(bit[i]&mask(len[j]))==bit[j]){
			rc(len[i]-len[j],bit[i]>>len[j],len[i]);
		}
	}
	
	while(pq.size()){
		int v,d;tie(d,v)=pq.top();pq.pop();
		dmp(v);
		dmp(d);
		if(v==1){
			cout<<d<<endl;
			return 0;
		}
		if(dist[v]!=d)continue;
		int a=topbit(v);
		int b=v^1<<a;
		rep(i,n){
			if(len[i]<=a){
				if((b&mask(len[i]))==bit[i]){
					rc(a-len[i],b>>len[i],d);
				}
			}else{
				if((bit[i]&mask(a))==b){
					rc(len[i]-a,bit[i]>>a,d+len[i]-a);
				}
			}
		}
	}
	cout<<0<<endl;
}



Measured memory_bytes: 4132
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct bian
{
	int nxt,to;
}bi[200020];
int n,m,head[100010],num,d[100010],st[100010],tp,l[100010],r[100010];
bool used[100010],ok[100010];
inline void add(int from,int to){bi[++num]=bian{head[from],to};head[from]=num;++d[to];}
void dfs(int v)
{
	for(int &i=head[v],u;i;i=bi[i].nxt)
		if(!used[(i+1)/2])
		{
			u=bi[i].to;used[(i+1)/2]=1;
			dfs(u);
		}
	st[++tp]=v;
}
int main()
{
	scanf("%d %d",&n,&m);
	int x,y;
	for(int i=1;i<=m;++i)
	{
		scanf("%d %d",&x,&y);
		add(x,y),add(y,x);
	}
	for(int i=1;i<=n;++i)if(d[i]&1)return printf("No"),0;
	for(int i=1;i<=n;++i)if(d[i]>=6)return printf("Yes"),0;
	dfs(1);
//	for(int i=1;i<=tp;++i)printf("%d ",st[i]);printf("\n");
	int minr=0x3f3f3f3f;
	for(int i=tp-1;i;--i)
	{
		ok[i]=ok[i+1];
		if(!l[st[i]])l[st[i]]=r[st[i]]=i;
		else
		{
			if(r[st[i]]>minr)return printf("Yes"),0;
			if(ok[l[st[i]]])return printf("Yes"),0;
			minr=min(minr,l[st[i]]);
			l[st[i]]=i;
			ok[i]=1;
		}		
	}
	printf("No");
	return 0;
}


Measured memory_bytes: 7040
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    x1, y1, x2, y2 = map(int, input().split())
    x = x2 - x1
    y = y2 - y1

    print(x2-y, y2+x, x1-y, y1+x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    char ch[1000];
    scanf("%s",ch);
    int w=0,e=0,s=0,n=0,len;
    len=strlen(ch);
    for(int i=0;i<len;i++)
    {
        if(ch[i]=='N')
            n+=1;
        else if(ch[i]=='S')
            s+=1;
        else if(ch[i]=='W')
            w+=1;
        else if(ch[i]=='E')
            e+=1;

    }
    if(((w>0 && e>0)||(w==0 && e==0))&&((s>0 && n>0)||(s==0 && n==0)))
        printf("Yes");
    else
        printf("No");

    return 0;
}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
using ppa = pair<pa,int>;
#define SORT(v, n) sort(v, v+n);
#define ALL(v) v.begin(),v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v),greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

//4近傍
//int dy[]={0, 1, 0, -1};
//int dx[]={1, 0, -1, 0};

//8近傍
//int dy[]={0,0,1,-1,1,1,-1,-1};
//int dx[]={1,-1,0,0,1,-1,1,-1};

const ll MOD = 1000000007;

ll pow_mod(ll a,ll b,ll mod){
    ll tmp = 1;
    a %= mod;
    if(b > 0){
        tmp = pow_mod(a, b/2, mod);
        if(b % 2) tmp = (((tmp*tmp)%mod)*a)%mod;
        else tmp = (tmp*tmp)%mod;
    }
    return tmp;
}

void solve() {
    map<char,int> mp;
    string w; cin >> w;
    rep(i,w.size()) mp[w[i]] += 1;
    for(char i = 'a'; i <= 'z'; i++){
        if(mp[i] % 2){
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
isFound = False
for x in range(N+1):
    if isFound:
        break
    for y in range(N+1):
        z = N-x-y
        if (10000*x+5000*y+1000*z==Y)&(z>=0):
            print('{} {} {}'.format(x,y,z))
            isFound = True
            break
if isFound == False:
    print('-1 -1 -1')

Measured memory_bytes: 40812
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
using namespace std;
template<class T>inline void rd(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const int maxn=400050;
ll a[maxn],k,n;
ll sum=0;
int main()
{
    cin>>k>>n;
    rep(i,1,n) rd(a[i]);
    rep(i,2,n) sum+=a[i]-a[i-1];
    ll temp=sum;
    rep(i,2,n) temp=min(temp,sum-(a[i]-a[i-1])+a[1]+k-a[n]);
    cout<<min(sum,temp)<<endl;
    return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>

int main(void)
{
	int n;
	int a;
	int b;
	int c;
	
	int i;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d%d%d", &a, &b, &c);
		
		if ((a * a) + (b * b) == (c * c)){
			printf("YES\n");
		}
		
		else if ((b * b) + (c * c) == (a * a)){
			printf("YES\n");
		}
		else if ((a * a) + (c * c) == (b * b)){
			printf("YES\n");
		}
		
		else {
			printf("NO\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 580
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

//最大公約数
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main(){
   string s;
   cin >> s;
   int a=0, b=0;
   rep(i,3){
       if(s[i]=='A') a++;
       else if(s[i]='B') b++;
   }
   if(a==3||b==3) cout << "No" << endl;
   else cout << "Yes" << endl;
}

Measured memory_bytes: 3600
X,N = map(int,input().split())

p = list(map(int,input().split()))

Ans = 400

for i in range(102):
    if max(0,X-i) in p:
        Ans = Ans
    else:
        Ans = max(0,X-i)
        break
    if min(101,X+i) in p:
        Ans=Ans
    else:
        Ans = min(101,X+i)
        break
print(Ans)

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

}

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

int main(){
	string s,t;
	cin >> s >> t;
	for(int i=0; i<101; i++){
		s = s.back() + s;
		s.pop_back();
		if(s == t){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

void fnInput(int& rnSwitchSiz, 
             vector<vector<int>>& rvvnLightSw, vector<int>& rvnReslt)
{
  int  nLightSiz;
  cin >> rnSwitchSiz >> nLightSiz;
  rvvnLightSw.resize(nLightSiz);

  for (int i = 0; i < rvvnLightSw.size(); i++)
  {
    int nLightSwSiz;
    cin >> nLightSwSiz;
    rvvnLightSw[i].resize(nLightSwSiz);

    for (int j = 0; j < rvvnLightSw[i].size(); j++)
      cin >> rvvnLightSw[i][j];
  }

  rvnReslt.resize(nLightSiz);
  for (int& rnReslt : rvnReslt)
    cin >> rnReslt;
}

bool fnLightSwChk(const vector<vector<int>>& cnrvvnLightSw,
                  const vector<int>& cnrvnSwitch,
                  const vector<int>& cnrvnReslt)
{
  for (int i = 0; i < cnrvvnLightSw.size(); i++)
  {
    int nLightUpCnt = 0;

    for (int j = 0; j < cnrvvnLightSw[i].size(); j++)
      nLightUpCnt += cnrvnSwitch[ cnrvvnLightSw[i][j] - 1 ];

    if (nLightUpCnt % 2 != cnrvnReslt[i])
      return false;
  }
  return true;
}

int fnNumOfCase(int nSwitchSiz,
                const vector<vector<int>>& cnrvvnLightSw, 
                const vector<int>& cnrvnReslt)
{
  int nNumOfCase = 0;
  vector<int> vnSwitch(nSwitchSiz);

  for (int n = 0; n < ( 1 << nSwitchSiz ); n++)
  {
    for (int i = 0; i < nSwitchSiz; i++)
      if (n & ( 1 << i ))
        vnSwitch[i] = 1;
      else
        vnSwitch[i] = 0;

    if (fnLightSwChk(cnrvvnLightSw, vnSwitch, cnrvnReslt))
      nNumOfCase++;
  }
  return nNumOfCase;
}
  
int main()
{
  int nSwitchSiz;
  vector<vector<int>> vvnLightSw;
  vector<int> vnReslt;

  fnInput(nSwitchSiz, vvnLightSw, vnReslt);
  cout << fnNumOfCase(nSwitchSiz, vvnLightSw, vnReslt) << endl;

  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;cin>>n;
  int64_t ans=n/(11);
  int64_t asn2=ans*2;
  if(11*ans<n){
    if(11*ans+6>=n)asn2++;
    else if(11*ans+11>=n)asn2+=2;
  }
  cout <<asn2<<endl;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		printARectangle();

	}
	
	public static void printARectangle() {
		
		Scanner sc = new Scanner(System.in);

		
		while (true) {
			
			int H = sc.nextInt();
			int W = sc.nextInt();
			
			if (H == 0 && W == 0) {
				
				break;
			}
			
			for (int i = 0; i < H; i++) {
			
				for (int j = 0; j < W; j++) {
				
					System.out.print("#");
				}
				System.out.println("");
			}
			
			System.out.println("");
		}
	}
}


Measured memory_bytes: 33176
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A;
    cin >> A;
    cout << A + A * A + A * A * A << endl;
    return 0;
}

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

int main(){
 int n,m;
 cin>>n>>m;
long long sumx,sumy,sum;
  sumx=0;
  sumy=0;
  sum=0;
vector<long long>x(n);
vector<long long>y(m);
  for(int i=0;i<n;i++){
    cin>>x[i];
    if(i!=0){
    x[i]-=x[0];
    }
  }
  x[0]=0;
    for(int i=0;i<n;i++){

    sumx+=(2*i-n+1)*x[i];
      if(sumx>0){
    sumx%=1000000007;
      }
  }
  for(int i=0;i<m;i++){
    cin>>y[i];
        if(i!=0){
    y[i]-=y[0];
    }
  }
  y[0]=0;    
  for(int i=0;i<m;i++){

    sumy+=(2*i-m+1)*y[i];
    if(sumy>0){
    sumy%=1000000007;
    }
  }
sum=(sumx*sumy)%1000000007;
     cout<<sum<<endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

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

    ll ans = 0;
    rep(i, n+1){
        string tmp = to_string(i);
        ll sum = 0;
        rep(j, tmp.size()){
            sum += tmp[j] - '0';
        }

        if(a <= sum && sum <= b) {
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, m, v, p = map(int, input().split())
alst = list(map(int, input().split()))
alst.sort(reverse = True)
left = p - 1
right = n
while right - left > 1:
    pos = (left + right) // 2
    if alst[pos] + m < alst[p - 1]:
        right = pos
        continue
    cnt = (p - 1) * m
    base = alst[pos] + m
    for i in range(p - 1, n):
        cnt += min(m, base - alst[i])
    if cnt >= m * v:
        left = pos
    else:
        right = pos
print(left + 1)

Measured memory_bytes: 20580
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main() 
{
	int W, H, N;
	cin >> W >> H >> N;
	int left = 0, right = W, up = H, down = 0;
	for (int i = 0; i < N; i++) {
		int x, y, a;
		cin >> x >> y >> a;
		if (a == 1) left = max(left, x);
		else if (a == 2)right = min(right, x);
		else if (a == 3) down = max(down, y);
		else up = min(up, y);
	}
	cout << max(0, right - left) * max(0, up - down);
}

Measured memory_bytes: 256
n = gets.strip.to_i
array = gets.split.map(&:to_i)
puts array.join(' ')

for i in 1..n-1 do
  key = array[i]
  j = i
  while j > 0 && array[j-1] > key do
    array[j] = array[j-1]
    j -= 1
  end
  array[j] = key
  puts array.join(' ')
end

Measured memory_bytes: 8792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static int LoadInt() { return int.Parse(Console.ReadLine()); }
        static int[] LoadIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static long[] LoadLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }

        static void Main(string[] args)
        {
            var vals = LoadIntArray();
            var N = vals[0];
            var K = vals[1];
            var Aarray = LoadIntArray();
            BigInteger result = 0;

            var doubleA = new List<int>();
            doubleA.AddRange(Aarray);
            doubleA.AddRange(Aarray);

            var power = (BigInteger)1e9 + 7;

            foreach(var i in Enumerable.Range(0, N))
            {
                var chunk = doubleA.Skip(i + 1).Take(N).ToArray();
                var chunk_num = chunk.Where(x => Aarray[i] > x).Count();
                var remain_num = Enumerable.Range(0, N - i - 1).Where(x => Aarray[i] > chunk[x]).Count();

                var sum = (BigInteger)(K - 1) * (BigInteger)K / 2 * (BigInteger)chunk_num + (BigInteger)K * (BigInteger)remain_num;
                result = (result + sum) % power;
            }
            Console.WriteLine(result);
        }

    }

}


Measured memory_bytes: 38088
import * as fs from 'fs';

namespace AtCoder {
    export interface Paramable {
        readonly args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc001 {
    export class TaskA implements AtCoder.Task, AtCoder.Paramable {
        public constructor(public readonly args: string[][]) {
        }

        public main(this: TaskA): void {
            const [c1, c2, c3]: string[] = this.args[0][0].split('');
            const [c4, c5, c6]: string[] = this.args[1][0].split('');

            if (c1 === c6 && c2 === c5 && c3 === c4) {
                console.log('YES');
            } else {
                console.log('NO');
            }

        }
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(r => r.split(' '));
    const task: AtCoder.Task = new TaskA(args);
    task.main();
}



Measured memory_bytes: 7372
#include <cstdio>
#include <list>
#include <algorithm>
using namespace std;

int main(int argc, char const *argv[])
{
    int q, x;
    char com[20];
    list<int> v;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%s", com);
        if (com[0] == 'i') {
            scanf("%d", &x);
            v.push_front(x); 
        } else if (com[6] == 'L') {
            v.pop_back();
        } else if (com[6] == 'F') {
            v.pop_front();
        } else if (com[0] == 'd') {
            scanf("%d", &x);
            for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
                if (*it == x) {
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i = 0;
    for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
        if (i++) printf(" ");
        printf("%d", *it);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 33892
#include<stdio.h>
#include<math.h>

int main(){

	int i,j,n,result;
	double xa,xb,ya,yb,ra,rb,pa,pb,oo;

	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
		oo=sqrt(pow(xb-xa,2)+pow(yb-ya,2));
		if(oo>ra+rb) {
			result=0;
		}
		else if(oo<=ra+rb){
			if(ra<rb && oo<rb-ra){
				result=-2;
			}
			else if(ra>rb && oo<ra-rb){
				result=2;
			}
			else{
				result=1;
			}
		}

		printf("%d\n",result);

	}




	return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int A;
        cin >> A;
        if (A % 2 == 0) {
            if (!(A % 3 == 0 || A % 5 == 0)) {
                puts("DENIED");
                return 0;
            }
        }
    }
    puts("APPROVED");
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int N=1e5+5;
int X,k,r[N],ans[N],m,n;
struct node{
	int L,R,tag,add;
}d[N<<2];
struct que{
	int t,a,id;
}q[N];
vector<int>vec;
inline void update(int o){
	d[o].L=min(d[o<<1].L,d[o<<1|1].L);
	d[o].R=max(d[o<<1].R,d[o<<1|1].R);
}
void build(int l,int r,int o){
	if(l==r)d[o]=(node){vec[l],vec[r],0,0};else{
		const int mid=l+r>>1;
		build(l,mid,o<<1),build(mid+1,r,o<<1|1);
		update(o);
	}
}
inline void pushdown(int o){
	if(d[o].tag){
		d[o<<1].tag=d[o<<1|1].tag=d[o].tag;
		d[o<<1].add=d[o<<1|1].add=0;
		if(d[o].tag==-1)
			d[o<<1].L=d[o<<1].R=d[o<<1|1].L=d[o<<1|1].R=0;
		else
			d[o<<1].L=d[o<<1].R=d[o<<1|1].L=d[o<<1|1].R=X;
		d[o].tag=0;
	}
	if(int&x=d[o].add){
		d[o<<1].add+=x,d[o<<1|1].add+=x;
		d[o<<1].L+=x,d[o<<1|1].L+=x;
		d[o<<1].R+=x;d[o<<1|1].R+=x;
		x=0;
	}
}
int query(int l,int r,int o,const int&pos){
	if(l==r)return d[o].L;
	pushdown(o);
	const int mid=l+r>>1;
	if(pos<=mid)return query(l,mid,o<<1,pos);
	return query(mid+1,r,o<<1|1,pos);
}
void increase(int l,int r,int o,const int&dlt){
	if(d[o].R+dlt<=X)
		d[o].L+=dlt,d[o].R+=dlt,d[o].add+=dlt;
	else if(d[o].L+dlt>=X)
		d[o].L=d[o].R=X,d[o].add=0,d[o].tag=1;
	else{
		pushdown(o);
		const int mid=l+r>>1;
		increase(l,mid,o<<1,dlt);
		increase(mid+1,r,o<<1|1,dlt);
		update(o);
	}
}
void decrease(int l,int r,int o,const int&dlt){
	if(d[o].L>=dlt)
		d[o].L-=dlt,d[o].R-=dlt,d[o].add-=dlt;
	else if(d[o].R<=dlt)
		d[o].L=d[o].R=d[o].add=0,d[o].tag=-1;
	else{
		pushdown(o);
		const int mid=l+r>>1;
		decrease(l,mid,o<<1,dlt);
		decrease(mid+1,r,o<<1|1,dlt);
		update(o);
	}
}
int main(){
	scanf("%d%d",&X,&k);
	for(int i=1;i<=k;++i)scanf("%d",r+i);
	r[k+1]=1e9+7;
	scanf("%d",&m);
	vec.push_back(-1);
	for(int i=1;i<=m;++i){
		scanf("%d%d",&q[i].t,&q[i].a);
		q[i].id=i;
		vec.push_back(q[i].a);
	}
	sort(vec.begin(),vec.end()),vec.erase(unique(vec.begin(),vec.end()),vec.end());
	n=vec.size()-1;
	build(1,n,1);
	int cur=-1;
	for(int i=1,it=1;i<=k+1&&it<=m;++i){
		while(it<=m&&q[it].t<=r[i]){
			int pos=lower_bound(vec.begin(),vec.end(),q[it].a)-vec.begin();
			int now=query(1,n,1,pos)+cur*(q[it].t-r[i-1]);
			if(now<0)now=0;
			if(now>X)now=X;
			printf("%d\n",now);
			++it;
		}
		if(cur==-1)
			decrease(1,n,1,r[i]-r[i-1]);
		else
			increase(1,n,1,r[i]-r[i-1]);
		cur*=-1;
	}
	return 0;
}

Measured memory_bytes: 9976
import sys
readline = sys.stdin.readline

N,K = map(int,readline().split())
A = [0] + list(map(int,readline().split()))

now = 1
while K > 0:
  if K & 1:
    now = A[now]
  A = [A[A[i]] for i in range(len(A))]
  K >>= 1

print(now)

Measured memory_bytes: 31352
#include <cstdio>
#include <map>

int A[1000000];

int main(){
  int n,m,ans=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    A[a%1000000]=1;
  }
  scanf("%d",&m);
  for(int i=0;i<m;i++){
    int a;
    scanf("%d",&a);
    ans+=A[a%1000000];
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 2896
n = int(input())
l = []
for i in range(n):
    s = input().split()
    l.append([int(s[1]),int(s[0])])
    
l.sort()
a = 0
for i in range(n):
    a+=l[i][1]
    if a>l[i][0]:
        print("No")
        exit(0)
        
print("Yes")

Measured memory_bytes: 35596
#include<bits/stdc++.h>
using namespace std;
using lint = long int;
#define pb push_back

string S, T;
int cn = 0;

int main(){
    cin >> S >> T;

    int len = S.size();
    for(int i = 0; i < len; i++){
        if(S[i] != T[i]) ++cn;
    }

    cout << cn << endl;
    return 0;

}



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

#define fasten(v) v.reserve(v.size())
#define wait() system("pause")
#define clock_starts() clock_t begin = clock()
#define clock_ends() clock_t end = clock()
#define print_running_time() double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC; \
printf("Elapsed Time : %.10f second(s)\n", elapsed_secs)
#define readfile(s) freopen(s, "r", stdin)
#define writefile(s) freopen(s, "w", stdout)
#define debug(s) cout<< #s <<" = "<< s <<endl
#define all(v) v.begin(), v.end()
#define cin_cout_is_cool ios_base::sync_with_stdio(false); cin.tie(NULL)
#define printBinary(n) cout << #n << " = " << bitset<64>(n) << endl
#define min_pq priority_queue<int, vector<int>, greater<int> >
#define MEMSET(a,val) memset(a, val, sizeof a)
#define PB push_back
#define endl '\n'
#define cin(n) scanf("%d", &n)
 
template<typename T>T max(T a_,T b_,T c_) { return max(a_,max(b_,c_)); }
template<typename T>T min(T a_,T b_,T c_) { return min(a_,min(b_,c_)); }

typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef pair<double, double> pdd;

#define ceil(num,d) 		( (int)(num/d) + (num%d>0 ? 1 : 0) )
#define block_no(idx) 		( ceil(idx, BLOCK_SIZE) )
#define block_starting(idx) ( ((block_no(idx)-1) * BLOCK_SIZE) +1 )
#define block_ending(idx) 	( min(n, block_no(idx)*BLOCK_SIZE) )
#define block_ranking(idx) 	((idx%BLOCK_SIZE==0)?BLOCK_SIZE:idx%BLOCK_SIZE)

int n;
map<int, int> mp;

int32_t main () {
	//readfile("input.in");
	//writefile("output.out");
	cin>>n;
	for(int i=1; i<=n; i++) {
		int x; cin>>x;
		mp[x]++;
	}
	int ret = 0;
	for(auto b : mp) {
		if(b.second < b.first) ret += b.second;
		else ret += (b.second-b.first);
	}
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n;
string ss[500];
vector<int>G[26];
bool used[26];
void dfs(int u)
{
	for(int a:G[u])
	{
		if(!used[a])
		{
			used[a]=1;
			dfs(a);
		}
	}
}
main()
{
	while(cin>>n,n)
	{
		for(int i=0;i<n;i++)cin>>ss[i];
		bool flag=1;
		for(int i=0;i<26;i++)G[i].clear();
		for(int i=0;i<n-1;i++)
		{
			string s=ss[i],t=ss[i+1];
			int id=0;
			while(id<s.size()&&id<t.size()&&s[id]==t[id])id++;
			if(id>=s.size());
			else if(id>=t.size())
			{
				flag=0;
			}
			else
			{
				G[s[id]-'a'].push_back(t[id]-'a');
			}
		}
		if(flag)
		{
			for(int i=0;i<26;i++)
			{
				G[i].erase(unique(G[i].begin(),G[i].end()),G[i].end());
				for(int j=0;j<26;j++)used[j]=0;
				dfs(i);
				flag&=!used[i];
			}
		}
		cout<<(flag?"yes":"no")<<endl;
	}
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
//typedef complex<long double> com;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;
	cin >> s >> t;
	ll a,b;
	cin >> a >> b;
	string u;
	cin >> u;
	if (u == s){
		cout << a-1 << " " << b << endl;
	} else {
		cout << a << " " << b-1 << endl;
	}
} 
 


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = Integer.parseInt(scanner.nextLine());
        int b = Integer.parseInt(scanner.nextLine());
        int h = Integer.parseInt(scanner.nextLine());

        System.out.print((a+b) * h / 2);
    }
}


Measured memory_bytes: 21460