akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>
#include <math.h>

using namespace std;

void solve1() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, q;
  cin >> n >> q;

  string s;
  cin >> s;

  int l[q], r[q];
  for (int i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
  }

  // count[i]:=i番目までの文字列に含まれている"AC"の個数(0-index)
  int count[n];
  for (int i = 0; i < n; i++) {
    count[i] = 0;
  }

  for (int i = 1; i < n; i ++) {
   if (s.substr(i - 1, 2) == "AC") {
     count[i] = 1;
   }

    count[i] += count[i - 1];
  }

  // debug
  // cout << "count" << endl;
  // for (int i = 0; i < n; i++) {
  //   cout << i << " : " << count[i] << endl;
  // }

  for (int i = 0; i < q; i++) {
    // 0-indexのため
    int left = l[i] - 1;
    int right = r[i] - 1;

    // 1. 0番目の文字の場合 -> count[right]のみ
    // left番目からright番目までに含まれる"AC"の個数
    // = 0番目からright番目までに含まれる"AC"の個数 - 0番目からleft-1番目までに含まれている"AC"の個数
    // 2. ただし、left-1番目の文字が"A"、left番目の文字が"C"だと、
    if (left == 0) {
      cout << count[right] << endl;
    }
    else if (count[left] == count[left - 1]) {
      cout << count[right] - count[left - 1] << endl;
    }
    else {
      cout << count[right] - count[left - 1] - 1 << endl;
    }
  }
}

void solve2() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, q;
  cin >> n >> q;

  string s;
  cin >> s;

  int l[q], r[q];
  for (int i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
  }

  // count[i]:=i+1番目までの文字列で、
  // i番目の文字が"A"で、その右隣が"C"である個数
  int count[n];
  for (int i = 0; i < n; i++) {
    count[i] = 0;
  }

  if (s.substr(0, 2) == "AC") {
    count[0] = 1;
  }
  for (int i = 1; i < n; i ++) {
   if (s.substr(i, 2) == "AC") {
     count[i] += (count[i - 1] + 1);
   }
   else {
     count[i] += count[i - 1];
   }
  }

  // // debug
  // cout << "count" << endl;
  // for (int i = 0; i < n; i++) {
  //   cout << i << " : " << count[i] << endl;
  // }

  for (int i = 0; i < q; i++) {
    int left = l[i] - 1;
    int right = r[i] - 1;

    if (left == 0) {
      cout << count[right - 1] << endl;
    }
    else {
      cout << count[right - 1] - count[left - 1] << endl;
    }
  }
}

int main() {
  // solve1();
  solve2();
}

Measured memory_bytes: 2256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  string s;
  while(cin>>s,s!="-"){
    int n;cin>>n;
    rep(i,n){
      int in;cin>>in;
      s=s.substr(in)+s.substr(0,in);
    }
    cout<<s<<endl;
  }
}

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

int f(int n) {
    return n * (n + 1) * (n + 2) / 6;
}

const int INF = 1e9;

int main() {
    vector <int> all, odd;
    for (int i = 0; f(i) < 1e6; i++) {
        int fi = f(i);
        all.push_back(fi);
        if (fi % 2) odd.push_back(fi);
    }

    vector <int> allDp(1e6, INF);
    allDp[0] = 0;
    for (int i = 0; i < 1e6; i++) {
        for (auto & j : all) {
            if (i + j >= 1e6) continue;
            allDp[i + j] = min(allDp[i + j], allDp[i] + 1);
        }
    }

    vector <int> oddDp(1e6, INF);
    oddDp[0] = 0;
    for (int i = 0; i < 1e6; i++) {
        for (auto & j : odd) {
            if (i + j >= 1e6) continue;
            oddDp[i + j] = min(oddDp[i + j], oddDp[i] + 1);
        }
    }


    int n;
    while (cin >> n, n) {
        cout << allDp[n] << " " << oddDp[n] << endl;
    }
    return 0;
}


Measured memory_bytes: 10552
#include <bits/stdc++.h>
using namespace std;
double dp[3001][3001];
double solve(vector<double> &ar, int i, int x)
{
    if(x==0)
    {
        return 1;
    }
    if(i==0)
    {
        return 0;
    }
    if(dp[i][x]>-0.9)
    {
        return dp[i][x];
    }
    return dp[i][x] = ar[i]*solve(ar,i-1,x-1) + (1-ar[i])*solve(ar,i-1,x);
}

int main() {
    int n;
    cin>>n;
    memset(dp,-1,sizeof dp);
    vector<double> ar(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>ar[i];
    }
    cout<<fixed<<setprecision(10)<<solve(ar,n,(n+1)/2);
}


Measured memory_bytes: 74340
n = gets.chop.to_i
apt = Array.new(4){ Array.new(3){ Array.new(10, 0) } }

n.times do
  b, f, r, v = gets.chomp.split(/\s/).map(&:to_i)
  apt[b-1][f-1][r-1] += v
end

apt.each_with_index do |building, index|
  puts "#" * 20 if index > 0
  building.each { |floor| puts "\s" + floor.join("\s") }
end

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#define test(t) int t; cin>>t; while(t--)
#define p1(x) { cout << " [" << #x << ": " << x << "]\n"; }
#define p2(x) { cout << " [" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]\n"; }
#define pb(x) { push_back(x); }
 
 
void solve()
{
	int n, k, ans=0;
	vector<int> p;
	cin>>n>>k;
	for(int i=0; i<n; i++) {
		int x;
		cin>>x;
		p.push_back(x);
	}
	sort(p.begin(), p.end());
	for(int i=0; i<k; i++) {
		ans+=p[i];
	}
	cout<<ans<<endl;
}
 
int main() {
	// your code goes here
	// test(t)
		solve();
	return 0;
}
 

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll n, t, x, ans, last;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> t;
	for(int i = 0; i < n; i++){
        cin >> x;
        if(i == 0){
            last = x;
        }
        else{
            if(x - last >= t){
                ans += t;
            }
            else{
                ans += x-last;
            }
            last = x;
        }
	}
	cout << ans+t << endl;
}


Measured memory_bytes: 256
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws FileNotFoundException{
		FScanner sc=new FScanner();
		//Scanner sc=new Scanner(System.in);
		int[] num=sc.readIntL();
		int[] chl=sc.readIntL();
		int itm=num[1];
		int cnt=0;
		int pay=0;
		Arrays.sort(chl);
		
		for(int i=0; i<chl.length-1; i++){
			//System.out.printf("%d/%d\n",itm,chl[i]);
			if(itm>0 && itm>=chl[i]){
				itm-=chl[i];
				cnt+=1;
			}
		}
		//System.out.printf("%d/%d\n",itm,chl[chl.length-1]);
		if(itm>0 && itm==chl[chl.length-1]){
			cnt+=1;
		}
		System.out.println(cnt);
	}
	
	static void solve(){}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static void disp(String[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%s ",data[i]);
		}
			System.out.println();
	}
	
	static class FScanner{
		Scanner sc;
		FScanner() throws FileNotFoundException{
			sc=new Scanner(System.in);
		}
		boolean hasNextLine(){
			boolean has=true;
			if(!sc.hasNextLine()){
				has=false;
			}
			return has;
		}
		int readInt(){
			String buf=sc.nextLine();
			return Integer.parseInt(buf);
		}
		long readLong(){
			long i=Long.parseLong(sc.nextLine());
			return i;
		}
		int[] readIntL(){
			String[] buf=sc.nextLine().split(" ");
			int[] num=new int[buf.length];
			for(int i=0; i<buf.length; i++){
				num[i]=Integer.parseInt(buf[i]);
			}
			return num;
		}
		
		String readString(){
			return sc.nextLine();
		}
		String[] readStringL(String dlm){
			String[] s=sc.nextLine().split(dlm);
			return s;
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN 2*int(1e5)+5
#define endl '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
const ll mod = 1e9+7;

int main(){
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	vector<int> v(n);
	for(int &i : v)
		cin >> i;
	sort(v.begin(), v.end(), greater<int>());
	for(int i = k; i < n; i++)
		ans += v[i];
	cout << ans << endl;
}


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

struct loop_info {
    lint loop_len;
    lint prefix_len;
    lint unit;
};

lint n, x, m;

lint f(lint z) {
    return z * z % m;
}

lint simple_solve(lint start, lint k) {
    lint now = start;
    lint res = 0;
    for (int i = 0; i < k; i++) {
        res += now;
        now = f(now);
    }
    return res;
}

loop_info get_loop() {
    vector<lint> appear_time(m, -1);
    lint now = x;
    lint time = 0;
    loop_info res;
    while (true) {
        if (appear_time[now] == -1) {
            appear_time[now] = time;
            time++;
            now = f(now);
        } else {
            res.loop_len = time - appear_time[now];
            res.prefix_len = appear_time[now];
            res.unit = simple_solve(now, res.loop_len);
            return res;
        }
    }
}

int main() {
    cin >> n >> x >> m;
    auto loop = get_loop();
    if (n < loop.prefix_len) {
        cout << simple_solve(x, n) << endl;
    } else {
        lint loop_num = (n - loop.prefix_len) / loop.loop_len;
        lint rem = n - loop_num * loop.loop_len;
        lint ans = simple_solve(x, rem) + loop.unit * loop_num;
        cout << ans << endl;
    }
}

Measured memory_bytes: 4016
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main() {

	string S;
	cin >> S;

	int a[15];
	for (int i = 0; i < S.size(); i++) {
		a[i] = S[i]-'0';
	}

	long long sum = 0;

	for (int i = 0; i < 1<<(S.size()-1) ; i++) {
		long long tmp =  a[0];
		for (int j = 0; j < S.size()-1; j++ ) {
			if ((i>>j) & 1 == 1) {
				sum += tmp;
				//cout << tmp << " ";
				tmp = 0;
			}
			tmp = 10*tmp + a[j + 1];
		}
		sum += tmp;
		//cout << tmp << endl;
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};

//--global--//



//----------//

ll solve(ll n, ll x, vector<vector<ll> > pos, vector<ll> paty){
    if(n == 1){
        ll dx[7] = {0LL, 0LL, 1LL, 2LL, 3LL, 3LL, 3LL};
        return dx[x];
    }
    ll res = 0;
    if(x > pos[n][0] && x < pos[n][1]){
        res += solve(n-1, x-1, pos, paty);
    }
    else if(x >= pos[n][1]){
        res += 1+paty[n-1]+solve(n-1, min(x, pos[n][2]-1) - pos[n][1], pos, paty);
    }
    return res;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    ll n, x;
    cin >> n >> x;
    vector<vector<ll> > pos(51);
    vector<ll> paty(51);
    paty[1] = 3LL;
    rep2(i, 2, 51){
        paty[i] = paty[i-1]*2+1LL;
    }

    pos[1].push_back(1LL);
    pos[1].push_back(3LL);
    pos[1].push_back(5LL);
    rep2(i, 2, 51){
        pos[i].push_back(1LL);
        pos[i].push_back(1+pos[i-1][2]+1LL);
        pos[i].push_back(1+pos[i-1][2]*2+2LL);
    }
    //Printer::print(pos);

    //cout << solve(1, min(x, pos[n][1]), pos, paty) << endl;
    cout << solve(n, x, pos, paty) << endl;
    
    
    return 0;
}


Measured memory_bytes: 384
MOD=10**9+7
S=input()
N=len(S)
if N==1:
  if S=='?' or int(S)==5:
    print(1)
  else:
    print(0)
  exit()

if S[0]=='?':
  x=[1]*10+[0]*3
else:
  x=[0]*13
  x[int(S[0])]=1

for i in range(1, N):
  if S[i]=='?':
    tmp=sum(x)
    x=[
      tmp-x[4]-x[8]-x[12],
      tmp-x[3]-x[8]-x[12],
      tmp-x[3]-x[7]-x[12],
      tmp-x[3]-x[7]-x[11],
      tmp-x[2]-x[7]-x[11],
      tmp-x[2]-x[6]-x[11],
      tmp-x[2]-x[6]-x[10],
      tmp-x[1]-x[6]-x[10],
      tmp-x[1]-x[5]-x[10],
      tmp-x[1]-x[5]-x[9],
      tmp-x[0]-x[5]-x[9],
      tmp-x[0]-x[4]-x[9],
      tmp-x[0]-x[4]-x[8]
    ]
  elif S[i]=='0':
    x=[x[0], x[4], x[8], x[12], x[3], x[7], x[11], x[2], x[6], x[10], x[1], x[5], x[9]]
  elif S[i]=='1':
    x=[x[9], x[0], x[4], x[8], x[12], x[3], x[7], x[11], x[2], x[6], x[10], x[1], x[5]]
  elif S[i]=='2':
    x=[x[5], x[9], x[0], x[4], x[8], x[12], x[3], x[7], x[11], x[2], x[6], x[10], x[1]]
  elif S[i]=='3':
    x=[x[1], x[5], x[9], x[0], x[4], x[8], x[12], x[3], x[7], x[11], x[2], x[6], x[10]]
  elif S[i]=='4':
    x=[x[10], x[1], x[5], x[9], x[0], x[4], x[8], x[12], x[3], x[7], x[11], x[2], x[6]]
  elif S[i]=='5':
    x=[x[6], x[10], x[1], x[5], x[9], x[0], x[4], x[8], x[12], x[3], x[7], x[11], x[2]]
  elif S[i]=='6':
    x=[x[2], x[6], x[10], x[1], x[5], x[9], x[0], x[4], x[8], x[12], x[3], x[7], x[11]]
  elif S[i]=='7':
    x=[x[11], x[2], x[6], x[10], x[1], x[5], x[9], x[0], x[4], x[8], x[12], x[3], x[7]]
  elif S[i]=='8':
    x=[x[7], x[11], x[2], x[6], x[10], x[1], x[5], x[9], x[0], x[4], x[8], x[12], x[3]]
  elif S[i]=='9':
    x=[x[3], x[7], x[11], x[2], x[6], x[10], x[1], x[5], x[9], x[0], x[4], x[8], x[12]]
    
  x=[x[j]%MOD for j in range(13)]

print(x[5])

Measured memory_bytes: 53484
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int m;
    cin>>m;
    rep(i,m){
        int x,y;
        cin>>x>>y;
        int ans=min({x-1,y-1,n-x,n-y});
        cout<<ans%3 +1 <<endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

long long cnt;
int i;
int a[1000000];
int n;
vector<int> G;

//???????????´???g????????\??????
void InsertionSort( int a[], int n, int g ) {
	for ( int i = g; i < n; i++ ) {
        int v = a[i];
        int j = i - g;
        while ( j >= 0 && a[j] > v ) {
            a[j+g] = a[j];
            j -= g;
            cnt++; 
        }
        a[j+g] = v;
    }
} 

void ShellSort( int a[], int n ) {
    //????????°???G = {1, 4, 13, 40, 121, ...}
    int h = 1;
    while ( true ) {
        if ( h > n ) {
            break;
        }
        G.push_back(h);
        h = 3*h + 1;
    }
    
    for ( int i = G.size()-1; i >= 0; i-- ) {
        InsertionSort( a, n, G[i] );
    }
}

int main() {
    scanf( "%d", &n );
    for ( int i = 0; i < n; i++ ) scanf( "%d", &a[i] );
    cnt = 0;
    
    ShellSort( a, n );
    
    printf( "%d\n", G.size() );
    for ( int i = G.size()-1; i >= 0; i-- ) {
        printf( "%d", G[i] );
        if ( i ) {
            printf( " " );
        }
    }
    printf( "\n" );
    printf( "%d\n", cnt );
    for ( int i = 0; i < n; i++ ) {
        printf( "%d\n", a[i] );
    }
    
	return 0;
} 

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

int main(){
  int R,G;
  cin>>R;
  cin>>G;
  //求める答えをｘとしてＲ＋ｘ＝２Ｇ
  //x=2G-R
  cout<<2*G-R<<endl;
}

Measured memory_bytes: 256
from random import *
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
X=[0]*26
XX=X[:]
Y=X[:]
YY=X[:]
P=[]
SC=0
N,M=0,0
for i in range(D):
  for j in range(26):
    X[j]+=C[j]
    XX[j]+=X[j]
  N,M=-1,-10**20
  for j in range(26):
    if Y==-1:
      N,M=0,X[0]+S[i][0]
    if M<X[j]+S[i][j]:
      N,M=j,X[j]+S[i][j]
  XX[N]-=X[N]
  X[N]=0
  P.append(N)
  SC+=X[N]
SC2=0
for i in range(10**5):
  SC2=SC
  d,q=randrange(0,D),randrange(0,26)
  SC2-=S[d][P[d]]
  SC2+=S[d][q]
  for j in range(26):
    Y[j]=0
  YY[P[d]],YY[q]=0,0
  for j in range(D):
    if j==d:
      Z=q
    else:
      Z=P[j]
    Y[P[d]]+=C[P[d]]
    Y[q]+=C[q]
    Y[Z]=0
    YY[P[d]]+=Y[P[d]]
    YY[q]+=Y[q]
  if SC2-sum(YY)>=SC-sum(XX) or randrange(0,100)==0:
    P[d]=q
    XX=YY[:]
    SC=SC2
for i in range(10**5):
  SC2=SC
  d,q=randrange(0,D),randrange(0,26)
  SC2-=S[d][P[d]]
  SC2+=S[d][q]
  for j in range(26):
    Y[j]=0
  YY[P[d]],YY[q]=0,0
  for j in range(D):
    if j==d:
      Z=q
    else:
      Z=P[j]
    Y[P[d]]+=C[P[d]]
    Y[q]+=C[q]
    Y[Z]=0
    YY[P[d]]+=Y[P[d]]
    YY[q]+=Y[q]
  if SC2-sum(YY)>=SC-sum(XX):
    P[d]=q
    XX=YY[:]
    SC=SC2
for i in range(D):
  print(P[i]+1)

Measured memory_bytes: 86096
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
int a[100005];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
	scanf("%d", &a[i]);
    }
    a[++n] = 0;
    int res = 0;
    for (int i = 1; i <= n; ++i) {
	res += abs(a[i] - a[i - 1]);
    }
    for (int i = 1; i <= n - 1; ++i) {
	int f = abs(a[i] - a[i - 1]) +  abs(a[i] - a[i + 1]);;
	int t =  abs(a[i + 1] - a[i - 1]);;
	printf("%d\n", res - f + t);
    }
    return 0;
}


Measured memory_bytes: 1664
MOD = 1000000007
n = gets.to_i
a = gets.split.map(&:to_i)

bits = 61
popcnt = [0] * bits

bits.times {|b|
    m = 1 << b
    a.each {|x|
        if x & m != 0
            popcnt[b] += 1
        end
    }
}

ans = 0
bits.times {|b|
    ans += popcnt[b] * (n-popcnt[b]) * 2**b
}

p ans % MOD

Measured memory_bytes: 34820
/**
 *   author:  cryforthemoon46
 *   created: 26.05.2020 13:38:52
**/
#include <bits/stdc++.h>
using namespace std;
using ld = long double;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ld a, b, c;
    cin >> a >> b >> c;

    bool is_true = c - (a + b) > 0 && a * b * 4 < pow(c - (a + b), 2);
    cout << ((is_true) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import math
def isPrime(number):
    for i in range(2,math.floor(math.sqrt(number))+1):
        if number%(i)==0:
            return False
    return True
N=int(input())
numbers=[]
for i in range(N):
    numbers.append(int(input()))
    pass
count=0
for number in numbers:
    if isPrime(number):
        count+=1
print(count)

Measured memory_bytes: 7960
import Data.Foldable
import Data.List

main :: IO ()
main = getContents >>= traverse_ (putStrLn.solve.map read.words).takeWhile (/="0 0").lines

solve       :: [Int] -> String
solve [x,y] = unlines $ f x (f y '#' '.') (f y '.' '#')
    where f n a b = take n.cycle $ a : [b]

Measured memory_bytes: 4640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int sum;
    if(a>=0&&b>=0&&c>=0&&k>=1&&k<=(a+b+c)&&((a+b+c)<=2000000000))
    {
        if(a>=k)
            sum=k;
        else
        {
            sum=a;
            k=k-a;
            if(b<k)
            {
                k=k-b;
                sum=sum-k;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

bool warshall_floyd(const int n,
                    vector<vector<pair<int, int>>>& g,
                    vector<vector<int64_t>>& cost) {
    for (auto i = 0; i < n; i++) {
        // 自身への距離は0
        cost[i][i] = 0;
        for (auto& elm : g[i]) {
            // 頂点iからの距離で初期化
            cost[i][elm.first] = elm.second;
        }
    }

    for (auto k = 0; k < n; k++) {
        for (auto i = 0; i < n; i++) {
            for (auto j = 0; j < n; j++) {
                if(cost[i][k] == INT64_MAX or cost[k][j] == INT64_MAX) continue;
                // 直接行く場合とkを経由する場合でより小さい距離を採用する
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }

    bool isNegativeCycle = false;
    for (auto i = 0; i < n; i++) {
        // 自身へのコストが0以下なら負の閉路がある
        if (cost[i][i] < 0) isNegativeCycle = true;
    }

    return isNegativeCycle;
}

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

    vector<vector<pair<int, int>>> g(n, vector<pair<int, int>>(0));
    for (auto i = 0; i < m; i++) {
        int s, t, d; cin >> s >> t >> d;
        g[s].emplace_back(t, d);
    }

    vector<vector<int64_t>> cost(n, vector<int64_t>(n, INT64_MAX));
    bool isNegativeCycle = warshall_floyd(n, g, cost);

    if(isNegativeCycle) {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }

    for (auto i = 0; i < n; i++) {
        for (auto j = 0; j < n - 1; j++) {
            if(cost[i][j] == INT64_MAX) cout << "INF ";
            else cout << cost[i][j] << " ";
        }
        if(cost[i][n - 1] == INT64_MAX) cout << "INF";
        else cout << cost[i][n - 1];
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3280
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, x;
    cin >> N >> x;

    if (x == 1 || x == 2 * N - 1) {
        print("No");
        return 0;
    }

    vector<int> ans(2 * N - 1);

    if (x == 2) {
        ans[N - 2] = 1;
        ans[N - 1] = x;
        int cnt = 3;
        REP(i, 2 * N - 1) {
            if (ans[i] > 0) continue;
            ans[i] = cnt++;
        }
    } else if(x == 2 * N - 2) {
        ans[N - 2] = 2 * N - 1;
        ans[N - 1] = x;
        int cnt = 1;
        REP(i, 2 * N - 1) {
            if (ans[i] > 0) continue;
            ans[i] = cnt++;
        }
    } else {
        ans[N - 3] = 1;
        ans[N - 2] = 2 * N - 1;
        ans[N - 1] = x;
        ans[N] = 2;
        ans[N + 1] = 2 * N - 2;
        int cnt = 3;
        REP(i, 2 * N - 1) {
            if (ans[i] > 0) continue;
            if (cnt == x) cnt++;
            ans[i] = cnt++;
        }
    }

    print("Yes");
    REP(i, 2 * N - 1) {
        print(ans[i]);
    }
    
}


Measured memory_bytes: 3948
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> x(n);
  for(int i=0;i<n;++i) cin >> x[i];
  vector<int> y(x);
  sort(x.begin(), x.end());
  int left = x[n/2-1];
  int right = x[n/2];
  for(int i=0;i<n-1;++i){
    if(y[i] <= left) cout << right << endl;
    else cout << left << endl;  
  }
  if(y[n-1] <= left){
    cout << right;
  }else{
    cout << left;
  }
  return 0;
}

Measured memory_bytes: 3712
N = int(input())
mod = 10 ** 9 + 7
memo = [{} for _ in range(N + 1)]

def is_agc(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]
        if ''.join(t).count('AGC') >= 1:
            return True
    return False

def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0

    for char in 'ATGC':
        if not is_agc(last3 + char):
            ret = (ret + dfs(cur + 1, last3[1:] + char)) % mod
        memo[cur][last3] = ret
    return ret

print(dfs(0, 'TTT'))


Measured memory_bytes: 3860
// Aizu 1114: Get a Rectangular Field
// 2017.9.13 bal4u@uu

#include <stdio.h>

int map[6][6], sum[6][6];

int main()
{
	int m, r, c, r2, c2, ans;

	scanf("%d", &m);
	while (m-- > 0) {
		for (r = 1; r <= 5; r++) for (c = 1; c <= 5; c++) scanf("%d", &map[r][c]);
		ans = 0;
		for (sum[r][0] = 0, r = 1; r <= 5; r++) for (c = 1; c <= 5; c++) sum[r][c] = sum[r][c-1] + map[r][c];
		for (r = 1; r <= 5; r++) for (c = 1; c <= 5; c++) {
			for (c2 = 5; c2 >= c; c2--) {
				int w, w2;
				if ((w2 = w = c2-c+1) > sum[r][c2]-sum[r][c-1]) continue;
				if (w2 > ans) ans = w2;
				for (r2 = r+1; r2 <= 5; r2++) {
					if (w > sum[r2][c2]-sum[r2][c-1]) break;
					w2 += w; if (w2 > ans) ans = w2;
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1836
#include<bits/stdc++.h>
using namespace std;
struct po{
	int x,y,dis;
}edge[100];
int num;
inline void add(int x,int y,int dis){
	edge[++num].x=x;
	edge[num].y=y;
	edge[num].dis=dis;
}
int main()
{
	int l,t;
	cin>>l;
	for(int i=0;i<21;i++) if(l&(1<<i)) t=i;
	for(int i=1;i<=t-1;i++) add(i,i+1,1<<i-1),add(i,i+1,0);
	add(t,20,0);
	add(t,20,1<<t-1);
	int g=1<<t;
	while(g<l){
		for(int i=0;i<21;i++) if((1<<i)&(l-g)) t=i;
		add(t+1,20,g);
		g|=1<<t;
	}
	cout<<"20 "<<num<<endl;
	for(int i=1;i<=num;i++) cout<<edge[i].x<<" "<<edge[i].y<<" "<<edge[i].dis<<endl;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll R;
    cin >> R;

    if (R < 1200) {
        cout << "ABC" << endl;
    } else if (R < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int main(){
	while(true){
		string s;
		cin>>s;
		if(s[0]=='#') break;
		vector<string> vc;
		int N=s.size();
		rep(i,1<<N){
			string t=s;
			bool can=1;
			rep(j,N) if((i>>j)&1){
				if(t[j]=='z') can=0;
				t[j]++;
			}
			if(!can) continue;
			bool is[26]={};
			is[0]=1;
			int x=0;
			rep(j,N) if(!is[t[j]-'a']) x|=(1<<j),is[t[j]-'a']++;
			if(x==i) vc.pb(t);
		}
		sort(all(vc));
		cout<<vc.size()<<endl;
		if(vc.size()<=10){
			for(string s:vc) cout<<s<<endl;
		}else{
			rep(i,5) cout<<vc[i]<<endl;
			rep(i,5) cout<<vc[vc.size()-5+i]<<endl;
		}
	}
}

Measured memory_bytes: 2348
use std::*;
use proconio::input;

struct Dsu {
    p: Vec<usize>,
    sz: Vec<u32>,
}

impl Dsu {
    pub fn new(n: usize) -> Self {
        let mut v = vec![0; n];
        for i in 1..n {
            v[i] = i;
        }
        Self {
            p: v,
            sz: vec![1; n]
        }
    }

    fn find(&mut self,mut x: usize) -> usize {
        let mut t = x;
        while self.p[x] != x {
            x = self.p[x];
        }
        
        while self.p[t] != t {
            let tt = self.p[t];
            self.p[t] = x;
            t = tt;
        }
        x
    }

    fn uni(&mut self, mut x: usize, mut y: usize) {
        x = self.find(x);
        y = self.find(y);
        if x == y {
            return;
        }
        self.sz[x] += self.sz[y];
        self.p[y] = x;
    }
}

fn main() {
    input! {
        n: u32,
        m: u32
    }
    let mut dsu = Dsu::new(n as usize + 1);
    for _ in 0..m {
        input! {
            a: usize,
            b: usize
        }
        dsu.uni(a, b);
    }
    let mut ans = 0;
    for i in 1..(n + 1) {
        ans = cmp::max(ans, dsu.sz[i as usize])
    }
    println!("{}", ans);
}

Measured memory_bytes: 6828
X, Y = map(int, input().split())

def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x%y)

g = Y / gcd(X, Y)

if g == 1:
  print("-1")
else:
  if g == 2:
    g = 3
  else:
    g = 2
  ans = X * g
  if ans <= 1e18:
    print(ans)
  else:
    print("-1")


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	string s;
	for(int i=0; i< n; i++) s += "A";
	for(int i=0; i< m; i++) s += "B";
	do{
		bool p = true;
		int a = 0, b = 0;
		for(int i=0; i< s.size(); i++){
			s[i] == 'A' ? a++ : b++;
			if(((a == 5 && b <= 3) || (b == 5 && a <= 3)) && i != s.size()-1){p = false; break;}
			if(a == 5 && b == 5 && s[i] == s[i-1]){p = false; break;}
			if((a == 6 || b == 6) && s[i] == s[i-1] && i != s.size()-1){p = false; break;}
		}
		if(p) cout << s << endl;
	}while(next_permutation(s.begin(), s.end()));
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  int ans = 0;
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  if(n == 1){
    cout << 1 << endl;
    return 0;
  }
  for(int i = 0; i < n-1; i++){
    if(s[i] == s[i+1]){
      ans++;
    }
  }
  cout << n-ans << endl;
}

Measured memory_bytes: 9596
#include<iostream>
using namespace std;
int main()
{
	int n,i,s=0,f;
	cin>>n;
	int a[n+1];
	for(i=1;i<=n;i++) cin>>a[i];
	while(1){
		f=1;
		for(i=1;i<=n;i++){
			if(a[i]%2==0)
				a[i]/=2;
			else{
				f=0;
				break;
			}
		}
		if(f==0){
			cout<<s<<endl;
			break;
		}
		else
			s++;
	}
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    ll a,b,c,k;cin>>a>>b>>c>>k;
    if(k<=a){
        cout<<k<<endl;
        return 0;
    }
    if(a<k&&k<=a+b){
        cout<<a<<endl;
        return 0;
    }
    cout<<2*a+b-k<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
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;
}

//切り上げの割り算は(a + b - 1) / bでできる
//時間を意識しろ
//コードテストちゃんとして
//画面とにらめっこするな書け
//WA出すたびにABCは五億円払え
//わからない問題はとばせ
//躊躇なくぐぐれ

//ここから
int main(){
    ll N,X,Y;
    cin>>N>>X>>Y;
    vl vec(N-1,0);
    rep2(i,1,N){
        rep2(j,i+1,N+1){
            ll b=abs(Y-j);
            ll c=abs(X-i);
            ll a=min(j-i,c+b+1);
            vec.at(a-1)++;
        }
    }
    rep(i,N-1){
        cout<<vec.at(i)<<endl;
    }
}

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

using namespace std;
#define ll long long

int main() {
  string s;
  string t;
  string u;
  int a,b;
  cin >> s;
  cin >> t;
  scanf("%d", &a);
  scanf("%d", &b);
  cin >> u;

  if(s == u) a = a - 1;
  if(t == u) b = b - 1;

  printf("%d %d\n", a, b);

	return 0;
}


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

const int mod=1e9+7;

int main() {
    int h, w;
    cin >> h >> w;
    string a[h];
    for (auto &s : a) cin >> s;
    vector<vector<int>> dp(h+1,vector<int>(w+1,0));
    for (int i=1;i<=h;i++) {
        for (int j=1;j<=w;j++) {
            if (a[i-1][j-1]=='#')
                continue;
            if (i==1&&j==1) {
                dp[1][1]=1;
                continue;
            }
            dp[i][j]=dp[i-1][j]+dp[i][j-1];
            dp[i][j]%=mod;
        }
    }
    cout << dp[h][w];
    return 0;
}


Measured memory_bytes: 9476
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string s;

int main(void){
  set<string> p;
  IN(N);
  REP(i, N) {
    IN(s);
    p.insert(s);
  }
  PRINT(p.size());
}


Measured memory_bytes: 19208
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e5+5;
struct node{
	int l,r,b,id;
}z[maxn];
int n,X;
bool cmp1(node aa,node bb) {
	int as = aa.b * aa.l + (X-aa.b)*aa.r;
	int bs = bb.b * bb.l + (X-bb.b) * bb.r;
	return as > bs;
}
bool ok(int SM) {
	int sm = 0;
	for(int i=1;i<=n;i++) sm-=z[i].b*z[i].l;
	int k = SM/X; int res = SM - k*X;
	for(int i=1;i<=k;i++) {
		sm += z[i].b*z[i].l + (X-z[i].b)*z[i].r;
	}
	if(k==n) return sm >= 0;
	int ans = sm;
	for(int i=1;i<=n;i++) {
		if(i<=k) {
			int yo = sm - z[i].b*z[i].l - (X-z[i].b)*z[i].r;
			yo += z[k+1].b*z[k+1].l + (X-z[k+1].b)*z[k+1].r;
			int oo = min(z[i].b,res);
			ans = max(ans,yo + oo*z[i].l + (oo==z[i].b?res-oo:0)*z[i].r );
		} else {
			int oo = min(z[i].b,res);
			ans = max(ans,sm + oo*z[i].l + (oo==z[i].b?res-oo:0)*z[i].r );
		}
	}
	return ans>=0;
}

main() {
	scanf("%lld%lld",&n,&X);
	for(int i=1;i<=n;i++) {
		scanf("%lld%lld%lld",&z[i].b,&z[i].l,&z[i].r); z[i].id = i;
	}
	sort(z+1,z+1+n,cmp1);
	int L = 0; int R = n*X,ans = 0 ,mid = 0;
	while(L<=R) {
		mid = (L+R)>>1;
		if(ok(mid)) ans = mid , R = mid - 1;
		else L = mid + 1;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 3328
// Problem Link: 
// Tutorial Link: 

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define ll  long long
#define all(v) v.begin(), v.end()
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<b;++i)
#define repb(i,a,b) for(LL i=a;i>b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL n, a[500];

int main()
{
	FIO;
	cin >> n;
	rep(i,1,n+1) cin >> a[i];
	LL cur = 1000, cnt = 0;
	a[0] = 500;
	a[n+1] = -1;
	rep(i,1,n+1) {
		if(a[i] <= a[i+1] && a[i] <= a[i-1]) {
			LL val = cur / a[i];
			cur -= val*a[i];
			cnt += val;
		}
		else if(a[i] >= a[i+1] && a[i] >= a[i-1]) {
			cur += cnt*a[i];
			cnt = 0;
		}
	}
	cout << cur << endl;
}

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

typedef long long LL;
typedef pair<LL,LL> PII;

int main() {
	int H,W;
	cin >> H >> W;
	int p, q ;
	for(int i=0; i<H; i++) {
		for(int j=0; j<W; j++) {
			string s;
			cin >> s;
			if(s == "snuke") {
				p = i;
				q = j;
			}
		}
	}
	char c  =  'A' + q;
	cout << c << p+1 << endl;
	
	return 0;
}



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

int n, m;
int max_n = INT_MIN, min_m = INT_MAX;

void read()
{
    for (int i = 0; i < n; i++)
    {
        int x_i;
        cin >> x_i;
        if (x_i > max_n)
        {
            max_n = x_i;
        }
    }

    for (int i = 0; i < m; i++)
    {
        int y_i;
        cin >> y_i;
        if (y_i <= min_m)
        {
            min_m = y_i;
        }
    }
}

int main()
{
    int x, y;
    cin >> n >> m >> x >> y;
    read();

    if (max_n < min_m && max_n > x && min_m <= y)
        cout << "No War" << endl;
    else
        cout << "War" << endl;
}


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

int main(void){
  int N;
  cin >> N;
  int a[N];

  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  for(int i=N-1;i!=-1;i--){
    if(i!=0)cout << a[i] << ' ';
    else cout << a[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int H,W,A,B; cin >> H >> W >> A >> B;
    rep(i,H) {
        rep(j,W) {
            if (i < B && j < A) cout << 1;
            else if (i >= B && j >= A) cout << 1;
            else cout << 0;
        }
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 3656
/*
sonu_verma1
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(a) push_back(a)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
ll powr(int n)
{
	ll an=1,i;
	for(i=1;i<=n;i++)
		an=an*2;
	return an;
}
int main()
{
	ll h;
	cin>>h;
	ll b=0,f=0;
	while(h)
	{
		if(h%2)
			f++;
		h=h/2;
		b++;
	}
		cout<<powr(b)-1;
 
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a,b;
    
    scanf("%d %d", &a, &b);
    
    if(a < b)
     printf("a < b\n");
     
    else if(a > b)
     printf("a > b\n");
     
    else if(a == b)
     printf("a == b\n");
     
    return (0);
    
}


Measured memory_bytes: 2100
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main() {
    int n, a;
    cin >> n >> a;
    if(n % 500 > a){
        print("No");
    }else{
        print("Yes");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

    REP(i, 1, 9) REP(j, 1, 9) {
        if (i * j == N) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


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



int main(){
	int m,n;//ねこ　階数
	cin>>m>>n;
	vector<vector<double> >    dp(1<<m, vector<double>(m,0) ) ;
	vector<vector<double> >   p(m,vector<double> (n,0) );
	
	for(int i=0;i< (1<<m) ;i++){
		for(int j=0;j<m;j++){
			if(  ( (1<<j) & i ) != 0 ) dp[i][j] = 1;  
		}
	}
	

	for(int i=0;i<m;i++)
		for(int j=0;j<n;j++)cin>>p[i][j];


	for(int i=n-1;i>=0;i--){
		vector<vector<double> > mem(1<<m,vector<double> (m,0) );
		for(int j=0;j<(1<<m);j++){
			for(int k = 0;k<m;k++){
				if( (j&(1<<k) ) == 0 ) continue;
				double mx = 0;
				for(int l = 0; l< m;l++ ) {
					mx = max(mx,mem[ (j&~(1<<k) )][l] ) ;
				}
				mem[j][k] = p[k][i]*dp[j][k] + (1- p[k][i])*mx;
			}
		}
		dp = mem;
	}

	cout << fixed << setprecision(10);
	cout << *max_element(dp[(1<<m) -1].begin(), dp[(1<<m) -1].end()) << endl;


	return 0;
}



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

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


int N,K;
//DP[i][j][k]=i番目,j個保留,奇妙さk
int DP[55][55][2525];
signed main() {
	cin>>N>>K;
	DP[0][0][0]=1;
	rep(i,N){
		rep(j,i+1){
			rep(k,i*i+1){
				DP[i][j][k]%=mod;
				int newj=k+2*j;
				//両方使う
				DP[i+1][j][newj]+=DP[i][j][k];
				//両方使わない
				DP[i+1][j+1][newj]+=DP[i][j][k];
				//i番目のボールを保留箱に、i番目の箱は保留
				DP[i+1][j][newj]+=DP[i][j][k]*j;
				//i番目の箱に保留ボールを、i番目のボールは保留
				DP[i+1][j][newj]+=DP[i][j][k]*j;
				//i番目の箱に保留ボールを、i番目のボールを保留箱に
				DP[i+1][j-1][newj]+=DP[i][j][k]*j*j;
			}
		}
	}
	cout<<DP[N][0][K]%mod<<endl;
}


Measured memory_bytes: 53504
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

type pair struct {
	cost      int
	src, dest int
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

type PriorityQueue []pair

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].cost <= pq[j].cost
}

func (pq *PriorityQueue) Push(x interface{}) {
	item := x.(pair)
	*pq = append(*pq, item)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

var sc = bufio.NewScanner(os.Stdin)

func next() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i

}

type Tree struct {
	me   int
	prev *Tree
}

func getTop(t *Tree) *Tree {
	if t.prev != nil {
		r := getTop(t.prev)
		t.prev = r
		return r

	}
	return t

}

func same(a *Tree, b *Tree) bool {
	t1 := getTop(a)
	t2 := getTop(b)
	return t1.me == t2.me
}

func unite(a *Tree, b *Tree) {
	getTop(a).prev = b
}

func main() {
	sc.Split(bufio.ScanWords)

	vertexs, edges := next(), next()

	// heap queue
	queue := make(PriorityQueue, 0, edges)

	// union-find tree
	nodes := make([]*Tree, vertexs)

	// O(V)
	for i := 0; i < vertexs; i++ {
		nodes[i] = &Tree{me: i, prev: nil}

	}

	// O(E log E)
	for i := 0; i < edges; i++ {

		src, dest, cost := next(), next(), next()

		if src > vertexs || dest > vertexs {
			panic("over")
		}

		p := pair{src: src, dest: dest, cost: cost}
		// O(log E)
		heap.Push(&queue, p)
	}

	results := 0

	for queue.Len() > 0 {
		item := heap.Pop(&queue).(pair)

		if !same(nodes[item.src], nodes[item.dest]) {
			results += item.cost
			unite(nodes[item.src], nodes[item.dest])
		}
	}

	fmt.Println(results)

}




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

int main(){
    int A, B;  cin >> A >> B;
    vector<string> ans(100);
    for(int i=0; i<50; i++) ans[i] = string(100,'#');
    for(int i=50; i<100; i++) ans[i] = string(100,'.');
    A--; B--;
    for(int i=0; i<50; i+=2){
        for(int j=1; j<100; j+=2){
            if(A>0){
                ans[i][j] = '.';
                A--;
            }
        }
    }

    for(int i=51; i<100; i+=2){
        for(int j=1; j<100; j+=2){
            if(B>0){
                ans[i][j] = '#';
                B--;
            }
        }
    }

    cout << "100 100" << endl;
    for(int i=0; i<100; i++){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 256