akhauriyash/Code-Regression huggingface dataset:
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
char mp[10][1000];
int nw[10][1000];
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
	int ret = 100000000;
	int h,w,k;cin>>h>>w>>k;
	for(int i = 0; h > i; i++){
		for(int j = 0; w > j; j++){
			cin>>mp[i][j];
		}
	}
	for(int bit = 0; (1<<(h-1)) > bit; bit++){
		int z = 0;
		for(int i = 0; h > i; i++){
			for(int j = 0; w > j; j++){
				nw[i][j]=0;
			}
		}
		for(int j = 0; w > j; j++){
			nw[0][j] += mp[0][j]-'0';
		}
		for(int i = 1; h > i; i++){
			bool in = false;
			if(bit & (1<<(i-1))){
				//cout << i << endl;
				in = true;
			}
			if(in){
				z++;
			}
			for(int j = 0; w > j; j++){
				nw[z][j] += mp[i][j]-'0';
			}
		}
		int wh[10];
		for(int i = 0; z >= i; i++){
			wh[i]=0;
		}
		int ans = 0;
		bool dd = false;
		bool _quit = false;
		for(int i = 0; w > i; i++){
			for(int j = 0; z >= j; j++){
				//cout << "(" << wh[j] << " ";
				wh[j]+=nw[j][i];
				//cout << wh[j] << ") ";
				if(wh[j] > k){
					dd=true;
				}
			}
			if(dd){
				ans++;
				//cout << "|";
				for(int j = 0; z >= j; j++){
					if(k < nw[j][i]){
						_quit=true;
						break;
					}
					wh[j]=nw[j][i];
				}
				dd=false;
			}
			if(_quit)break;
		}
		//cout << endl;
		//cout << (_quit?1:0) << " " << ans << " " << __builtin_popcount(bit) << endl;
		if(!_quit)ret = min(ret,ans+__builtin_popcount(bit));
	}
	cout << ret << endl;
}

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


using namespace std;

int main()
{long long int N;
cin>>N;
long long int A = 2*N;
long long int S[A];
for(int x = 0;x<A;x++){
    cin>>S[x];
}
sort(S,S+A);
long long int B = 0;
for(int x = 0;x<A;x+=2){
    B+=S[x];
}
cout<<B<<endl;
}


Measured memory_bytes: 256
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial,sin
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

h,w,a,b=MI()
lis=[[0]*w for i in range(h)]
for i in range(b):
    for j in range(w):
        if j<a:
            lis[i][j]=1
        else:
            lis[i][j]=0
#print(lis)
for i in range(h-b):
    for j in range(w):
        if j<a:
            lis[i+b][j]=0
        else:
            lis[i+b][j]=1
#print(lis)
for i in range(h):
    for j in range(w):
        print(lis[i][j],end="")
    print()
            
        



        
    
    


    


    


Measured memory_bytes: 18012
#include<iostream>

using namespace std;

int fe(int W) {
    for(int l = 0; l < W; l++) {
        if(l%2) {
            cout << '#';
        }else{
            cout << '.';
        }
    }
    cout << endl;
    return 0;
}

int me(int W) {
    for(int l = 0; l < W; l++) {
        if(l%2) {
            cout << '.';
        }else{
            cout << '#';
        }
    }
    cout << endl;
    return 0;
}

int main(){
    int i, l, H=0, W=0;
    while(1){
        cin >> H >>  W;
        if(H == 0 && W == 0) {
            return 0;
        } else {
            for(i = 0; i < H; i++) {
                if(i%2) {
                    fe(W);
                }else{
                    me(W);
                }
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define MAX 1000000007

using namespace std;

lli a[50][2],b[50][2];


int main() {
    int n,m;
	cin >> n>>m;
	
    rep0(i,n)cin >> a[i][0] >> a[i][1];
    rep0(i,m)cin >> b[i][0] >> b[i][1];
    
   
    for(int i=0;i<n;i++){
         lli ans_p=1000000007;
         int ans;
        for(int j=0;j<m;j++){
            if(abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1])<ans_p){
                ans_p=abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1]);
                ans=j+1;
            }
        }
        cout << ans << endl;
    }
    
}




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

using namespace std;

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

const ll M = 1e9+7;
const ll INF = 1e9+7;

ll n, m, k;
ll par[110000], ch[110000], bl[110000];

ll root(ll v) {
  if (par[v] == v) return v;
  return par[v] = root(par[v]);
}

int main() {
  cin >> n >> m >> k;
  
  for (ll i = 0; i < n; i++) {
    par[i] = i;
  }
  
  for (ll i = 0; i < m; i++) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    bl[a]++; bl[b]++;
    a = root(a);
    b = root(b);
    par[a] = b;
  }
  
  for (ll i = 0; i < n; i++) {
    ch[root(i)]++;
  }
  
  for (ll i = 0; i < k; i++) {
    ll c, d;
    cin >> c >> d;
    c--; d--;
    if (root(c) == root(d)) {
      bl[c]++; bl[d]++;
    }
  }
  
  for (ll i = 0; i < n; i++) {
    cout << ch[root(i)] - bl[i] - 1 << " ";
  }
  
  cout << endl;
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

#define int ll



signed main(){
    int r,g;
    cin>>r>>g;
    cout<<g*2-r<<endl;
    return 0;
}

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

int main(){
  int x[101],i=0,p=0;
  char s[201];

  while( scanf("%s",s) != EOF){
    if ( s[0] == '+' ){
      x[p-1]=x[p-1] + x[p];
      p--;
      
    } else if ( s[0] == '-' ){
      x[p-1]=x[p-1] - x[p];
      p--;
    } else if ( s[0] == '*' ){
      x[p-1]=x[p-1] * x[p];
      p--;
    } else {
      p++;
      x[p] = atoi(s);
      
    }
  }
  printf("%d\n",x[p]);
  return 0;
}

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

int main()
{
    int n,k,x;
    long long sm=0;
    vector <int>v;

    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<k;i++){
        sm+=v[i];
    }
    cout << sm << endl;
    return 0;
}


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

set<char> ACGT{'A', 'C', 'G', 'T'};

int main() {
  string S;
  cin >> S;
  int ans{}, len{};
  for (const char &c : S) {
    if (ACGT.find(c) != ACGT.end()) {
      ++len;
    } else {
      ans = max(ans, len);
      len = 0;
    }
  }
  ans = max(ans, len);

  cout << ans << endl;
  return 0;
}


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

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans=max(a*b,c*d);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                           //     #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;
                                        
                                  class pas{
                                    	public:
                                    	int x,y;
                                    	pas(int x=0,int y=0):x(x),y(y) {}
                                    	pas operator + (pas p) {return pas(x+p.x,y+p.y);}
                                    	pas operator - (pas p) {return pas(x-p.x,y-p.y);}
                                    	pas operator * (int a) {return pas(x*a,y*a);}
                                    	pas operator / (int a) {return pas(x/a,y/a);}
                                    //	double absv() {return sqrt(norm());}
                                    	int norm() {return x*x+y*y;}
                                    	bool operator < (const pas &p) const{
                                    		return x != p.x ? x<p.x: y<p.y;
                                    	}
                                    	bool operator == (const pas &p) const{
                                    		return x==p.x && y==p.y;
                                    	}
                                    };

           signed main(){
        
           	int n;
           	cin>>n;
           	
           	for(int i=n;i>=1;i--){
           		if((i&-i)==i){
           		cout<<i<<endl;
           			return 0;
           		}
           	
           	}
           	
           //	cout<<-1<<endl;
           	
           	return 0;
           	
           	
           }
             

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

map<ll,ll> prime_factor(ll n) {
  map<ll,ll> ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 2; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(all(ret));
  return (ret);
}

int main() {
    ll n;
    cin >> n;
    /* map<ll,ll> x=prime_factor(n);
    for(auto y:x)debug(y.S);*/
    vector<ll> x=divisor(n);
    vector<ll> y=divisor(n-1);
    int ans=1;
    for(auto p:x){
        ll temp=n;
        while(temp%p==0)temp/=p;
        if((temp-1)%p==0)ans++;
    }
    ans+=sz(y);
  	if(n!=2)ans++;
    cout << ans;


}

/*



 */




Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int a, b, c, d, e, f;
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
	int x;
	x = a + b + c + d + e + f - min(a, min(b, min(c, d))) - min(e, f);
	printf("%d\n", x);

	return 0;
}

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

using namespace std;
struct res{
    string name;
    int order;
    int score;
}a[200];

bool cmp(res x, res y)
{
    if(x.name==y.name) return x.score>y.score;
    else return x.name<y.name;
}
int main()
{
    int n;
    while(scanf("%d",&n)!=-1)
    {
        getchar();
        for(int i=1;i<=n;i++)
        {
             cin>>a[i].name>>a[i].score;
             a[i].order=i;
        }
        sort(a+1,a+n+1,cmp);
        for(int i=1;i<=n;i++)
        {
            cout<<a[i].order<<endl;
        }
    }

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int K,A,B;
	cin>>K>>A>>B;
	if(K==1)cout<<"OK"<<endl;
	else {
		for(int i=A;i<=B;i++){
			if(i%K==0){
				cout<<"OK"<<endl;
				break;
			}
			if(i==B)cout<<"NG"<<endl;
		}
	}
}

Measured memory_bytes: 3124
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.bitmanip;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  string s; readV(s);
  int x, y; readV(x, y);

  auto ss = s.split('T').map!(si => si.length.to!int).array;
  int[] u, v;
  foreach (i, si; ss[1..$]) {
    if (i%2 == 0) u ~= si.to!int;
    else          v ~= si.to!int;
  }

  writeln(calc(u, 0, y) && calc(v, ss[0], x) ? "Yes" : "No");
}

auto calc(int[] u, int p0, int pg)
{
  auto ofs = 8010, b = new bool[](ofs*2+1), b2 = new bool[](ofs*2+1);
  b[p0+ofs] = true;
  foreach (ui; u) {
    b2[] = false;
    b2[0..$-ui][] |= b[ui..$][];
    b2[ui..$][] |= b[0..$-ui][];
    b[] = b2[];
  }
  return b[pg+ofs];
}


Measured memory_bytes: 2556
N = int(input())
T, A = map(int, input().split())
for i in range(N - 1):
    Ti, Ai = map(int, input().split())
    mt = T // Ti + (1 if T % Ti > 0 else 0)
    ma = A // Ai + (1 if A % Ai > 0 else 0)
    m = max(mt, ma)
    Ti *= m
    Ai *= m
    T, A = Ti, Ai
print(T + A)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (ll)(s); i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int main(){
    ll a,b; cin>>a>>b; b++;
    ll waru=2;
    ll bit=0LL;
    while(b/(waru/2)>0){
        ll atemp=a/waru * (waru/2) +  max(a%waru - waru/2,0LL);
        ll btemp=b/waru * (waru/2) +  max(b%waru - waru/2,0LL);
        if((btemp-atemp)%2==1) bit=(bit | (1LL<<((int)log2(waru) -1 )));
        waru*=2;
    }
    cout<<bit<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
const int N=2e5+10;
int n,head[N],cnt,fa[N],w[N];
int siz[N],mx[N],rt,sum,vis[N],cc,top;
ll Ans;
struct Ed{int fr,to;ll w;}E[N*30];
struct edge{int next,to,w;}a[N<<1];
void link(int x,int y,int w) {a[++cnt]=(edge){head[x],y,w};head[x]=cnt;}
int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
int cmp1(const Ed&A,const Ed&B) {return A.w<B.w;}
void Getsum(int x,int fr)
{
	for(int i=head[x];i;i=a[i].next)
		if(a[i].to!=fr&&!vis[a[i].to])
			Getsum(a[i].to,x);sum++;
}
void Getrt(int x,int fr)
{
	siz[x]=1;mx[x]=0;
	for(int i=head[x];i;i=a[i].next)
	{
		int R=a[i].to;
		if(R==fr||vis[R]) continue;
		Getrt(R,x);siz[x]+=siz[R];
		mx[x]=max(mx[x],siz[R]);
	}
	mx[x]=max(mx[x],sum-siz[x]);
	if(mx[rt]>mx[x]) rt=x;
}
int P;ll VAL;
void DFS(int x,int fr,ll dep)
{
	if(dep+w[x]<VAL) VAL=dep+w[x],P=x;
	for(int i=head[x];i;i=a[i].next)
		if(!vis[a[i].to]&&a[i].to!=fr)
			DFS(a[i].to,x,dep+a[i].w);
}
void Link(int x,int fr,ll dep)
{
	E[++cc]=(Ed){x,P,VAL+dep+w[x]};
	for(int i=head[x];i;i=a[i].next)
		if(!vis[a[i].to]&&a[i].to!=fr)
			Link(a[i].to,x,dep+a[i].w);
}
void Solve(int x)
{
	rt=sum=0;Getsum(x,0);Getrt(x,0);
	vis[x=rt]=1;VAL=1e18;DFS(x,0,0);Link(x,0,0);
	for(int i=head[x];i;i=a[i].next)
		if(!vis[a[i].to]) Solve(a[i].to);
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) scanf("%d",&w[i]);
	for(int i=1,x,y,w;i<n;i++)
		scanf("%d%d%d",&x,&y,&w),link(x,y,w),link(y,x,w);
	mx[0]=1e9;Solve(1);
	sort(E+1,E+cc+1,cmp1);
	for(int i=1;i<=cc;i++)
		if(E[i].fr>E[i].to) swap(E[i].fr,E[i].to);
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=cc;i++)
	{
		int x=find(E[i].fr),y=find(E[i].to);
		if(x!=y) fa[x]=y,Ans+=E[i].w;
	}
	cout<<Ans<<endl;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

int main() {
  std::cout << std::fixed << std::setprecision(20);
  char a;
  cin >> a;
  if(a >= 'a' && a <= 'z'){
    cout << "a" << endl; 
  }else{
    cout << "A" << endl; 
  }
}

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

int main() {
  int X,N;
  cin>>X>>N;
  vector<int> a(N);
  rep(i,N){
    cin >> a.at(i);
  }
  if(N==0){
    cout<<X<<endl;
  }
  else{
    int ok=1;
    rep(i,a.size()){
      if(X==a.at(i)){
        ok=0;
      }
    }
    if(ok==1){
      cout<<X<<endl;
    }
    else{
      rep(sa,100){
        ok=1;
        rep(i,a.size()){
          if((X-sa-1)==a.at(i)){
            ok=0;
          }
        }
        if(ok==1){
          cout<<X-sa-1<<endl;
          break;
        }
        else{
          ok=1;
          rep(i,a.size()){
            if((X+sa+1)==a.at(i)){
              ok=0;
            }
          }
          if(ok==1){
            cout<<X+sa+1<<endl;
            break;
          }
        }
      }
    }
  }
  
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }



int main()
{
	int n;
	cin >> n;
	while(n--)
	{
		/*
		int h, m;
		char k;
		
		cin >> h >> k >> m;
				
		h = h * 60 + m;
		
		m *= 12.0;
		
		int d = (360 < abs(h - m) ? 720 - abs(h - m) : abs(h - m));
		
		cout << (d < 60 ? "alert" : (d < 180 ? "warning" : "safe")) << endl;
		 */
		
		int h, m;
		char k;
		
		cin >> h >> k >> m;
		
		int lg = h * 60 + m;
		int st = m * 12;
		
		int d = abs(lg - st);
		if(360 < d) d = 720 - d;
		
		cout << (0 <= d && d < 60 ? "alert" : (180 <= d && d <= 360 ? "safe" : "warning")) << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int INF = 1234567890;
constexpr int MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
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;
}
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int fact(int n) { return n > 1 ? n * fact(n - 1) % MOD : 1; }
int modinv(int a)
{
    int b = MOD, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}
constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    string ans;

    for (int i = 0; i < n; i++)
    {
        ans.push_back(s[i]);
        ans.push_back(t[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define INF ( 1 << 25 )
int N,mas[16][17],dp[1<<16];
int rec(int bit){
  if(dp[bit]) return dp[bit];
  if(!bit) return 0;
  int ret = INF;
  for(int i = 0 ; i < N ; i++ ){
    if(!(bit & (1 << i))) continue;
    int min_cost = mas[i][0];
    for(int j = 0 ; j < N ; j++ ){
      if(!(bit & (1 << j))) min_cost = min( min_cost, mas[i][j+1]);
    }
    ret = min( ret, min_cost + rec(bit&~(1 << i)));
  }
  return dp[bit] = ret;
}
int main(){
  while(scanf("%d",&N), N ){
    for(int i = 0 ; i < 1 << N ; i++ ) dp[i] = 0;
    for(int i = 0 ; i < N ; i++ ){
      for(int j = 0 ; j <= N ; j++ ){
        scanf("%d",&mas[i][j]);
      }
    }
    printf("%d\n",rec((1 << N)-1));
  }
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int sum=0;
  int max=0;
  for(int i=0;i<S.length();i++){
    if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){
      sum+=1;
    }
    else{
      if(sum>max){
        max=sum;
        sum=0;
      }
    }
  }
  if(sum>max){
    max=sum;
    sum=0;
  }
  cout << max <<endl;
}

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

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

    int skip;

    if (l >= 0) {
        skip = 1;
    } else {
        skip = min(-l + 1, n);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i == skip) {
            continue;
        }

        ans += (l + i - 1);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void addprint(int w){
        for(int i1 = 0; i1 < w; i1++){
            if(i1 % 2 == 0)System.out.print("#");
            else System.out.print(".");
        }
        System.out.println("");
    }
    public static void evenprint(int w){
        for(int i1 = 0; i1 < w; i1++){
            if(i1 % 2 == 1)System.out.print("#");
            else System.out.print(".");
        }
        System.out.println("");
    }

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int h, w;
        while(true){
            h = scanner.nextInt();
            w = scanner.nextInt();
            if(h == 0 && w == 0)break;
            for(int i = 0; i < h; i++){
                if(i%2 == 0)addprint(w);
                else evenprint(w);
            }
            System.out.println("");
        }

    }
}



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

int main()
{
  vector<char> v;
  char c;
  while(cin >> c){
    if(c == '0') v.push_back('0');
    else if(c == '1') v.push_back('1');
    else{
      if(v.empty()) continue;
      else v.pop_back();
    }
  }
  
  for(char x : v) cout << x;
  cout << endl;
    
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <iterator>
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<int,int> pii;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MAXN = 2e5+50;
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define f first
#define s second
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }

void solve(){
    ll n,res=0;
    cin>>n;
    vector<ll> vec(n);
    for(int i=0;i<n;++i)
         cin>>vec[i];
    for(int i=0;i<n-1;++i){
        if(vec[i]>vec[i+1]){
           res+=vec[i]-vec[i+1];
           vec[i+1]=vec[i];
        }
    }
    cout<<res<<endl;    
  
}
int main(){
 
   ios::sync_with_stdio(false);
  cin.tie(0);

     solve();
}

Measured memory_bytes: 4756
#include <algorithm>

#include <bitset>

#include <tuple>

#include <cstdint>

#include <cstdio>

#include <cctype>

#include <assert.h>

#include <stdlib.h>

#include <stdio.h>

#include <cassert>

#include <cfloat>

#include <climits>

#include <cmath>

#include <complex>

#include <ctime>

#include <deque>

#include <fstream>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <list>

#include <limits>

#include <map>

#include <memory>

#include <queue>

#include <random>

#include <set>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>

#include <math.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	if (N % 10 == 3) {
		cout << "bon" << endl;
	}
	else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
		cout << "pon" << endl;
	}
	else {
		cout << "hon" << endl;
	}
}


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

int main(){
	int N;
	cin >> N;
	vector<pair<pair<string, int>, int>> List(N);
	for(int i = 0; i < N; i++){
		string S;
		int A;
		cin >> S >> A;
		List[i] = make_pair(make_pair(S, -A), i + 1);
	}
	
	sort(List.begin(), List.end());
	
	for(int i = 0; i < N; i++){
		cout << List[i].second << endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for (ll i = m ; i < (ll)n ; ++i)
#define VL                vector<ll>
#define VLL               vector<vector<ll>>
#define VLLL              vector<vector<vector<ll>>>
#define INF               2e9;
#define INF_LL            1LL<<60;
#define MOD               1000000007;

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 処理
void Solve()
{
	ll N;
	cin >> N;

	vector<P> ans;
	if (IsOdd(N)) {
		REP(i, N - 1) ans.emplace_back(i + 1, N);
	}

	REP(i, N / 2) {
		for (ll j = i + 1; j < N / 2; j++) {
			ll lSt = i + 1;
			ll rSt = N - lSt;
			ll lEnd = j + 1;
			ll rEnd = N - lEnd;
			if (IsEven(N)) {
				rSt++, rEnd++;
			}
			ans.emplace_back(lSt, lEnd);
			ans.emplace_back(lSt, rEnd);
			ans.emplace_back(rSt, lEnd);
			ans.emplace_back(rSt, rEnd);
		}
	}

	cout << ans.size() << endl;
	for (auto one : ans) {
		cout << one.first << " " << one.second << endl;
	}
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int x;
  cin >> x;
  if (x == 7 || x == 5 || x == 3) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

}


Measured memory_bytes: 768
#include <utility>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	int a[100][100] = {0};
	for ( int i = 0; i < n; i++ ) {
		int u;
		cin >> u;
		int k;
		cin >> k;
		for ( int j = 0; j < k; j++ ) {
			int v;
			cin >> v;
			a[u-1][v-1] = 1;
		}
	}
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < n; j++ ) {
			cout << a[i][j];
			if ( j < n - 1 ) cout << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;
#define ul unsigned long long

#define rup(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rdn(i, a, b) for(int (i) = (a); (i) > (b); (i)--)
bool isGoo(string s) {
	bool res;
	if (s.length() % 2 != 0) return false;
	string part = string(s, 0, s.length()/2);
	string other = string(s, s.length() / 2, s.length());
	if (part == other) {
		return true;
	}
	return false;
}

int main() {
	string s;
	cin >> s;
	int length = 0;
	for (int i = 1; i < s.length(); i++) {
		string str = string(s, 0, s.length() - i);
		if (isGoo(str)) {
			length = str.length();
			break;
		}
	}
	cout << length;
	return 0;
}





Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    K = int(input())
    X = int(input())
    Y = int(input())

    if N <= K:
        ans = N * X
    else:
        ans = K * X + (N - K) * Y

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#include <vector>
#include <cctype>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
using namespace std;

char map[12][12];

void dfs(int y, int x){
    map[y][x] = '0';
    if (0 <= x+1 && x+1 < 12 && 0 <= y && y < 12 && map[y][x+1] == '1') dfs(y, x+1);
    if (0 <= x-1 && x-1 < 12 && 0 <= y && y < 12 && map[y][x-1] == '1') dfs(y, x-1);
    if (0 <= x && x < 12 && 0 <= y+1 && y+1 < 12 && map[y+1][x] == '1') dfs(y+1, x);
    if (0 <= x && x < 12 && 0 <= y-1 && y-1 < 12 && map[y-1][x] == '1') dfs(y-1, x);
    return;
}

int main(){
    while (1){
	int ans = 0;
	for (int i = 0; i < 12; i++)
	    cin >> map[i];
	if (cin.eof()) break;	
	for (int i = 0; i < 12; i++){
	    for (int j = 0; j < 12; j++){
		if (map[i][j] == '1')
		    dfs(i, j), ans++;
	    }
	}
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 0
n = list(map(int, list(input())))
n.reverse()
n.append(0)
ans = 0

for i in range(len(n)):
    # d <= 4 -> and += d
    # d == 5 -> next d <= 4 ans += d else ans += d next digit += 1
    # d >= 6 -> ans += 10 - d next digit += 1
    if n[i] <= 4:
        ans += n[i]
    elif n[i] == 5:
        if n[i + 1] <= 4:
            ans += n[i] 
        else:
            ans += n[i]
            n[i + 1] += 1
    else:
        ans += 10 - n[i]
        n[i + 1] += 1
print(ans)


Measured memory_bytes: 21228
#!/usr/bin/env python3
import sys


def solve(N: int, S: str, T: str):
    
    ans = ''
    for s, t in zip(list(S),list(T)):
        ans += s + t
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(N, S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a[1009][1009];
int n,m,k;
int x;
vector<int> v,v2,v3;
int main()
{
cin>>n>>m>>k;
for(int i=1;i<=k;i++)
{
    cin>>x;
    for(int j=0;j<x;j++)
        v.push_back(i);
}
for(int i=0;i<n;i++)
{
    for(int j=0;j<m;j++)
    {
        int ans1=i*m+j;
        int ans2=i*m+m-1-j;
        if(i%2==0)
            cout<<v[ans1]<<" ";
        else
            cout<<v[ans2]<<" ";
    }
    cout<<endl;
}/*
for(int i=0;i<n;i++)
{
    for(int j=0;j<m;j++)
    {
        cout<<a[i][j]<<" ";
    }
    cout<<endl;
}
*/}


Measured memory_bytes: 384
#include <stdio.h>

int main(void);

int main(void)
{
    int a, n, i, min = 1000000, max = -1000000;
    long sum = 0;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &a);
        sum += a;
        if(a < min){
            min = a;
        }
        if(a > max){
            max = a;
        }
    }
     printf("%d %d %ld\n", min, max, sum);
     return(0);
}


Measured memory_bytes: 2132
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int N;
    cin >> N;
    Graph M(N, vector<int>(N));
    rep(i, N){
        rep(j, N){
            cin >> M[i][j];
            if(M[i][j] == -1) M[i][j] = INF;
        }
    }

    vector<int> d(N, INF), p(N, -1);
    vector<bool> visited(N);
    d[0] = 0;
    p[0] = -1;
    int sum = 0;

    while(1){
        int mincost = INF;
        int u;
        rep(i, N){
            if( !visited[i] && d[i] < mincost){
                mincost = d[i];
                u = i;
            }
        }

        if(mincost == INF) break;
        sum += d[u];
        visited[u] = true;

        rep(v, N){
            if( !visited[v] && M[u][v] != INF){
                if(M[u][v] < d[v]){
                    d[v] = M[u][v];
                    p[v] = u;
                }
            }
        }
    }
    
    cout << sum << endl;

}


Measured memory_bytes: 3168
import java.util.Scanner;

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

    int[] input_number_list = new int[number];
    boolean is_even = true;
    int count = 0;

    for(int i = 0; i < number; i++){
      input_number_list[i] = scanner.nextInt();
    }

    while(is_even){
      for(int j = 0;j < input_number_list.length;j++){
        if(input_number_list[j] % 2 != 0){
          is_even = false;
          break;
        }
        input_number_list[j] = input_number_list[j]/2;
      } 
      if(is_even) count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int A, B;
  cin >> A >> B;
  int price = B * 10;
  int tax_8 = floor(price * 0.08);
  if (A == tax_8) cout << price << endl;
  else {
    int cnt = 0;
    while (true) {
      price++;
      tax_8 = floor(price * 0.08);
      if (A == tax_8) {
        cout << price << endl;
        break;
      }
      cnt++;
      if (cnt == 9) {
        cout << -1 << endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 3588
def d_div_game():
    def prime_factorization(n):
        """n を素因数分解したときの素数とその指数の辞書"""
        from collections import defaultdict
        if n == 1:
            return {2: 0}  # 1 は素数の 0 乗の積とみなす
        i, table = 2, defaultdict(int)
        while i**2 <= n:
            while n % i == 0:
                table[i] += 1
                n //= i
            i += 1
        if n > 1:
            table[n] = 1
        return table

    def sub(n):
        """1 + ... + e = e*(e+1)//2 <= n となる最大の e を返す"""
        for e in range(1, n + 2):
            if e * (e + 1) > 2 * n:  # e = n + 1 は必ずこの不等式を満たす
                return e - 1

    return sum(sub(v) for v in prime_factorization(int(input())).values())

print(d_div_game())

Measured memory_bytes: 9464
#coding:utf-8
N, K = map(int,input().split())
P = list(map(int,input().split()))
P = [(p+1)/2 for p in P]
mx = sum(P[:K])
sm = sum(P[:K])
for i in range(N-K):
    sm = sm - P[i] + P[K+i]
    mx = max(mx,sm)
print (mx)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
int main() {
    int n;
    cin >> n;
    set<string> s;
    rep(i,n) {
        string si;
        cin >> si;
        s.insert(si);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 19264
#include <stdio.h>

int main(void) {
    int a, b, x;
    scanf("%d%d%d", &a, &b, &x);
    if(a > x) printf("NO\n");
    else {
        if(a + b >= x) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int max_len = 0;
    for (int diff = 1; diff < n; ++diff) {
        int len = 0;
        for (int i = 0; i < n - diff; ++i) {
            if (len == diff) {
                len = 0;
            }
            if (len + n - i - diff <= max_len) {
                break;
            }
            if (s[i] == s[i + diff]) {
                len++;
                if (len > max_len) {
                    max_len = len;
                }
            } else {
                len = 0;
            }
        }
    }
    cout << max_len << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct uftree{
	int par[200005];
	int rank[200005];
	int cnt[200005];
	uftree(){
	}
	void init(int n){
		for(int i=0;i<n;i++){
			par[i]=i;
			rank[i]=0;
			cnt[i]=1;
		}
	}
	int find(int x){
		if(par[x]==x)return x;
		return par[x]=find(par[x]);
	}

	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y)return;
		if(rank[x]<rank[y]){
			cnt[y]+=cnt[x];
			par[x]=y;
		}else{
			if(rank[x]==rank[y])rank[x]++;
			cnt[x]+=cnt[y];
			par[y]=x;
		}
	}

	int getCnt(int x){
		x=find(x);
		return cnt[x];
	}

	bool same(int x,int y){
		return find(x)==find(y);
	}
};


int n,p1,p2;
uftree uf;
int f[1001],t[1001];
string str[1001];
int dp[601][601];
int prev[601][601];
vector<int> G[601];
int cnt[601][2];
vector<int> member[601][2];
int gr[601][2];
int flag[601];
int nv;

bool dfs(int v,int c){
	gr[nv][c]=v;
	flag[v]=c;
	cnt[nv][c]+=uf.getCnt(v);
	for(int i=0;i<p1+p2;i++){
		if(uf.same(i,v))member[nv][c].push_back(i);
	}
	for(int i=0;i<G[v].size();i++){
		if(flag[G[v][i]]>=0){
			if(flag[v]==flag[G[v][i]])return false;
		}else{
			if(!dfs(G[v][i],1-c))return false;
		}
	}
	return true;
}

void solve(){
	uf.init(p1+p2);
	for(int i=0;i<n;i++){
		if(str[i]=="yes"){
			uf.unite(f[i],t[i]);
		}
	}
	for(int i=0;i<p1+p2;i++){
		G[i].clear();
	}
	for(int i=0;i<n;i++){
		if(str[i]=="no"){
			G[uf.find(f[i])].push_back(uf.find(t[i]));
			G[uf.find(t[i])].push_back(uf.find(f[i]));
		}
	}
	memset(dp,0,sizeof(dp));
	memset(flag,-1,sizeof(flag));
	memset(gr,-1,sizeof(gr));
	memset(cnt,0,sizeof(cnt));
	dp[0][0]=1;
	nv=0;
	for(int i=0;i<p1+p2;i++){
		member[nv][0].clear();
		member[nv][1].clear();
		int v=uf.find(i);
		if(flag[v]==-1){
			if(!dfs(v,0)){
				printf("no\n");
				return;
			}
			if(cnt[0]==cnt[1]){
				printf("no\n");
				return;
			}
			for(int j=p1;j>=0;j--){
				if(dp[nv][j]==0)continue;
				dp[nv+1][j+cnt[nv][0]]+=dp[nv][j];
				prev[nv+1][j+cnt[nv][0]]=j;

				dp[nv+1][j+cnt[nv][1]]+=dp[nv][j];
				prev[nv+1][j+cnt[nv][1]]=j;
			}
			nv++;
		}
	}
	if(dp[nv][p1]!=1){
		printf("no\n");
		return;
	}
	vector<int> ans;
	int nowp1=p1;
	for(int i=nv;i>=1;i--){
		int diff=nowp1-prev[i][nowp1];
		if(diff>0){
			if(diff==cnt[i-1][0]){
				for(int j=0;j<member[i-1][0].size();j++){
					ans.push_back(member[i-1][0][j]);
				}
			}else{
				for(int j=0;j<member[i-1][1].size();j++){
					ans.push_back(member[i-1][1][j]);
				}
			}
		}
		nowp1=prev[i][nowp1];
	}
	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++){
		printf("%d\n",ans[i]+1);
	}
	printf("end\n");
}

int main(void){
	while(1){
		scanf("%d%d%d",&n,&p1,&p2);
		if(n==0 && p1==0 && p2==0)break;
		for(int i=0;i<n;i++){
			cin >> f[i] >> t[i] >> str[i];
			f[i]--;
			t[i]--;
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 5144
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    string s;
    cin >> s;
    bool abc[26];
    rep(i, 26) {
        abc[i] = false;
    }
    rep(i, s.size()) {
        abc[s[i] - 'a'] = true; //char型小文字アルファベットを数値に変換 -'a'
    }
    rep(i, 26) {
        if(!abc[i]) {
            char ans = i + 'a'; //数値を適合する小文字アルファベットに変換 +'a'
            printf("%c\n", ans);
            return 0;
        }
    }
    printf("None\n");
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>

using namespace std ;

const int N=1e5+10 ;

char s[N] ;
int n , k ;

int main ()
{
	int i , cnt=0 ;
	scanf(" %d %d %s ",&n,&k,s+1);
	for ( i=1 ; i<n ; i++ )
		if ( s[i]^s[i+1] ) ++cnt;
	printf("%d\n",min(n-(cnt-2*k)-1,n-1));
	return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int A, B, C, X;
	int sum = 0;
	int count = 0;
	
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &X);
	
	for(int i=A; i>=0; i--)
	{
		sum = 500 * i;
		
		if(sum > X) continue;
		else if(sum == X)
		{
			count++;
			continue;
		}
		else
		{
			for(int j=B; j>=0; j--)
			{
				sum = 500 * i;
				
				if((sum + 100 * j) > X) continue;
				else if((sum + 100 * j) == X)
				{
					count++;
					continue;
				}
				else
				{
					sum = sum + 100 * j;
					
					for(int k=C; k>=0; k--)
					{
						if((sum + 50 * k) > X) continue;
						else if((sum + 50 * k) == X)
						{
							count++;
							continue;
						}
						else break;
					}
				}
			}
		}
	}
	
	printf("\n");
	printf("%d\n", count);
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<pair<int,int>> vp;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<bool>> vbb;
typedef pair<int,int> pi;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define REP(n, x) for(int i = n; i < x; i++)
#define REPN(n, x) for(int i = x; i >= n; i--)
#define REPVS(arr) for(auto &x : arr)
#define REPV(arr) for(auto x : arr)
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(x) printf("%s\n", s.c_str())
#define F first
#define S second

const int INF = INT_MAX;

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n, d;
    scanf("%d%d", &n, &d);
    ll x, y;
    ll temp;
    int ans = 0;
    REP(0, n){
        scanf("%lld%lld", &x, &y);
        temp = x*x + y*y;
        temp = ceil(sqrt(temp));
        if(temp <= d){
            ans++;
        }
    }
    pi(ans);
    return 0;
}

Measured memory_bytes: 3868
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )
#define SQRTI(n) static_cast<uint64_t>(::floor(::sqrt(static_cast<double>(n))))

#ifdef __DEBUG__
template<typename T, typename U>
std::ostream& operator<<(std::ostream &os, const std::pair<T, U> &pair)
{
  os << pair.first << ": " << pair.second;
  return os;
}

template<class ForwardIterator>
std::ostream& _iterator_to_display(
  std::ostream &os, 
  ForwardIterator begin, ForwardIterator end, 
  const std::string &delim = ", "
)
{
  auto itr = begin;
  while (itr != end) {
    os << *itr;
    ++itr;
    if (itr != end) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  _iterator_to_display(os, list.begin(), list.end());
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &vector)
{
  _iterator_to_display(os, vector.begin(), vector.end());
  return os;
}

template<typename T, class C=std::less<T>>
std::ostream& operator<<(std::ostream &os, const std::set<T> &set)
{
  _iterator_to_display(os, set.begin(), set.end());
  return os;
}

template<typename T, typename U, class C=std::less<T>>
std::ostream& operator<<(std::ostream &os, const std::map<T, U> &map)
{
  _iterator_to_display(os, map.begin(), map.end());
  return os;
}
#endif /* __DEBUG__ */

int main(int argc, char **argv)
{
  unsigned R;
  std::cin >> R;
  
  if (R < 1200) {
    std::cout << "ABC" << std::endl;
  } else if (R < 2800) {
    std::cout << "ARC" << std::endl;
  } else {
    std::cout << "AGC" << std::endl;
  }

  return 0;
}

Measured memory_bytes: 256
a = input()

if a[0] == a[1] == a[2] == a[3]:
    print("No")
elif a[0] == a[1] and a[2] == a[3]:
    print("Yes")
elif a[0] == a[2] and a[1] == a[3]:
    print("Yes")
elif a[0] == a[3] and a[1] == a[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import Control.Applicative
main = solve

solve = do
    n <- fmap (read :: String -> Int) . words <$> getLine
    let w = n !! 0
        h = n !! 1
        x = n !! 2
        y = n !! 3
        r = n !! 4
        circle = getCircle x y r
    printResult w h circle

printResult :: Int -> Int -> Circle -> IO ()
printResult w h c
    | 0 <= (left c) && (right c) <= w && 0 <= (bottom c) && (top c) <= h = putStrLn "Yes"
    | otherwise = putStrLn "No"

type Left   = Int
type Right  = Int
type Top    = Int
type Bottom = Int
data Circle = Circle
    { left :: Left
    , right :: Right
    , top :: Top
    , bottom :: Bottom
    } deriving (Show)

getCircle :: Int -> Int -> Int -> Circle
getCircle x y r = Circle (x - r) (x + r) (y + r) (y - r)

Measured memory_bytes: 3676