akhauriyash/Code-Regression huggingface dataset:
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	vector<vector<int>> a(H, vector<int>(W));
	vector<vector<int>> tate(H, vector<int>(W));
	vector<vector<int>> yoko(H, vector<int>(W));
	
	queue<int> idx_que;

	REP(h, H) {
		cin >> S[h];
	}

	REP(h, H) {
		REP(w, W) {
			if (S[h][w] == '#') {
				a[h][w] = 0;
			} else {
				a[h][w] = 1;
			}
		}
	}

	REP(h, H) {
		REP(w, W) {
			if (a[h][w] == 0) {
				yoko[h][w] = 0;
				int cnt = idx_que.size();
				while(!idx_que.empty()) {
					yoko[h][idx_que.front()] = cnt;
					idx_que.pop();
				}
			} 
			else {
				idx_que.push(w);
			}
		}
		int cnt_ln = idx_que.size();
		while(!idx_que.empty()) {
			yoko[h][idx_que.front()] = cnt_ln;
			idx_que.pop();
		}
	}

	REP(w, W) {
		REP(h, H) {
			if (a[h][w] == 0) {
				tate[h][w] = 0;
				int cnt = idx_que.size();
				while(!idx_que.empty()) {
					tate[idx_que.front()][w] = cnt;
					idx_que.pop();
				}
			}
			else {
				idx_que.push(h);
			}
		}
		int cnt_ln = idx_que.size();
		while(!idx_que.empty()) {
			tate[idx_que.front()][w] = cnt_ln;
			idx_que.pop();
		}
	}
	
	int max_lamp = 0;
	REP(h, H) {
		REP(w, W) {
			max_lamp = max(max_lamp, yoko[h][w] + tate[h][w] - 1);
		}
	}

	cout << max_lamp << endl;

	return 0;
}


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

int main() {
  int h,w;
  cin >> h >> w;
  vector<vector<char>> map(h,vector<char>(w));
  
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> map.at(i).at(j);
    }
  }
  
  vector<int> allWhiteRows;
  vector<int> allWhiteCols;
  for(int i=0; i<h; i++){
    bool all = true;
    for(int j=0; j<w; j++){
      if(map.at(i).at(j) == '#'){
        all = false;
      }
    }
    if(all){
      allWhiteRows.push_back(i);
    }
  }

  for(int i=0; i<w; i++){
    bool all = true;
    for(int j=0; j<h; j++){
      if(map.at(j).at(i) == '#'){
        all = false;
      }
    }
    if(all){
      allWhiteCols.push_back(i);
    }
  }
  
  for(int i=0; i<h; i++){
    bool flag = false;
    for(int j=0; j<w; j++){
      if(
        find(allWhiteRows.begin(), allWhiteRows.end(),i) == allWhiteRows.end()
        && find(allWhiteCols.begin(), allWhiteCols.end(),j) == allWhiteCols.end()
        ) {
        cout << map.at(i).at(j);
        flag = true;
      }
    }
    if(flag){
      cout << endl;
    }
    
  }
  
  
  
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        if (n * 500 >= x) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0063
"""
import sys



def is_palindrome(txt):
    rev = txt[::-1]
    if txt == rev:
        return True
    else:
        return False



def main(args):
    count = 0
    for line in sys.stdin:
        txt = line.strip()
        if is_palindrome(txt):
            count += 1
    print(count)


if __name__ == '__main__':
    main(sys.argv[1:])

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

const int INF = 1e10;
int n, a, dp[100001];

int main() {    
    ios::sync_with_stdio(false);
    cin >> n;

    fill(dp, dp+n, INF);

    for (int i=0; i<n; ++i) {
        cin >> a;
        *lower_bound(dp, dp+n, a) = a;
    }

    cout << lower_bound(dp, dp+n, INF) - dp << endl;
    return 0;
}

Measured memory_bytes: 3540
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s = r.readLine();
    int n = Integer.parseInt(s);

    int[][] mat = new int[2][n];

    for(int i = 0; i < 2; i++)
    {
      s = r.readLine();
      String[] sl = s.split("[\\s]+");
      for(int j = 0; j < n; j++)
      {
        mat[i][j] = Integer.parseInt(sl[j]);
      }
    }

    for(int j = 1; j < n; j++)
    {
      mat[0][j] += mat[0][j - 1];
    }

    for(int j = n - 2; 0 <= j; j--)
    {
      mat[1][j] += mat[1][j + 1];
    }

    int m = 0;

    for(int j = 0; j < n; j++)
    {
      m = Math.max(mat[0][j] + mat[1][j], m);
    }

    System.out.println(m);

  }
}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm> 
#include<cstring>
#define ios ios::sync_with_stdio(false)
#define mem(arr) memset(arr,0,sizeof(arr))
using namespace std;
typedef long long ll;
const ll maxn = 1e6 + 10;
const ll mod = 1e9 + 7;
ll a[maxn] = {0,0,0,1,1};
int main() 
{
	int n;
    cin>>n;
    for(int i = 4; i <= n; i++)
        a[i] = (a[i - 1] + a[i - 3]) % mod;
    cout<<a[n]<<endl;
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cassert>

using namespace std;

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

int64_t comb[60][60];

int main() {

	rep(i, 55) {
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i) {
				comb[i][j] = 1;
			} else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}

	int N, A, B; cin >> N >> A >> B;
	vector<int64_t> v(N);
	rep(i, N) cin >> v[i];
	sort(v.rbegin(), v.rend());
	printf("%.16f\n", std::accumulate(v.begin(), v.begin() + A, 0LL) / (double) A);

	int lidx = 0;
	for (int i = A - 1; i >= 0; i--) {
		if (v[i] > v[A - 1]) {
			lidx = i + 1;
			break;
		}
	}

	int ridx = N;
	REP(i, A, N) {
		if (v[A - 1] > v[i]) {
			ridx = i;
			break;
		}
	}

	int64_t sum = 0;
	auto CountTarget = ridx - lidx;
	if (v[A - 1] != v[0]) {
		cout << comb[CountTarget][A - lidx] << "\n";
	} else {
		REP(n, A, min(B, CountTarget) + 1) {
			sum += comb[CountTarget][n];
		}
		cout << sum << "\n";
	}
}


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

int main() {
	int a,b,c,x;
	cin >> a >> b >> c >> x;
	int counter=0;
	rep(i,a+1){
		rep(j,b+1){
			rep(k,c+1){
				int m = 500*i + 100*j + 50*k ;
				if(m == x) {
					counter++;
				}
				if(m>=x) break;

			}
		}
	}
	cout << counter << endl;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x, y;
string s;
ll prime[200];
// < ----------- func eh ---------------- ? //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> k>> x>> y;
	if(n <= k) cout<<n*x;
	else cout<<k*x + (n-k)*y;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3588
# coding: utf-8
# Your code here!

s = list(input())
for i in range(8):
    siki = s[0]
    for j in range(3):
        if i&(1<<j):
            siki+='+'+s[j+1]
        else:
            siki+='-'+s[j+1]
    g=int(siki[0])
    for j in range(1,6,2):
        if siki[j]=='+':
            g+=int(siki[j+1])
        else:
            g-=int(siki[j+1])
    if g==7:
        siki+="=7"
        print(*siki,sep="")
        break

Measured memory_bytes: 3064
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]
N, M = getInput()
A = getInput()
_4M = sum(A) / (4*M)
A.sort(reverse=True)
cnt = 0
for i in A:
    if i >= _4M:
        cnt += 1
print('Yes') if cnt >= M else print('No')

Measured memory_bytes: 3064
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <iostream>

using namespace std;

using P = pair<int64_t, int64_t>;
struct Edge {
    int64_t to, cost;
};

int N;
constexpr int64_t INF = 1ll << 50;
unordered_map<int64_t, vector<Edge>> G;
unordered_map<int64_t, int64_t> d;
int64_t po = 1000010ll;

void dijkstra(){
    priority_queue<P, vector<P>, greater<P>> que;
    d[0] = 0;
    que.push(P(0, 0));

    while(!que.empty()){
        P p = que.top();
        que.pop();
        int64_t v = p.second;
        if(d[v] == 0 && v != 0){
            d[v] = INF;
        }
        if(d[v] < p.first) continue;
        for(const auto& e : G[v]){
            if(d[e.to] == 0 && e.to != 0){
                d[e.to] = INF;
            }
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){
    int M;
    cin >> N >> M;

    for(int i = 0; i < M; ++i){
        int64_t p, q, c;
        cin >> p >> q >> c;
        --p, --q;
        G[p * po + c].push_back(Edge{q * po + c, 0});
        G[q * po + c].push_back(Edge{p * po + c, 0});

        G[p * po + c].push_back(Edge{p * po, 0});
        G[p * po].push_back(Edge{p * po + c, 1});
        G[q * po + c].push_back(Edge{q * po, 0});
        G[q * po].push_back(Edge{q * po + c, 1});
    }

    dijkstra();

    int64_t ans = d[(N-1) * po];
    cout << (ans == 0 ? -1 : ans) << endl;
}

Measured memory_bytes: 77300
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static bool[] b;
	static int[] h;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		int n=s[0],m=s[1];
		b=new bool[n];
		h=new int[n];
		var e=new int[m][];
		for(int i=0;i<m;i++){e[i]=sc.Ia;}
		Array.Sort(e,(u,v)=>u[2]-v[2]);
		Uf uf=new Uf(n);
		long ans=0;
		for(int i = 0;i<m;i++) {
			if(!uf.Same(e[i][0],e[i][1])){
				uf.Union(e[i][0],e[i][1]);
				ans+=e[i][2];
			}
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Uf{
	private int[] arr,hi;
	public int all;
	public Uf(int n){
		arr=new int[n];
		hi=new int[n];
		all=n;
		for(int i=0;i<n;i++){arr[i]=-1;}
	}
	public void Union(int a,int b){
		a=Root(a);
		b=Root(b);
		if(a!=b){
			if(hi[a]<hi[b]){
				int v=b;
				b=a;
				a=v;
			}
			arr[a]+=arr[b];
			hi[a]=Math.Max(hi[a],hi[b]+1);
			arr[b]=a;
			all--;
		}
	}
	public bool Same(int a,int b){return Root(a)==Root(b);}
	public int Total(int a){return -arr[Root(a)];}
	public int Root(int a){return arr[a]<0?a:arr[a]=Root(arr[a]);}
}


public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 29764
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x,n; cin >> x >> n;
    map<int,int> m;
    rep(i,0,n){
        int p; cin >> p;
        m[p]++;
    }
    rep(i,0,300){
        if(m[x-i]==0){
            cout << x-i << endl;
            return 0;
        }
        else if(m[x+i]==0){
            cout << x+i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3616
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
map<int,int>cnt;
int main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		int tmp=i;
		for(int j=2;j*j<=tmp;j++){
			while(tmp%j==0){
				tmp/=j;
				cnt[j]++;
			}
		}
		if(tmp!=1)cnt[tmp]++; 
	}
	vector<int>v;
	for(auto p:cnt){
		v.push_back(p.second);
	}
	if((int)v.size()<3){
		cout<<0<<endl;
		return 0;
	}
	int ans=0;
	for(int c1=0;c1<v.size();c1++)
		for(int c2=0;c2<v.size();c2++)
			for(int c3=0;c3<v.size();c3++){
				if(c1!=c2&&c1!=c3&&c2!=c3)
					if(v[c1]>=4&&v[c2]>=4&&v[c3]>=2){
						ans++;
					}
			}
	ans/=2;
	for(int c1=0;c1<v.size();c1++)
		for(int c2=0;c2<v.size();c2++){
			if(c1!=c2){
				if(v[c1]>=14&&v[c2]>=4)ans++;
				if(v[c1]>=24&&v[c2]>=2)ans++;
			}
		}
	for(int c1=0;c1<v.size();c1++)if(v[c1]>=74)ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
 * Owner   : Tatsuhiro Hashimoto
 * Created : 2020-05-02 (Thu)
 */

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

#define endl "\n"
#define FSP(n) cout << fixed << setprecision(n);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
static inline ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b);}
static inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
#define prepare cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);

int K, A, B;

signed main() {
    prepare
    cin >> K >> A >> B;
    bool T = false;
    for (int i = 1; i < 1000; ++i) {
        if (A <= i * K && i * K <= B) {
            T = true;
             break;
        }
    }
    if (T) cout << "OK" << endl;
    else cout << "NG" << endl;;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define REP(i,c) for(int i=1;i<(c);i++)
using namespace std;
using ll = long long;
int main()
{
  ll N;
  cin >> N;
  ll sum = 0;
  REP(i, N)
  {
    sum += i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main(){
  int n; cin >> n;
  int a[n];
  REP(i, n) cin >> a[i];

  vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(n+1, vector<ll>(2)));
  REP(i, n+1)REP(j, n+1){
    dp[i][j][0] = LLONG_MIN;
    dp[i][j][1] = LLONG_MAX;
  }

  function<ll(int, int, int)> rec = [&](int l, int r, int turn){
    if(l > r) return 0LL;
    if(turn == 0){
      if(dp[l][r][turn] != LLONG_MIN) return dp[l][r][turn];
      ll l_v = rec(l+1, r, 1-turn) + a[l];
      ll r_v = rec(l, r-1, 1-turn) + a[r];
      return dp[l][r][turn] = max(l_v, r_v);
    } else {
      if(dp[l][r][turn] != LLONG_MAX) return dp[l][r][turn];
      ll l_v = rec(l+1, r, 1-turn) - a[l];
      ll r_v = rec(l, r-1, 1-turn) - a[r];
      return dp[l][r][turn] = min(l_v, r_v);
    }
  };

  cout << rec(0, n-1, 0) << endl;

  return 0;
}


Measured memory_bytes: 493568
time = int(input())
kakko = input()
hidarikakko = 0 #(
migikakko = 0 #)
hidariHuyasu = 0 #左に増やす(の数
migiHuyasu = 0 #右に
#左に増やすのを考える
for i in range(time):
    if kakko[i] == "(":
        hidarikakko += 1
    else:
        if hidarikakko == 0:
            hidariHuyasu += 1
        else:
            hidarikakko -= 1
#右に増やすのを考える
hidarikakko = 0 #(
migikakko = 0 #)
gyaku = range(time)
# print(gyaku)
# gyaku.reverse()
for i in reversed(range(time)):
    if kakko[i] == ")":
        migikakko += 1
    else:
        if migikakko == 0:
            migiHuyasu += 1
        else:
            migikakko -= 1
print("(" * hidariHuyasu + kakko + ")" * migiHuyasu)

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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    vector<int> y = x;
    sort(y.begin(), y.end());
    if(y[n/2-1] == y[n/2]){
        rep(i,n) cout << y[n/2] << endl;
    }
    else{
        rep(i,n){
            if(x[i] <= y[n/2-1]) cout << y[n/2] << endl;
            else cout << y[n/2-1] << endl;
        }
    }
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vec vector
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << a << endl
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define Yes "Yes"
#define YES "YES"
#define No "No"
#define NO "NO"


int main() {
  string S;
  cin >> S;
  int s = S.size();
  if (S[s-1] == 's')
    S += "e";
  S += "s";
  print(S);
  return 0;
}

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

#define W -10
#define B -9
#define MAX 10001
#define INF 1000000000

void ISS(void);
void DA(void);

typedef struct{
  int k;
  int *ten;
  int *omomi;
}rist;

int n;/*頂点数*/
rist T[MAX];
int color[MAX];/*色分け用配列*/
int d[MAX];
int pi[MAX];
int main()
{
  int i,j,youso,kazu,v,kyori;

  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    {
      scanf("%d%d",&youso,&T[i].k);
      /*動的にメモリを確保*/
      T[i].ten=(int *)malloc( T[i].k*sizeof(int) );
      T[i].omomi=(int *)malloc( T[i].k*sizeof(int) );
      for(j=0;j<T[i].k;j++)
	{
	  scanf("%d%d",&T[i].ten[j],&T[i].omomi[j]);
	}
    }
  
   DA();

  for(i=0;i<n;i++)printf("%d %d\n",i,d[i]);
  for(i=0;i<n;i++)
    {
      free(T[i].ten);
      free(T[i].omomi);
    }
  return 0;
}

void ISS(void)
{
  int i;
  for(i=0;i<n;i++)
    {
      d[i]=INF;
      pi[i]=EOF;
      color[i]=W;
    }
  
  d[0]=0;
}

void DA(void)
{
  int i,j,z,min,point;

  ISS();

  while(1)
    {
      min=INF;
      for(i=0;i<n;i++)
	{
	  if(color[i]!=B && d[i]<min)
	    {
	      min=d[i];
	      j=i;
	    }
	}
      
      if(min==INF)
	{
	  break;
	}

      color[j]=B;

      for(z=0;z<T[j].k;z++)
	{

	  point=T[j].ten[z];
	  
	  if(color[point]!=B && (d[j]+T[j].omomi[z])<d[point])
	    {
	      pi[point]=j;
	      d[point]=d[j]+T[j].omomi[z];
	    }
	}
    }
}



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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  int h,w,n; cin >> h >> w >> n;
  vector<int> a(n); for(int i=0;i<n;i++) { cin >> a[i]; }
  
  int b[h][w], flag=1, pos_h=0, pos_w=0;
  for(int i=0;i<n;i++) {
    for(int j=0;j<a[i];j++) {
      if(flag>0) {
        b[pos_h][pos_w++] = (i+1);
        if(pos_w>=w) {
          flag=-1;
          pos_h++;
          pos_w--;
        }
      } else {
        b[pos_h][pos_w--] = (i+1);
        if(pos_w<0) {
          flag=1;
          pos_h++;
          pos_w++;
        }
      }
    }
  }  

  for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) { cout << b[i][j] << " "; }
    cout << endl;
  }
  return 0;
}
 

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> v;
	REP(i, 2*n){
		v.push_back(i+1);
	}

	int order[m];
	REP(i, m) cin >> order[i];

	REP(i, m){
		if (!(order[i])){
			vector<int> v1(v.begin(), v.begin() + n);
			vector<int> v2(v.begin() + n, v.end());
			vector<int> tmp;
			REP(j, n){
				tmp.push_back(v1[j]);
				tmp.push_back(v2[j]);
			}

			v = tmp;
		}
		else {
			int k = order[i];
			vector<int> v1(v.begin(), v.begin() + k);
			vector<int> v2(v.begin() + k, v.end());
			vector<int> tmp;

			copy(ALL(v2), back_inserter(tmp));
			copy(ALL(v1), back_inserter(tmp));
			v = tmp;
		}
	}

	for (auto x : v) cout << x << endl;

}



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

int main(void){
    long long ans=0,n,d;
    cin >> n >> d;
    d *= d;
    rep(i,n){
        long long x,y;
        cin >> x >> y;
        if((x*x)+(y*y) <= d)ans++;
    }
    cout << ans << endl;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	string s, t;
	cin >> s;
	cin >> t;
	int n = s.size(), m = t.size();
	vector<pii> sum_s(n + 1), sum_t(m + 1);
	sum_s[0] = sum_t[0] = pii(0, 0);
	int i0;
	for (i0 = 0; i0 < n; i0++) {
		sum_s[i0 + 1] = sum_s[i0];
		if (s[i0] == 'A') {
			sum_s[i0 + 1].first++;
		}
		else {
			sum_s[i0 + 1].second++;
		}
	}
	for (i0 = 0; i0 < m; i0++) {
		sum_t[i0 + 1] = sum_t[i0];
		if (t[i0] == 'A') {
			sum_t[i0 + 1].first++;
		}
		else {
			sum_t[i0 + 1].second++;
		}
	}
	int q;
	cin >> q;
	for (i0 = 0; i0 < q; i0++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int x, y;
		x = (sum_s[b].first - sum_s[a - 1].first) - (sum_s[b].second - sum_s[a - 1].second);
		y = (sum_t[d].first - sum_t[c - 1].first) - (sum_t[d].second - sum_t[c - 1].second);
		if ((max(x, y) - min(x, y)) % 3 == 0) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}

}

Measured memory_bytes: 2560
#include<cstdio>
#include<map>
using namespace std;
map<int,int>mp; 
int n,x;
int main(){
	scanf ("%d",&n);
	for (register int i=1;i<=n;++i){
		scanf ("%d",&x);
		if (mp[x]==0) mp[x]=1;
		else{
			printf ("NO\n");return 0;
		}
	}
	printf ("YES\n");
	return 0;
} 

Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const ll INF = 10e16;
const int maxN = 500010;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1000000007;

int a[maxN]; 
int main()
{

	string s;
	cin>>s;
	if(s[0] != s[1] || s[1] != s[2] || s[2] != s[0])
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}

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

int main()
{
   int A,B;
   cin >> A >> B;
   int count = 0;

   for(int i = A; i <= B; i++){
       int a = i%10;
       int b = i/10000%10;
       int c = i/10%10;
       int d = i/1000%10;

       if (a == b && c == d){
           count++;
       }
   }
   cout << count << endl;

}

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


Int N,M,K;
Int X,Y,Z,D;
const int MAXN=105;
Int B,C;


struct DisJointSet{
    vector<int> SZ;
    vector<int> ID;
    int n;

    DisJointSet(int n){
        SZ.resize(n);
        ID.resize(n);
        this->n=n;
        
        for(int i=0;i<n;++i){
            ID[i]=i;
            SZ[i]=1;
        }
    }
    
    int find(int x){
        return (ID[x]==x ? x:find(ID[x]));
    }
    
    void Union_find(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(SZ[x]>SZ[y]){
            ID[y]=x;
            SZ[x]+=SZ[y];
        }
        else{
            ID[x]=y;
            SZ[y]+=SZ[x];
        }
        return;
    }
};
map<Int,Int> dp;
Int health(Int x){
    if(x==1) return 1;
    if(dp.count(x)) return dp[x];
    return dp[x]=1+health(x>>1LL)*2LL;
}

int main()
{
        cin>>N;
        cout<<health(N)<<"\n";
        
  
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[100100];

bool solve() {
    int odd = 0;
    for (int i = 0; i < n; i++)
        odd += a[i]%2;
    return odd % 2 == 0;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << (solve()?"YES":"NO") << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

const int maxn = 2005;
char grid[maxn][maxn];
int lft[maxn][maxn];
int rght[maxn][maxn];
int up[maxn][maxn];
int down[maxn][maxn];

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

	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> grid[i][j];
		}
	}
	for(int j = 0; j < m; j++){
		int lst = -1;
		for(int i = 0; i < n; i++){
			if(grid[i][j] == '#')
				lst = i;
			up[i][j] = i - lst - 1;
		}
	}
	for(int j = 0; j < m; j++){
		int lst = n;
		for(int i = n - 1; i >= 0; i--){
			if(grid[i][j] == '#')
				lst = i;
			down[i][j] = lst - i - 1;
		}
	}
	for(int i = 0; i < n; i++){
		int lst = -1;
		for(int j = 0; j < m; j++){
			if(grid[i][j] == '#')
				lst = j;
			lft[i][j] = j - lst - 1;
		}
	}
	for(int i = 0; i < n; i++){
		int lst = m;
		for(int j = m - 1; j >= 0; j--){
			if(grid[i][j] == '#')
				lst = j;
			rght[i][j] = lst - j - 1;
		}
	}
	int res = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(grid[i][j] == '.')
				res = max(res, down[i][j] + up[i][j] + lft[i][j] + rght[i][j] + 1);
		}
	}
	cout << res;
}




Measured memory_bytes: 66944
import math

def main():
	S = list(input())
	ls = len(S)
	RL = []
	rc = 0
	lc = 0
	for i in range(ls):
		if i != ls - 1:
			if S[i] == "R":
				rc += 1
			elif S[i] == "L" and S[i + 1] == "L":
				lc += 1
			elif S[i] == "L" and S[i + 1] == "R":
				lc += 1
				RL.append({
					"right": rc,
					"left": lc
				})
				rc = 0
				lc = 0
		else:
			lc += 1
			RL.append({
				"right": rc,
				"left": lc
			})
	cnt = []
	for i in range(len(RL)):
		rl = RL[i]
		rc = rl["right"]
		lc = rl["left"]
		cnt += ["0"] * (rc - 1)
		cnt += [str(int(lc / 2) + math.ceil(rc / 2))]
		cnt += [str(int(rc / 2) + math.ceil(lc / 2))]
		cnt += ["0"] * (lc - 1)

	print(" ".join(cnt))

main()

Measured memory_bytes: 29380
#include<bits/stdc++.h>
#define M 200005 
using namespace std;
int mark[M],t,k,n;
int P=1e9+7;
int F[M];
void Init(){
	F[0]=1;
	for(int i=1;i<=n;i++)F[i]=1LL*i*F[i-1]%P;
}
int fast(int x){
	int n=P-2;
	long long res=1,a=x;
	while(n){
		if(n&1)res=(res*a)%P;
		a=a*a%P;
		n>>=1;
	}
	return res;
}
int C(int n,int m){
	if(n<0)return 0;
	if(m==0)return 1;
	if(n<m)return 0; 
	return F[n]*1LL*fast(F[n-m])%P*fast(F[m])%P;
}
void Add(int &x,int y){
	x+=y;
	if(x>=P)x-=P;
	if(x<0)x+=P;
}
int solve(int m){
	int ans=0;
	Add(ans,C(n-2,m));//0
	Add(ans,C(n-2,m-1)*2%P);
	Add(ans,-C(t-1+n-k,m-1));
	if(m>=2)Add(ans,C(n-2,m-2));//2
	return ans;
}
int main(){
	int x;
	scanf("%d",&n);
	Init();
	memset(mark,0,sizeof(mark));
	for(int i=1;i<=n+1;i++){
		scanf("%d",&x);
		if(mark[x])k=i,t=mark[x];
		else mark[x]=i;
	}//...t...k...
	n++;
	//printf("mark=%d k=%d\n",t,k);
	for(int i=1;i<=n;i++){
		printf("%d\n",solve(i));
	}
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<long long int> vec(M);
    for(int m=0; m<M; m++) {
        cin >> vec[m];
    }
    
    sort(vec.begin(), vec.end());
    
    priority_queue<long long int> que;
    for(int m=0; m<M-1; m++) {
        que.push(vec[m+1]-vec[m]);
    }
    
    for(int i=1; (!que.empty() && i<N); i++) {
        que.pop();
    }
    long long int ans=0;
    while(!que.empty()) {
        ans += que.top();
        que.pop();
    }
    
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

int main(){
	int d,t,s;
	scanf("%d%d%d",&d,&t,&s);
	if(d<=t*s) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 3720
def solve():
  while True:
    n = int(input())
    if not n:
      break
    m = int(input())
    edge = [[0 for i in range(n + 1)] for j in range(n + 1)]
    for i in range(m):
      a,b = map(int,input().split())
      edge[a][b] = 1
      edge[b][a] = 1
    friends1 = [i for i in range(n + 1) if edge[1][i]]
    friends2 = []
    for friend in friends1:
      friends_lst = [i for i in range(n + 1) if edge[friend][i]]
      friends2.extend(friends_lst)
    ans = len(set(friends1 + friends2))
    if ans:
      ans -= 1
    print(ans)
solve()  


Measured memory_bytes: 8056
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

long solve (int n)
{
	readln;
	auto a = readln.splitter.map !(to !(long)).array;
	auto total = sum (a);
	long cur = 0;
	long res = long.max;
	foreach (i, c; a)
	{
		if (i > 0)
		{
			res = min (res, abs (total - 2 * cur));
		}
		cur += c;
	}
	return res;
}

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		writeln (solve (n));
	}
}


Measured memory_bytes: 4860
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll INF = ll(INT_MAX) << 20;
    int n, m, q, s, t, a, b, c;
    ll L;
    cin >> n >> m >> L;
    vector<vector<ll>> dist(n, vector<ll>(n, INF));
    vector<vector<ll>> fuel(n, vector<ll>(n, INF));
    for(int i = 0; i < n; i++)
        dist[i][i] = 0;
    for(int i = 0; i < m; i++) {
        cin >> a >> b >> c;
        if (c > L) continue;
        a--; b--;
        dist[a][b] = min(dist[a][b], ll(c));
        dist[b][a] = min(dist[b][a], ll(c));
    }
    for(int k = 0; k < n; k++) {
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                if (dist[i][k] + dist[k][j] < dist[i][j]) {
                    dist[i][j] = dist[i][k] + dist[k][j];
                }
            }
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if (i == j) {
                fuel[i][j] = 0;
                continue;
            }
            if (dist[i][j] <= L)
                fuel[i][j] = 1;
        }
    }
    for(int k = 0; k < n; k++) {
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                if (fuel[i][k] + fuel[k][j] < fuel[i][j]) {
                    fuel[i][j] = fuel[i][k] + fuel[k][j];
                }
            }
        }
    }
    cin >> q;
    while(q--) {
        cin >> s >> t;
        s--; t--;
        if (fuel[s][t] == INF)
            cout << -1 << endl;
        else
            cout << fuel[s][t] - 1 << endl;
    }
    return 0;
}




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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    int D,N;
    cin >> D >> N;
    if(D==0){
        if(N==100) cout << 101 << endl;
        else cout << N << endl;
    }else if(D==1){
        if(N==100) cout << 10100 << endl;
        else cout << N*100 << endl;
    }else{
        if(N==100) cout << 1010000 << endl;
        else cout << N*10000 << endl;
    }
    return 0;
}

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

using namespace std;

long long x[100001], endx[100001];
long long w[100001];

int main() {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
#endif

	long long n, l, t;
	cin >> n >> l >> t;
	long long c = 1;
	for (long long i = 1; i <= n; ++i) {
		cin >> x[i] >> w[i];
		if (w[i] == 1) {
			c = (c + t / l - 1) % n + 1;
			endx[i] = x[i] + t % l;
			if (endx[i] >= l) {
				endx[i] -= l;
				c = c % n + 1;
			}
		} else {
			c = (c + n - t / l - 1) % n + 1;
			endx[i] = x[i] - t % l;
			if (endx[i] < 0) {
				endx[i] += l;
				c = (c + n - 2) % n + 1;
			}
		}
	}

	sort(endx + 1, endx + n + 1);

	for (long long i = c; i <= n; ++i) cout << endx[i] << '\n';
	for (long long i = 1; i < c; ++i) cout << endx[i] << '\n';

	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using RoomInfo = std::pair<long long, long long>; //どの部屋に残っているか
using Node = std::pair<RoomInfo, int>; // first, second:cost

namespace std {
    template <>
    class hash<std::pair<long long, long long>> {
    public:
        size_t operator()(const std::pair<long long, long long>& x) const {
            return hash<long long>()(x.first) ^ hash<long long>()(x.second);
        }
    };

    template <>
    class hash<std::pair<RoomInfo, int>> {
    public:
        size_t operator()(const std::pair<RoomInfo, int>& x) const {
            return hash<RoomInfo>()(x.first) ^ hash<int>()(x.second);
        }
    };
}


int main() {
    int n, m, k;
    std::vector<int> d; // is darkroom
    int e[100][100];
    std::queue<Node> q;
    std::unordered_map<RoomInfo, std::vector<RoomInfo>> g; //from, to
    std::unordered_set<RoomInfo> visited;

    std::cin >> n >> m >> k;
    if (m == 0) {
        std::cout << 0 << std::endl; // すべて明るい
        return 0;
    }

    d.resize(n, 0);
    for (int i = 0; i < m; i++) {
        int a;
        std::cin >> a;
        d[a-1] = 1;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
            int a;
            std::cin >> a;
            e[i][j] = a-1; // i番目の部屋からj番目の道でaに行く
        }
    }

    // グラフを作成


    RoomInfo node;
    for (int i = 0; i < n; i++) {
        if (d[i]) {
            if (i < 64) {
                node.first |= 1ull << i;
            }
            else {
                node.second |= 1ull << (i - 64);
            }
        }
    }

    q.push(std::make_pair(node, 0));
    visited.insert(node);

    while (!q.empty()) {
        auto node = q.front(); q.pop();
        node.second++;

        // i番目の道を使用
        for (int i = 0; i < k; i++) {
            RoomInfo next = std::make_pair(0, 0);
            // j番目の部屋から移動
            for (int j = 0; j < n; j++) {
                // 居なければcontinue;
                if (j < 64) {
                    if (!(node.first.first & 1ull << j)) continue;
                }
                else {
                    if (!(node.first.second & 1ull<< (j - 64))) continue;
                }
                int to = e[j][i];
                // 移動先も暗い部屋
                if (d[to]) {
                    if (to < 64) next.first |= 1ull << to;
                    else next.second |= 1ull << (to - 64);
                }
            }

            if (!next.first && !next.second) {
                std::cout << node.second << std::endl;
                return 0;
            }
            if (!visited.count(next)) {
                q.push(std::make_pair(next, node.second));
                visited.insert(next);
            }
        }
    }

    return 0;
}


Measured memory_bytes: 7480
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
typedef long long ll;

ll x,cnt;
ll a=100;
	
int main()
{
	cin>>x;
	while(1)
	{
		if(a>=x)
		{
			cout<<cnt;
			return 0;
		}
		a+=a*0.01;
		cnt++;
	}
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll N; cin >> N;
    vector<int> v(N + 1);
    ll count = 0;
    for (int i = 1; i <= N; ++i) {
        cin >> v[i];
        if (v[i] % 2 == 1 && i % 2 == 1) count++;
    }
    cout << count << endl;
}

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

int main() {
  int N,K,s;
  cin >> N>>K;

  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (x*2 <= K){
    s += 2*x; 
    }
    else{
      s += (K-x)*2;
    }
  }
    cout << s << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main
{
	static final int MAX_X = 8;
	static final int MAX_Y = 8;
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
		String s;
		do
		{
			int[][] map = new int[MAX_Y+1][MAX_X+2];
			for (int i=0; i<MAX_Y; i++) {
				s = br.readLine();
				for(int j=1; j<MAX_X+1; j++)
					map[i][j] = Integer.parseInt(s.charAt(j-1)+"");
			}
			System.out.println(figure(map));
		} while((s=br.readLine())!=null && s.isEmpty());
	}
	private static char figure(int[][] map)
	{
		for (int i = 0; i < MAX_Y; i++) {
			for (int j = 1; j < MAX_X+1; j++) {
				if(map[i][j]==1){
					if(map[i+1][j] == 1 && map[i][j+1]==1){
						if(map[i+1][j+1]==1)	return 'A';
						else 					return 'G';
					} else if(map[i+1][j] == 0 && map[i][j+1]==1){
						if(map[i+1][j+1]==1)	return 'E';
						else 					return 'C';						
					} else {
						if(map[i+1][j+1]==1)		return 'F';
						else if (map[i+1][j-1]==1)	return 'D';	
						else 						return 'B';
					}
				}
			}
		}
		return '0';
	}
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    string S, T;
    int N, A, B, C;
    double x, y, z;
    cin >> S >> T;
    int ans = 0;
    FOR(i, 0, 3)
    ans += S[i] == T[i];
    cout << ans << endl;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N;
    string S;
    cin >> S;

    sort(S.begin(), S.end());

    if (S.at(0) == S.at(1) && !(S.at(2) == S.at(1)) && S.at(2) == S.at(3)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3640
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(a[k-1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define mkp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin>>s;
	if(s == "BBB"||s == "AAA")cout<<"No\n";
	else cout<<"Yes\n";
	return 0;
} 

Measured memory_bytes: 256
#include <cctype>
#include <cstdio>
using namespace std;

int main()
{
	char x;//?????????
	
	while(1){
		scanf("%c",&x);
		
		//??¢??????????????????????????\
		if(isalpha(x)){
			//??§??????????°???????
			if(isupper(x))
				printf("%c", tolower(x));
			//?°????????????§??????
			else if(islower(x)) 
				printf("%c", toupper(x));
		}
		//??¢????????????????????\????????????
		else {
			printf("%c", x);
		}
		if(x == '\n')break;
	}
	
	return 0;
}

Measured memory_bytes: 944