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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N,M;
string A[55],B[55];
signed main(){
    cin>>N>>M;
    rep(i,N)cin>>A[i];
    rep(i,M)cin>>B[i];

    for(int i=0;i+M<=N;i++){
        for(int j=0;j+M<=N;j++){
            bool ok=true;
            rep(k,M)if(A[i+k].substr(j,M)!=B[k])ok=false;
            if(ok){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
      private static long MOD = (long) (1e9+7);
      private static long rev_2_MOD = (long) (1e9+8)/2;

      public static void main(String[] args) {

            Scanner sc = new Scanner(System.in);
            int N = sc.nextInt();
            long ans = 0;
            long sum_1 = 0;
            long sum_2 = 0;
            for (int i = 0 ;i<N;i++){
                  long tmp = sc.nextLong();
                  sum_1 = modPlus(sum_1,tmp);
                  sum_2 = modPlus(sum_2,modTimes(tmp,tmp));
            }
            sum_1 = modTimes(sum_1,sum_1);
            ans = modTimes(modMinus(sum_1,sum_2),rev_2_MOD);
            System.out.println(ans);




      }
      public static long modPlus(long a ,long b){
            return (a + b) % MOD;
      }
      public static long modTimes(long a ,long b){
            return (a * b) % MOD;
      }
      public static long modMinus(long a , long b){
            long tmp = a - b;
            if(tmp<0){
                  return tmp + MOD;
            }
            else return tmp;
      }


}


Measured memory_bytes: 57512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    ll res=0;
    rep(i,n){
        ll a;cin>>a;
        while(a%2==0){
            res++;
            a/=2;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  string s;
  cin >> s;
  int n = sz(s);

  bool good = true;
  rep(i,n) {
    if (i%2 == 0 && s[i] == 'L') good = false;
    if (i%2 == 1 && s[i] == 'R') good = false;
  }

  puts(good?"Yes":"No");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main()
{
	std::string masu;

	std::cin >> masu;

	int cnt = 0;
	for (int i = 0; i < masu.size(); i++) {
		if (masu[i] == '1') {
			cnt++;
		}
	}
	std::cout << cnt << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	if(n%2){
		printf("%d\n",n*(n-1)/2-n/2);
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++){
				if(i+j==n) continue;
				printf("%d %d\n",i,j);
			}
	}else{
		printf("%d\n",n*(n-1)/2-(n+1)/2);
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++){
				if(i+j==n+1) continue;
				printf("%d %d\n",i,j);
			}
	}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n, num;
  char mark;
  bool cards[4][13] = { };

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> mark >> num;
    switch(mark){
    case 'S': cards[0][num-1] = true; break;
    case 'H': cards[1][num-1] = true; break;
    case 'C': cards[2][num-1] = true; break;
    case 'D': cards[3][num-1] = true; break;
    }
  }

  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 13; j++){
      if(!cards[i][j]){
	switch(i){
	case 0: cout << "S "; break;
	case 1: cout << "H "; break;
	case 2: cout << "C "; break;
	case 3: cout << "D "; break;
	}
	cout << j+1 << endl;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef pair <int,int> pr;
#define fr(i, n) for(int i = 0; i < n; i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c)(c).begin(), (c).end()
#define tr(c, i) for (typeof ((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x)((c).find(x) != (c).end())
#define cpresent(c, x)(find(all(c), x) != (c).end())
// for mod power a^b%m use power<lli> (a,b,m)
template < class mytype >
mytype power(mytype a, mytype b, mytype m){if (b == 1) return a % m;if (b == 0) return 1;
lli root = power < lli > (a, b / 2, m);lli ans = (root * root) % m;if (b % 2) ans = (ans * a) % m;
return ans;
}
// for gcd use gcd<int> (a,b)
template < class type >type gcd(type a, type b){if (a == 0) return b;else return gcd(b % a, a);}
template < class type >type mod_inv(type a, type p) {return power(a, p - 2, p);}

// use from here bitches
int n, k;
vector<int> height(100002) , values(100002 , -1);
int dp(int x){
if(values[x] != -1) return values[x];
if(x >= n-1) return 0;int ans = INT_MAX;
for(int j = 1 ; j <= k && x+j < n ; j++){
	ans = min(ans , abs(height[x+j] - height[x]) + dp(x+j));
}
return values[x] = ans;
}


int main()
{    
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	fr(i , n){
		cin >> height[i];
	}
	cout << dp(0);
		

	


    return 0;
	
}


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

int main(){
  string s;
  int cnt=0;
  cin >> s;
  int j=s.size()-1;
  for(int i=0;;i++,j--){
    if(j<=i)break;
    if(s[i]!=s[j])cnt++;
  }
  cout<< cnt <<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
const int N=1e6+5;
typedef long long ll;
const ll mod=1e9+7;
const ll hjb=1e4+7;
char s[N];
ll hjball[N];
ll f[N];
ll Hash(int l,int r){
    return ((f[r]-f[l-1]*hjball[r-l+1]%mod)%mod+mod)%mod;
}
bool pre[N];
bool nxt[N];
int main()
{
    scanf("%s",s+1);
    int n=strlen(s+1);
    hjball[0]=1;
    for(int i=1;i<=n;i++)
        hjball[i]=(hjball[i-1]*hjb)%mod;
    for(int i=1;i<=n;i++)
        f[i]=(f[i-1]*hjb%mod+s[i]-'a')%mod;
    for(int d=1;d<=n;d++)
        for(int i=d*2;i<=n;i+=d)
            if(Hash(1,i-d)==Hash(d+1,i))
                pre[i]=true;
    for(int d=1;d<=n;d++)
        for(int i=n-2*d+1;i>=1;i-=d)
            if(Hash(i,n-d)==Hash(i+d,n))
                nxt[i]=true;
    if(!pre[n]){
        printf("1\n1\n");
        return 0;
    }
    int cnt=0;
    for(int i=1;i<n;i++)
        if(!pre[i]&&!nxt[i+1])
            cnt++;
    if(cnt){
        printf("2\n%d\n",cnt);
        return 0;
    }
    printf("%d\n1\n",n);
}


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

int main() {
  int n,k;
  cin >> n >> k;
  int i=0;
  int f=1;
    while(i<n){
      if(f<k){
        f *=2;
        i++;
      }
      else{
        f +=k;
        i++;
      }
    }
  
	cout << f <<endl;
}


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

int main()
{
	long long n,x=0;
	cin>>n;
	for(int i=1;i<=10000000;i++)
	{
		x=(x*10+7)%n;
		if(x==0)
		{
		  cout<<i;
		  return 0;	
		}
	}
	
	cout<<"-1";
	
	return 0;
	
}

Measured memory_bytes: 3660
def simple(y, r):
    return (100 + y * r) / 100.0


def compound(y, r):
    return ((100 + r) / 100.0) ** y


while True:
    n = int(raw_input())
    if n == 0:
        break

    y = int(raw_input())

    m = (0, 0)

    for i in range(n):
        b, r, t = map(int, raw_input().split())
        if t == 1:
            interest = simple(y, r)
        else:
            interest = compound(y, r)

        if interest > m[1]:
            m = (b, interest)

    print m[0]

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

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class UnionFind {
    vector<pair<int,int>> _nodes;

public:
    UnionFind(int size) : _nodes(vector<pair<int,int>>(size+1, {-1,1})) {}

    int findRoot(int a) {
        if (_nodes[a].first == -1) return a;
        const int root = findRoot(_nodes[a].first);
        _nodes[a] = {root, 0};
        return root;
    }
    void unite(int a, int b) {
        const int rootA = findRoot(a);
        const int rootB = findRoot(b);
        if (rootA == rootB) return;

        _nodes[rootA].second += _nodes[rootB].second;
        _nodes[rootB] = {rootA, 0};
    }
    int findSize(int a) {
        const int root = findRoot(a);
        return _nodes[root].second;
    }
};

class DDecayedBridges {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N, M;
	    in >> N >> M;
	    vector<int> A(M), B(M);
	    REP(i,0,M) in >> A[i] >> B[i];

	    ll inconvinience = (ll)N * (N-1) / 2;
	    vector<ll> answer;
	    UnionFind uf(N);

	    RREP(i,0,M) {
            answer.emplace_back(inconvinience);
            if (uf.findRoot(A[i]) != uf.findRoot(B[i])) {
                inconvinience -= uf.findSize(A[i]) * uf.findSize(B[i]);
                uf.unite(A[i], B[i]);
            }
	    }

	    RREP(i,0,M) {
	        out << answer[i] << "\n";
	    }
	}
};


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


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

int main ()
{
    string s ;
    int num ;

    cin >> num ;
    cin >> s ;

    for (int i = 0 ; i < s.size() ; i ++)
    {
        s[i]+=num ;

        if (s[i] > 90)
        {
            s[i] -= 26 ;
        }
    }

    cout << s ;

    return 0 ;
}


Measured memory_bytes: 256
# import numpy as np
# import scipy as sp
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(str,list(input()))) for i in range(h)]  # 文字列の二次元配列入力
# s = [list(map(int, input().split())) for i in range(n)] # 数値の二次元配列入力
# a = b[:], a = [x[:] for x in b] # deepcopy
# chr(ord('a') + 1) # chrのインクリメント
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#

s = input()
print(700+100*s.count('o'))


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
vector<int> c[N];
int l[N][N];
int dfs(int x,int y,int d) {
	if (d == 0) return 1;
	int ret = 1;
	for (int i=0;i<c[y].size();i++) if (c[y][i] != x) ret += dfs(y,c[y][i],d-1);
	return ret;
}
int main() {
	int n,k;
	scanf("%d %d",&n,&k);
	for (int i=0;i<n-1;i++) {
		int x,y;
		scanf("%d %d",&x,&y);
		c[x].push_back(y);
		c[y].push_back(x);
	}
	int ans = 0;
	for (int i=1;i<=n;i++)
		for (int j=0;j<c[i].size();j++) {
			if (k % 2) ans = max(ans,dfs(i,c[i][j],k/2)+dfs(c[i][j],i,k/2));
			else ans = max(ans,dfs(i,c[i][j],k/2)+dfs(c[i][j],i,k/2-1));
		}
	printf("%d\n",n-ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  if (n == m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if (Math.abs(a - c) <= d) {
			System.out.println("Yes");
		} else if (Math.abs(b - c) <= d && Math.abs(a - b) <= d) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

int main(void) {
    int p,q,r;
    cin >> p >> q >> r;

    int minv = INT32_MAX;

    if (minv > p + q) {
        minv = p+q;
    }


    if (minv > r + q) {
        minv = r+q;
    }

    if (minv > p + r) {
        minv = p+r;
    }

    cout << minv << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<algorithm>
#include<memory.h>
#include<vector>
#include<stdio.h>
#include<cstdlib>
#include<map>
#include <set>
#include<stack>
#include<cmath>
#include<queue>
#include<bitset>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const int MOD = 1e9 + 7;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
const int N = 1e9 + 1;


int p(int a , int b ){
	int sum = a;
	for (int i = 1; i < b; i++)
		sum *= a;
	return sum;
}
int main() {
	int x; 
	scanf("%d", &x);
	int mx = 1;
	for (int i = 1; i < x; i++){
		for (int j = 2; j < x; j++){
			int z = p(i, j);
			if (z > x)
				break;
			mx = max(mx, z);
		}
	}
	printf("%d\n", mx);

	return 0;
}



Measured memory_bytes: 256
N=int(input())
num_digits=0
for i in range(17):
    if N//(10**i)>0: num_digits=i
max_digits=N//(10**num_digits)
nines=9
if num_digits==0: print(max_digits)
else:
    for i in range(1,num_digits):
        nines+=9*10**i
    temp=N-max_digits*10**num_digits
    if temp/nines==1: print(max_digits+num_digits*9)
    else: print((max_digits-1)+num_digits*9)

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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int N,M,h,Ra,Rb,R[100000][2]={{}},H[100000]={},cnt=0,good[100000]={}; 

    cin>>N>>M;
    rep(i,N){
        cin>>h;
        H[i]=h;;
    }
    rep(i,M){
        cin>>Ra>>Rb;
        R[i][0]=Ra;
        R[i][1]=Rb;
    }

    rep(i,M){
        if(H[R[i][0]-1]<H[R[i][1]-1]){
            good[R[i][1]-1]++;
            good[R[i][0]-1]=-999999;
        }
        else if(H[R[i][0]-1]>H[R[i][1]-1]){
            good[R[i][0]-1]++;
            good[R[i][1]-1]=-999999;
        }
        else{
            good[R[i][0]-1]=-999999;
            good[R[i][1]-1]=-999999;
        }
    }
    rep(i,N){
        if(good[i]>=0){
            cnt++;
        }
    }

    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 5220
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using static System.Math;
using Debug = System.Diagnostics.Debug;

class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        //要するに同じ文字は連続してはいけない、ある文字を挟んで文字が2つあってはいけない(4文字以上の回文はn-2文字の回文を消すと自動で消えてくれる)
        int aCount = s.Count(x => x == 'a');
        int bCount = s.Count(x => x == 'b');
        int cCount = s.Count(x => x == 'c');
        int[] abc = new int[] { aCount, bCount, cCount }.OrderByDescending(x => x).ToArray();
        Console.WriteLine(abc.Max() - abc.Min() <= 1 ? "YES" : "NO");
    }
}



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

int main()
{
	int a, b, c, x; cin >> a >> b >> c >> x;

	int ans = 0;

	for (int i = 0; i <= a; i++) {

		for (int j = 0; j <= b; j++) {

			int tmp = x / 50 - 10 * i - 2 * j;

			if (0 <= tmp && tmp <= c) ans++;

		}

	}
	
	cout << ans<< endl;

	return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a));
#define size_of(a) (int)a.size()

typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;

const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
const Double EPS = 1e-9;

int n;
int M[1010], D[1010], hh[1010], mm[1010], id[1010];
bool enter[1010];

int prev[1010];
int sum_time[1010];

void solve() {
	minit(sum_time, 0);
	int month = -1, day = -1;
	int god_in = -1;
	
	for_(i,0,n) {
		int cur_time = 60 * hh[i] + mm[i];
		
		if (month != M[i] || day != D[i]) {
			minit(prev, -1);
			god_in = -1;
			
			month = M[i];
			day = D[i];
			
			if (id[i] == 0) god_in = cur_time;
			else prev[ id[i] ] = cur_time;
		} else {
			if (id[i] == 0) {
				if (enter[i]) {
					god_in = cur_time;
				} else {
					for_(j,0,1010) {
						if (prev[j] == -1) continue;
						//cout << "time : " << i << " add to " << j << " " << cur_time - max(god_in, prev[j]) << endl;
						sum_time[j] += cur_time - max(god_in, prev[j]);
					}
					god_in = -1;
				}
			} else {
				if (enter[i]) {
					prev[ id[i] ] = cur_time;
				} else {
					if (god_in != -1) {
						//cout << "time : " << i << " add to " << id[i] << " " << cur_time - max(god_in, prev[id[i]]) << endl;
						sum_time[ id[i] ] += cur_time - max(god_in, prev[ id[i] ]);
					}
					prev[ id[i] ] = -1;
				}
			}
		}
	}
	
	int ans = 0;
	for_(j,0,1010) ans = max(ans, sum_time[j]);
	cout << ans << endl;
}

int main() {
	while (cin >> n, n) {
		//cout << n << endl;
		char c;
		for_(i,0,n) {
			scanf("%d/%d %d:%d %c %d", &M[i], &D[i], &hh[i], &mm[i], &c, &id[i]);
			if (c == 'I') enter[i] = true;
			else enter[i] = false;
			//cout << M[i] << " " << D[i] << " " << hh[i] << " " << mm[i] << (enter[i] ? " I " : " O ") << id[i] << endl;
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  int depth = 0;
  int minv = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '(') {
      depth++;
    } else {
      depth--;
      minv = min(minv, depth);
    }
  }
  for (int i = 0; i < -minv; i++) {
    cout << '(';
  }
  cout << s;
  for (int i = 0; i < depth - minv; i++) {
    cout << ')';
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll a, b;
    cin >> a >> b;
    cout << a/__gcd(a, b)*b << "\n";
    return 0;
}

Measured memory_bytes: 256
S = input()
T = [0 * x for x in range(len(S))]
Rcount = 0
Lcount = 0

for i in range(len(S)):
  if S[i] == 'R':
    j = S[i:].find('L')
    if j % 2 == 0:
      T[i+j] += 1
    else:
      T[i+j-1] += 1
  else:
    j = S[:i].rfind('R')
    if (i-j) % 2 == 0:
      T[j] += 1
    else:
      T[j+1] += 1

print(T[0], end ="")
for i in range(len(S)-1):
  print (" " + str(T[i+1]), end ="")


Measured memory_bytes: 4984
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll nCm(ll n, ll m){
    if(m == 0 || m == n){
        return 1;
    } else if(m == 1){
        return n;
    }
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------

int main(void){
    string s;
    cin >> s;

    string ans = "";
    for(int i = 0; i < s.size(); i++){
        if(i % 2 == 0){
            ans += s[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <climits>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <bitset>
#include <fstream>
#include <tr1/unordered_map>
#include <assert.h>

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status ()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) << endl;
}

const int MAXN = 2e5;
const int MAX_LOG = (int) log2 (MAXN);

int N, A[MAXN + 5];

struct RMQ
{

	int Log[MAXN + 5];
	pii Min[MAX_LOG + 1][MAXN + 5];

	inline void init ()
	{
		Log[1] = 0; for (int i = 2; i <= N; ++i) Log[i] = Log[i >> 1] + 1;
		for (int i = 1; i <= N; ++i) Min[0][i] = mp (A[i], i);
		for (int i = 1; i <= Log[N]; ++i)
			for (int j = 1; j + (1 << i) - 1 <= N; ++j)
				Min[i][j] = min (Min[i - 1][j], Min[i - 1][j + (1 << (i - 1))]);
	}

	inline pii query (int l, int r) 
	{ 
		int k = Log[r - l + 1];
		return min (Min[k][l], Min[k][r - (1 << k) + 1]);
	}
} T[2];

priority_queue <pii, vector <pii>, greater <pii> > Q;

inline void Init ()
{
	static int B[MAXN + 5];
	for (int i = 1; i <= N; ++i) B[i] = A[i];
	for (int i = 1; i <= N; i += 2) A[i] = 0x3f3f3f3f;
	T[0].init ();
	for (int i = 1; i <= N; ++i) A[i] = B[i];
	for (int i = 0; i <= N; i += 2) A[i] = 0x3f3f3f3f;
	T[1].init ();
	for (int i = 1; i <= N; ++i) A[i] = B[i];
	Q.push (T[1].query (1, N));
}

set <int> S;

inline void update (int l, int r)
{
	if (l > r) return ;
	Q.push (T[l & 1].query (l, r));
}

inline void Solve ()
{
	Init ();

	S.insert (0), S.insert (N + 1);
	for (int n = N / 2; n; --n)
	{
		int x = Q.top().y; Q.pop();
		int xr = *S.upper_bound (x), y = T[!(x & 1)].query (x + 1, xr - 1).y;
		printf("%d %d ", A[x], A[y]);

		S.insert (x), S.insert (y);
		int l = *(--S.lower_bound (x)), r = *S.upper_bound (y);

		update (l + 1, x - 1);
		update (x + 1, y - 1);
		update (y + 1, r - 1);
	}
}

inline void Input ()
{
	N = read<int>();
	for (int i = 1; i <= N; ++i) A[i] = read<int>();
}

int main ()
{

	Input ();
	Solve ();

	return 0;
}



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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nm[0];
        var m = nm[1];
        var digits = new int[n];
        for (int i = 0; i < digits.Length; ++i)
        {
            digits[i] = int.MinValue;
        }
        for (int i = 0; i < m; ++i)
        {
            var sc = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            
            if (digits[sc[0] - 1] > int.MinValue && digits[sc[0] - 1] != sc[1] || digits.Length > 1 && sc[0] == 1 && sc[1] == 0)
            {
                Console.WriteLine("-1");
                return;
            }
            digits[sc[0] - 1] = sc[1];
        }

        if (digits.Length == 1)
        {
            Console.WriteLine(Math.Max(digits[0], 0));
            return;
        }

        var s = Math.Max(digits[0], 1).ToString();
        s += new string(digits.Skip(1).Select(x => (char)(Math.Max(x, 0) + '0')).ToArray());
        Console.WriteLine(s);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    string s;
    cin >> s;
    int count = 0;
    for(int i = 0;i < 3;i++){
        if(s[i] == '1'){
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int a, b, c, d, left=0, right = 0;

int main(){
    scanf("%d %d %d %d", &a, &b, &c, &d);
    left = a+b;
    right = c+d;
    if(left == right)
        printf("Balanced\n");
    else if(left > right)
        printf("Left\n");
    else
        printf("Right\n");
}


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

ll n, a, x[MAXN], dp[MAXN][MAXN][MAXN * MAXN], ans;

int main()
{
	cin >> n >> a;
	for(int i = 0; i < n; i++){
        cin >> x[i];
	}
	dp[0][0][0] = 1;
	for(int i = 0; i < n; i++){
        for(int j = 0; j <= n; j++){
            for(int k = 0; k <= MAXN * MAXN; k++){
                if(k - x[i] >= 0 && j >= 1){
                    dp[i + 1][j][k] = dp[i][j][k] + dp[i][j - 1][k - x[i]];
                }
                else if(k - x[i] < 0){
                    dp[i + 1][j][k] = dp[i][j][k];
                }
            }
        }
	}
    for(int i = 1; i <= n; i++){
        ans += dp[n][i][i * a];
    }
    cout << ans << endl;

	return 0;
}


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

namespace _1_6_C_2
{
    class Program
    {
        static void Main(string[] args)
        {
            University university = new University();
            int informationVolume = int.Parse(Console.ReadLine());
            for (int i = 0; i < informationVolume; ++i)
            {
                string[] information = Console.ReadLine().Split(' ');
                university.Move(information);
            }
            for (int i = 0; i < 4; ++i)
            {
                for (int j = 0; j < 3; ++j)
                {
                    Console.WriteLine(university.buildings[i].floors[j].RoomString());
                }
                if (i == 3)
                {
                    break;
                }
                Console.WriteLine("####################");
            }
        }
    }
    class University
    {
        internal Building[] buildings = new Building[4];

        public University()
        {
            for (int i = 0; i < 4; ++i)
            {
                buildings[i] = new Building();
            }
        }
        internal void Move(string[] information)
        {
            
            int b = int.Parse(information[0]);
            int f = int.Parse(information[1]);
            int r = int.Parse(information[2]);
            int t = int.Parse(information[3]);
            buildings[b-1].floors[f-1].rooms[r-1].room += t;
        }
    }
    class Building
    {
        internal Floor[] floors = new Floor[3];
        public Building()
        {
            for(int i = 0; i < 3; ++i)
            {
                floors[i] = new Floor();
            }
        }

    }
    class Floor
    {
        internal Room[] rooms = new Room[10];

        public Floor()
        {
            for (int i = 0; i < 10; ++i)
            {
                rooms[i] = new Room();
            }
        }
        internal string RoomString()
        {
            string roomstring = "";
            for (int i = 0; i < 10; ++i)
            {
                roomstring += " " + rooms[i].room;
            }
            return roomstring;
        }
    }
    class Room
    {
        internal int room = 0;
    }
}




Measured memory_bytes: 15940
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
typedef vector<pairs> p;


ll gcd(ll A,ll B){
    if (A%B==0)return(B);
    else return(gcd(B,A%B));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> g(9);
    for(ll i=0;i<n;++i){
        ll a;
        cin>>a;
        a /= 400;
        if(a > 7){
            a = 8;
        }
        g[a]++;
    }

    ll x = 0;
    for(ll i=0;i<8;++i){
        if(g[i] > 0){
            x++;
        }
    }
    ll y = x + g[8];
    if(x == 0){
        x = 1;
    }
    cout<<x<<' '<<y<<endl;

    return 0;
}

Measured memory_bytes: 256
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 1], [0, 2, 1, 0], [2, 1, 0, 0], [1, 0, 2, 0], [2, 0, 1, 1], [1, 2, 0, 1]]
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
            break
        if x[j] == y[z[i][j]]:
            order[j] = 1
            if x[j] == x[-j-1]:
                order[j] = 2
    else:
        if 2 in order:
            print('Yes')
            break
        if z[i][3] == sum(order) % 2:
            print('Yes')
            break
else:
    print('No')

Measured memory_bytes: 7696
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, h, N);
    vi dp(N);
    dp[1] = abs(h[1] - h[0]);
    for (ll i = 2; i < N; ++i)
    {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    OUT(dp[N - 1]);
}

Measured memory_bytes: 1792
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

using ll = int64_t;

template<int Mod>
struct MintBase {
  int64_t x; // typedef long long int64_t;
  MintBase(int64_t x=0):x((x%Mod+Mod)%Mod){}
  MintBase operator-() const { return MintBase(-x);}
  MintBase& operator+=(const MintBase a) {
    if ((x += a.x) >= Mod) x -= Mod;
    return *this;
  }
  MintBase& operator-=(const MintBase a) {
    if ((x += Mod-a.x) >= Mod) x -= Mod;
    return *this;
  }
  MintBase& operator*=(const MintBase a) { (x *= a.x) %= Mod; return *this;}
  MintBase operator+(const MintBase a) const { return MintBase(*this) += a;}
  MintBase operator-(const MintBase a) const { return MintBase(*this) -= a;}
  MintBase operator*(const MintBase a) const { return MintBase(*this) *= a;}
  MintBase pow(int64_t t) const {
    if (!t) return 1;
    MintBase a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime Mod
  MintBase inv() const { return pow(Mod-2);}
  MintBase& operator/=(const MintBase a) { return *this *= a.inv();}
  MintBase operator/(const MintBase a) const { return MintBase(*this) /= a;}
};

//const int Mod = 1000000007;
//const int Mod = 998244353;

using mint = MintBase<1000000007>;

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(int, const char**)
{
    int n;
    cin >> n;
    mint all = 1;
    rep(i, n)
    {
        all *= 10;
    }
    mint ex = 1;
    rep(i, n)
    {
        ex *= 9;
    }
    mint ex2 = 1;
    rep(i, n)
    {
        ex2 *= 8;
    }
    mint ans = all - (ex * 2) + ex2;
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 3620
n = int(input())
a = list(map(int, input().split()))

a = list(sorted(a))
j = 0
for i in range(1, n - 1):
    if abs(a[-1] - 2 * a[i]) < abs(a[-1] - 2 * a[j]):
        j = i
print("%d %d" % (a[-1], a[j]))

Measured memory_bytes: 62704
N = int(input())
nums = [int(input()) for _ in range(N)]

ans = sum(nums)
m = sorted([num for num in nums if num % 10 != 0])

if ans % 10 != 0:
    print(ans)
elif len(m) > 0:
    print(ans - m[0])
else:
    print(0)


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){

  int n,t,a;
  scanf("%d", &n);
	scanf("%d %d", &t, &a);
  long h[n];
  for (int i = 0; i < n; i++) {
    scanf("%ld", &h[i]);
  }
  double temp;
  double min = -1;
  int place;
  for (int i = 0; i < n; i++) {
    temp = t - h[i]*0.006;
    temp -= a;
    if (temp < 0) {
      temp *= -1;
    }
    if (min == -1 || temp < min) {
      min = temp;
      place = i+1;
    }
  }
  printf("%d\n", place);

  return 0;
}

Measured memory_bytes: 128
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
using namespace std;
int n;
int s[21]={0};
int d[21][21]={0};
void warshall_floyd(){
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
				}
					
			
		}
	}
	
}
int main(){
	
	int m;
	int a,b,c1,c2;
	char comma;
	int x1,x2,y1,y2;
	cin>>n>>m;
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i!=j)
				d[i][j]=999999;
		}
	}
	
	for(int i=0;i<m;i++){
		cin>>a>>comma>>b>>comma>>c1>>comma>>c2;
		d[a][b]=c1;
		d[b][a]=c2;
	}
	
	warshall_floyd();
	
	cin>>x1>>comma>>x2>>comma>>y1>>comma>>y2;
	
	cout<<y1-y2-d[x1][x2]-d[x2][x1]<<endl;
}

Measured memory_bytes: 1164
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"*t,=map(int,open(0).read().split());print(max(0,min(t[3::2])-max(t[2::2])+1))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 25936
from collections import deque
S = input()
S = deque(S)
N = int(input())

rev = 0

for i in range(N):
  Q = input().split()
  if Q[0] == "1":
    rev += 1
    rev %= 2
  else:
    if (rev + int(Q[1])) % 2 == 1:
      S.appendleft(Q[2])
    else:
      S.append(Q[2])
S = "".join(S)
if rev == 1:
  S = S[::-1]
print(S)
           
  

Measured memory_bytes: 8436
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18;

/*--------------------------------------------------------------------*/

signed main(){
	int n;cin>>n;
	vi cnt(4,0);
	rep(i,n){
		string s;cin>>s;
		if(s[0]=='A'){
			cnt[0]++;
		}else if(s[0]=='W'){
			cnt[1]++;
		}else if(s[0]=='T'){
			cnt[2]++;
		}else {
			cnt[3]++;
		}
	}
	cout<<"AC"<<" x "<<cnt[0]<<endl;
	cout<<"WA"<<" x "<<cnt[1]<<endl;
	cout<<"TLE"<<" x "<<cnt[2]<<endl;
	cout<<"RE"<<" x "<<cnt[3]<<endl;

	return 0;
}



Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  ll n, m;
  cin >> n >> m;
  ll res = 0;
  for(int i = 1; (ll)i * i <= m; i++){
    if(m % i != 0)continue;
    if(m / i >= n)res = max(res, (ll)i);
    if(i >= n)res = max(res, m / i);
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
     
    #define ff first
    #define ss second
    #define mp make_pair
     
    #define pb push_back
    #define endl "\n"
     
    #define int long long int
    #define double long double
     
    #define bp __builtin_popcountll
    #define inf 1e17
    const int N=1e6+6;
    const int M=1e9+7;
    
    signed main(){
    	FAST
    	int n,m;
    	cin>>n>>m;
    	if(n==m)
    	cout<<"Yes";
    	else
    	cout<<"No";
    	
    } 
  

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define LL long long
int ar[100010];
char s[100010];
long long cnt[26][26];
long long tot[26];
const int maxn = 400010;
const int logn = 19;
vector <int> v[maxn];
set<int>st;
list<int>li;
map<string,int>mp;
pair<int,int>p;
bool mark[maxn];
int d[maxn];
int n, k;


void join() {
    long long x,y;
    cin>>x>>y;
     //cout<<ceill(double(x*y)/2LL);
     if(x==1 or y==1) cout<<"1";
     else cout<<(x*y+1)/2;
}

void solve() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; i++) {
	     cin >> a[i];
     }
    for(int i = 0; i < n; i++) {
	     cout<< a[i];
     }
}

int main()
{
    //int tc;
//	scanf("%d", &tc);
	//while(tc--) {
	    //solve();
	    join();
//	}
    return 0; 
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    deque<char> deque1(s.begin(), s.end());
    int N,rflag=0;
    cin>>N;
    while(N--){
        int op1,op2;
        char op3;
        cin>>op1;
        if(op1==1)
            rflag+=1;
        else{
            cin>>op2>>op3;
            if(rflag%2==0){
                if (op2==1)
                    deque1.push_front(op3);
                else
                    deque1.push_back(op3);
            }
            else{
                if (op2==1)
                    deque1.push_back(op3);
                else
                    deque1.push_front(op3);
            }

        }
    }
    if(rflag%2==0){
        for(auto it:deque1)
            cout<<it;
    }
    else{
        for(int i=deque1.size()-1;i>=0;i--)
            cout<<deque1[i];
    }


}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(All(a));
  ll ans = INF;
  rep(i,n-k+1) {
    ans = min(ans, a[i+k-1]-a[i]);
  }
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 4032
def getlist():
	return list(map(int, input().split()))

N, M = getlist()
A = getlist()


bc = []
A = sorted(A)
for i in range(M):
	B, C = getlist()
	bc.append([C, B])

bc = sorted(bc)

A2 = []
cnt = 0
for i in range(M):
	b, c = bc[-1 - i][0], bc[-1 - i][1]
	if cnt + c <= N:
		A2 += [b] * c
		cnt += c
	else:
		A2 += [b] * (N - cnt)
		break

ans = 0
m = len(A2)
for i in range(m):
	x = A[i]
	y = A2[i]
	if x >= y:
		ans += x
	else:
		ans += y

for i in range(m, N):
	ans += A[i]

print(ans)

Measured memory_bytes: 26076
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 510


int V,E;
int capacity[NUM][NUM];

vector<int> G[NUM];
bool used[NUM];

void add_edge(int from,int to){
	G[from].push_back(to);
	G[to].push_back(from);
	capacity[from][to] = 1;
	capacity[to][from] = 1;
}

int dfs(int node_id,int sink,int flow){
	if(node_id == sink)return flow;
	used[node_id] = true;

	for(int i = 0; i < G[node_id].size(); i++){
		int to = G[node_id][i];
		if(used[to] == false &&  capacity[node_id][to] > 0){
			int tmp_flow = dfs(to,sink,min(flow,capacity[node_id][to]));
			if(tmp_flow > 0){
				capacity[node_id][to] -= tmp_flow;
				capacity[to][node_id] += tmp_flow;
				return tmp_flow;
			}
		}
	}
	return 0;
}


int max_flow(int source,int sink,int limit){
	int flow = 0,add;
	while(limit > 0){
		for(int i = 0; i < V; i++)used[i] = false;
		add = dfs(source,sink,1);
		if(add == 0)break;
		flow += add;
		limit--;
	}
	return flow;
}


int main(){

	int N,E,Q;
	scanf("%d %d %d",&N,&E,&Q);

	V = N;

	int from,to;
	for(int loop = 0; loop < E; loop++){
		scanf("%d %d",&from,&to);
		from--;
		to--;
		add_edge(from,to);
	}

	int ans = max_flow(0,N-1,BIG_NUM);

	int command,A,B;

	for(int loop = 0; loop < Q; loop++){
		scanf("%d %d %d",&command,&A,&B);
		A--;
		B--;

		if(command == 1){
			add_edge(A,B);
		}else{

			if(capacity[A][B] == 1 && capacity[B][A] == 1){
				//Do nothing
			}else if(capacity[A][B] == 2){
				if(max_flow(B,A,1) == 1){
					//Do nothing
				}else{
					max_flow(N-1,0,1);
					if(capacity[B][A] == 1){
						//Do nothing
					}else{
						max_flow(B,A,1);
					}
					ans--;
				}
			}else{ //capacity[B][A] == 2

				if(max_flow(A,B,1) == 1){
					//Do nothing
				}else{
					max_flow(N-1,0,1);
					if(capacity[A][B] == 1){
						//Do nothing
					}else{
						max_flow(A,B,1);
					}
					ans--;
				}
			}

			capacity[A][B] = 0;
			capacity[B][A] = 0;
		}

		ans += max_flow(0,N-1,1);
		printf("%d\n",ans);
	}

	return 0;
}



Measured memory_bytes: 4396
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let X: i64 = a.iter().sum();
    let mut x = 0;
    let mut ans = std::i64::MAX;
    for i in 0..a.len() {
        x += a[i];
        if i + 1 < n {
            ans = min(ans, i64::abs(X - 2 * x));
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 8444