akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a, b) << " " << max((ll)0, (a + b) - n) << endl;
}


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

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int k=0,length=0,i=0,max=0,sum=0;
            boolean first=true;
            int[] card=null;
            
            while ((line = br.readLine()) != null) {
            	if(line.equals("0 0"))break;
	            if(first){
	            	String[] tokens=line.split(" ");
	            	length=Integer.parseInt(tokens[0]);
	            	card=new int[length];
	            	k=Integer.parseInt(tokens[1]);
	            	first=false;
	            	i=0;
	            }else{
	            	card[i]=Integer.parseInt(line);
	            	i++;
	            	sum=0;
	            	if(i>=k){
	            		for(int j=i-k;j<i;j++){
	            			sum+=card[j];
	            		}
	            		if(i==k){
	            			max=sum;
	            		}else if(sum>max){
	            			max=sum;
	            		}
	            	}
	            	if(i==length){
	            		System.out.println(max);
	            		first=true;
	            	}
	            }
            }
        }
    }

}

Measured memory_bytes: 34876
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,m;
    cin >> n;
    m = n % 10;
    switch(m){
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
            break;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
using namespace std;
int N;
int ans[1<<17];
vector<pair<int,int> >G[1<<17];
void dfs(int u,int p,int pc)
{
	int nc=1;
	for(pair<int,int>q:G[u])
	{
		int v=q.first;
		if(v==p)continue;
		if(nc==pc)nc++;
		ans[q.second]=nc;
		dfs(v,u,nc);
		nc++;
	}
}
main()
{
	cin>>N;
	for(int i=0;i<N-1;i++)
	{
		int u,v;cin>>u>>v;
		u--,v--;
		G[u].push_back(make_pair(v,i));
		G[v].push_back(make_pair(u,i));
	}
	int id=0;
	for(int i=1;i<N;i++)
	{
		if(G[id].size()<G[i].size())id=i;
	}
	cout<<G[id].size()<<endl;
	dfs(id,-1,0);
	for(int i=0;i<N-1;i++)cout<<ans[i]<<endl;
}


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

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() //string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  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;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 0;
  ll x;
  cin >> x;

  if (x == 2 || x == 3)
  {
    cout << x;
    return 0;
  }
  while (true)
  {
    for (j = 2; j * j <= x; j++)
    {
      if (x % j == 0)
      {
        break;
      }
      if ((j + 1) * (j + 1) > x)
      {
        cout << x;
        return 0;
      }
    }
    x++;
  }
  cout << ans << endl;
}


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

int A[210000];

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

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

	std::sort(A,A+N);
	for(int i=0;i<N-1;i++){
		if(A[i]==A[i+1]){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 100000;
struct node{
    int R, C, A;
    friend bool operator < (node a, node b) {
        return a.A < b.A;
    }
}nd[MAXN + 5];
int fa[2*MAXN + 5], key[2*MAXN + 5], siz[2*MAXN + 5];
int find(int x) {
    return fa[x] = (fa[x] == x ? x : find(fa[x]));
}
int N, H, W;
int main() {
    long long ans = 0;
    scanf("%d%d%d", &N, &H, &W);
    for(int i=1;i<=H;i++) fa[i] = i, siz[i] = 1, key[i] = 0;
    for(int i=1;i<=W;i++) fa[i + H] = i + H, siz[i + H] = 1, key[i + H] = 0;
    for(int i=1;i<=N;i++)
        scanf("%d%d%d", &nd[i].R, &nd[i].C, &nd[i].A);
    sort(nd + 1, nd + N + 1);
    for(int i=N;i>=1;i--) {
        int fx = find(nd[i].R), fy = find(nd[i].C + H);
        if( fx == fy ) {
            if( siz[fx] >= key[fx] + 1 ) {
                key[fx]++;
                ans += nd[i].A;
            }
        }
        else {
            if( siz[fx] + siz[fy] >= key[fx] + key[fy] + 1 ) {
                siz[fx] += siz[fy], key[fx] += key[fy] + 1, fa[fy] = fx;
                ans += nd[i].A;
            }
        }
    }
    printf("%lld\n", ans);
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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

  s.erase(unique(s.begin(),s.end()),s.end());
  cout << s.size() << endl;

  return 0;
}


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

ll MOD = 1e9+7;

int main(){
    int n,k; cin >> n >> k;
    ll sum = 0;
    for(int i = k;i<=n+1;++i){
        ll a = i;
        ll b = n+1-i;
        sum += (a*b+1)%MOD;
        sum %= MOD;
    }
    cout << sum << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-7)
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1 
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
#define equals(a,b) (fabs((a)-(b)) < EPS)

using namespace std;

const int IINF = INT_MAX;

class Point{
public:
  double x,y;

  Point(double x = -IINF,double y = -IINF): x(x),y(y){}

  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}

};

double dot(Point a,Point b){ return a.x*b.x + a.y*b.y; }

double cross(Point a,Point b){ return a.x*b.y - a.y*b.x; }

double norm(Point a){ return a.x*a.x+a.y*a.y; }

double abs(Point a){ return sqrt(norm(a)); }

Point rotate(Point a,double rad){ return Point(cos(rad)*a.x - sin(rad)*a.y,sin(rad)*a.x + cos(rad)*a.y); }

double toRad(double agl){ return agl*M_PI/180.0; }

int ccw(Point p0,Point p1,Point p2){
  Point a = p1-p0;
  Point b = p2-p0;
  if(cross(a,b) > EPS)return COUNTER_CLOCKWISE;
  if(cross(a,b) < -EPS)return CLOCKWISE;
  if(dot(a,b) < -EPS)return ONLINE_BACK;
  if(norm(a) < norm(b))return ONLINE_FRONT;
  return ON_SEGMENT;
}

const int MAX_N = 110;
int N,M,Ume,Momo,SakuraHappyInnovation,counter[MAX_N],limit[3];
Point ps[MAX_N],p[3][20];
double d[3],w[110],a[110];

bool LT(double A,double B)  { return !equals(A,B) && A < B; }
bool LTE(double A,double B) { return  equals(A,B) || A < B; }

bool inside(Point h,Point t,double ta,double tw,double td){
  double rad_w = toRad(tw), rad_d = toRad(td/2.0);
  Point tmp = Point(ta*cos(rad_w),ta*sin(rad_w));
  Point alpha = rotate(tmp,-rad_d) + t;
  Point beta  = rotate(tmp,rad_d)  + t;
  int res_ccw = ccw(t,alpha,h);
  bool res1 = ( res_ccw != CLOCKWISE );
  res_ccw = ccw(t,beta,h);
  bool res2 = ( res_ccw != COUNTER_CLOCKWISE );
  double dist = abs(h-t);
  bool res3 = LTE(dist,ta);
  return res1 && res2 && res3;
}

inline void compute(){
  rep(i,N) counter[i] = 0;
  rep(_,M){
    rep(i,N){
      bool failed = false;
      if( inside(ps[i],Point(0,0),a[_],w[_],d[0]) ) {
        rep(j,3) if( !failed ) rep(k,limit[j]) failed |= inside(ps[i],p[j][k],a[_],w[_],d[j]);
      } else failed = true;
      if( !failed ) ++counter[i];
    }
  }
  int maxi = -1;
  rep(i,N) if( counter[i] != 0 ) maxi = max(maxi,counter[i]);
  if( maxi == -1 ) puts("NA");
  else {
    bool first = true;
    rep(i,N) if( counter[i] == maxi ){
      if( !first ) printf(" "); first = false;
      printf("%d",i+1);
    }
    puts("");
  }
}

int main(){
  while( scanf("%d %d",&N,&M), N|M ){
    rep(i,N) scanf("%lf %lf",&ps[i].x,&ps[i].y);
    scanf("%d %d %d %lf %lf %lf",&Ume,&Momo,&SakuraHappyInnovation,d,d+1,d+2);
    limit[0] = Ume, limit[1] = Momo, limit[2] = SakuraHappyInnovation;
    rep(i,Ume) scanf("%lf %lf",&p[0][i].x,&p[0][i].y);
    rep(i,Momo) scanf("%lf %lf",&p[1][i].x,&p[1][i].y);
    rep(i,SakuraHappyInnovation) scanf("%lf %lf",&p[2][i].x,&p[2][i].y);
    rep(i,M) scanf("%lf %lf",w+i,a+i);
    compute();
  }
  return 0;
}

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

int main(){
	string n;
	cin >> n;
	bool ok = false;
	rep(i,3){
		if(n[i] == '7') ok = true;
	}
	if(ok){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
    return 0;
}



Measured memory_bytes: 3596
a = [int(i) for i in input().split()]
if (a[0] == a[1] and a[0] != a[2]) or (a[0] == a[2] and a[0] != a[1]) or (a[2] == a[1] and a[2] != a[0]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9084
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)
//string s = to_string(i);
int a = 0, b = 0, x = 0, y = 0, z = 0, n = 0;
string s = ""; asas; cncn;

int main(void) {
	vcha a(9);
	rep(i, 9)cin >> a[i];
	cout << a[0] << a[4] << a[8] << rt;
	please AC;
}

Measured memory_bytes: 256
//
// C - 一次元リバーシ / 1D Reversi
//

#include <iostream>

using namespace std;

int main() {
    string S;
    cin >> S;
    int count = 0;
    for (int i = 0; i < S.length() - 1; i++) {
        if (S[i] != S[i + 1]) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N,A;

int main(){
    cin >> N >> A;
    if(N%500 <= A) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		Map<String, Integer> dic = new HashMap<>();
		int count = stdIn.nextInt();

		for(int i = 0; i < count; i++){
			int command = stdIn.nextInt();

			switch(command){
				case 0:
					dic.put(stdIn.next(), stdIn.nextInt());
					break;

				case 1:
					String key = stdIn.next();

					if(dic.get(key) != null){
						System.out.println(dic.get(key));
					}else{
						System.out.println(0);
					}

					break;

				case 2:
					dic.remove(stdIn.next());
					break;
			}


		}
		stdIn.close();
	}

}



Measured memory_bytes: 193624
#include <iostream>
#include <vector>

using nodes = std::vector<std::pair<int, int>>;

void make_tree(std::vector<nodes> const& rootless,
               int root,
               std::vector<int>& roots,
               std::vector<long long int>& dists) {
  for (auto const& p : rootless[root]) {
    auto c = p.first;
    if (roots[c] == 0) {
      roots[c] = root;
      dists[c] = dists[root] + p.second;
      make_tree(rootless, c, roots, dists);
    }
  }
}

int main() {
  int N;
  std::cin >> N;
  std::vector<nodes> rootless(N+1, nodes());

  for (int i=1; i<N; i++) {
    int a, b, c;
    std::cin >> a >> b >> c;
    rootless[a].emplace_back(b, c);
    rootless[b].emplace_back(a, c);
  }

  int Q, K;
  std::cin >> Q >> K;

  std::vector<int> roots(N+1, 0);
  std::vector<long long int> dists(N+1, 0);
  roots[K]=K;
  make_tree(rootless, K, roots, dists);

  for (int i=0; i<Q; i++) {
    int x, y;
    std::cin >> x >> y;

    std::cout << (dists[x] + dists[y]) << '\n';
  }

  return 0;
}


Measured memory_bytes: 16256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)


int main(){
    int n;
    scanf("%d",&n);
    int a[n-1];
    long sum=0;
    F(i,0,n-1){
        scanf("%d",a+i);
    }
    int b[n];
    F(j,0,n){
        b[j]=0;
    }
    F(j,0,n-1){
        b[a[j]-1]++;
    }
    F(k,0,n){
        printf("%d\n",b[k]);
    }
    return 0;
}

Measured memory_bytes: 3288
#include<iostream>
#include<string>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

int main(){

    string s; cin >> s;

    int n = s.size();

    string sub1 = s.substr(0, n/2);
    int n1 = sub1.size();
    // cout << sub1 << endl;
    string sub2 = s.substr(n/2 + 1, n);
    // cout << sub2 << endl;


    bool ans = true;
    
    rep(i, n1/2){
        if (sub1[i] != sub1[n1 - i - 1]) ans = false;
        // cout << sub1[i] << sub1[n1 - i - 1] << endl;
    }
    // cout << ans << endl;

    if (sub1 != sub2) ans = false;

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m,k[15]={},s[15][15]={},p[15]={},ans=0,cnt1,cnt2;
  cin >> n >> m;
  for(int i=0; i<m; i++) {
    cin >> k[i];
    for(int j=0; j<k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for(int i=0; i<m; i++) {
    cin >> p[i];
  }
  for(int i=0; i<(1<<n); i++) {
    cnt2=0;
    for(int j=0; j<m; j++) {
      cnt1=0;
      for(int l=0; l<k[j]; l++) {
        if(i&(1<<s[j][l]-1)) {
          cnt1++;
        }
      }
      if(cnt1%2==p[j]) {
        cnt2++;
      }
    }
    if(cnt2==m) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        string[] s = new string[a[0]];
        for (int i = 0; i < a[0]; i++)
        {
            s[i] = Console.ReadLine();
        }
        Console.WriteLine("".PadLeft(a[1] + 2, '#'));
        for (int i = 0; i < a[0]; i++)
        {
            Console.WriteLine($"#{s[i]}#");
        }
        Console.WriteLine("".PadLeft(a[1] + 2, '#'));
    }
}


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

void solve()
{
    char ch;
    cin>>ch;
    if(ch>='a'&&ch<='z')
        cout<<'a'<<endl;
    else
        cout<<'A'<<endl;
}

int main()
{
    solve();
}


Measured memory_bytes: 3556
import java.util.*;

class Main {
	public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        
        int num1 = sc.nextInt();
        int[] num = new int[num1];

        for(int i = 0;i < num1;i++){
            num[i] = sc.nextInt();
        }

        for(int i = num1;i > 0;i--){
            if(i == 1)  System.out.print(num[i -1]);
            else System.out.print(num[i - 1]+" ");
        }

        System.out.println();
    }
}



Measured memory_bytes: 26268
MOD = 10**9+7

N = int(input())
A = list(map(int, input().split()))

A_sum = sum(A)

r = 0
for i, a in enumerate(A):
    x = A[i]*(A_sum - a)
    r = (r+x) % MOD

# print(r)

r = (r * pow(2, MOD-2, MOD)) % MOD

print(r)

Measured memory_bytes: 31380
#include<iostream>
#include <string.h>
using namespace std;
int main()
{
	char a[4];
	cin.getline(a,4);
	if(!strcmp(a,"MON"))
		cout<<6<<endl;
	else if(!strcmp(a,"TUE"))
		cout<<5<<endl;
	else if(!strcmp(a,"WED"))
		cout<<4<<endl;
	else if(!strcmp(a,"THU"))
		cout<<3<<endl;
	else if(!strcmp(a,"FRI"))
		cout<<2<<endl;
	else if(!strcmp(a,"SAT"))
		cout<<1<<endl;
	else if(!strcmp(a,"SUN"))
		cout<<7<<endl;
	else
		return 0;
	return 0;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  ll a, b, k;
  cin >> a >> b >> k;
  if ((k < a) ) {
    cout << a - k << " " << b << endl;
  } else if (k < a + b) {
    cout << 0 << " " << b - (k - a) << endl;
  } else {
    cout << 0 << " " << 0 << endl;
  }
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;
int main()
{
  int H, W;
  cin >> H >> W;
  char data[H][W];
  for (int y = 0; y < H; y++)
  {
    for (int x = 0; x < W; x++)
    {
      cin >> data[y][x];
    }
  }

  for (int x = 0; x < W + 2; x++)
  {
    cout << '#';
  }
  cout << endl;

  for (int y = 0; y < H; y++)
  {
    cout << '#';
    for (int x = 0; x < W; x++)
    {
      cout << data[y][x];
    }
    cout << '#' << endl;
  }

  for (int x = 0; x < W + 2; x++)
  {
    cout << '#';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

template<class T, class U>inline bool chmax(T &a, const U &b) { if(a<b){ a=b; return 1; } return 0; }
template<class T, class U>inline bool chmin(T &a, const U &b) { if(b<a){ a=b; return 1; } return 0; }

int main() {
  int n; cin>>n;
  vector<pair<int, int>> ab(n);
  vector<int> as(n), bs(n);
  vector<int> acc(100010, 0);

  rep(i, n) {
    int a, b; cin>>a>>b;
    as[i] = a; bs[i] = b;
    ab[i].first = a; ab[i].second = b;
    ++acc[a]; --acc[b];
  }

  rep(i, 100010-1) acc[i+1] += acc[i];
  int s2 = *max_element(acc.begin(), acc.end());

  sort(as.begin(), as.end());
  sort(bs.begin(), bs.end());
  int s1 = s2;
  rep(i, n) {
    int a = ab[i].first, b = ab[i].second;
    int l = lower_bound(as.begin(), as.end(), b) - as.begin();
    int r = upper_bound(bs.begin(), bs.end(), a) - bs.begin();
    s1 = max(s1, l-r);
  }
  print(s1, s2);

  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

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

  VI a(n);
  REP(i,n)cin >> a[i];

  int mx = a[0];
  int cnt=1;
  FOR(i,1,n){
    if(mx < a[i]){
      mx = a[i];
      cnt++;
    }
  }

  if(k<=cnt){
    cout << 0 << endl;
    return(0);
  }

  ll ans=INF;
  REP(i,(1<<n)){
    if(__builtin_popcount(i) < k)continue;

    mx = a[0];
    ll cost = 0;
    FOR(j,1,n){
      if(mx < a[j]){
        mx = a[j];
        continue;
      }
      if((i>>j)&1){
        cost += mx - a[j] + 1;
        mx++;
      }
    }

    chmin(ans, cost);
  }

  cout << ans << endl;
}



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

using namespace std;

#define all(x) (x).begin(),(x).end()

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

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(void){

    int n;
    cin >> n;

    ll ans  = 0;
    for(int i = 1; i <= n; ++i){
        ll x = n / i;
        ans += x * (x + 1) * i / 2;
    }

    cout << ans << "\n";

    return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

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

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

void fail() {
  cout << "No\n";
  exit(0);
}

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};


int main() {
  int N;
  cin >> N;
  vector< int > A(N), B(N);
  cin >> A >> B;

  // 閉路がやばい
  // 一通りしかない場合
  vector< pair< int, int > > ev;
  for(int i = 0; i < N; i++) ev.emplace_back(A[i], 0);
  for(int i = 0; i < N; i++) ev.emplace_back(B[i], 1);
  sort(begin(ev), end(ev));
  int unmatch = 0;
  bool ok = false;

  for(auto &p : ev) {
    if(p.second == 0) {
      ++unmatch;
      if(unmatch >= 2) ok = true;
    } else {
      if(unmatch == 0) fail();
      --unmatch;
    }
  }

  if(ok) {
    cout << "Yes\n";
    exit(0);
  }
  UnionFind uf(N);
  vector< int > xs(A);
  sort(begin(xs), end(xs));
  xs.erase(unique(begin(xs), end(xs)), end(xs));

  vector< int > rev(N);
  for(int i = 0; i < N; i++) {
    A[i] = lower_bound(begin(xs), end(xs), A[i]) - begin(xs);
    B[i] = upper_bound(begin(xs), end(xs), B[i]) - begin(xs) - 1;
    rev[B[i]] = i;
  }
  for(int i = 0; i < N; i++) {
    A[i] = rev[A[i]];
    uf.unite(i, A[i]);
  }


  if(uf.size(0) == N) {
    fail();
  }

  cout << "Yes\n";


}



Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int N, K; cin >> N >> K;
    string S; cin >> S;
    string T = S;
    reverse(T.begin(), T.end());
    S += T;
    char minC = '~';
    int maxRep = 1;
    string minSuffix = "";
    for(int i=0;i<N;i++){
        if(S[i] > minC) continue;
        if(S[i] < minC){
            minC = S[i];
            maxRep = 0;
            minSuffix = "~";
        }
        int len = 0;
        for(int j=i;j<N+i;j++){
            if(minC == S[j]) ++len;
            else break;
        }
        int repLen = len;
        for(int j=1;j<K;j++){
            repLen *= 2;
            if(repLen >= N){
                repLen = N;
                break;
            }
        }
        string curSuffix = "";
        for(int j=i+len;j<N+i;j++){
            if(repLen + curSuffix.size() == N) break;
            curSuffix += S[j];
        }
        if(maxRep < repLen || maxRep == repLen && minSuffix > curSuffix){
            maxRep = repLen;
            minSuffix = curSuffix;
        }
    }
    cout << string(maxRep, minC) << minSuffix << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math

#tmp = input().split()
#n,m = list(map(lambda a: int(a), tmp))

k = int(input())
s = input()
#tmp = input().split()
#n,m,k = list(map(lambda a: int(a), tmp))


if(k>=len(s)):
	print(s)
	sys.exit()
print(s[0:k]+"...")





Measured memory_bytes: 9100
a, v = map(int, input().split())
b, w = map(int, input().split())
T = int(input())

if a == b:
    print("YES")
    exit(0)

if v <= w:
    print("NO")
    exit(0)

if a < b:
    t = (b-a) / (v-w)
#    mod_t = (b-a) % (v-w)
else:
    t = (a-b) / (v-w)
#    mod_t = (a-b) % (v-w)

if 0 < t <= T:
    print("YES")
else:
    print("NO")


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool OK = true;
  rep(i,n/2){
    if(s[i]!=s[n-i-1]) {
      OK = false;
      break;
    }
    else if(s[i]!=s[i+(n/2)+1]){
      OK = false;
      break;
    }
  }
  if(OK) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N, K;
    cin >> N >> K;
    int ans = 0;
    while(N){
        ans++;
        N /= K;
    }
    cout << ans << endl;
}


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

void fnInput(vector<int> &a_rviTarget, vector<int> &a_rviSearch)
{
  int iTargetCnt;
  cin >> iTargetCnt;

  for (int i = 0; i < iTargetCnt; i++)
  {
    int iTarget;
    cin >> iTarget;
    a_rviTarget.push_back(iTarget);
  }

  int iSearchCnt;
  cin >> iSearchCnt;

  for (int i = 0; i < iSearchCnt; i++)
  {
    int iSearch;
    cin >> iSearch;
    a_rviSearch.push_back(iSearch);
  }
}

void fnLinearSearch(const vector<int> &a_cnrviTarget, const vector<int> &a_cnrviSearch, int &a_riFound)
{
  for (auto itviSearch = begin(a_cnrviSearch); itviSearch != end(a_cnrviSearch); itviSearch++)
    for (auto itviTarget = begin(a_cnrviTarget); itviTarget != end(a_cnrviTarget); itviTarget++)
      if (*itviTarget == *itviSearch)
      {
        a_riFound++;
        break;
      }
}

void fnResultOut(int a_iFound)
{
  cout << a_iFound << endl;
}

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

  vector<int> viTarget, viSearch;
  int iFound = 0;

  fnInput(viTarget, viSearch);
  fnLinearSearch(viTarget, viSearch, iFound);
  fnResultOut(iFound);

  return 0;
}

Measured memory_bytes: 1328
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from bisect import bisect_left, bisect_right
from collections import Counter

# 主題　ICPC
# square route
# 使用言語:Python3
# URL:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2015&lang=jp


def how_many(a, x):
    # リストaのなかでxが何個あるのかを返す関数
    return bisect_right(a, x) - bisect_left(a, x)


def solve(n, m):
    # とく関数
    a = [int(input()) for _ in range(n)]
    b = [int(input()) for _ in range(m)]

    sum_a = [0 for i in range(n + 1)]
    sum_b = [0 for i in range(m + 1)]

    # sum_a[i]=縦の左からi番目までの累積和(i=0 の時は0と定義する)
    # sum_b[i]=横の左からi番目までの累積和(i=0　の時は0と定義する)

    for i in range(n):
        sum_a[i + 1] = sum_a[i] + a[i]

    for i in range(m):
        sum_b[i + 1] = sum_b[i] + b[i]

    all_range_h = []

    all_range_w = []

    for i in range(n + 1):
        for j in range(i + 1, n + 1):
            all_range_h.append(sum_a[j] - sum_a[i])

    for i in range(m + 1):
        for j in range(i + 1, m + 1):
            all_range_w.append(sum_b[j] - sum_b[i])

        # all_range_h=縦の長さでの、ありうる長さの組み合わせ（重複あり） =nC2
        # all_range_w=横の長さでの、ありうる長さの組み合わせ（重複あり） =mC2

    all_range_w.sort()
    # 縦の長さを決めて、（Lとする）そのとり方がX通りあったとする。この時、横の長さがLとなるものが何個あるのかを考える。これを考える際に二部探索するので予め縦の長さの組み合わせをソートしておく。
    # これをYとしたときX*Yがこの時のありうる総数である。

    ans = 0

    data_h = dict(Counter(all_range_h))

    # data_hに（key=ありうる縦の長さの個数、value=その取り方の総数)を持つ辞書を作る。

    for key in data_h.keys():
        ans += data_h[key] * how_many(all_range_w, key)

    return ans


flag = True

while flag:
    n, m = map(int, input().split())
    # 終わりのサイン:(n,m)=(0,0)
    if n == m == 0:
        flag = False
        break
    else:
        print(solve(n, m))







Measured memory_bytes: 77408
import scala.io.StdIn.readLine

object Main {
  def sum(n:Int, s:Int, x:Int):Int = {
    if(n==1) { if(s >= 0 && s<=9 && s > x ) 1 else 0 }
    else { for(i <- x+1 to (if(s<9) s else 9) ) yield sum(n-1,s-i,i) }.sum
  }

  def getSum(sb:StringBuilder):Unit = {
    val r = readLine.split(" ").map(_.toInt)

    if(r(0)==0 && r(1)==0) print(sb.result)
    else {
      println(sum(r(0),r(1),-1))
      getSum(sb)
    }
  }

  def main(args:Array[String]) = getSum(new StringBuilder)
}

Measured memory_bytes: 45736
a, b = map(int, input().split())

def getPrimeFactors(x):
    ans = []
    for d in range(2, int(x**0.5)+1):
        while x%d == 0:
            ans.append(d)
            x //= d
    if x != 1:
        ans.append(x)
    return ans

res_a = getPrimeFactors(a)
res_b = getPrimeFactors(b)

res = len(set(res_a) & set(res_b))
print(res + 1)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
Created on Tue Sep  8 01:23:04 2020

@author: liang
"""

N = int(input())
S = input()
R_list = list()
G_list = list()
B_list = list()

for i in range(N):
    if S[i] == 'R':
        R_list.append(i)
    elif S[i] == 'G':
        G_list.append(i)
    else:
        B_list.append(i)
#print(R_list, G_list, B_list)
ans = len(R_list)*len(G_list)*len(B_list)
"""
set1 = set()
for r in R_list:
    for g in G_list:
        # r < g
        if r > g:
           # print(r,g)
            r, g = g, r ##ダメ
           
            【rは絶対書き換えたらダメ】
            gのfor文中 rの値は固定して考えているので、
            外側ループの変数を書き換えるような演算をしてはいけない
              => for文内で別の変数（コピー）を用意し、そのコピーについて演算を行うこと
           
            #print(r,g)
        if 2*g - r < N and S[2*g-r] == 'B':
            set1.add((r,g))
            ans -= 1
        if 2*r - g >= 0 and S[2*r-g] == 'B':
            set1.add((r,g))
            ans -= 1
        if (r+g)%2 == 0 and S[(r+g)//2] =='B':
            set1.add((r,g))
            ans -= 1   
#ans = len(R_list)*len(G_list)*len(B_list)         
"""
for r in R_list:
    for g in G_list:
        up = max(r,g)
        down = min(r,g)
        diff = up - down
        if up + diff < N and S[up+diff] == 'B':
            ans -= 1
        if down - diff >= 0 and S[down - diff] == 'B':
            ans -= 1
        if diff%2 == 0 and S[down + diff//2] =='B':
            ans -= 1

print(ans)
        

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

int main() {
  int N;
  cin>>N;
  vector<int> d(N);
    for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  cout<<d.at(N/2)-d.at(N/2-1);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
#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 rsort(v) sort(v.rbegin(), v.rend())


int main() {
  int R,C,K;
  cin >> R >> C >> K;
  vector<vector<ll>> item(R+1,vector<ll>(C+1,0));
  rep(i,K) {
    int r,c; ll v;
    cin >> r >> c >> v;
    r--; c--;
    item[r][c] = v;
  }
  vector<vector<vector<ll>>> dp(R+1,vector<vector<ll>>(C+1,vector<ll>(4,0)));
  repr(i,R,0) {
    repr(j,C,0) {
      repr(k,3,0) {
        dp[i][j][k] = max(dp[i+1][j][0]+item[i][j],max(dp[i][j+1][k+1]+item[i][j],dp[i][j+1][k]));
      }
    }
  }
  print(dp[0][0][0]);
  return 0;
}

Measured memory_bytes: 707328
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int a[10][10], x, y, s;

signed main() {
	while (scanf("%d,%d,%d",&x,&y,&s)!=EOF) {
		if (s==3) {
			rep(i,10) rep(j,10) if (abs(i-x)+abs(j-y)<=2) a[i][j]++;
		}
		else {
			a[x][y]++;
			rep(d,4*s) {
				int xx = x+(s==1?dx:ddx)[d], yy = y+(s==1?dy:ddy)[d];
				if (!ool(xx,yy,10,10)) a[xx][yy]++;
			}
		}
	}
	int p = 0, q = 0;
	rep(i,10) rep(j,10) {
		if (a[i][j]) chmax(q,a[i][j]);
		else p++;
	}
	cout << p << endl << q << endl;
}



Measured memory_bytes: 3184
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
//#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
template <typename T>
void print(T x)
{
	std::cout << x << " ";
}
template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}
int main() {
	int a, s;
	cin >> a >> s;
	int ans = 0;
	rep(i, a+1) {
		if (i > s)break;
		rep(j, a+1) {
			int k = s - (i + j);
			if (k >= 0 && k <= a)ans++;
		}
	}print(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX


bool v[51][10001];
 
void solve()
{
   int n, m, s;
   cin >> n >> m >> s;
   vector<vector<pair<int,pii>>> q(n+1);
   rep(i,0,m-1)
   {
     int l, r, a, b;
     cin >> l >> r >> a >> b;
     q[l].pb({r,{a,b}});
     q[r].pb({l,{a,b}});
   }

   int c[n+1], d[n+1];
   rep(i,1,n)
    cin >> c[i] >> d[i];

   int limit =  10000;
   set<pair<int,pii>> q1;
   s = min(s,limit);
   q1.insert({0,{1,s}});
   int ans[n+1];
   rep(i,2,n)
    ans[i] = ll_MAX;

   while(q1.size())
   {
        pair<int,pii> curr = *q1.begin();
        q1.erase(q1.begin());
        int in = curr.sc.fr;
        int ss = curr.sc.sc;
        if(ss<0)
            continue;
        ss = min(ss, limit);
        int w = curr.fr;
        if(v[in][ss])
            continue;
        ans[in] = min(ans[in], w);
        v[in][ss] = 1;
        loop(q[in])
        {
            q1.insert({w+it.sc.sc,{it.fr,ss-it.sc.fr}});
        }
        q1.insert({w+d[in],{in,ss+c[in]}});
   }

   rep(i,2,n)
    cout << ans[i] << endl;

}


signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 68272