akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

struct I{
    int l,r;
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<int> X(N),L(N);
    vec<int> v;
    vec<I> interval;
    for(int i=0;i<N;i++){
        cin >> X[i] >> L[i];
        int l = X[i]-L[i],r = X[i]+L[i];
        v.push_back(l);
        v.push_back(r);
        interval.push_back({l,r});
    }
    int inf = 2e9;
    int ma = 0;
    sort(interval.begin(),interval.end(),[](I& a,I& b){
        return (a.r!=b.r? a.r<b.r:a.l<b.l);
    });

    int ans = 0;
    int now = -inf;
    for(int i=0;i<N;i++){
        if(now<=interval[i].l){
            ans++;
            now = interval[i].r;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2804
n,k = map(int, input().split())
l = [0] + list(map(int, input().split()))
a = list()
for i in range(n):
  l[i+1] += l[i]
a = [l[j]-l[i] for i in range(n) for j in range(i+1,n+1)]
x = 0
for i in range(40,-1,-1):
  t = 2**i
  b = list(filter(lambda y: y&(t+x) == (t+x),a))
  if len(b) >= k:
    a = b
    x += t
print(x)

Measured memory_bytes: 65788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 10000
#define MAP 100
#define Pair pair<int,int>

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

int main(){
    int H,W; cin >> H >> W;
    int N; cin >> N;
    int a[N];
    for(int i = 0; i < N; i++) cin >> a[i];
    int masu[H][W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            masu[i][j] = 0;
        }
    }
    int pointer = 0;
    for(int i = 0; i < H; i++){
        int ans[W];
        if(i%2 == 0){
            for(int j = 0; j < W; j++){
                ans[j] = pointer + 1;
                a[pointer]--;
                if(a[pointer] == 0) pointer++;
            }
        } else {
            for(int j = W-1; j >= 0; j--){
                ans[j] = pointer+1;
                a[pointer]--;
                if(a[pointer] == 0) pointer++;
            }
        }
        for(int j = 0; j < W-1; j++) cout << ans[j] << " ";
        cout << ans[W-1] << endl;
    }
}





Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>

using namespace std;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int k;
    cin>> k;

    for(int i = 0; i<n;i++){
        if(s[i] != s[k-1]){
            s[i]='*';
        }
    }
    cout<<s<<endl;

    return 0;
}

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

int main()
{
    int bingo[3][3],i,j;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>bingo[i][j];
        }
    }

    int n;
    cin>>n;
    int b;
    for(i=0;i<n;i++)
    {
        cin>>b;
        for(j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                if(b==bingo[j][k])
                {
                    bingo[j][k]=0;
                    break;
                }
            }
        }
        if((bingo[0][0]==bingo[0][1]&&bingo[0][0]==bingo[0][2])||(bingo[1][0]==bingo[1][1]&&bingo[1][0]==bingo[1][2])||(bingo[2][0]==bingo[2][1]&&bingo[2][0]==bingo[2][2])||(bingo[0][0]==bingo[1][0]&&bingo[0][0]==bingo[2][0])||(bingo[0][1]==bingo[1][1]&&bingo[0][1]==bingo[2][1])||(bingo[0][2]==bingo[1][2]&&bingo[0][2]==bingo[2][2])||(bingo[0][0]==bingo[1][1]&&bingo[0][0]==bingo[2][2])||(bingo[0][2]==bingo[1][1]&&bingo[0][2]==bingo[2][0]))
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()

typedef unsigned long long ll;


int main(){ 
int W,H,N; cin >> W >> H >> N;
vector<vector<int>> a(N,vector<int> (3));
rep(i,N){
    rep(j,3){
        cin >> a[i][j];
    }
}
vector<vector<int>> b(H,vector<int> (W));
rep(i,H){
    rep(j,W){
        b[i][j] = 0;
    }
}
rep(i,N){
    if(a[i][2] == 1){
        rep(j,H){
            rep(k,a[i][0]){
            b[j][k]++;
            }
        }
    }
    else if(a[i][2] == 2){
        rep(j,H){
            for(int k = a[i][0]; k < W;k++){
            b[j][k]++;
        }
    }
    }
    else if(a[i][2] == 3){
        rep(j,W){
            rep(k,a[i][1]){
            b[k][j]++;

        }
    }
    }
    else{
        rep(j,W){
            for(int k = a[i][1]; k < H;k++){
            b[k][j]++;
        }
    }
    }
}
    int sum = 0;
    rep(i,H){
        rep(j,W){
            if(b[i][j] == 0){
                sum++;
            }
        }
    }
    cout << sum << endl;


}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>

using namespace std;

void solv()
{
	int N; scanf("%d", &N);
	char S[10010]; scanf("%s", S);
	int cur = 0;
	while ('\0' != S[cur]){
		S[cur] = ((S[cur] - 'A' + N) % 26) + 'A';
		cur++;
	};

	printf("%s", S);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL lpow(LL a,LL n){LL ans=pow(a,n)*10;if(ans%10<5)return ans/10;return ans/10+1;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
int scmpr(const void* a,const void* b){return strcmp(*(char**)b,*(char**)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL N,i,ans=0;
  scanf("%lld",&N);
  LL A[N];
  FOR(i,0,N)scanf("%lld",&A[i]);
  FOR(i,0,N)if(A[i]%2==0&&A[i]%3!=0&&A[i]%5!=0)ans=1;
  if(ans==1)printf("DENIED");
  else printf("APPROVED");

  //printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {


			int k = sc.nextInt();
			String s = sc.next();

			if ( s.length() <= k ) {
				System.out.println(s);
			}
			else {
				System.out.println(s.subSequence(0, k) + "...");
			}
		}
	}

}

Measured memory_bytes: 38672
parseInt(x) = parse(Int, x)
MOD = 10^9+7

function F(x)
    factorial(big(x))
end

function Comb(n, k)
    return div(F(n),F(k)*F(n-k)) % MOD
end
function main()
    x, y = parseInt.(split(readline()))
    z = min(x, y)
    ans = 0
    if (x + y) % 3 == 0
        n = Int((x + y) / 3)
        l = z - n
        if l >= 0
            ans = Comb(n,l)
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 128792
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string.h>
using namespace std;
typedef long long int llint;
int main() {
	int n;
	cin >> n;
	if (n % 10 == 9) {
		cout << "Yes" << endl;
	}
	else {
		n /= 10;
		if (n == 9) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

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

int64_t solve(vector<int64_t> &g, vector<int64_t> &as, int64_t now)
{
	if (0 <= g[now])
	{
		return g[now];
	}
	vector<int64_t> puni;
	for (auto &a : as)
	{
		if (0 <= now - a)
		{
			puni.emplace_back(solve(g, as, now - a));
		}
	}
	sort(puni.begin(), puni.end());
	for (int64_t i = 0;; i++)
	{
		auto itr = lower_bound(puni.begin(), puni.end(), i);
		if (itr != puni.end() && *itr == i)
		{
			continue;
		}
		g[now] = i;
		break;
	}
	return g[now];
}

int main()
{
	int64_t n, k;
	cin >> n >> k;
	vector<int64_t> as(n);
	for (auto &a : as)
	{
		cin >> a;
	}
	vector<int64_t> g(k + 1, -1);
	g[0] = 0;
	cout << (solve(g, as, k) ? "First" : "Second") << endl;
	return 0;
}

Measured memory_bytes: 12416
n,m=map(int,input().split())
c=[]
d=[]
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    c.append(b)
  if b==n:
    d.append(a)
#O(m)
if len(set(c)&set(d))!=0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")





Measured memory_bytes: 21836
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

class Siki {

	int stack[100];		//????????????
	int num;			//????´???°

	

public:
	Siki() {
		num = 0;
	}

	void push( int val ) {
		if (num >= 100) {
			cout << "overflow" << endl;
			return;
		}
		stack[num] = val;
		num++;
	}

	int pop() {
		if (num == 0) {
			cout << "underflow" << endl;
			return -1;
		}
		num--;
		return stack[num];
	}

	int getTop() { return stack[num-1]; }
	int getValue(int n) { return stack[n]; }

};

int main() {

	Siki s;

	//??°???????????§7??? 100?????\??????700????????\???
	//?????????99?????\?????????99????????\???
	//????¨?800????????§??????

	char input[800];
	for (int i = 0; i < 800; i++) {
		input[i] = '\0';
	}

	gets(input);

	int kazu = 0;
	char in[100];

	while (sscanf(input, "%s", in, sizeof(in) ) == 1) {

		if(in[0] == '+'){
			int a = s.pop();
			int b = s.pop();
			s.push(b + a);
		}
		else if (in[0] == '-') {
			int a = s.pop();
			int b = s.pop();
			s.push(b - a);
		}
		else if (in[0] == '*') {
			int a = s.pop();
			int b = s.pop();
			s.push(b * a);
		}
		else if (in[0] == '/') {
			int a = s.pop();
			int b = s.pop();
			s.push(b / a);
		}
		else {
			
			s.push( atoi(in) );
			
		}
		int l = strlen(in) + 1;
		for (int i = 0; i < 800-l; i++) {
			input[i] = input[i + l];
		}
		
	}
	cout << s.pop() << endl;
	
	return 0;


}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, C;
  cin >> N >> C;

  vector<PLL> xs(2*N);
  REP(i,N){
	cin >> xs[i];
  }

  LL ans = 0;
  LL sum = 0;
  VL accr(N+1), accl(N+1);
  REP(i,N){
	sum += xs[i].SS;
	accr[i+1] = max(accr[i], sum - xs[i].FF);
	maxi(ans, accr[i+1]);
  }
  sum = 0;
  for(int i=N-1;i>=0;--i){
	sum += xs[i].SS;
	accl[i] = max(accl[i+1], sum - (C - xs[i].FF));
	maxi(ans, accl[i]);
  }

  sum = 0;
  REP(i,N){
	sum += xs[i].SS;
	maxi(ans, sum - 2*xs[i].FF + accl[i+1]);
  }
  sum = 0;
  for(int i=N-1;i>=0;--i){
	sum += xs[i].SS;
	maxi(ans, sum - 2*(C - xs[i].FF) + accr[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();    
        int N, M;
        {int[] a = r.ii(); N = a[0]; M = a[1];}
        int[] x = new int[M];
        int j = 0;
        for(int i = 0; i < M ; i++){
            int[] temp = r.ii();
            if(temp[0] == 1)
                x[j++] = temp[1];
            else if(temp[1] == N)
                x[j++] = temp[0];
        }
        Arrays.parallelSort(x, 0, j);
        for(int i = 0; i < j-1; i++){
            if(x[i] == x[i+1]){
                println("POSSIBLE");
                return;
            }
        }
        println("IMPOSSIBLE");
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 59936
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
const int INF=1001001001;

int main() {
  int N,A,B;
  cin>>N>>A>>B;
  string s;
  cin>>s;
  int t=A+B,d=B;
  for(int i=0;i<N;i++){
    if(t>0){
      if(s[i]=='a'){cout<<"Yes"<<endl;t--;}
      else if(s[i]=='b'&&0<d){cout<<"Yes"<<endl;t--;d--;}
      else{cout<<"No"<<endl;}
    }
    else{cout<<"No"<<endl;}
  }
  return 0;
}

Measured memory_bytes: 3724
#include <stdio.h>
int ch[15];
int main(){
	int n,i,k;
	char a,b;
	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%c%c",&b,&a);
		if(a=='G') ch[1]=1;
		else if(a=='P') ch[3]=1;
		else if(a=='Y') ch[2]=1;
		else ch[4]=1;	
	}
k=ch[1]+ch[2]+ch[3]+ch[4];
if(k==3) printf("Three");
else printf("Four");	
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int a,b,c;
  char op;
  while(1){
  scanf("%d %c %d",&a,&op,&b);
  
 if(op == '+'){
   c=a+b;
    printf("%d\n",c);
  }

 else if(op == '-'){
   c=a-b;
   printf("%d\n",c);
 }

 else if(op == '*'){
   c=a*b;
   printf("%d\n",c);
 }

 else if(op == '/'){
   c=a/b;
   printf("%d\n",c);
 }
 if(op == '?')break; 

  }
 return 0;
}

Measured memory_bytes: 600
# AliceとBobは、2人で1枚ポーカーを行います。
# 1枚ポーカーは、トランプを用いて行う2人ゲームです。
#
# 今回使用するトランプでは、各カードに 1 から 13 までの数が書かれています。
# カードの強さは、カードに書かれている数で決まり，強さの基準は以下の通りです。
# 弱 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9 < 10 < 11 < 12 < 13 < 1 強
#
# 1枚ポーカーは以下の手順で行います。
#
# 各プレイヤーは、トランプからカードを1枚選んで、自分の手札とします。
# 両プレイヤーは、手札を見せ合います。強いカードを持っているプレイヤーが勝ちです。
# なお、両プレイヤーの持っているカードの強さが同じ場合は引き分けです。
# 2人の対戦を眺めていたあなたは、AliceとBobの手札を知ることができます。
# Aliceが持っているカードに書かれている数は A、Bobが持っているカードカードに書かれている数は Bです。
# 2人の代わりに、勝敗を判定するプログラムを作ってください。

input_alice, input_bob = map(int,input().split())

result = 'ret'

if input_alice > input_bob:
    if input_bob == 1:      # Bobがエースなので勝ち～
        result = 'Bob'
    else:
        result = 'Alice'
elif input_alice < input_bob:
    if input_alice == 1:     # Aliceがエースなので勝ち～
        result = 'Alice'
    else:
        result = 'Bob'
else:
    result = 'Draw'         # どっちも同じ手札なので引き分け～

print(result)


Measured memory_bytes: 8896
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T &a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T &a, T b) {
	a = std::min(a, b);
}

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)
			return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)
		return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i;
		res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)
		return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod ;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int> engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/


signed main() {
	int n,a,b;cin>>n>>a>>b;
	if((b-a)%2==0){
		cout<<(b-a)/2<<endl;
	}else {
		int ans1=(a+b)/2;
		int ans2=((n-a)+(n-b))/2+1;
		cout<<min(ans1,ans2)<<endl;
	}
}


Measured memory_bytes: 256
N = int(input())
Menu = []
for _ in range(N):
    a, b = map(int, input().split())
    Menu.append((a + b, a, b))
Menu.sort(reverse=True)
ans = 0
for i, (_, a, b) in enumerate(Menu):
    if i % 2 == 0:
        ans += a
    else:
        ans -= b
print(ans)

Measured memory_bytes: 90612
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n; cin>>n;
    vector<string> w(n);
    rep(i,n) cin>>w[i];
    int cnt=0;
    rep(i,n-1){
        if(w[i].back()!=w[i+1].front()){
            cout<<"No"; return 0;
        }
        rep(j,n){
            if(w[i]==w[j]) cnt++;
        }
    }
    if(cnt==n-1) cout<<"Yes";
    else cout<<"No";
}

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

typedef struct{
  int k;
  int w[51];
  int p[51];
} Data;

int s,b,m;

typedef struct{
  int kingaku;
  int max_num;
} Ans;

Ans memo[110][60][310];

Ans dfs(Data d[], int f[], int i, int j, int nokori){
  Ans ans;
  if(i == b){
    ans.kingaku = 0;
    ans.max_num = 0;
    return ans;
  }

  if(memo[i][j][nokori].max_num != -1)
    return memo[i][j][nokori];

  int nexti = i;
  int nextj = j+1;

  if(j == d[f[i]].k){
    nextj = 0; nexti++;
  }

  ans = dfs(d,f,nexti,nextj,nokori);
  Ans tmp;

  if(nokori >= d[f[i]].p[j]){
    tmp = dfs(d,f,nexti,nextj,nokori-d[f[i]].p[j]);
    tmp.max_num += d[f[i]].w[j];
    tmp.kingaku += d[f[i]].p[j];
    if(tmp.max_num > ans.max_num){
      ans = tmp;
    }else if(tmp.max_num == ans.max_num && tmp.kingaku < ans.kingaku){
      ans = tmp;
    }
  }

  return memo[i][j][nokori] = ans;
}


int main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  Ans a;

  while(cin >> s >> b >> m){
    Data d[110] = {};
    int f[110] = {};
    for(int i = 0;i < s;i++){
      cin >> d[i].k;
      for(int j = 0;j < d[i].k;j++){
        cin >> d[i].w[j] >> d[i].p[j];
      }
    }

    for(int i = 0;i < b;i++){
      cin >> f[i];
    }

    memset(memo,-1,sizeof(Ans)*110*60*310);

    a = dfs(d,f,0,0,m);
    cout << a.max_num << " " << a.kingaku << endl;
  }

  return 0;
}






Measured memory_bytes: 19472
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define sort_v(a) sort(a.begin(), a.end())

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

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

    int cnt = 0;
    rep(i, 0, s.size())
    {
        if (i == 0)
        {
            if (s[i] != 'A')
            {
                cout << "WA" << endl;
                return 0;
            }
        }
        else
        {
            if (s[i] == 'C')
                cnt++;
        }
    }
    if (cnt != 1)
    {
        cout << "WA" << endl;
        return 0;
    }
    rep(i, 1, s.size())
    {
        if (s[i] == 'C')
        {
            if (!(i >= 2 && i < s.size() - 1))
            {
                cout << "WA" << endl;
                return 0;
            }
        }
        else
        {
            if (!islower(s[i]))
            {
                cout << "WA" << endl;
                return 0;
            }
        }
    }
    cout << "AC" << endl;
}


Measured memory_bytes: 256
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll n;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>n;
	cout<<(n/3);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.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 4000

struct Edge{
	Edge(int arg_to,ll arg_cost){
		to = arg_to;
		cost = arg_cost;
	}
	int to;
	ll cost;
};

struct Data{
	Data(ll arg_sum_cost){
		sum_cost = arg_sum_cost;
	}
	bool operator<(const struct Data &arg) const{
		return sum_cost > arg.sum_cost;
	}
	ll sum_cost;
};

int V,M;
ll weight_table[NUM];
vector<Edge> G[NUM];
vector<Data> DELI;

ll recursive(int node_id,int pre_node,int weight){

	vector<Data> TMP;
	ll tmp_cost;

	for(int i = 0; i < G[node_id].size(); i++){
		if(G[node_id][i].to == pre_node)continue;

		tmp_cost = weight*G[node_id][i].cost+recursive(G[node_id][i].to,node_id,weight);
		TMP.push_back(Data(tmp_cost));
	}

	if(TMP.size() == 0)return 0;

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

	for(int i = 1; i < TMP.size(); i++){
		DELI.push_back(TMP[i]);
	}

	return TMP[0].sum_cost;
}

int main(){

	scanf("%d %d",&V,&M);

	int from,to;
	ll cost;

	for(int loop = 0; loop < V-1; loop++){
		scanf("%d %d %lld",&from,&to,&cost);
		from--;
		to--;
		G[from].push_back(Edge(to,cost));
		G[to].push_back(Edge(from,cost));
	}

	for(int i = 0; i < V; i++){
		scanf("%lld",&weight_table[i]);
	}

	ll tmp_cost;

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

		tmp_cost = recursive(i,-1,weight_table[i]);
		DELI.push_back(Data(tmp_cost));
	}

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

	int max_index = min((int)DELI.size()-1,M-1);

	ll ans = 0;

	for(int i = 0; i <= max_index; i++){
		ans += DELI[i].sum_cost;
	}

	printf("%lld\n",ans);

	return 0;
}



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

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  long a,b,gap;
  vector<long> vec;
  vec.push_back(0);
  for(int ii=1;ii<=999;ii++){
	vec.push_back(ii+vec[ii-1]);
  }
  
  cin >> a >> b;
  gap = b - a;
  cout << vec[gap] - b;
  
  return 0;
}


Measured memory_bytes: 256
i,j,x,y,n,s;main(t){char a[99],b[99],c[99];scanf("%d",&n);while(n-->0){x=y=s=t=0;scanf("%s%s",a,b);while(a[++x]!='\0');while(b[++y]!='\0');for(x--,y--;x>=0||y>=0||t;){i=x<0?0:a[x]-'0';j=y<0?0:b[y]-'0';t=i+j+t;c[s]=t%10+'0';t=t>9?t/10:0;x>=0&&x--;y>=0&&y--;if(s++>80)break;}s>80&&puts("overflow");if(s<81){while(s-->0)printf("%c",c[s]);puts("");}}exit(0);}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#define ll long long
int mark[10];
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(c>=a&&c<=b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;





}



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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int X; cin >> X;
    int ans = 1;
    for(int b = floor(sqrt(X)); b > 1; b--)
    {
        int p = 2;
        while(true)
        {
            if(pow(b, p) > X) break;
            ans = max(ans, (int)pow(b, p));
            p++;
        } 
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <list>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

int main() {
	int n;
	while (cin >> n, n) {
		int a, b;
		char c;
		vi d(n), t(n), p(n);
		vector<char> e(n);
		int maxp = -1;
		REP(i, n) {
			cin >> a >> c >> b;
			d[i] = a * 100 + b;
			cin >> a >> c >> b;
			t[i] = a * 60 + b;
			cin >> e[i] >> p[i];
			maxp = max(maxp, p[i]);
		}

		vi isIn(maxp+1), inTime(maxp+1), sum(maxp+1);
		REP(i, n) {
			if (e[i] == 'I') {
				isIn[p[i]] = 1;
				inTime[p[i]] = t[i];
				if (p[i] == 0) {
					FOR(j, 1, maxp) {
						inTime[j] = t[i];
					}
				}
			}
			else {
				isIn[p[i]] = 0;
				if (p[i] == 0) {
					FOR(j, 1, maxp) {
						if (isIn[j]) {
							sum[j] += t[i] - inTime[j];
						}
					}
				}
				if (isIn[0]) {
					sum[p[i]] += t[i] - inTime[p[i]];
				}
			}
		}

		int ans = 0;
		FOR(i, 1, maxp) {
			ans = max(ans, sum[i]);
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll a;
  cin >> a;
  ll b;
  cin >> b;
  ll h;
  cin >> h;
  ll m;
  cin >> m;

  double hr = 2*M_PI / 720.0 * (h*60+m);
  double mr = 2*M_PI / 60 * m;
  double r = abs(hr - mr);

  printf("%.20lf\n", sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(r)));

  return 0;
}


Measured memory_bytes: 4156
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 

const int MAX = 1100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{ 
    int n,k;
    cin>>n>>k;
    //青赤青赤…青赤と並べて青i個赤i-1個使う。
    //求める答えは(k-i)+(i-1)C(i-1)*(n-k)-(i-1)+iCi
    // 前処理
    COMinit();
    for(int i=1;i<=k;i++){
        if(n-k>=i-1){
            cout<<(COM(k-1,i-1)*COM(n-k+1,i))%MOD<<endl;
        }
        else{cout<<0<<endl;}
    }
    return 0;
}

Measured memory_bytes: 25984
#include<bits/stdc++.h>
using namespace std;
unsigned long long ans = 1,n;
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i++)
		ans = ans * i % 1000000007;
	cout << ans << endl;
	return 0;
}

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }



int main() {
	
	int h, w;
	cin >> h >> w;
	
	VVI a(h + 1, VI(w + 1, 0));
	VVI b(h + 1, VI(w + 1, 0));
	REP(i, h)REP(j, w)cin >> a[i][j];
	REP(i, h)REP(j, w)cin >> b[i][j];

	vector<vector<vector<bool>>> dp(h+10, vector<vector<bool>>(w+10, vector<bool>(50900, false)));

	dp[0][0][25000 + a[0][0] - b[0][0]] = true;
	dp[0][0][25000 + b[0][0] - a[0][0]] = true;

	REP(i, h)REP(j, w) {
		REP(k, 50000) {
			if (dp[i][j][k]) {
				dp[i + 1][j][k + a[i + 1][j] - b[i + 1][j]] = true;
				dp[i + 1][j][k - a[i + 1][j] + b[i + 1][j]] = true;
				dp[i][j + 1][k + a[i][j + 1] - b[i][j + 1]] = true;
				dp[i][j + 1][k - a[i][j + 1] + b[i][j + 1]] = true;
			}
		}
	}
	int ans = INF;

	REP(i, 50000) {
		if (dp[h - 1][w - 1][i]) {
			ans = min(ans, abs(25000 - i));
		}
	}

	cout << ans << endl;

	


}



Measured memory_bytes: 51712
n,m = (int(i) for i in input().split())  
d = [[int(i) for i in input().split()] for i in range(n)] 
count = 0
for i,v in enumerate(d):
  for j in range(i+1,len(d)):
    sum = 0
    # print(d[i],d[j])
    for k in range(len(v)):
      sum += abs(d[i][k] - d[j][k])**2
    if pow(sum,1/2).is_integer():
      count += 1

print(count)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
   int n;cin >>n;
   V l(n);
    for (int i = 0; i < n; ++i) {
        cin >>l[i];
    }
    sort(all(l));
    ll ans=0;
    for (int i = 0; i < n; ++i) {
        for (int j =i+1; j < n; ++j) {
            int sum=l[i]+l[j];
            int key=lower_bound(all(l),sum)-l.begin();
            if(key==n)key--;
            if(l[key]>=sum)key--;
            ans+=key-j;
        }
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 3576
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#define SF scanf
#define PF printf
#define MAXN 200010
using namespace std;
int n;
int a[4][MAXN],x,y;
int b[MAXN];
int cnt1[2],cnt2[2];
int tree[MAXN];
void add(int x,int val){
    while(x){
        tree[x]+=val;
        x-=x&(-x);
    }
}
int que(int x){
    int res=0;
    while(x<=n){
        res+=tree[x];
        x+=x&(-x);
    }
    return res;
}
int main(){
	SF("%d",&n);
	for(int i=1;i<=3;i++)
		for(int j=1;j<=n;j++)
			SF("%d",&a[i][j]);
	for(int i=1;i<=n;i++){
		if(a[1][i]<a[2][i]&&a[2][i]>a[3][i]){
			PF("No");
			return 0;
		}
		if(a[1][i]>a[2][i]&&a[2][i]<a[3][i]){
			PF("No");
			return 0;
		}
		int miv=min(a[1][i],a[3][i]);
		int mav=max(a[1][i],a[3][i]);
		if(i%2==1){
			if(miv%6!=1||mav%6!=3){
				PF("No");
				return 0;
			}
		}
		else{
			if(miv%6!=4&&mav%6!=0){
				PF("No");
				return 0;
			}
		}
		if(a[1][i]>a[2][i]&&a[2][i]>a[3][i])
			cnt2[i%2]^=1;
		b[i]=miv/3+1;
	}
	for(int i=1;i<=n;i+=2){
		int now=que(b[i])+b[i];
		cnt1[1]=(cnt1[1]+abs(now-i)/2)%2;
		add(b[i],2);
	}
	memset(tree,0,sizeof tree);
	for(int i=2;i<=n;i+=2){
		int now=que(b[i])+b[i];
		cnt1[0]=(cnt1[0]+abs(now-i)/2)%2;
		add(b[i],2);
	}
	if(cnt1[0]!=cnt2[1]||cnt1[1]!=cnt2[0])
		PF("No");
	else
		PF("Yes");
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define mod 1000000007
#define eps 0.000000001
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<" "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double PI = acos(-1.0);

void cp()
{
    int k;
    string s;
    cin >> k >> s;
    if(ln(s) <= k)
        cout << s;
    else
    {
        string t;
        for(int i = 0; i < k; i++)
            t += s[i];
        cout << t << "...";
    }
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

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

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 305, MOD = 998244353;
int dp[N][N][N], a[N];

void add(int &a, int b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}

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

	int n = 0, k;
	string s;
	cin >> s >> k;

	k = min(k, N - 1);

	for (const char &c : s) {
		if (c == '0')
			n++;
		else
			a[n]++;
	}

	n++;

	reverse(a, a + n);

	dp[0][0][0] = 1;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < N; j++) {
			for (int z = 0; z < N; z++) {
				if (dp[i][j][z]) {
					for (int h = 0; h <= a[i] + j; h++) {
						add(dp[i + 1][j + a[i] - h][z + max(0, a[i] - h)], dp[i][j][z]);
					}
				}
			}
		}
	}

	int ans = 0;

	for (int i = 0; i <= k; i++) {
		add(ans, dp[n][0][i]);
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 30704
<?php /*test.php*/

$t = new temp();

$t->stdin(fgets(STDIN));

unset($t);

class temp{
	private $stdin = array();
	
	public function __construct(){
	}

	public function stdin($data = null){
		$this->stdin = explode(" ", $data);
		
		$a = 0;
		
		for($i = 1; $i <= $this->stdin[0]; $i++){
			if($i < 10){
				if($i >= $this->stdin[1] &&
					$i <= $this->stdin[2]){
					$a += $i;
				}
			}else{
				$buf = str_split($i);
				$temp = 0;
				foreach($buf as $num){
					$temp += $num;
				}
				unset($num);
				if($temp >= $this->stdin[1] &&
					$temp <= $this->stdin[2]){
					$a += $i;
				}
			}
		}
		unset($i);
		echo "$a";
	}
}

?>


Measured memory_bytes: 3828
/* ***********************************************
Author        :yang12138
Created Time  :2018年01月07日 星期日 22时25分59秒
File Name     :A.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

void solve(){
	int a,b,c;
	scanf("%d/%d/%d",&a,&b,&c);
	printf("2018/01/%02d\n",c);
}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define FACE_LIMIT 6
#define FACE_NUMBER_LIMIT 100

typedef struct {
	int number[FACE_LIMIT];
} DICE_NUMBER_MAPPER;

typedef struct {
	DICE_NUMBER_MAPPER number[FACE_LIMIT];
} DICE;

typedef struct {
	int forward;
	int top;

	int answer;
} QNA;

int InputDice(DICE* dice);
int ContainsNumber(int* num, int question, int size);
int GetQuestion(int* num, QNA* res);
void GetAnswer(DICE* dice, QNA* qnas, int size);
void NumbersToMapper(int* numbers, DICE_NUMBER_MAPPER* mapper);

int main(void) {
	DICE dice;
	QNA* qnas;
	int idx;
	int size;

	while(InputDice(&dice));

	do {
		scanf("%d", &size);
	} while(size < 1 || size > 24);

	qnas = (QNA*)malloc(sizeof(QNA) * size);
	for (idx = 0; idx < size; idx++) {
		QNA qna;
		GetQuestion(dice.number[0].number, &qna);
		*(qnas + idx) = qna;
	}

	GetAnswer(&dice, qnas, size);

	for (idx = 0; idx < size; idx++) {
		QNA qna = *(qnas + idx);
		printf("%d\n", qna.answer);
	}

	free(qnas);
}

int InputDice(DICE* dice) {
	int size;
	int nums[FACE_LIMIT];
	DICE_NUMBER_MAPPER mapper[FACE_LIMIT];

	for (size = 0; size < FACE_LIMIT; size++) {
		scanf("%d", &nums[size]);
		if (nums[size] < 0 || nums[size] > 100 || ContainsNumber(nums, nums[size], size)) {
			return -1;
		}
	}

	NumbersToMapper(nums, mapper);
	memcpy(dice->number, mapper, sizeof(DICE_NUMBER_MAPPER) * (FACE_LIMIT + 1));

	return 0;
}

int ContainsNumber(int* num, int question, int size) {
	int idx;

	for (idx = 0; idx < size; idx++) {
		if (*(num + idx) == question) {
			return 1;
		}
	}

	return 0;
}

int GetQuestion(int* num, QNA* res) {
	int a;
	int b;

	scanf("%d %d", &a, &b);
	if (!ContainsNumber(num, a, FACE_LIMIT) ||
		!ContainsNumber(num, b, FACE_LIMIT)) {
		return -1;
	}

	res->top = a;
	res->forward = b;

	return 0;
}

void GetAnswer(DICE* dice, QNA* qnas, int size) {
	int idx;
	int idm;
	int idq;

	for (idq = 0; idq < size; idq++) {
		QNA* qna = (qnas + idq);
		int forward = qna->forward;
		int top = qna->top;

		for (idx = 0; idx < FACE_LIMIT; idx++) {
			DICE_NUMBER_MAPPER map = dice->number[idx];
			int isFind = 0;

			if (map.number[0] == top) {
				for (idm = 1; idm < FACE_LIMIT - 1; idm++) {
					if (map.number[idm] == forward) {
						int tmpIdx = idm + 1 == FACE_LIMIT - 1 ? 1 : idm + 1;
						qna->answer = map.number[tmpIdx];
						isFind = 1;
						break;
					}
				}
			}

			if (isFind) {
				break;
			}
		}
	}
}

void NumbersToMapper(int* numbers, DICE_NUMBER_MAPPER* mapper) {
	int id1;
	int id2;

	int set[][FACE_LIMIT] = {
			{ 0, 1, 2, 4, 3, 5 }
			,{ 1, 0, 3, 5, 2, 4 }
			,{ 2, 0, 1, 5, 4, 3 }
			,{ 3, 1, 0, 4, 5, 2 }
			,{ 4, 0, 2, 5, 3, 1 }
			,{ 5, 1, 3, 4, 2, 0 }
	};

	for (id1 = 0; id1 < FACE_LIMIT; id1++) {
		for (id2 = 0; id2 < FACE_LIMIT; id2++) {
			DICE_NUMBER_MAPPER* map = mapper + id1;
			map->number[id2] = *(numbers + set[id1][id2]);
		}
	}
}


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

int INF = 1e9;
int n, m;

struct Edge{
    /*辺の情報を入れる構造体で行き先とコストを表している*/
    //g[a].push_back(edge(b, c))みたいな感じでいれる
    int to, cost;
    Edge(int to, int cost) : to(to), cost(cost) {}
};

vector<Edge> g[105];//edgeの配列でmax_vに対応するindexは各頂点のindex　それぞれのg[v]に対して複数のedgeが入っている
vector<vector<ll> > d(105, vector<ll>(105));//距離
vector<vector<pair<ll, int> > > costvec(105, vector<pair<ll, int> >(105));
vector<bool> use(1005, false);
 
void warshall_floyd(void){
    rep(k, n)rep(i, n)rep(j, n) {
        d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
    }
}

int main(void){
    cin>>n>>m;
    rep(i, 105)rep(j, 105) d[i][j] = INF;
    rep(i, 105) d[i][i] = 0;
    rep(i, n)rep(j, n) costvec[i][j] = make_pair(INF, INF);
    rep(i, m){
        int a, b, c;
        cin>>a>>b>>c;
        --a;--b;
        g[a].push_back(Edge(b, c));
        g[b].push_back(Edge(a, c));
        d[a][b] = c;
        d[b][a] = c;
        costvec[a][b] = make_pair(c, i);
        costvec[b][a] = make_pair(c, i);
    }
    warshall_floyd();
    int ans = m;
    int now = 0;
    /*rep(i, n){
        rep(j, n){
            cout<<d[i][j]<<" ";
        }
        cout<<endl;
    }*/
    rep(k, n){
        rep(i, n)rep(j, n){
            if(d[k][i] == d[k][j] + costvec[i][j].first && use[costvec[i][j].second] == false){
                //cout<<i<<j<<k<<endl;
                now++;
                use[costvec[i][j].second] = true;
            }
        }
    }
    cout<<m-now<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 

using namespace __gnu_pbds;
using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) (n).begin(), (n).end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
    else cout << "No\n";
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <time.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 2147483647

int main() {
	ios_base::sync_with_stdio(false);
	
	int a; cin >> a;
	string s; cin >> s; 
	if (a >= 3200) {
		cout << s << "\n";
	}
	else {
		cout << "red" << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc014.contest.atcoder.jp/tasks/agc014_b>
問題文============================================================
 高橋君は木の問題が苦手です。そこで、青木君は高橋君の練習相手になってあげることにしました。
 
 まず、高橋君は N 頂点からなる木を用意し、頂点に 1 から N の番号を付けました。 そして、各辺に 0 と書きました。
 
 次に、青木君は高橋君に M 個のクエリを与えました。i 個目のクエリは以下のような内容です。
 
 頂点 ai と頂点 bi を結ぶパス上の辺すべてに対して、書かれている数を 1 増やす。
 全てのクエリを終えた後、高橋君は青木君にどの辺を見ても書かれている数が偶数になったと伝えました。
 しかし、青木君は最初に高橋君が用意していた木を確認していなかったので、
 高橋君が正しくクエリを処理できたか分かりませんでした。
 
 青木君を助けるために、高橋くんの言う性質を満たす木が存在するかどうかを判定してください。
=================================================================

解説=============================================================
適当に投げて見たら通った。
 全ての頂点の次数が偶数であればok
 一つでも奇数が存在すると　木が作れないことが証明できるらしい（根つき木やLCAで考える）
 詳細は解説を読む
================================================================
*/
string solve(){
    ll N,M; cin >> N >> M;
    vector<ll> a(M),b(M);
    for(int i = 0; i < M;i++){
        cin >> a[i] >> b[i];
    }
    vector<ll> cnt(N+1);
    for(int i = 0; i < M;i++){
        cnt[a[i]]++; cnt[b[i]]++;
    }
    for(auto v:cnt){
        if(v&1) return "NO";
    }
    return "YES";
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


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

const int MOD = 1000000007;
int n;

struct Matrix
{
    int arr[50][50];
    
    Matrix& mult(const Matrix B)
    {
        Matrix A;
        swap(*this, A);
        
        for (int i = 0; i != n; ++i)
        {
            for (int j = 0; j != n; ++j)
            {
                arr[i][j] = 0;
                for (int k = 0; k != n; ++k)
                    arr[i][j] = (arr[i][j] + A.arr[i][k] * (long long) B.arr[k][j]) % MOD;
            }
        }
        
        return *this;
    }
    
    Matrix& exp(long long e)
    {
        Matrix A;
        swap(*this, A);
        
        for (int i = 0; i != n; ++i)
            for (int j = 0; j != n; ++j)
                arr[i][j] = (i == j);
        
        while (e)
        {
            if (e & 1) mult(A);
            A.mult(A);
            e >>= 1;
        }
        
        return *this;
    }
};

int main()
{
    long long k;
    cin >> n >> k;
    Matrix adj_mat;
    for (int i = 0; i != n; ++i)
        for (int j = 0; j != n; ++j)
            cin >> adj_mat.arr[i][j];
    
    adj_mat.exp(k);
    int ans = 0;
    for (int i = 0; i != n; ++i)
        for (int j = 0; j != n; ++j)
            ans = (ans + adj_mat.arr[i][j]) % MOD;
    
    cout << ans;
}

Measured memory_bytes: 256