akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

using mint = modint998244353;

ostream& operator<<(ostream& out, mint m){
  out << m.val();
  return out;
}

struct node{
  mint sum,evinv;
  int sumzw;
};

node empty(){
  return {0,0,0};
}

int n,k;

node lacz(node a,node b){
  return { a.sum + b.sum, 
    a.evinv + b.evinv + a.sumzw * b.sum,
    a.sumzw + b.sumzw};
}

node mapping(mint x, node a){
  return {a.sum * x, a.evinv * x, a.sumzw};
}
mint composition(mint x,mint y){
  return x * y;
}
mint jeden(){
  return 1;
}

lazy_segtree<node, lacz, empty , mint, mapping, composition, jeden> tree;

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> k;
  tree = {vector<node>(n,{0,0,1})};
  
  vector<int> p(n);
  R(i,n){
    cin >> p[i];
    p[i]--;
  }
  R(i,k)tree.set(p[i], {1,0,0});
  
  mint kinv = mint(1) / k;
  mint res = 0;
  R(i,n-k){
    res += tree.all_prod().evinv * kinv;
    res += mint(k-1) / 2;
    tree.apply(0, n, (k-1) * kinv);
    tree.set(p[i+k], {1,0,0});
  } 
  res += mint(k) * (k - 1) / 4;
  cout << res << "\n";
}


Measured memory_bytes: 15648
#!/usr/bin/env python3
# %%
stdin = open(0)

# %%
A, B, C = map(int, stdin.read().split())


# %%
def is_poor(A, B, C):
    for _ in range(3):
        A, B, C = B, C, A
        if A == B != C:
            return True
    return False


# %%
answer = 'Yes' if is_poor(A, B, C) else 'No'
print(answer)

# %%


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


#define dhai_machli ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define loop(i,n) for(int i=0; i<n; i++)



using namespace std;

int main()
{



    dhai_machli;

    
   int n;
    cin>>n;


     cout<<48-n<<endl;



    




    return 0;
}

Measured memory_bytes: 3620
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();

	let s = get().as_bytes();
    let t = get().as_bytes();
    
    if s.len() != t.len() {
    	println!("No");
        return;
    }
    
    use std::collections::HashMap;
    
    let mut hs = HashMap::new();
    let mut ht = HashMap::new();
    
    for i in 0..s.len() {
    	let cs = s[i];
        let x = hs.len();
        let p = *hs.entry(cs).or_insert(x);
        let ct = t[i];
        let y = ht.len();
        let q = *ht.entry(ct).or_insert(y);
        if p != q {
        	println!("No");
            return;
        }
    }
    
    println!("Yes");
    
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
map<pair<int,int>,int>mp;
pair<int,int> dg(int n){
	pair<int,int> ret;
	ret.first=n%10;
	while(n){
		int dd=n%10;
		n/=10;
		if(n==0)ret.second=dd;
	}
	return ret;
}
int main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		mp[dg(i)]++;
	}
	ll ans=0;
	for(auto u:mp){
		pair<int,int> pp={u.first.second,u.first.first};
		ans+=mp[pp]*u.second;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3540
import std.algorithm, std.array, std.conv, std.range, std.stdio, std.string;
void main()
{
    auto buf = readln.chomp.split.to!(long[]);
    long a = buf[0], b = buf[1], k = buf[2];
    auto e = a.min(k);
    a -= e;
    k -= e;
    e = b.min(k);
    b -= e;
    k -= e;
    "%d %d".writefln(a, b);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

ll dp[100005][13];

int main(){
    string s;
    cin>>s;
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    rep(i,s.size()){
        rep(j,13){
            if(s[i]=='?'){
                rep(k,10){
                dp[i+1][(j*10+k)%13]+=dp[i][j];
                dp[i+1][(j*10+k)%13]%=mod;
                }
            }
        else {
            int k=(int)(s[i]-'0');
            dp[i+1][(j*10+k)%13]+=dp[i][j];
            dp[i+1][(j*10+k)%13]%=mod;
            }
        }
    }
    cout<<dp[(int)s.size()][5]<<endl;
    return 0;
}


Measured memory_bytes: 10624
#include <stdio.h>

int main(void){
	int n,l[100],max=-1,sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&l[n]);
		if(max<l[n]) max=l[n];
		sum+=l[n];
	}
	if(sum-max>max) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int a[2][N];

int main() {
	int n;cin>>n;
	rep(i,n) cin>>a[0][i];
	int sum=a[0][0];
	rep(i,n) {cin>>a[1][i];sum+=a[1][i];}
	int ans=sum;
	rep1(i,n-1) {sum+=a[0][i]-a[1][i-1];ans=max(ans,sum);}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
//#define mod 998244353
#define inf 1000000000
#define pr1(a) cout << a << "\n"
#define pr2(a,b)cout << a <<  " " <<b<< "\n"
#define pr3(a,b,c) cout << a <<" " << b << " " << c << "\n"

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

int gcd(int a, int b){
    if(b==0)return a;
    gcd(b,a%b);
}
const int maxn = 2*1e5 + 10;

void solve(){

    int n;
    cin >> n;

    int r = 0, g =0,b =0;

    string s;
    cin >> s;

    for(int i = 0;i<n;i++){
        if(s[i]=='R')r++;
        else if(s[i]=='B')b++;
        else g++;

    }

    int ans = r*b*g;

    for(int i = 0;i<=n-3;i++){
        for(int j = i+2;j<n;j++ ){
            if(s[i]!=s[j] && (i+j)%2==0 && s[i]!=s[(i+j)/2] && s[j]!=s[(i+j)/2]){
                ans-=1;
            }
        }
    }

    cout << ans << endl;

} 

signed main() 
{   
    IOS;
    int t = 1;
    // cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 3660
//2019年12月8日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

namespace {
    // printElms(&a[0], a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}



#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 10000000000000000;


ll ansmat[10][10];



int main(){
    int n;
    cin >> n;
    ll ans = 0;

    rep1(l,9)rep1(r,9){
        // prints("l,r",l,r);
        if(l == r&&n >= l){ansmat[l][r]++;}
        if(n>=l*10+r) ansmat[l][r]++;
        rep(i,10)if(n>=l*100+10*i+r)ansmat[l][r]++;
        rep(i,100)if(n>=l*1000+10*i+r)ansmat[l][r]++;
        rep(i,1000)if(n>=l*10000+10*i+r)ansmat[l][r]++;
        if(l == 1)rep(i,10000)if(n>=l*100000+10*i+r)ansmat[l][r]++;

        
//            if (tmplist[0] == l && tmplist[tmplist.size()-1] == r) {ansmat[l][r]++;}//prints("added");}
        
    }
    //prints(ansmat[1][2]);

    rep1(l,9)rep1(r,9){
        ans+=ansmat[l][r]*ansmat[r][l];
    }

    prints(ans);


    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A>> B>> C>> D ;
  int L,R;
  L = A+B;
  R = C+D;
  if (L > R){
    cout << "Left" << endl;
  }
  else if(L==R){
  cout << "Balanced" << endl;
  }
  else{
  cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
public class Main{
  static int top;
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    char[] ch;
    String str;
    int i;

    for(;;){
      str = sc.nextLine();
      if(".".equals(str))break;
      ch = new char[str.length()];
      top = 0;
      out.println(solve(ch, str));
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static String solve(char[] ch, String str){
    char[] stack;
    int i;

    stack = new char[str.length()];
    for(i = 0;i < str.length();i++){
      ch[i] = str.charAt(i);
      if(ch[i] == '(')push(stack, ch[i]);
      else if(ch[i] == '[')push(stack, ch[i]);
      else if(ch[i] == ')'){
        if(top != 0 && seetop(stack) == '(')top--;
        else return("no");
      }else if(ch[i] == ']'){
        if(top != 0 && seetop(stack) == '[')top--;
        else return("no");
      }
    }
    if(top == 0)return "yes";
    else return "no";
  }
  private static char pop(char[] stack){
    return stack[--top];
  }
  private static void push(char[] stack, char a){
    stack[top++] = a;
    return;
  }
  private static char seetop(char[] stack){
    return stack[top - 1];
  }
}

Measured memory_bytes: 32204
n = int(input())
a = []
b = []
for _ in [0]*n:
  a += [list(map(int,input().split()))]
a.sort(key=lambda t:-t[0])
for _ in [0]*n:
  b += [list(map(int,input().split()))]
b.sort(key=lambda s:s[1])
c = 0
for t in a:
  for s in b:
    if t[0]<s[0] and t[1]<s[1]:
      c += 1
      b.remove(s)
      break
print(n-len(b))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <set>

int main() {
  int N;

  std::cin >> N;

  std::set<std::string> s;
  bool ok = true;
  std::string prev = "";

  for (int i = 0; i < N; i++) {
    std::string W;
    std::cin >> W;

    if (s.find(W) != s.end()) {
      ok = false;
    } else if (i != 0 && W[0] != prev[prev.size() - 1]) {
      ok = false;
    } else {
      prev = W;
      s.insert(W);
    }
  }

  std::cout << (ok ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int main()
{
	char s[120];
	int n;
	scanf("%d",&n);
	scanf("%s",s);
	int a[120];
	int flag=0;
	int nn=0;
	int i=0;
	for(;i<strlen(s);i++)
	{
		if(s[i]=='I')
		flag++;
		if(s[i]=='D')
		flag--;
		a[nn++]=flag;
	}
	int max=a[0];
	i=i-1;
	for(;i>=0;i--)
	{
		if(max<a[i])
		max=a[i];
	}
	if(max<0)
	printf("0");
	else
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 256
l = list(int(i) for i in input().split())
A = list(int(i) for i in input().split())

left_cost = 0
right_cost = 0

for i in range(l[1]):
    if A[i] < l[2]:
        left_cost += 1
    else:
        right_cost += 1

if left_cost < right_cost:
    print("%d" % left_cost)
else:
    print("%d" % right_cost)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

bool bused[50][50],wused[50][50];
char deta[50][50];
int dh[4] = {1,0,-1,0}, dw[4] = {0,1,0,-1};
int w,h;

void W(int a, int b){
	queue<P> que;
	que.push(P(a,b));
	while(que.size() != 0){
		P p = que.front(); que.pop();
		rep(i,4){
			int th = p.fi+dh[i], tw = p.sec+dw[i];
			if(0<=th&&th<h&&0<=tw&&tw<w){
				if(!wused[th][tw] && deta[th][tw] == '.'){
					wused[th][tw] = true;
					que.push(P(th,tw));
				}
			}
		}
	}
}

void B(int a, int b){
	queue<P> que;
	que.push(P(a,b));
	while(que.size() != 0){
		P p = que.front(); que.pop();
		rep(i,4){
			int th = p.fi+dh[i], tw = p.sec+dw[i];
			if(0<=th&&th<h&&0<=tw&&tw<w){
				if(!bused[th][tw] && deta[th][tw] == '.'){
					bused[th][tw] = true;
					que.push(P(th,tw));
				}
			}
		}
	}
}

int main(){
	while(scanf("%d%d", &w, &h),w||h){
		rep(i,50) rep(j,50){
			wused[i][j] = false;
			bused[i][j] = false;
		}
		rep(i,h) rep(j,w) scanf(" %c", &deta[i][j]);
		rep(i,h) rep(j,w){
			if(deta[i][j] == 'W') W(i,j);
			if(deta[i][j] == 'B') B(i,j);
		}
		int wcnt = 0, bcnt = 0;
		rep(i,h) rep(j,w){
			if(bused[i][j] == true && wused[i][j] == false) bcnt++;
			if(bused[i][j] == false && wused[i][j] == true) wcnt++;
		}
		printf("%d %d\n", bcnt, wcnt);
	}
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll X;
    cin >> X;
    if(400 <= X  && X <= 599) PR(8);
    if(600 <= X  && X <= 799) PR(7);
    if(800 <= X  && X <= 999) PR(6);
    if(1000 <= X  && X <= 1199) PR(5);
    if(1200 <= X  && X <= 1399) PR(4);
    if(1400 <= X  && X <= 1599) PR(3);
    if(1600 <= X  && X <= 1799) PR(2);
    if(1800 <= X  && X <= 1999) PR(1);


    return 0;
}

/*



*/

Measured memory_bytes: 3632
from sys import stdin
def input():
    return stdin.readline().strip()

def main():
    n = int(input())
    p, m = [0]*n, [0]*n
    for i in range(n):
        x, y = map(int, input().split())
        p[i] = x + y
        m[i] = x - y

    print(max(max(p) - min(p), max(m) - min(m)))

main()

Measured memory_bytes: 72024
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

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


int main() {
	ll H, W;
	cin >> H >> W;

	vector<vector<string>> S(H + 1, vector<string>(W + 1));
	repn(i, H)repn(j, W) cin >> S[i][j];

	ll gyo;
	char retsu;
	repn(i, H)repn(j, W) {
		if (S[i][j] == "snuke") { gyo = i; retsu = 'A' - 1 + j; }
	}
	cout << retsu << gyo<<endl;
	
	system("PAUSE");
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t t=0; t<v.size(); ++t){cout << " " << #v << "[" << t << "]=" << v[t];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    string s;
    cin >> s;
    
    bool iseven = (s.length() % 2 == 0);
    bool issandwitch = (s[0] == s[s.length()-1]);
    
    if (iseven && issandwitch) cout << "First" << endl;
    else if (!iseven && issandwitch) cout << "Second" << endl;
    else if (iseven && !issandwitch) cout << "Second" << endl;
    else if (!iseven && !issandwitch) cout << "First" << endl;
    
    return 0;
    
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

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

#define INF 1000000

int main(){
    int n, m; cin >> n >> m;
    vector<int> c(m);
    rep(i, m) {
        cin >> c[i];
    }
    vector<int> dp[n+1];
    vector<int> tmp(m, INF);
    rep(i, n+1) {
        dp[i] = tmp;
    }
    rep(i, m) {
        rep(j, n+1) {
            if(i  == 0) {
                if(j%c[i] == 0)
                    dp[j][i] = j/c[i];
            } else {
                if(j - c[i] >= 0) {
                    dp[j][i] = min(dp[j-c[i]][i] + 1, dp[j][i-1]);
                } else {
                    dp[j][i] = dp[j][i-1];
                }
            }
        }
    }
    // rep(i, n + 1) {
    //     rep(j, m) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[n][m-1] << endl;
}



Measured memory_bytes: 9016
#include<iostream>
#include<cstring>
#include<cstdio>
//#include<time.h>
//#include<complex>
#include<algorithm>
#include<stdlib.h>
using namespace std;

#define LL long long
int qread()
{
	char c; int s=0; while ((c=getchar())<'0' || c>'9');
	do s=s*10+c-'0'; while ((c=getchar())>='0' && c<='9'); return s;
}

//Pay attention to '-' and LL of qread!!!!

int n;
#define maxn 531111
const int mod=924844033,G=5; int rev[maxn];
struct Edge{int to,next;}edge[maxn<<1]; int first[maxn],le=2;
void in(int x,int y) {Edge &e=edge[le]; e.to=y; e.next=first[x]; first[x]=le++;}
void insert(int x,int y) {in(x,y); in(y,x);}

int B[maxn],A[maxn],D[maxn],Ans[maxn],cnt[maxn],fac[maxn],inv[maxn];
int C(int n,int m) {return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}

int powmod(int a,int b)
{
	int ans=1;
	while (b) {if (b&1) ans=1ll*ans*a%mod; a=1ll*a*a%mod; b>>=1;}
	return ans;
}

void dft(int *a,int n,int type)
{
	int wei=0; while ((1<<wei)!=n) wei++;
	for (int i=0;i<n;i++)
	{
		rev[i]=0;
		for (int j=0;j<wei;j++) rev[i]|=((i>>j)&1)<<(wei-j-1);
	}
	for (int i=0;i<n;i++) if (i<rev[i]) a[i]^=a[rev[i]]^=a[i]^=a[rev[i]];
	for (int i=1;i<n;i<<=1)
	{
		int t=powmod(G,(mod-1)/(i*2));
		if (type==-1) t=powmod(t,mod-2);
		for (int j=0,p=i<<1;j<n;j+=p)
		{
			int tmp=1;
			for (int k=0;k<i;k++,tmp=1ll*tmp*t%mod)
			{
				int now=1ll*tmp*a[j+k+i]%mod;
				a[j+k+i]=(a[j+k]+mod-now)%mod;
				a[j+k]=(a[j+k]+now)%mod;
			}
		}
	}
	if (type==-1)
	{
		int ni=powmod(n,mod-2);
		for (int i=0;i<n;i++) a[i]=1ll*a[i]*ni%mod;
	}
}

void mul(int *a,int *b,int *c,int n)
{
	dft(a,n,1); dft(b,n,1);
	for (int i=0;i<n;i++) c[i]=1ll*a[i]*b[i]%mod;
	dft(c,n,-1);
}

int size[maxn];
void dfs(int x,int fa)
{
	size[x]=1;
	for (int i=first[x];i;i=edge[i].next)
	{
		Edge &e=edge[i]; if (e.to==fa) continue;
		dfs(e.to,x); size[x]+=size[e.to];
		cnt[size[e.to]]++; cnt[n-size[e.to]]++;
	}
}

int main()
{
	n=qread();
	for (int i=1,x,y;i<n;i++) {x=qread(); y=qread(); insert(x,y);}
	dfs(1,0);
	
	fac[0]=1; for (int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=powmod(fac[n],mod-2); for (int i=n;i;i--) inv[i-1]=1ll*inv[i]*i%mod;
	for (int i=1;i<=n;i++) B[n-i+1]=1ll*cnt[i]*fac[i]%mod;
	for (int i=0;i<=n;i++) A[i]=inv[i];
	int mm=1; for (;mm<=(n+n);mm<<=1);
	mul(B,A,D,mm);
	for (int i=1;i<=n;i++) Ans[i]=1ll*inv[i]*D[n+1-i]%mod;
	
	for (int i=1;i<=n;i++) Ans[i]=(1ll*n*C(n,i)%mod+mod-Ans[i])%mod;
	for (int i=1;i<=n;i++) printf("%d\n",Ans[i]);
	return 0;
}

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

ll dequeToInt(const deque<ll>& d) {
    ll ans = 0;
    ll cnt = 1;
    for (int i = d.size() - 1; i >= 0; --i) {
        ans += d[i] * cnt;
        cnt *= 10;
    }
    return ans;
}

deque<ll> make_appended_deque(deque<ll> d, ll n) {
    deque<ll> ans = move(d);
    ans.push_back(n);
    return ans;
}

int main() {
    ll k;
    cin >> k;
    queue<deque<ll>> q;
    for (int i = 1; i < 10; ++i) {
        deque<ll> d;
        d.push_back(i);
        q.push(d);
    }
    int cnt = 1;
    while (true) {
        deque<ll> x = q.front();
        q.pop();
        if (cnt == k) {
            cout << dequeToInt(x) << endl;
            break;
        }
        if (x.back() != 0) {
            q.push(make_appended_deque(x, x.back() - 1));
        }
        q.push(make_appended_deque(x, x.back()));
        if (x.back() != 9) {
            q.push(make_appended_deque(x, x.back() + 1));
        }
        cnt++;
    }
}


Measured memory_bytes: 129312
#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iomanip>
#define For(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int gcd(int a,int b)
{
	return a?gcd(b%a,a):b;
}

int lcm(int a,int b)
{
	return a/gcd(a,b)*b;
} 
 
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int d1=a+c,d2=b+d,d3=a+d,d4=b+c;
	int maxx=min(min(min(d1,d2),d3),d4) ;
	cout<<maxx<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,i;
	
	while(scanf("%d", &n) != EOF){
		for(i = 1; i < 513; i *= 2){
			if(n%(i*2) != 0){
				printf("%d", i);
				
				n -= i;
				
				if(n != 0) printf(" ");
			}
		}
		printf("\n");
	}
	
	return(0);
}

Measured memory_bytes: 600
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
typedef struct{int x;int y;int d;LL u;}H;
LL i,j,k,n,o=1e9+7,s,sz,f[200040]={1},pv[200040],vf[200040],w[200040],z[200040];
H c,e[400005];
int C(H a,H b){return a.x<b.x;}
LL P(LL x,LL y)
{
	LL i=o-2,v=x;
	for(;i;i>>=1)
	{
		if(i&1)
		{
			v=v*y%o;
		}
		y=y*y%o;
	}
	return v;
}
H dfs(LL g,LL r,LL v)
{
	LL m=1,t=0;
	H c;
	for(int i=pv[v];i<pv[v+1];i++)
	{
		if(e[i].y^g)
		{
			if(e[i].d)
			{
				m=m*e[i].u%o*P(P(f[t+e[i].d],f[t]),f[e[i].d])%o;
				t+=e[i].d;
			}
			else
			{
				c=dfs(v,i,e[i].y);
				m=m*c.u%o*P(P(f[t+c.d],f[t]),f[c.d])%o;
				t+=c.d;
			}
		}
	}
	e[r].d=c.d=++t;
	e[r].u=c.u=m;
	return c;
}
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(;i<n-1;i++)
	{
		cin>>e[i].x>>e[i].y;
		e[i+n-1].x=e[i].y;
		e[i+n-1].y=e[i].x;
		w[e[i].x]++;
		w[e[i].y]++;
		e[i].u=e[i+n-1].u=1;
	}
	sz=2*n-2;
	sort(e,e+sz,C);
	for(i=0;++i<sz;)
	{
		if(e[i].x>e[i-1].x)
		{
			for(j=e[i-1].x;j++<e[i].x;)
			{
				pv[j]=i;
			}
		}
	}
	for(j=e[sz-1].x;j++<n+1;)pv[j]=sz;
	for(i=0;i++<n;)
	{
		f[i]=f[i-1]*i%o;
	}
	for(i=0;i++<n;)
	{
		if(w[i]<2&&vf[e[pv[i]].y])z[i]=vf[e[pv[i]].y];
		else
		{
			c=dfs(0,sz,i);
			z[i]=c.u;
			if(w[i]<2)vf[e[pv[i]].y]=c.u;
		}
	}
	for(i=0;i++<n;)cout<<z[i]<<endl;
}

Measured memory_bytes: 19456
#include <stdio.h>
int main(){
	char a[100];
	scanf("%s",&a);
	for (int i = 0; i < 3; ++i)
	{
		if (a[i]=='9')
		{
			a[i]='1';
		}else if (a[i]=='1')
		{
			a[i]='9';
		}
	}
	printf("%s\n",a);
}

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

int main(){
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if(e - a > k){
      cout << ":(" << endl;
    }else{
      cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int ans = 0;
        for(int a= 0;a<K;a++){
            for(int b= 0 ;b<K;b++){
                for(int c= 0;c<K;c++){
                    ans = ans + mgcd(a+1,b+1,c+1);
                }
            }
        }
        System.out.println(ans);
    }

    public static final int mgcd(int a, int b, int c) {
        int g = gcd(a,b);
        g = gcd(g,c);
    return g;
    }

    public static final int gcd(int a, int b) {

        if (a < b) {
            int tmp = a;
            a = b;
            b = tmp;
        }

        int r = -1;
        while (r != 0) {
            r = a % b;
            a = b;
            b = r;
        }

        return a;
    }


}

Measured memory_bytes: 35660
N, K = map(int, input().split())
S = list(input())

target = S[K - 1]
if target == 'A':
    replace = 'a'
elif target == 'B':
    replace = 'b'
else:
    replace = 'c'

S[K - 1] = replace
ans = ''.join(S)
print(ans)


Measured memory_bytes: 38256
list=list(map(int,input().split()))

if list[0]%(list[1]+list[2])==0:
	print((list[0]//(list[1]+list[2]))*list[1])
elif list[0]%(list[1]+list[2])<=list[1]:
	print((list[0]//(list[1]+list[2]))*list[1]+list[0]%(list[1]+list[2]))
else:
	print(list[0]//(list[1]+list[2])*list[1]+list[1])

Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
int main(){
 string a,b,c;
 cin>>a>>b>>c;
 int as=a.size()-1,bs=b.size()-1;
 if(a[as]==b[0] && b[bs]==c[0])cout<<"YES"<<endl;
 else cout<<"NO"<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if(s == u) --a;
    if(t == u) --b;
    printf("%d %d\n", a, b);
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// 998244353;// ;
constexpr long long INF = numeric_limits<LL>::max() / 2;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<LL>>g, rev;
vector<edge>edges;
vector<LL>v;
map<LL, LL>ma;
set<LL>st;
LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans,a[3][3], b[510000], dp[50000];
string str, ss;
bool f;
char c;
bool func() {
	if (a[0][0] == -1 && a[0][1] == -1 && a[0][2] == -1)return 1;
	if (a[1][0] == -1 && a[1][1] == -1 && a[1][2] == -1)return 1;
	if (a[2][0] == -1 && a[2][1] == -1 && a[2][2] == -1)return 1;
	if (a[0][0] == -1 && a[1][0] == -1 && a[2][0] == -1)return 1;
	if (a[0][1] == -1 && a[1][1] == -1 && a[2][1] == -1)return 1;
	if (a[0][2] == -1 && a[1][2] == -1 && a[2][2] == -1)return 1;
	if (a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1)return 1;
	if (a[2][0] == -1 && a[1][1] == -1 && a[0][2] == -1)return 1;
	return 0;
}
int main() {
	rep(i, 3)rep(j, 3) {
		cin >> a[i][j];
	}
	cin >> n;
	rep(i, n) {
		LL x;
		cin >> x;
		rep(i, 3)rep(j, 3) {
			if (a[i][j] == x)a[i][j] = -1;
		}
	}
	if (func())cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	
	int pasta1,pasta2,pasta3,juice1,juice2;
	int pasta,juice;
	int price;

	scanf("%d",&pasta1);
	scanf("%d",&pasta2);
	scanf("%d",&pasta3);
	scanf("%d",&juice1);
	scanf("%d",&juice2);
	
	if (pasta1<pasta2) pasta=pasta1;
	else pasta=pasta2;
	if (pasta3<pasta) pasta=pasta3;
	if (juice1<juice2) juice=juice1;
	else juice=juice2;

	price=pasta+juice-50;

	printf("%d\n",price);
	
	return 0;
}
	

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=200005;
ld a[N],b[N],A[N],B[N],c[N],ans;
int q[N];
ld xie(int x,int y){
	return (a[y]-a[x])/(y-x);
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read();
	int p=0;
	For(i,1,n){
		a[i]=read(); if(a[i]>=a[p])p=i;
	}
	For(i,1,n)b[i]=-read();
	For(i,0,n-p){
		A[i]=a[i+p]; B[i]=b[i+p];
	}
	For(i,n-p+1,n){
		A[i]=a[i+p-n]; B[i]=b[i+p-n];
	}
	c[0]=c[1]=0;
	For(i,2,n)c[i]=2*(c[i-1]-B[i-1])-c[i-2];
	For(i,0,n){
		a[i]=A[i]-c[i];
	}
	int top=0;
	For(i,0,n){
		while(top>=2&&xie(q[top-1],q[top])<xie(q[top],i))top--;
		q[++top]=i;
	}
	For(i,1,top-1){
		For(j,q[i],q[i+1]-1)ans+=c[j]+((j-q[i])*a[q[i+1]]+(q[i+1]-j)*a[q[i]])/(q[i+1]-q[i]);
	}
	printf("%.10f\n",ans/n);
}


Measured memory_bytes: 12212
#include<stdio.h>
int main()
{
    /*
    int a,b,c;
    char s[101];
    // 整数の入力
    scanf("%d", &a);
    // スペース区切りの整数の入力
    scanf("%d %d",&b,&c);
    // 文字列の入力
    scanf("%s",s);
    // 出力
    printf("%d %s\n",a+b+c,s);
    for(int i=0;i<10;i++){
        printf("hello");
    }
    */
   int s,w;
   scanf("%d",&s);
   if(s%10==2||s%10==4||s%10==5||s%10==7||s%10==9){
       printf("hon");
       return 0;
   }
   if(s%10==0||s%10==1||s%10==6||s%10==8){
       printf("pon");
       return 0;
   }
   if(s%10==3){
       printf("bon");
       return 0;
   }
}

Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>


int main(){
    std::string S;
    std::cin >> S;
    if(S[0]=='R' && S[1]=='R' && S[2]=='R'){
        std::cout << 3 << std::endl;
    }else if(S[0]=='R' && S[1]=='R' && S[2]!='R'){
        std::cout << 2 << std::endl;
    }else if(S[0]!='R' && S[1]=='R' && S[2]=='R'){
        std::cout << 2 << std::endl;
    }else if(S[0]!='R' && S[1]!='R' && S[2]!='R'){
        std::cout << 0 << std::endl;
    }else{
        std::cout << 1 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define uu unsigned
#define io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mkp make_pair
#define all(x) x.begin(),x.end()
#define ss second
#define ff first
#define mit map<ll,ll>::iterator
#define sit unordered_set<ll>::iterator
#define lit list<ll>::iterator
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pf push_front
#define printf __mingw_printf
#define printcas cout<<"Case "<<cas<<": "
#define _ continue;
#define endl '\n'
#define __ cout<<endl;continue;
#define vec4d(nam,type,a,b,c,d,fix) vector<vector<vector<vector<type>>>> nam(a,vector<vector<vector<type>>>(b,vector<vector<type>>(c,vector<type>(d,fix))))
int main()
{
     io;
    //string hudai(1000000,'a');
    int T=1;
   // cin>>T;
     for(int cas=1;cas<=T;cas++)
    {
        ll N,W,fix=1e10,valsum=0;
        cin>>N>>W;
        vl w(N+1),v(N+1);
        for(ll i=1;i<=N;i++)
        {
            cin>>w[i]>>v[i];
            valsum+=v[i];
        }
        vector<vl> dp(100005,vl(N+1,fix));
        ll i,j,lasti=0;
        for(j=0;j<=N;j++)dp[0][j]=0;
        for( i=1;i<=valsum;i++)
        {
            for( j=1;j<=N;j++)
            {
                if(v[j]<=i)
                {
                    dp[i][j]=min(dp[i][j-1],w[j]+dp[i-v[j]][j-1]);
                    if(dp[i][j]>W)dp[i][j]=fix;
                }
                else dp[i][j]=dp[i][j-1];
            }
            if(dp[i][N]!=fix) lasti=i;
        }
        cout<<lasti;

    }
    return 0;
}


Measured memory_bytes: 85308
import java.util.Scanner;

/**
 * Another way to put the question is to calculate the longest arc between two houses around the circle. the
 * houses will be visited in such a way that the arc won't be passed through.
 * substract the length of the longest arc from the circumference(k) of the circular pond. that is the answer
 */
public class Main {
    public static void main(String[] args) {
        final Scanner input = new Scanner(System.in);
        int k= input.nextInt();
        int n=input.nextInt();

       int maxArc =0,northToFirst=0,lastToNorth=0;



        //for the first case
        int cur=0,prev=0;

        //get the dis

        for (int i = 1; i <= n; i++) {
            prev =cur;
            cur =input.nextInt();

            //get the distance between the zero point(north) and first house
            if(i==1){
               northToFirst = cur;
            }
            //get the distance between the last house and the zero point (north)
            if(i==n){
                lastToNorth = k-cur;
            }

            //compare every other arcs
            if(i>=2){
                int arc = cur-prev;
                if(arc > maxArc){
                    maxArc = arc;
                }
            }


        }
        //check the last arc. i.e. spack between the first and last houses

        if((lastToNorth + northToFirst) > maxArc){
            maxArc = lastToNorth + northToFirst;
        }

        //answer, i.e min distance around the lake is

        System.out.println(k-maxArc);


    }
}


Measured memory_bytes: 64440
a,b = map(int,input().split())
c,d = map(int,input().split())
e,f = map(int,input().split())

if c==a or d==a:
    if a==e or a==f:
        print("NO")
    else:
        print("YES")
elif c==b or d==b:
    if b==e or b==f: 
        print("NO")
    else:
        print("YES")
else:
    print("YES")

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeSet;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		String input = scanner.next();
		StringBuilder s = new StringBuilder(input);
		ArrayList<TreeSet<Integer>> app = new ArrayList<TreeSet<Integer>>();
		for(int i = 0 ; i < 26 ; i++)
			app.add(new TreeSet<Integer>());
		for(int i = 0 ; i < s.length(); i++)
			app.get(s.charAt(i) - 'a').add(i);
		int q = scanner.nextInt();
		for(int i = 0 ; i < q ; i++)
		{
			int type;
			type = scanner.nextInt();
			if(type == 1)
			{
				int indx;
				char c;
				indx = scanner.nextInt() - 1;
				c = scanner.next().charAt(0);
				app.get(s.charAt(indx) - 'a').remove(indx);
				s.setCharAt(indx, c);
				app.get(c - 'a').add(indx);
			}
			else
			{
				int l, r, ans = 0;
				l = scanner.nextInt() - 1;
				r = scanner.nextInt() - 1;
				for(int j = 0 ; j < 26 ; j++)
				{
					Integer ret = app.get(j).ceiling(l); 
					if(ret != null && ret <= r)
						ans += 1;
				}
				System.out.println(ans);
			}
		}
		scanner.close();
	}
}

Measured memory_bytes: 107396
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <utility>

intmax_t f(intmax_t a, intmax_t b) {
  return b - (b-a+1) / 2;
}

int main() {
  intmax_t n, a, b;
  scanf("%jd %jd %jd", &n, &a, &b);

  if ((b-a) % 2 == 0) {
    printf("%jd\n", (b-a)/2);
  } else {
    printf("%jd\n", std::min(f(a, b), f(n-a+1, n-b+1)));
  }
}


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

using namespace std;
#define INF 100000
#define MAX_N 12
#define MAX_M 210
using namespace std;

int cost[MAX_N][MAX_N];
int num[MAX_M][MAX_M];
int DP[MAX_N];
int d[MAX_N];
bool used[MAX_N];
int H, W;
int V;
void solve();

int main()
{
	while (~scanf("%d %d", &H, &W))
	{
		V = 10;
		memset(DP, -1, sizeof(DP));
		DP[1] = 0;
		for (int i = 0; i <= 9; i++) {
			for (int j = 0; j < V; j++) {
				cost[i][j] = INF;
			}
		}

		for (int i = 0; i <= 9; i++) {
			for (int j = 0; j <= 9; j++) {
				scanf("%d", &cost[i][j]);
			}
		}

		for (int i = 0; i < 10; i++) {
			cost[i][i] = INF;
		}

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				scanf("%d", &num[i][j]);
			}
		}

		solve();
	}
    return 0;
}

void dijkstra(int s)
{
	fill(d, d+V, INF);
	fill(used, used+V, false);
	d[s] = 0;

	while (true) {
		int v = -1;
		for (int u = 0; u < V; u++) {
			if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
		}

		if (v == -1) break;
		used[v] = true;

		for (int u = 0; u < V; u++) {
			d[u] = min(d[u], d[v] + cost[v][u]);
		}

	}
}

int get_cost(int n) {
	if (DP[n] != -1) return DP[n];

	dijkstra(n);
	return DP[n] = d[1];
}

void solve() {
	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if(num[i][j] != -1) {
				ans += get_cost(num[i][j]);
			}
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = s[0];
            int k = s[1];

            int[] h = ReadLine().Split(' ').Select(int.Parse).ToArray();

            int ans = 0;
            for (int i = 0; i < n; i++)
            {
                if (h[i] >= k) ans++;
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 19040
n,a,b,c=map(int, input().split())
l=[int(input()) for _ in range(n)]
from itertools import product
X=product([0,1,2,3],repeat=n)

def score(x):
  atmp=0
  btmp=0
  ctmp=0
  score=0
  for i in range(n):
    if x[i]==1:
      if atmp!=0:
        score+=10
      atmp+=l[i]
    elif x[i]==2:
      if btmp!=0:
        score+=10
      btmp+=l[i]
    elif x[i]==3:
      if ctmp!=0:
        score+=10
      ctmp+=l[i]
    else:continue
  if atmp>0 and btmp>0 and ctmp>0:
    score+=(abs(a-atmp)+abs(b-btmp)+abs(c-ctmp))
  else: score=float("inf")
  return score

smin=float('inf')
for x in X:
  smin=min(smin,score(x))
print(smin)
  

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

signed main(){
  int A, B, K;
  scanf("%lld%lld%lld", &A, &B, &K);
  if(A >= K){
    A -= K;
  }
  else{
    K -= A;
    A = 0;
    B = max(0ll, B - K);
  }
  printf("%lld %lld\n", A, B);
  return 0;
}

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

int main(void){
    string a,b,c;
    cin >> a >> b >> c;
    if(a[a.size()-1]==b[0] and b[b.size()-1]==c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
Ans = 0
Rem = False
for i in range(N):
    A = int(input())
    if A > 0:
        if Rem:
            Ans += (A-1)//2 + 1
            Rem = (True if (A-1)%2 == 1 else False)
        else:
            Ans += A//2
            Rem = (True if A%2 == 1 else False)
    else: Rem = False
print(Ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int a[]=new int [3];
		
		for(int i=0;i<3;i++)
		{
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		
		System.out.println((a[2]*10)+(a[1])+(a[0]));
	}
}

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

int main(){
	int a,b,c,x,y;
	int count[3];
	int dis;
	int total;
	cin >> a>>b>>c>>x>>y;
	
	count[0]=x;
	count[1]=y;
	count[2]=0;
	total=x*a+y*b;
	
	for(;;){
		// A,Bを1減らして、Cを2増やしたときのコスト減
		dis=-2*c;
		// cout << dis <<endl;
		if(count[0]>0)dis+=a;
		if(count[1]>0)dis+=b;
		if(dis>0){
			total-=dis;
			count[0]--;
			count[1]--;
			count[2]+=2;
		}else{
			break;
		}
	}
	cout << total <<endl;
	// cout << count[0]<<' '<<count[1]<<' '<<count[2]<<endl;
	return 0;
}

Measured memory_bytes: 256
N=gets.to_i
T,A=gets.split.map(&:to_i)
H=gets.split.map(&:to_i)
argmin=1
min=100000
for i in 1..N
	dif=(A-T+H[i-1]*0.006).abs
	if dif<min
		min=dif
		argmin=i
	end
end
puts argmin

Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <climits>

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;

  char a[H][W + 1];
  int i, j;

  for (i = 0; i < H; i++) {
    cin >> a[i];
    a[i][W] = '\0';
  }

  int rows[H];
  int cols[W];

  for (i = 0; i < H; i++) {
    rows[i] = 0;
  }
  for (i = 0; i < W; i++) {
    cols[i] = 0;
  }

  for (i = 0; i < H; i++) {
    for (j = 0; j < W; j++) {
      if (a[i][j] == '#') {
	rows[i] = 1;
      }
    }
  }

  for (j = 0; j < W; j++) {
    for (i = 0; i < H; i++) {
      if (a[i][j] == '#') {
	cols[j] = 1;
      }
    }
  }

  for (i = 0; i < H; i++) {
    if (rows[i] == 1) {
      for (j = 0; j < W; j++) {
	if (cols[j] == 1) {
	  cout << a[i][j];
	}
      }
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256