akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

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

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

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  int N; cin >> N;
  int i,X;

  FOR(i,1,50000){
      X = floor((double)i * 1.08);
      if(X==N){cout << i << endl; return 0;}
      if(X>N){cout << ":(" << endl; return 0;}
  }

  return 0;
}


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

typedef pair<int, int> P;

int main() {
    int H, W, D;
    cin >> H >> W >> D;

    int a[H + 1][W + 1];
    vector<P> v(H * W + 1);
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> a[i][j];
            v[a[i][j]] = P(i, j);
        }
    }

    int Q;
    cin >> Q;

    vector<int> L(Q), R(Q);
    for (int i = 0; i < Q; i++) {
        cin >> L[i] >> R[i];
    }

    vector<int> b(H * W + 1, 0);
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (a[i][j] + D <= H * W) {
                b[a[i][j] + D] = abs(v[a[i][j] + D].first - i) +
                                 abs(v[a[i][j] + D].second - j);
            }
        }
    }

    for (int i = D + 1; i <= H * W; i++) {
        b[i] += b[i - D];
    }

    for (int i = 0; i < Q; i++) {
        cout << b[R[i]] - b[L[i]] << endl;
    }
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

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

int main() {
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    A-=1;
    ll no = 0;
    no = B/C-A/C;
    no += B / D - A / D;
    ll g = lcm(C, D);
    no -= B / g - A / g;
    ll ans = B-A-no;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
	
  
  int a,b,c,d,i,j,k;
  cin >> a;
  cin >> b;
  vector<string> s(a);
  
  for(i=0;i<a;i++){
	cin >>s[i];
  }
  sort(s.begin(),s.end());
  
  for(auto it=s.begin();it != s.end();it++){
	cout << *it ;
  }
  
  cout <<endl;
  
  return 0;
}


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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=1e5+10;
char a[MAXN],b[MAXN];
int q,n,m,p1[MAXN],p2[MAXN];

int main()
{
    scanf("%s%s%d",a+1,b+1,&q);
    n=strlen(a+1);m=strlen(b+1);
    for(int i=1;i<=n;i++)
        p1[i]=p1[i-1]+(a[i]=='A');
    for(int i=1;i<=m;i++)
        p2[i]=p2[i-1]+(b[i]=='A');
    while(q--)
    {
        int l1,l2,r1,r2;
        scanf("%d%d%d%d",&l1,&r1,&l2,&r2);
        int s1=p1[r1]-p1[l1-1]+(r1-l1+1-(p1[r1]-p1[l1-1]))*2;
        int s2=p2[r2]-p2[l2-1]+(r2-l2+1-(p2[r2]-p2[l2-1]))*2;
        if(s1%3==s2%3) puts("YES");
        else puts("NO");
    }
    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>

int main(int argv, char *argc[]){
    
    int count, x, y, inputn;
    char inputc;
    char *stotal, *htotal, *ctotal, *dtotal;
    
    stotal = calloc(13, sizeof(char));
    htotal = calloc(13, sizeof(char));
    ctotal = calloc(13, sizeof(char));
    dtotal = calloc(13,sizeof(char));
    
    scanf("%d\n", &count);
    
    for(x=0; count>x; x++){
        scanf("%c %d\n", &inputc, &inputn);
        
        switch(inputc){
            case 'S':
                stotal[inputn-1] = 1;
                break;
            case 'H':
                htotal[inputn-1] = 1;
                break;
            case 'C':
                ctotal[inputn-1] = 1;
                break;
            case 'D':
                dtotal[inputn-1] = 1;
                break;
        }
    }
    
    for(x=0; 4>x; x++){
        for(y=0; 13>y; y++){
            switch(x){
                case 0:
                    if(0 == stotal[y]){
                    printf("S %d\n", y+1);
                    }
                    break;
                case 1:
                    if(0 == htotal[y]){
                    printf("H %d\n", y+1);
                    }
                    break;
                case 2:
                    if(0 == ctotal[y]){
                    printf("C %d\n", y+1);
                    }
                    break;
                case 3:
                    if(0 == dtotal[y]){
                    printf("D %d\n", y+1);
                    }
                    break;
            }
        }
    }
    
    free(stotal);
    free(htotal);
    free(ctotal);
    free(dtotal);
    return 0;
}

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

using namespace std;

#define ll long long

int main() {
	ll x,y,z,k;
	cin >> x>>y>>z>>k;
	ll  a[1000];
	ll  b[1000];
	ll  c[1000];
	for (int i = 0; i < x;i++)cin >> a[i];
	for (int i = 0; i < y; i++)cin >> b[i];
	for (int i = 0; i < z; i++)cin >> c[i];
	vector<ll> ans;
  	if(k==x*y*z){
      	for (int i = 0; i <x;i++) {
            for (int j = 0; j < y; j++) {
              for(int l=0;l<z;l++){
                 ans.push_back(a[i]+b[j]+c[l]);
              }
            }
        }
      	sort(ans.begin(),ans.end(),greater<ll>());
        for (int i = 0; i < k; i++) {
            cout << ans[i] << endl;
        }
        return 0;
    }

	for (int i = 0; i <x;i++) {
		for (int j = 0; j < y; j++) {
          ans.push_back(a[i]+b[j]);
		}
	}
	sort(ans.begin(), ans.end(), greater<ll>());
    vector<ll> ans2;
  	for(int i=0;i<k;i++){
      	for(int j=0;j<z;j++){
          	ans2.push_back(ans[i]+c[j]);
        }
    }
  	sort(ans2.begin(), ans2.end(), greater<ll>());
	for (int i = 0; i < k; i++) {
		cout << ans2[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 43364
#include <stdio.h>

int main(){
  int G[100][100],n,i,j,a,b,k;

  for(i=0;i<100;i++){
    for(j=0;j<100;j++){
      G[i][j] = 0;
    }
  }

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&k);
      G[i-1][k-1] = 1;
      }
    }

    for(i=0;i<n;i++){
      for(j=0;j<n-1;j++){
        printf("%d ",G[i][j]);
      }
      printf("%d\n",G[i][j]);
    }
    return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int INF=1e15;
const int MAX=200001;
const int MOD=1e9+7;
int fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
 
int COM(int n,int k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int keta(int x){
    int ret=1;
    while(x>=10){
        x/=10;
        ret++;
    }
    return ret;
}

signed main(){
    int N;cin>>N;
    int MA=1;
    for(int i=1;i<=sqrt(N);i++){
        if(N%i==0)MA=i;
    }
    cout<<max(keta(MA),keta(N/MA))<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int v[100][100];

int main(){
  int i,j,n,u,a,b;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      v[i][j] = 0;

  for(i=0;i<n;i++){
    scanf("%d",&a);
    scanf("%d",&b);
    for(j=0;j<b;j++){
      scanf("%d",&u);
      v[a-1][u-1] = 1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",v[i][j]);
      if(j<n-1)printf(" ");
    }
    printf("\n");
  }
  return 0;
}



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

int main(){
	string s, t;
  	cin >> s >> t;
  
  	string ans = t + s;
  	cout << ans << endl;
}

Measured memory_bytes: 256
#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  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL N;cin >> N;
    vector<LL> A(N);
    rep(i,N)cin >> A[i];

    vector<vector<LL>> ct(60,vector<LL>(2,0));
    rep(i,N){
        rep(j,60){
            if(A[i] & (1LL << j))ct[j][1]++;
            else ct[j][0]++;
        }
    }

    LL ans = 0;
    for(int i = 59;i >= 0;--i){
        ans = ans * 2 % MOD;
        ans += ct[i][1] * ct[i][0] % MOD;
    }

    cout << ans % MOD << endl;
}



Measured memory_bytes: 2560
fun main(args: Array<String>){
    val n = Integer.parseInt(readLine())
    val aInput: List<String> = readLine()!!.split(" ")
    val bInput: List<String> = readLine()!!.split(" ")
    val aList = aInput.map { it.toLong() }
    val bList = bInput.map { it.toLong() }
    var shortage = 0L
    var excess = 0L
    var shortageNum = 0
    val excessList = mutableListOf<Long>()
    for(i in 0 until n){
        if(aList[i] < bList[i]){
            shortage += bList[i] - aList[i]
            shortageNum++
        }else if(aList[i] > bList[i]){
            excessList.add(aList[i] - bList[i])
            excess += aList[i] - bList[i]
        }
    }

    if(shortage == 0L){
        println(0)
        return
    }

    val sortedExcessList = excessList.sortedDescending()

    for((i, ex) in sortedExcessList.withIndex()){
        shortage -= ex
        if(shortage <= 0){
            println(i+1+shortageNum)
            return
        }
    }
    println(-1)
}

Measured memory_bytes: 84420
#include <bits/stdc++.h>
using namespace std;
#define go(i, a, n) for (ll i = a; i < n; i++)
#define gor(i, a, n) for (ll i = n - 1; i >= 0; i--)
#define gos(i, a, n, step) for (ll i = a; i < n; i += step)
#define show(a) cout << a << '\n'
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod 1000000007
#define mem(a, k) memset(a, k, sizeof(a))
#define answer(z, k) cout << "Case #" << z << ": " << k << endl;
auto t1 = chrono::high_resolution_clock::now();

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

    int n;
    cin >> n;
    map<string, int> m;
    go(i, 0, n)
    {
        string s;
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;

    auto t2 = chrono::high_resolution_clock::now();
    auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
    clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
    return 0;
}

Measured memory_bytes: 3800
#include <stdio.h>

int main(void)
{
	char S[10], T[10], U[10];
	int A, B, i;

	scanf("%s %s\n%d %d\n%s", S, T, &A, &B, U);

	if(S[0] == U[0])
	{
		for(i = 0; U[i] != '\0'; i++)
		{
			if(S[i] != U[i])
			{
				break;
			}
		}
		printf("%d %d", A-1, B);
	}
	else if(T[0] == U[0])
	{
		for(i = 0; U[i] != '\0'; i++)
			{
				if(T[i] != U[i])
				{
					break;
				}
			}
			printf("%d %d", A, B-1);
	}
	return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		int[] a = new int[] {in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt()};
		
		for (int i  =0; i < 3; i++) {
			a[i + 1] = Math.min(a[i + 1], a[i] * 2);
		}
		for (int i = 2; i >= 0; i--) {
//			a[i] = Math.min(a[i], a[i + 1]);
		}
		long n = in.nextLong() * 4;
		long result = 0;
		
		for (int i = 3; i >= 0; i--) {
			long div = n >>> i;
			result += div * a[i];
			n -= div << i;
		}
		out.println(result);
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

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


Measured memory_bytes: 22868
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = (1ll << 31) - 1;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
struct RangeMinimumQuery {
	int n;
	vector<T>d;
	RangeMinimumQuery(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, INF);
	}
	void update(int i, T x) {
		d[n + i] = x;
		for (int j = (n + i) / 2; j > 0; j >>= 1)d[j] = min(d[2 * j], d[2 * j + 1]);
	}
	T find(int a, int b, int k = 1, int l = 0, int r = -1) {
		if (r < 0)r = n;

		if (r <= a || b <= l)return INF;
		else if (a <= l&&r <= b)return d[k];
		else {
			T vl, vr;
			vl = find(a, b, 2 * k, l, (l + r) / 2);
			vr = find(a, b, 2 * k + 1, (l + r) / 2, r);
			return min(vl, vr);
		}
	}

};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	RangeMinimumQuery<int>rmq(n);
	rep(i, 0, q) {
		int com, x, y; cin >> com >> x >> y;
		if (com)cout << rmq.find(x, y + 1) << endl;
		else rmq.update(x, y);
	}
	return 0;
}

Measured memory_bytes: 3808
import sys
import math
# from collections import Counter
input = sys.stdin.readline
# import numpy as np

def inp():
    return(int(input()))

def inps():
    return str(input())
    
def inlt():
    return(list(map(int,input().split())))
    
def inlst():
    return(list(map(str,input().split())))
    
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split())) 

def tri(arr):
    cnt = 0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                if arr[i]==arr[j] or arr[i]==arr[k] or arr[k]==arr[j]:
                    continue
                if arr[i]+arr[j]>arr[k] and arr[i]+arr[k]>arr[j] and arr[k]+arr[j]>arr[i]:
                    cnt+=1
    return cnt
n = inp()
arr = inlt()
print(tri(arr))



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

#define mp(x, y) make_pair((x), (y))

typedef long long ll;

int n, m;
char a[55][55];
char b[55][55];

int main()
{
	scanf("%d %d\n", &n, &m);
	for(int i=0; i<n; i++) {
		scanf("%s\n", a[i]);
	}
	for(int i=0; i<m; i++) {
		scanf("%s\n", b[i]);
	}
	for(int i=0; i+m-1<n; i++) {
		for(int j=0; j+m-1<n; j++) {
			int ok=1;
			for(int i1=0; i1<m; i1++) {
				for(int j1=0; j1<m; j1++) {
					if(a[i+i1][j+j1]!=b[i1][j1]) ok=0;
				}
			}
			if(ok) {
				printf("Yes\n");
				return 0;
			}
		}
	}

	printf("No\n");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 1000
#define VMAX 10000

int A[MAX], n, m, ans;
int B[MAX], T[VMAX + 1];

void solve(){
    bool V[MAX];
    ans = 0;
    
    sort(B, B+n);
    for(int i = 0; i < n; i++){
        T[B[i]] = i;
        V[i] = false;
    }
    for(int i = 0; i < n; i++){
        if(V[i]) continue;
        int cur = i;
        int s = VMAX;
        int sum = 0;
        int num_men = 0;
        while(1){
            V[cur] = true;
            num_men++;
            sum += A[cur];
            s = min(A[cur], s);
            cur = T[A[cur]];
            if(V[cur]) break;
        }
        
        ans += min((sum + (num_men -  2) * s), (sum + s + (num_men + 1) * m));
    }
}

int main(void){
    cin >> n;
    m = VMAX;
    
    for(int i = 0; i < n; i++){
        cin >> A[i];
        B[i] = A[i];
        m = min(m, A[i]);
    }
    
    solve();
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 3156
N,K = map(int,input().split())


mod = 10**9+7

MAX = N + 10
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX

def cominit():
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] % mod



def cmb(n,r):
    if n < 0 or r < 0 or r > n:return 0
    if r > n/2: r = n-r        
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod
    
cominit()

#%%
ans = 0
for i in range(min(K+1,N)):
    ans += cmb(N,i)*cmb(N-1,i)
    ans %= mod
print(ans)

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



int main() {
    ll n;
    cin >> n;
    
    
    cout << n * (n-1) / 2 << endl;
    
    
    return 0;
}


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

int main(int argc, char const *argv[]) {
  int N, M;
  cin >> N >> M;

  int city[N];
  for(int i=0; i<N; i++){
    city[i] = 0;
  }

  int v1,v2;
  for(int i=0; i<M; i++){
    cin >> v1 >> v2;
    city[v1 - 1]++;
    city[v2 - 1]++;
  }

  for(int i=0; i<N; i++){
    cout << city[i] << endl;
  }
  return 0;
}


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

int main(){
    int n;
  	cin >> n;
    vector<int> vec(n) ;

    for (int i = 0; i < n; i++)
    {
        cin >> vec.at(i) ;
      	//cout << vec.at(i) << endl;
    }

    for (int i = 0; i < n; i++)
    {
      	int y = vec.at(i);
        int x = 0 ;
        int num = 0;
        for (int j = 0; j < n; j++)
        {
            if(j >= i && x < vec.at(j)){
                x = vec.at(j);
                num = j;
            }
        }
      	//cout << x << endl ;
        for (int k = 0; k < n; k++)
        {
            if(k == num){
                vec.at(k) = y;
            }
            else if(k == i){
                vec.at(k) = x;
            }
        }    
    }
    
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += pow(-1,i)*vec.at(i);
    }
    cout << ans;
    
}

Measured memory_bytes: 3916
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, M;
  int ans = 0;
  vector<int> A1(3);
  vector<int> A2(3);
  vector<int> A3(3);
  vector<int> x(3, 0);
  vector<int> y(3, 0);
  vector<int> z(3, 0);
//  vector<pair<int,int>> AB(N);

  for(int i = 0; i < 3; i++){
    cin >> A1[i] >> A2[i] >> A3[i]; 
  }
  cin >> N;
  vector<int> b(N);
  for(int i = 0; i < N; i++){
    cin >> b[i];
  }

  for(int i = 0; i < N; i++){
    for(int j = 0; j < 3; j++){
      if(b[i] == A1[j]){
        x[j]++;
      }
      else if(b[i] == A2[j]){
        y[j]++;
      }
      else if(b[i] == A3[j]){
        z[j]++;
      }
    }
  }

  // for(int i = 0; i < 3; i++){
  //   cout << x[i] << "_" << y[i] << "_" << z[i] << endl; 
  // }

  if(x[0] > 0 && y[1] > 0 && z[2] > 0){
    cout << "Yes" << endl;
    return 0;
  }
  else if(x[2] > 0 && y[1] > 0 && z[0] > 0){
    cout << "Yes" << endl;
    return 0;
  }
  
  for(int i = 0; i < 3; i++){
    if(x[i] > 0 && y[i] > 0 && z[i] > 0){
      cout << "Yes" << endl;
      return 0;
    }
  }


    if(x[0] > 0 && x[1] > 0 && x[2] > 0){
      cout << "Yes" << endl;
      return 0;
    }
    else if(y[0] > 0 && y[1] > 0 && y[2] > 0){
      cout << "Yes" << endl;
      return 0;
    }
    else if(z[0] > 0 && z[1] > 0 && z[2] > 0){
      cout << "Yes" << endl;
      return 0;
    }


  cout << "No" << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    int m = sc.nextInt();
	    if (n==m) System.out.println("Yes");
	    else System.out.println("No");
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N, M, L;
  cin >> N >> M;
  int s, t, e;
  vector< tuple<int, int, int> > rec;
  int sal[N];
  while(cin >> s>> t >> e, s || t || e) {
    --s, --t;
    rec.emplace_back(s, t, e);
  }
  cin >> L;
  for(int i = 0; i < L; i++) {
    vector<int> b(M);
    memset(sal, 0, sizeof(sal));
    for(int j = 0; j < M; j++) cin >> b[j];
    for(int j = 0; j < rec.size(); j++) {
      int s, t, e;
      tie(s, t, e) = rec[j];
      sal[s] += b[t] * e;
    }
    for(int j = 0; j < N; j++) cout << sal[j] << (j == N-1 ? "\n":" ");
  }
  return 0;
}

Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
string s,st;
int n,h;

void shuffle()
{
    st.clear();
    for(int i=h;i<s.size();i++) st=st+s[i];
    for(int i=0;i<h;i++) st=st+s[i];
    s=st;
}

int main()
{
    while (1>0)
    {
        s.clear();
        getline(cin,s);
        if (s=="-") return 0;
        scanf("%d\n",&n);
        for(int i=1;i<=n;i++)
        {
            scanf("%d\n",&h);
            shuffle();
        }
        for(int i=0;i<s.size();i++)
            printf("%c",s[i]);
        printf("\n");
    }
}



Measured memory_bytes: 3232
# -*- coding: utf-8 -*-

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

N = int(input())
A = [int(a) for a in input().split()]

# GCDの結合則を利用する
# 左端、右端からの累積GCDを求めておくと、Aiを取り除いた場合のGCDがすぐに計算できる。
# つまり、
# L(i): n=0,...,iまでのGCD 
# R(i): n=i,...,N-1までのGCD
# このとき、Aiを除いた全体のGCDは、GCD(L(i-1), R(i+1))で計算できる。

L = [0] * N
R = [0] * N

L[0] = A[0]
R[-1] = A[-1]
for i in range(1, N):
    L[i] = gcd(L[i-1], A[i])
    idx = N-1-i
    R[idx] = gcd(R[idx+1], A[idx])

mx = 0
for i in range(N):
    if i == N-1:
        v = L[N-2]
    elif i == 0:
        v = R[1]
    else:
        v = gcd(R[i+1], L[i-1])
    mx = max(v, mx)
print(mx)

Measured memory_bytes: 14052
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,k,r,s,p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    int ans = 0;
    for(int i = 0;i < n;i++)
    {
        if(i - k >= 0 && t[i] == t[i - k])
        {
            t[i] = ' ';
        }
        else
        {
            if(t[i] == 'r')
            {
                ans += p;
            }
            else if(t[i] == 's')
            {
                ans += r;
            }
            else
            {
                ans += s;
            }
        }
    }
    cout << ans << "\n";
 
    return 0;
}

Measured memory_bytes: 512
n = int(input())
*A, = map(int, input().split())
DP = [[0 for j in range(n+1)] for i in range(n+1)]
for l in range(1, n+1):
    for i in range(n-l+1):
        DP[i][i+l] = max(A[i]-DP[i+1][i+l], A[i+l-1]-DP[i][i+l-1])
print(DP[0][n])


Measured memory_bytes: 121692
#include<stdio.h>

int main(void){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    int X = (a+d-1)/d;
    int Y = (c+b-1)/b;
    if(X>=Y){
        printf("Yes");
    } else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;
ll n,m,a,b;
ll ksm(ll a,ll b){
	ll res=1,t=a;
	while(b){
		if(b&1)res=(res*t)%mod;
		t=(t*t)%mod;
		b>>=1;
	}
	return res;
}
ll jc[N],inv[N];
void init(){
	jc[0]=inv[0]=1;
	for(int i=1;i<N;i++)jc[i]=(jc[i-1]*i)%mod,inv[i]=ksm(jc[i],mod-2);
}
ll C(ll a,ll b){
	return ((jc[b]*inv[a])%mod*inv[b-a])%mod;
}
int main()
{
	//freopen("H:\\c++1\\in.txt","r",stdin);
	//freopen("H:\\c++1\\out.txt","w",stdout);
	init();
	scanf("%lld%lld%lld%lld",&n,&m,&a,&b);
	ll ans=0;
	for(int i=1;i<=n-a;i++){
		ll ans1=C(b-1,b+i-2);
		ll ans2=C(m-b-1,n-i+m-b-1);
		ans=(ans+ans1*ans2)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
def main():
    N, K = (int(_) for _ in input().split())
    A = [int(_)-1 for _ in input().split()]
    visited = [-1] * N
    now = cc = 0
    while True:
        if visited[now] == -1:
            visited[now] = cc
            cc += 1
            now = A[now]
        else:
            T = cc - visited[now]
            break
    if K < visited[now]:
        for i in range(N):
            if visited[i] == K:
                print(i+1)
                break
    else:
        K -= visited[now]
        for i in range(N):
            if visited[i] == K%T + visited[now]:
                print(i+1)
                break
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 32328
use std::io::*;

fn main(){
    let x : usize = input();
    let a : usize = input();
    let ans = if x < a {0} else {10};
    println!("{}", ans);
}

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
  int n,cnt;
  char s[100];
  cnt=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%c",&s[i]);
    if(s[i]=='Y'){
      cnt=1;
    }
  }
  if(cnt==1){
    puts("Four");
  }else{
    puts("Three");
  }
  return 0;
}


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

using namespace std;

int main(){
	int n, l;
	scanf("%d%d", &n, &l);
	vector<int> a(n), ans;
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	int t, p;
	bool f = false;
	for(int i = 1; i < n; i++){
		t = a[i - 1] + a[i];
		if(t >= l){
			p = i;
			f = true;
			break;
		}
	}
	if(f){
		printf("Possible\n");
		for(int i = 1; i < p; i++){
			printf("%d\n", i);
		}
		for(int i = n - 1; i >= p; i--){
			printf("%d\n", i);
		}
	}else{
		printf("Impossible\n");
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;






signed main() {
    ll n, k;
    cin >> n >> k;
    ll r = 0;
    
    r = pow(n/k,3);
    
    if (k % 2 == 0) {
        r += pow(n/(k/2) - n/k, 3);
    }
    
    mes(r);

}
    
    
    
    
    


Measured memory_bytes: 4072
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            int n = Integer.parseInt(sc.nextLine());
            int[] a = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                int k = sc.nextInt();
                a[i] = k;
            }
            for (int i = 1; i <= n; i++) {
                System.out.printf("node %d: ", i);
                System.out.printf("key = %d, ", a[i]);
                if (parent(i) >= 1) {
                    System.out.printf("parent key = %d, ", a[parent(i)]);
                }
                if (left(i) <= n) {
                    System.out.printf("left key = %d, ", a[left(i)]);
                }
                if (right(i) <= n) {
                    System.out.printf("right key = %d, ", a[right(i)]);
                }
                System.out.println();
            }
        } catch (NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }

    private static int parent(int i) {
        return i / 2;
    }

    private static int left(int i) {
        return i * 2;
    }

    private static int right(int i) {
        return i * 2 + 1;
    }
}



Measured memory_bytes: 30276
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

signed main(){

	lli n;
	cin>>n;

	vector<lli> p(n);
	REP(i,0,n){
		cin>>p[i];
		p[i]--;
	}

	lli m = 40000;
	vector<lli> a(n),b(n);
	REP(i,0,n){
		a[i] = m*(i+1);
		b[i] = m*(n-i);
	}

	for(lli i=0;i<n;i++){
		lli index = p[i];
		a[index]+=(i+1);
	}

	REP(i,0,n)cout<<a[i]<<" ";
	cout<<endl;
	REP(i,0,n)cout<<b[i]<<" ";
	cout<<endl;

	return 0;
}

Measured memory_bytes: 1152
x = int(input())
dp = [False for _ in range(x + 1)]
dp[0] = True
for item in [100, 101, 102, 103, 104, 105]:
    for i in range(x + 1):
        if i - item >= 0:
            if dp[i - item]:
                dp[i] = True

print(1 if dp[x] else 0)
exit(0)


Measured memory_bytes: 3864
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,k; cin >> n >> k;
    ll max_a = 1e12 + 10;
    int max_pow = 0;
    ll temp = 1;
    while(temp < max_a){
        temp <<= 1;
        max_pow++;
    }
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    // cout << temp << " " << max_pow << endl;
    ll dp_0[max_pow] = {}, dp_1[max_pow] = {};
    temp = 1;
    int k_max = 0;
    while(temp <= k){
        temp <<= 1;k_max++;
    }
    rep(i,n){
        rep(j,k_max){
            ll atemp = a[i] >> j;
            if(1 & atemp)dp_1[j]++;
            else dp_0[j]++;
        }
    }
    // cout << k_max;
    vector<ll> theory_ans(k_max,0);
    rep(i,k_max){
        if(dp_0[i] <= dp_1[i])theory_ans[i] = 0;
        else theory_ans[i] = 1;
    }
    ll ans= 0;
    rep(i,k_max)ans += theory_ans[i] * pow(2, i);
    // cout << ans << endl;
    ll res;
    auto change = [&](vector<ll> vec){
        ll ret = 0;
        rep(i,k_max)ret += vec[i] * pow(2, i);
        return ret;
    };
    auto f = [&](ll x){
        ll ret = 0;
        rep(i,n){
            ret += (x ^ a[i]);
        }
        return ret;
    };

    if(ans <= k){
        res = ans;
        cout << f(res) << endl;
        return 0;
    }
    int k_bit[k_max];
    rep(i,k_max){
        if((k >> i) & 1)k_bit[i] = 1;
        else k_bit[i] = 0;
    }

    ll ret = 0;
    for(int i = k_max-1; 0 <= i;i--){
        vector<ll> temp = theory_ans;
        if(!k_bit[i])continue;
        for(int j = k_max-1;i < j;j--)temp[j] = k_bit[j];
        temp[i] = 0;
        res = change(temp);
        // cout << res << endl;
        assert(res <= k);
        ret = max(ret, f(res));
    }

    ret = max(ret,f(k));

    cout << ret << endl;
    return 0;
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef struct calendar {
    int wy, eby;
    string name;
    bool operator<(const calendar &another) const {
	return wy < another.wy;
    };
}CAL;
int main() {
    int n, q;
    while (cin >> n >> q && n&&q) {
	CAL data[1000];
	for (int i = 0; i<n; ++i) 
            cin >> data[i].name >> data[i].eby >> data[i].wy;
	sort(data, data+n);
	for (int i = 0; i<q; ++i) {
	    int j, y; cin >> y;
	    for (j = 0; j<n; ++j)
		if (data[j].wy >= y) break;
	    if (j == n) cout << "Unknown" << endl;
	    else if (data[j].wy - data[j].eby + 1 <= y) cout << data[j].name << " " << y-(data[j].wy-data[j].eby) << endl;
	    else cout << "Unknown" << endl;
	}
    }
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N>> M;
  vector<pair<int ,int>> p(N);
  vector<pair<int ,int>> ch(M);
    for(int i = 0;i <N;i++){
      int a,b;
      cin >> a >> b;
      p[i] = make_pair(a,b);
    }
  for(int i = 0;i <M;i++){
      int c,d;
      cin >> c >> d;
      ch[i] = make_pair(c,d);
    }
  for(int i = 0;i <N;i++){
    vector<pair<int ,int>> D(M);//各学生とチェックポイントの距離を入れる配列
    for(int j = 0;j <M;j++){
      int dist = abs(p[i].first-ch[j].first) + abs(p[i].second-ch[j].second);
      D[j] = make_pair(dist,j+1);
    }
    sort(D.begin(), D.end());
    cout << D[0].second << endl;
  }
      
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
S = [list(input()) for _ in range(n)]
Sc = Counter(S[0])
scv = list(Sc.items())
for i in range(len(Sc)):
    for j in range(1, n):
        s, c = scv[i]
        if c > S[j].count(s):
            scv[i] = [s, S[j].count(s)]

scv = sorted(scv, key=lambda x:x[0])
ans = ""
for s, c in scv:
    ans += s*c

print(ans)


Measured memory_bytes: 3316
#include<cstdio>

int day_date[12]={3,6,0,3,5,1,3,6,2,4,0,2};
int mon;
int day;

int main()
{
	while(true)
	{
		scanf("%d%d",&mon,&day);
		if(mon==0)break;
		int date=(day+day_date[mon-1]-1)%7;
		if(date==0) printf("Monday");
		if(date==1) printf("Tuesday");
		if(date==2) printf("Wednesday");
		if(date==3) printf("Thursday");
		if(date==4) printf("Friday");
		if(date==5) printf("Saturday");
		if(date==6) printf("Sunday");
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 0
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int h,w;
string t;
char board[1010][1010];
int dp[1010][1010];
signed main(){
    I(h); I(w);
    REP(i,h){
        cin >> t;
        REP(j,w){
            board[i+1][j+1] = t[j];
        }
    }
    dp[0][1] = 1;
    REPS(i,h) REPS(j,w) 
        board[i][j] == '.' ? dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod : 0;
    cout << dp[h][w] << endl;
}

Measured memory_bytes: 9216
#include <iostream>

using namespace std;

class priorityQueue {
private:
    long *queueArray;
    long size;
public:
    priorityQueue() {
        this->queueArray = new long[2000001];
        this->size = 0;
    }

    void print() {
        for (int i = 1; i <= size; i++) {
            cout << queueArray[i] << " ";
        }
        cout << endl;
    }

    void insert(long num) {
        this->queueArray[size+1] = num;
        size++;
        heapfyInsert();
        //print();
    }

    long remove() {
        long max = queueArray[1];
        queueArray[1] = queueArray[size];
        size--;
        heapfyRemove();
        //print();
        return max;
    }

    void heapfyInsert() {
        bool heap = false;
        long pos = size;
        while (!heap && pos > 1) {
            if (queueArray[pos] < queueArray[pos / 2]) {
                heap = true;
            } else {
                long aux = queueArray[pos];
                queueArray[pos] = queueArray[pos / 2];
                queueArray[pos / 2] = aux;
                pos = pos / 2;
            }
        }
    }

    void heapfyRemove() {
        bool heap = false;
        long pos = 1;
        long biggest = -1;
        while(!heap && pos < size) {
            if (pos * 2 <= size && queueArray[2 * pos] > queueArray[pos] ) {
                biggest = 2 * pos;
            } else{
                biggest = pos;
            }
            if(pos * 2 + 1 <= size && queueArray[2 * pos + 1] > queueArray[biggest]){
                biggest = 2*pos+1;
            }
            if(biggest != pos) {
                long aux = queueArray[pos];
                queueArray[pos] = queueArray[biggest];
                queueArray[biggest] = aux;
                pos = biggest;
            }else{
                heap = true;
            }
        }
    }
};


int main() {
    auto heap = new priorityQueue();
    string operation;
    long n;
    while (cin >> operation && operation != "end") {
        if (operation == "insert") {
            cin >> n;
            heap->insert(n);
        } else {
            long aux = heap->remove();
            cout << aux << endl;
        }
    }
    //heap->print();
    return 0;
}


Measured memory_bytes: 10868
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n; cin>>n;
  int a; string op; cin>>a;
  ll dp[n][3]; memset(dp,-INF,sizeof(dp)); dp[0][0]=a;

  rep(i,n-1){
    cin>>op>>a;
    ll tmp[3];
    if(op=="+"){
      rep(j,3) tmp[j]=dp[i][j];
    }else{
      tmp[0]=dp[i][1];
      tmp[1]=max(dp[i][0],dp[i][2]);
      tmp[2]=dp[i][1];
    }
    dp[i+1][2] = tmp[2]+a;
    dp[i+1][1] = max(dp[i+1][2], tmp[1]-a);
    dp[i+1][0] = max(dp[i+1][1], tmp[0]+a);
  }
  ll ans = max(dp[n-1][0],dp[n-1][1]);
  ans = max(ans,dp[n-1][2]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
#define rep(i,n) for(ll i =0; i < n ; i ++)

bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int a,b,c;
  cin>> a>>b>>c;
  if(a==b && b!=c) cout<<"Yes"<<endl;
  else if(a==c && b!=a) cout<<"Yes"<<endl;
  else if(c==b && a!=c) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>

#define INF 1000000000;
#define MOD 1000000007;
typedef long long ll;
using namespace std;

int main()
{
    int N, K; cin >> N >> K;
    cout << (N%K == 0 ? 0 : 1) << endl;
}


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

int n,m;
int ans[105][105];
char ch;

int main()
{
	scanf("%d%d\n",&n,&m);
	for(int i=1;i<=n;i++)
	{
	  for(int j=1;j<=m;j++)
	  {
	    scanf("%c",&ch);
	    if(ch=='.') ans[i][j]=0;
	    else ans[i][j]=1;
	  }
	  scanf("\n");
	}
	for(int i=1;i<=n;i++)
	{
	  int sum=0;
	  for(int j=1;j<=m;j++) if(!ans[i][j]) sum++;
	  if(sum==m)
	  {
	    for(int j=i+1;j<=n;j++) for(int k=1;k<=m;k++) ans[j-1][k]=ans[j][k];
	    n--,i--;
	  }
	}
	for(int i=1;i<=m;i++)
	{
	  int sum=0;
	  for(int j=1;j<=n;j++) if(!ans[j][i]) sum++;
	  if(sum==n)
	  {
	    for(int j=i+1;j<=m;j++) for(int k=1;k<=n;k++) ans[k][j-1]=ans[k][j];
	    m--,i--;
	  }
	}
	if(!m || !n) cout<<"\n";
	for(int i=1;i<=n;i++)
	{
	  for(int j=1;j<=m;j++) if(ans[i][j]) cout<<"#";else cout<<"."; 
	  cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String[] arsg) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str = br.readLine();
		int count = Integer.parseInt(br.readLine());
		for(int i = 0;i<count;i++){
			String str1[] = br.readLine().split(" ");
			int a = Integer.parseInt(str1[1]);
			int b = Integer.parseInt(str1[2])+1;
			if(str1[0].equals("print")) print(a,b,str);
			else if(str1[0].equals("reverse")){ str = reverse(a,b,str);}
			else if(str1[0].equals("replace")){ str = replace(a,b,str1[3],str);}
		}
	}
	
	static void print(int a, int b, String str){
		str = str.substring(a,b);
		System.out.println(str);
	}
	
	static String reverse(int a, int b,String str){
		StringBuffer rev = new StringBuffer(str.substring(a,b));
		String revStr = rev.reverse().toString();
		str = str.substring(0,a) + revStr + str.substring(b,str.length());
		return str;
	}
	
	static String replace(int a, int b, String str2,String str){
		String before = str.substring(0,a);
		String after = str.substring(b,str.length());
		str = before + str2 + after;
		return str;
	}
}

Measured memory_bytes: 25172
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}


int main(void){
	ll n,x,y;
	cin>>n;
	vector<ll> X,Y,D;
	rep(i,n){
		cin>>x>>y;
		X.push_back(x);
		Y.push_back(y);
	}
	int guki = abs(X[0] + Y[0])%2;
	rep(i,n){
		if(abs(X[i]+Y[i])%2 != guki){
			cout<<-1<<endl;
			return 0;
		}
	}
	rep(i,40){
		if(i==0){
			if(guki == 0){
				D.push_back(1);
			}else{
				D.push_back(1);
			}
			continue;
		}
		if(i==1){
			if(guki == 0){
				D.push_back(1);
				continue;
			}
		}
		D.push_back(D[i-1] * 2);
		if(D[i] * 2 > 1e12) break;
	}
	int m = D.size();
	cout<<m<<endl;
	rep(i,m){
		cout<<D[i]<<" ";
	}
	cout<<endl;
	rep(i,n){
		x = -X[i]; y = -Y[i];
		rep(j,m-1){
			if(j == 0){
				if(guki == 0){
					x += 1;
					cout<<'R';
					continue;
				}
			}
			ll d = D[j];
			if(abs(x)/d%2 == 1){
				if(abs(y)/d/2%2 == 1 ^ abs(x-d)/d/2%2 == 0){
					cout<<'R';
					x += d;
				}else{
					cout<<'L';
					x -= d;
				}
			}else{
				if(abs(x)/d/2%2 == 1 ^ abs(y-d)/d/2%2 == 0){
					cout<<'U';
					y += d;
				}else{
					cout<<'D';
					y -= d;
				}
			}
		}
		if(x > 0){
			cout<<'L';
		}else if(x < 0){
			cout<<'R';
		}else if(y > 0){
			cout<<'D';
		}else{
			cout<<'U';
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256