akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359

const int N = 550;

int ans[N * N];

int main() {
  int n, i, j, k, num;
  cin >> n;
  vector<int> vec;
  for (i = 1; i <= n; i++) {
    cin >> num;
    ans[num] = i;
    vec.push_back(num);
  }

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

  int curIdx;
  for (i = 0, j = 1; i < n; i++) {
    curIdx = vec[i];
    num = ans[curIdx];
    for (k = 0; k < num - 1 && j < curIdx; j++) {
      if (ans[j] == 0) {
        ans[j] = num;
        k++;
      }
    }

    if (k < num - 1) {
      cout << "No" << endl;
      return 0;
    }
  }

  for (i = vec.size() - 1, j = n * n; i >= 0; i--) {
    curIdx = vec[i];
    num = ans[curIdx];
    for (k = 0; k < n - num && j > curIdx; j--) {
      if (ans[j] == 0) {
        ans[j] = num;
        k++;
      }
    }

    if (k < n - num) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  for (i = 1; i <= n * n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
  int N, M;
  cin >> N >> M;

  vector<long long> X(M), Y(M), Box(N, 1);
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    X[i] = x; Y[i] = y;
  }

  set<int> red;
  red.insert(0);
  for (int i = 0; i < M; i++) {
    int from = X[i], to = Y[i];

    if (Box[from] == 0) {
      continue;
    }
    
    set<int>::iterator itr = red.find(from);
    if (itr != red.end()) {
      red.insert(to);
      if (Box[from] == 1) {
	red.erase(itr);
      }
    }
    Box[to]++;
    Box[from]--;
  }

  cout << red.size() << endl;
  return 0;
}


Measured memory_bytes: 7296
// 2011/07/07 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int data[100];
		for(int i=0; i<n; i++)
			cin >> data[i];

		int key;
		cin >> key;

		int cnt = 0;
		for(int low=0, high=n-1; low<=high;){
			int middle = (low+high)/2;
			cnt++;
			if(key==data[middle])
				break;
			else if(key<data[middle])
				high = middle-1;
			else
				low  = middle+1;
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
//6.12
import java.util.Scanner;
import java.io.*;

class Main{
    int num[]=new int[30000];
    int l[]=new int[30000],r[] =new int[30000];
    int max(int a,int b){return a>b?a:b;}
    boolean islower_line(double x,double y,double a,double b){
	return y < a*x+b;
    } 
    void put_xy(int m,int w,double x,double y){
	int tl=0,tr=m;
	int mid=0,ans=-1;
	while(tl <= tr){
	    mid =(tl+tr)/2;
	    if (islower_line(x,y,(r[mid]-l[mid])/(double)w,l[mid])){
		ans=mid;
		tr=mid-1;
	    }else tl=mid+1;
	}
	//System.out.println(islower_line(x,y,(r[ans]-l[ans])/(double)w,
	//l[ans]));
	num[ans]++;
	return;
    }
    int solve(int m,int s,int w){
	int ret=0,now=0;
	int head=0,tail=0;
	int lbase=0,rbase=0;
	while(true){
	    //back++
	    while(tail < m){
		if ((long)w*(long)(l[tail]-lbase+r[tail]-rbase) > 2*s)break;
		now+=num[tail];
		tail++;
	    }
	    ret=max(ret,now);
	    if (tail == m)break;
	    //head++;
	    head++;
	    lbase=l[head-1];
	    rbase=r[head-1];
	    now-=num[head-1];
	}
	return ret;
    }

    /*
    void run(){
	Scanner in = new Scanner(System.in);
	//System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
	int n,m,w,h;
	int s;
	while(true){
	    n=in.nextInt();
	    m=in.nextInt();
	    w=in.nextInt();
	    h=in.nextInt();
	    s=in.nextInt();
	    if (n == 0)break;
	    for(int i=0;i<m;i++)num[i]=0;
	    for(int i=0;i<m;i++){
		int tmp;
		l[i]=in.nextInt();
		r[i]=in.nextInt();
	    }
	    for(int i=0;i<n;i++){
		double x,y;
		x=in.nextDouble();
		y=in.nextDouble();
		put_xy(m,w,x,y);
	    }
	    s=w*h-s;
	    System.out.println(n-solve(m,s,w));
	}
    }
    */

    void run(){
	Scanner in = new Scanner(System.in);
	//System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
	int n,m,w,h;
	int s;
	while(true){
	    n=Integer.parseInt(in.next());
	    m=Integer.parseInt(in.next());
	    w=Integer.parseInt(in.next());
	    h=Integer.parseInt(in.next());
	    s=Integer.parseInt(in.next());
	    if (n == 0)break;
	    for(int i=0;i<m;i++)num[i]=0;
	    for(int i=0;i<m;i++){
		int tmp;
		l[i]=Integer.parseInt(in.next());
		r[i]=Integer.parseInt(in.next());
	    }
	    for(int i=0;i<n;i++){
		double x,y;
		x=Double.parseDouble(in.next());
		y=Double.parseDouble(in.next());
		put_xy(m,w,x,y);
	    }
	    s=w*h-s;
	    System.out.println(n-solve(m,s,w));
	}
    }

    public static void main(String args[]){
	Main a = new Main();
	a.run();
    }
}

Measured memory_bytes: 13000
# -*- coding: utf-8 -*-

N, L, T = map(int, input().split())

ants = []
for i in range(N):
    x, w = map(int, input().split())
    ants.append((x, w))

# After T
ants2 = []
for ant in ants:
    ants2.append((ant[0] + T * (3 - 2 * ant[1])) % L)

st = 0
for i in range(N):
    if ants2.count(ants2[i]) == 1:
        st = i
        break

# Number of collision for Ants[st]
cl = 0
for i in range(N):
    if ants[i][1] == ants[st][1]:
        continue  # same direction
    else:
        if ants[st][1] == 1:
            if ants[i][0] > ants[st][0]:
                fc = (ants[i][0] - ants[st][0]) / 2
            else:
                fc = (L - (ants[st][0] - ants[i][0])) / 2
        else:
            if ants[i][0] > ants[st][0]:
                fc = (L - (ants[i][0] - ants[st][0])) / 2
            else:
                fc = (ants[st][0] - ants[i][0]) / 2
        cl += (3 - 2 * ants[st][1]) * int(2 * (T - fc) // L + 1)

stant = ants2[st]
ants2.sort()
idx = ants2.index(stant) - cl - st

for i in range(N):
    print(ants2[(i + idx) % N])

Measured memory_bytes: 18464
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

struct segmentTree {
    int N;
    vector<int> tree;
    segmentTree(int n) {
        int i;
        int size = 1;
        rep(i, n) {
            if (size > n) break;
            size *= 2;
        }
        this->N = size;
        this->tree.resize(2 * size - 1);
        rep(i, size) this->tree[i] = 0;
    }
    void update(int idx, int val) {
        int i = N + idx - 1;
        tree[i] = val;
        while (i > 0) {
            i = (i - 1) / 2;
            tree[i] = max(tree[i], val);
        }
    }
    int query(int l, int r) {
        return innerQuery(0, l, r, 0, N);
    }
    int innerQuery(int idx, int l, int r, int cl, int cr) {
        if (cl >= r || cr <= l) return 0;
        if (cl >= l && cr <= r) return tree[idx];
        int cm = (cl + cr) / 2;
        return max(innerQuery(idx * 2 + 1, l, r, cl, cm), innerQuery(idx * 2 + 2, l, r, cm, cr));
    }
};

int compress(vector<ll>& x, map<ll, ll>& zip, vector<ll>& unzip) {
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    rep(i, x.size()) {
        zip[x[i]] = i;
        unzip[i] = x[i];
    }
    return x.size();
}

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

    int N;
    cin>>N;
    vector<pair<ll, ll>> xd(N);
    vector<ll> com;
    rep(i, N) {
        cin>>xd[i].first>>xd[i].second;
        com.push_back(xd[i].first);
        com.push_back(xd[i].first + xd[i].second);
    }
    sort(xd.begin(), xd.end());

    map<ll, ll> zip;
    vector<ll> unzip(2 * N);
    compress(com, zip, unzip);

    segmentTree st(2 * N);
    vector<ll> dp(N + 1);
    dp[N] = 1;
    for (int i = N - 1; i >= 0; --i) {
        ll x = zip[xd[i].first];
        ll d = zip[xd[i].first + xd[i].second];

        ll r = max(i, st.query(x, d));
        st.update(x, r);

        dp[i] = (dp[i + 1] + dp[r + 1]) % 998244353;
    }
    cout<<dp[0]<<endl;
}

Measured memory_bytes: 41196
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start < end) {
			f(start)
			loop(start + 1, end)(f)
		}

	val n = Scanner.nextInt % 1000

	pw.println(if (n == 0) n else 1000 - n)
	pw.flush()
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 54584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll a,b;
bool flag;
const ll MOD = 1000000007;
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
void fact(ll m,map<ll,ll> &X){
    X[1]=0;
    while(m){
        flag=false;
        For(i,2,sqrt(m)+2){
            if(m%i==0){
                flag=true;
                m/=i;
                X[i]++;
                break;
            }
        }
        if(flag) continue;
        X[m]++;
        break;
    }
}
void Main(){    
    cin>>a>>b;
    ll GCD=gcd(a,b);
    map<ll,ll> X;
    fact(GCD,X);
    cout<<X.size()<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int A, B, C;
    std::cin >> A >> B >> C;
    int g = max<int>({ A * 10 + B + C,A + B * 10 + C,A + B + C * 10 });
    cout << g << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<algorithm>

using namespace std;

int main() {
	int N,i;
	int L[1000];
	int sum = 0;
	int Lmax=0;
	cin >> N;
	for (i = 0; i < N; ++i) {
		cin >> L[i];
	}
	for (i = 0; i < N; ++i) {
		if (Lmax < L[i]) {
			Lmax = L[i];
		}
	}
//	cout <<"Lmax"<< Lmax << endl;
	for (i = 0; i < N; ++i) {
		sum += L[i];
	}
	sum -= Lmax;
	if (sum > Lmax) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

int main() {
  queue< pair<string,int> > tasks;
  int n, q, t;
  string s;
  cin >> n >> q;
  for (int i=0; i<n; i++) {
    cin >> s >> t;
    tasks.push(make_pair(s, t));
  }
  for (int time=0; !tasks.empty(); tasks.pop()){
    auto task = tasks.front();
    if (task.second > q) {
      time += q;
      task.second -= q;
      tasks.push(task);
    } else {
      time += task.second;
      cout << task.first << ' ' << time << endl;
    }
  }
}

Measured memory_bytes: 6316
#include <iostream>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;

const int INF = 1e+9;

struct State {
  int f, v, tickets;
  State(int f, int v, int t) : f(f), v(v), tickets(t) {}
};

struct Node {
  int to, c;
  Node(int to, int c) : to(to), c(c) {}
};

bool operator > (const State& lhs, const State& rhs){
  if(lhs.f == rhs.f)
    return (lhs.v == rhs.v) ? lhs.tickets > rhs.tickets : lhs.v > rhs.v;
  else
    return lhs.f > rhs.f;
}

int N, M, C, d[101][11];
vector<Node> G[101];

void dijkstra(int s){
  for(int i = 0; i <= N; ++i)
    for(int j = 0; j <= C; ++j)
      d[i][j] = INF;
  for(int i = 0; i <= C; ++i)
    d[s][i] = 0;
  priority_queue<State, vector<State>, greater<State> > que;
  que.push(State(0, s, C));
  while(!que.empty()){
    State st = que.top();
    que.pop();
    if(d[st.v][st.tickets] < st.f)
      continue;
    for(int i = 0; i < G[st.v].size(); ++i){
      Node n = G[st.v][i];
      if(d[n.to][st.tickets] > st.f + n.c){
	d[n.to][st.tickets] = st.f + n.c;
	que.push(State(d[n.to][st.tickets], n.to, st.tickets));
      }
      if(d[n.to][st.tickets - 1] > st.f + n.c / 2){
	d[n.to][st.tickets - 1] = st.f + n.c / 2;
	que.push(State(d[n.to][st.tickets - 1], n.to, st.tickets - 1));
      }
    }
  }
}


int main() {
  int s, e, a, b, f;
  while(cin >> C >> N >> M >> s >> e && (N || M || C || s || e)){
    for(int i = 0; i <= 100; ++i)
      G[i].clear();
    for(int i = 0; i < M; ++i){
      scanf("%d%d%d", &a, &b, &f);
      G[a].push_back(Node(b, f));
      G[b].push_back(Node(a, f));
    }
    dijkstra(s);
    int ans = INF;
    for(int i = 0; i <= C; ++i)
      ans = min(ans, d[e][i]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1284
#include<stdio.h>
#include<math.h>

int main(void)
{
  int N;
  scanf("%d", &N);

  int max;
  int count;
  double z1, z2;
  for(int i=1;i<=N;i++){
    count = 0;
    max = sqrt(N);
    for(int x=1;x<max;x++){
      for(int y=1;y<x+1;y++){
	  z1 = (-x-y+sqrt(-3*x*x-2*x*y-3*y*y+4*i))/2;
	  z2 = (-x-y-sqrt(-3*x*x-2*x*y-3*y*y+4*i))/2;
	  
	  if(ceil(z1) == floor(z1) && z1>0 && z1<=y){
	    int a;
	    a = z1;
	    if(pow(x,2.0)+pow(y,2.0)+pow(a,2.0)+x*y+y*a+a*x == i){
	      if(x==y && y==a) count++;
	      else if(x==y || y==a || a==x) count += 3;
	      else count += 6;
	    }
	  }
	  if(z1 != z2){
	    if(ceil(z2) == floor(z2) && z2>0 && z2<=y){
	    int b;
	    b = z2;
	    if(pow(x,2.0)+pow(y,2.0)+pow(b,2.0)+x*y+y*b+b*x == i){
	      if(x==y && y==b) count++;
	      else if(x==y || y==b || b==x) count += 3;
	      else count += 6;
	    }
	  }
	}
      }
    }
    printf("%d\n", count);
  }

  return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main ()
{
    ll n,a[100005],b[100005],c[100005];
    cin>>n;
    ll dp[n+5][3];
    for (int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);

    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<'\n';


}

Measured memory_bytes: 8272
#include <stdio.h>


int main(){
  int n,p[20],count,i;
  
  scanf("%d\n",&n);
  for(i=0; i<n; i++){
  scanf("%d\n",&p[i]);
  }
  
  count=0;
  
  for(i=1; i<n-1; i++){
  	if((p[i-1]<p[i])&&(p[i]<p[i+1])){count++;}
    if((p[i-1]>p[i])&&(p[i]>p[i+1])){count++;}  
  }
  
  printf("%d",count);
  
  return(0);
}


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

const int maxn = 100005;
int a[maxn], vis[maxn], n, m, x, y, mn, cur;
priority_queue<int, vector<int>, greater<int> > Q;
vector<int> e[maxn];
long long ans;

void dfs(int u) {
	int sz = e[u].size();
	if (a[u] < mn) mn = a[u], cur = u;
	vis[u] = 1;
	if (!sz) return;
	rep (i, 0, sz - 1)
		if (!vis[e[u][i]]) dfs(e[u][i]);
}

int main() {
	scanf("%d%d", &n, &m);
	if (n < 2 * (n - m - 1)) 
		return puts("Impossible"), 0;
	if (n - 1 == m)
		return puts("0"), 0;
	rep (i, 1, n) scanf("%d", &a[i]);
	rep (i, 1, m) {
		scanf("%d%d", &x, &y); x++; y++;
		e[x].push_back(y); e[y].push_back(x);
	}
	rep (i, 1, n)
		if (!vis[i]) {
			mn = 2e9;
			dfs(i);
			ans += mn;
			a[cur] = 0;
		}
	rep (i, 1, n)
		if (a[i]) Q.push(a[i]);
	m = 2 * (n - m - 1) - (n - m);
	while (m-- > 0) {
		ans += Q.top();
		Q.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7168
#include <stdio.h>
    int main ()
    {
        int m[10];
 
        int i, j, x, y;

        for (i = 0; i < 10; ++i){
	        scanf("%d", &m[i]);
}

        for (i = 0; i < 10; ++i) 
        {
            for (j = i + 1; j < 10; ++j) 
            {
                if (m[i] < m[j]) 
                {
                    x = m[i];
                    m[i] = m[j];
                    m[j] = x;
                }
            }
        }

        for (i = 0; i < 3; ++i) 
        {
            printf("%d\n", m[i]);
        }
 return 0;
    }


Measured memory_bytes: 2120
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

h,a = get_nums_l()
print((h + a -1)//a)

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

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

    vector<int> P(N + 1, 0);
    ll ans = 0;
    rep(i, N) {
        int A = 0;
        cin >> A;
        if (i + A < N)
            P[i + A]++;
        if (i - A >= 0)
            ans += P[i - A];
    }

    cout << ans << endl;
    Would you please return 0;
}

Measured memory_bytes: 3984
n, k = map(int, input().split())
d = set(list(map(int, input().split())))
d = list(set([i for i in range(10)])-d)
d.sort()
import itertools

import sys
for k in range(6):
  for i in itertools.product(d, repeat=k):
    ans = 0
    for j in range(len(i)):
      ans += i[-j-1]*10**j
    if ans >= n:
      print(ans)
      sys.exit()
  


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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
		// 1行目数字、2行目文字
		String s = br.readLine();
		
		int i = s.indexOf("A");
		int j = s.lastIndexOf("Z");


        //System.out.println(i);
        //System.out.println(j);
        System.out.println(j - i + 1);
        return;
    }
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }

}

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


void input(); template<typename First,typename... Rest> void input(First&,Rest&...);
void inputVector(); template<typename First,typename... Rest>  void inputVector(std::vector<First>&,Rest&...);
#define loop(n) for(int i = 0;i < (int)(n);++i)


void calculate(){
    int N,A;
    input(N,A);
    N %= 500;
    if(N <= A)
    {
        std::cout << "Yes\n";
    }
    else
    {
        std::cout << "No\n";
    }
}

int main(int,char**){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    calculate();
}



void input(){return;}
template<typename First,typename... Rest>
void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}

void inputVector(){return;}
template<typename First,typename... Rest> 
void inputVector(std::vector<First> &first,Rest&... rest){
    int N = first.size();
    for(int i = 0;i < N;i++){
        std::cin >> first[i];
    }
    inputVector(rest...);
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int a,i;
  int flag=0;
  long sum=0;
    
  scanf("%d",&a);
  for(i=1;i<=a;i++)
  {
    if(i%3==0&&i%5==0)
        flag+=1;
      
    if(i%3==0)
        flag+=1;
      
    if(i%5==0)
        flag+=1;
      
    if(flag==0)
        sum+=i;
      
    flag=0;
  }
  printf("%ld",sum);
  return 0;
}

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

void solve() {
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	for (int i = n - m; i >= 0; i--) {
		bool ok = true;
		string res = s;
		for (int j = i; j < i + m; j++) {
			if (res[j] != '?' && res[j] != t[j - i]) {
				ok = false;
				break;
			}
			res[j] = t[j - i];
		}
		if (ok) {
			for (int j = 0; j < n; j++) {
				if (res[j] == '?') res[j] = 'a';
			}
			cout << res;
			return;
		}
	}
	cout << "UNRESTORABLE";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

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

int main()
{
	long long int n, x;
	cin >> n >> x;
	long long int ans = 0, in;
	long long int okashi[101];
	for (long long int i = 0; i < n; ++i)
	{
		cin >> okashi[i];
	}
	sort(okashi, okashi + n);
	for (long long int i = 0; i < n - 1; ++i)
	{
		x -= okashi[i];
		ans += (x >= 0);
	}
	cout << ans + (x == okashi[n - 1]) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) a>b?a:b

 int Max[100001][3];
int maxm(int A[][3], int miss, int row, int N)
{
  int maxi=INT_MIN,k=0,index1,index2;
   if(Max[row][miss]!=-1)
  {
    return Max[row][miss];
  }
  for(int i=0;i<3;i++)
    {
      if(i!=miss&&k==0)
      {
       	index1=i;
        k=1;
      }
      else if(i!=miss&&k==1)
      {
        index2=i;
      }
    }
  if(row==N-1)
  {
    return max(A[row][index1],A[row][index2]);
  }
  
  return Max[row][miss]=max( ( A[row][index1]+maxm(A,index1,row+1,N) ),( A[row][index2]+maxm(A,index2,row+1,N) ) );
}
  
int main()
{
  int N;
  cin>>N;
  int A[N][3];
  for(int i=0;i<N;i++)
  {
    for(int j=0;j<3;j++)
    {
      cin>>A[i][j];
    }
  }
 for(int i=0;i<100001;i++)
 {
   for(int j=0;j<3;j++)
   {
     Max[i][j]=-1;
   }
 }
  int ans1,ans2,ans3,ans;
  ans1=maxm(A,0,0,N);
  ans2=maxm(A,1,0,N);
  ans3=maxm(A,2,0,N);
 // cout<<ans1<<ans2<<ans3;
  ans=max(ans1,ans2);
  ans=( max(ans,ans3) );
  cout<<ans;
}

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

int main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<3;i++){
        if(s[i]=='o'){
            ans++;
        }
    }
    cout<<700+ans*100<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node *Node;
Node root;

Node treeSearch(Node u, int k){
}

Node treeSuccessor(Node x){
}

void treeDelete(Node z){
  Node y;
  Node x;
  if(z->left == NIL || z->right == NIL){
    y = z;
  }

  if(y->left != NIL){
    x = y->left;
  }
  else{
    x = y->right;
  }

  if(x != NIL){
    x->p = y->p;
  }
  if(y->p == NIL){
    root = x;
  }else if(y == y->p->left){
    y->p->left = x;
  }else{
    y->p->right = x;
  }

  if(y != z){
    z->key = y->key;
  }
}
    

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->p = y;

  if(y == NIL){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else{
    y->right = z;
  }
}

void inorder(Node u){
  if(u == NIL){
    return;
  }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u == NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

    
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root,x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

    
    



Measured memory_bytes: 25148
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
    int N;
    cin >> N;
    int ans=-1;
    
    for(int i=1; i<(N/2)+1; i++){
        int A = i;
        int B = N-i;
        int A_sum=0;
        int B_sum=0;
        
        while(A>0){
            A_sum+=A%10;
            A=A/10;
        }
        while(B>0){
            B_sum+=B%10;
            B=B/10;
        }
        
        if(A_sum+B_sum<ans||ans<0){
            ans=A_sum+B_sum;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <cstdio>
#include<vector>
#include<map>
#include<utility>
#include<list>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;

int n;

int main(void) {
	cin >> n;
	int sum = 0;
	int l = 0;
	for (int i = 0; i < n; i++) {
		int li;
		cin >> li;
		sum += li;
		if (li > l)
			l = li;
	}
	string ret;
	if (l < sum - l)
		ret = "Yes";
	else ret = "No";
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

constexpr ll inf=1e9;
int main()
{
    ll h=in(),n=in();
    map<ll,ll>waza;
    for(ll i=0;i<n;++i){
        ll a=in(),b=in();
        if(waza.count(a)==0||waza[a]>b)waza[a]=b;
    }

    auto ans=vec2<ll>(waza.size()+1,h+1,inf);
    ans[0][0]=0;
    auto itr=waza.begin();
    for(ll i=1;i<=waza.size();++i,++itr){
        ll d=itr->first,m=itr->second;
        for(ll j=0;j<=h;++j){
            for(ll k=0;;++k){
                ans[i][j]=min(ans[i][j],ans[i-1][max(0ll,j-k*d)]+k*m);
                if(j-k*d<0)break;
            }
        }
    }
    cout<<ans.back().back()<<endl;
}


Measured memory_bytes: 78592
#[allow(unused_imports)]
use proconio::{fastout, input};
use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        k: u64,
        a: [u64; n],
        b: [u64; m],
    }
    let a_sum = std::iter::once(0).chain(a.into_iter()).cumsum::<u64>().collect_vec();
    let b_sum = std::iter::once(0).chain(b.into_iter()).cumsum::<u64>().collect_vec();
    let mut ans: usize = 0;
    let mut j: usize = m;
    for i in 0 as usize ..= n {
        if a_sum[i] > k {
            break;
        }
        while a_sum[i] + b_sum[j] > k {
            j -= 1;
        }
        ans = std::cmp::max(ans, i + j);
    }
    println!("{}", ans);
}


Measured memory_bytes: 10976
N = int(input())
inputData = input().split()
A = [int(x) for x in inputData]
inputData = input().split()
B = [int(x) for x in inputData]

total_mons = 0
debt = 0

if B[N-1] < A[N]:
    total_mons += B[N-1]
    B[N - 1] = 0
else:
    total_mons += A[N]
    B[N - 1] = B[N - 1] - A[N]


for i in reversed(range(1, N)):

    if (B[i-1] + B[i]) < A[i]:
        total_mons += B[i-1] + B[i]
        B[i-1] = 0
    else:
        total_mons += A[i]
        if B[i] < A[i]:
            B[i-1] = B[i-1] - (A[i] - B[i])


if B[0] < A[0]:
    total_mons += B[0]
else:
    total_mons += A[0]

print(total_mons)

Measured memory_bytes: 23616
a = [0 for i in range(3 * 1000000 + 1)]

s = int(input().rstrip())

a[s] = 1

for i in range(2, 1000000+1):
    if s % 2 == 0:
        s = int(s / 2)
    else:
        s = int(3 * s + 1)
    #print(s)
    
    if a[s] == 1:
        break
    a[s] = 1
        
print(i)


Measured memory_bytes: 27544
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	vi v(3);
	rep(i,0,3)cin>>v[i];
	sort(all(v));
	cout<<(v[0]+v[1])<<endl;
	
	return 0;
}

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

int main(){
    unsigned long N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    --A;
    --B;
    --C;
    --D;
    string s;
    cin >> s;
    deque<bool> mp(s.size());
    transform(s.begin(), s.end(), mp.begin(), [](auto c){return c == '.';});
    auto f = [&mp](auto first, auto last){
        auto t = false;
        for(unsigned long i = first; i <= last; ++i)if(mp[i])t = false;
        else if(t)return false;
        else t = true;
        return true;
    };
    if(C > D){
        unsigned long i = B;
        for(; i < D; ++i)if(mp[i - 1] && mp[i] && mp[i + 1])break;
        mp[i] = false;
    }
    puts(f(B, D) && f(A, C) ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define int long long 
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef unsigned long long ULL;
 
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()
#define f first
#define s second
#define FILL(a, b) memset(a, b, sizeof(a))
 
const int MAX = 400*1000+5;
const int INF = 1000*1000*1000 + 7;
const LL LINF = 1LL*INF*INF;
const int MOD = INF;
const double PI = acos(-1.);
const int MAXN = 3*100007;
const double EPS = 1e-6;
 
mt19937 rnd(time(0));

signed main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	vector<VI> a(n, VI(n));
	vector<pair<int, PII>> edges;
	FOR(i, 0, n)
	{
		FOR(j, 0, n)
		{
			cin >> a[i][j];
			if (i < j)
			{
				edges.PB({a[i][j], {i, j}});
			}
		}
	}
	auto d = a;
	FOR(k, 0, n)
	{
		FOR(i, 0, n)
		{
			FOR(j, 0, n)
			{
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	if (a != d)
	{
		cout << -1 << "\n";
		return 0;
	}

	sort(ALL(edges));
	vector<VI> dist(n, VI(n, INF));
	FOR(i, 0, n)
	{
		dist[i][i] = 0;
	}
	LL res = 0;
	FOR(it, 0, SZ(edges))
	{
		int w = edges[it].f;
		int u = edges[it].s.f;
		int v = edges[it].s.s;
		if (dist[u][v] > w)
		{
			dist[u][v] = w;
			res += w;
			FOR(i, 0, n)
			{
				FOR(j, 0, n)
				{
					dist[i][j] = min(dist[i][j], dist[i][v] + dist[u][j] + w);
					dist[i][j] = min(dist[i][j], dist[i][u] + dist[v][j] + w);
				}
			}
		}
	}
	cout << res << "\n";
	
	return 0;
}

Measured memory_bytes: 3448
#include<iostream>
using namespace std;
int main() {
 int a=0;
  int b=0;
  
  cin >> a;
  cin >> b;
  
  if ((a+b)%2==0)cout << (a+b)/2;
  else cout << ((a+b)/2)+1;
  cout <<endl;
  
  
  
}


Measured memory_bytes: 256
'use strict'
function main(input) {
  input = input.trim().split(' ')
  const N = input[0] - 0
  const K = input[1] - 0
  let ans = Math.pow(Math.floor(N / K), 3)
  if (K%2===0) ans += Math.pow(Math.floor((N + K/2) / K), 3)
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll h, w, a, b;
string s[1000];
int main() {
	cin >> h >> w >> a >> b;
	REP(i, h) {
		REP(j, w) {
			s[i].push_back('0');
		}
	}
	REP(i, b) {
		REP(j, a) {
			s[i][j] = '1';
		}
	}
	FOR(i, b, h) {
		FOR(j, a, w) {
			s[i][j] = '1';
		}
	}
	REP(i, h) {
		REP(j, w) {
			cout << s[i][j];
		}
		cout << endl;
	}
}



Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(i,arr)       for(int& i:arr)cin>>i;
#define output(i,arr)      for(int& i:arr)cout<<i<<" ";
#define for_each(arr)      for(auto& it:arr)
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
   // #endif
    cin>>n;
    map<string,int>mp;
    
    int mx=0;
    for(int i=0; i<n; i++){
    	cin>>s;
    	mp[s]++;
    	//pp[s]++;
    	mx=max(mx,mp[s]);
    }
  // for(auto it:mp)cout<<it.ff<<" "<<it.ss<<endl;
    
	//cout<<mx<<endl;
	for(auto it:mp){
		if(mp[it.ff]==mx){
			cout<<it.ff<<endl;
		}
	}

    

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll MOD = 1e9 + 7;

ll modpow(ll x, ll k) {
	if (k == 0) return 1;
	ll ret = modpow(x, k/2);
	ret = (ret * ret) % MOD;
	if (k%2 == 1) ret = (ret * x) % MOD;
	return ret;
}

ll fact(ll n) {
	ll ret = 1;
	for (int i = 1; i <= n; i++)
		ret = (ret * i) % MOD;
	return ret;
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	ll n, m, k;
	cin >> n >> m >> k;

	ll a = 0, b = 0;
	for (int i = 1; i < m; i++)
		a = (a + n * i * (m-i)) % MOD;
	a = (a * n) % MOD;
	for (int i = 1; i < n; i++)
		b = (b + m * i * (n-i)) % MOD;
	b = (b * m) % MOD;

	ll c = fact(n*m-2);
	c *= modpow(fact(k-2), MOD-2); c %= MOD;
	c *= modpow(fact(n*m-k), MOD-2); c %= MOD;
	//cerr << a << ' ' << b << ' ' << c << endl;

	ll ans = ((a+b) * c) % MOD;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, m;
    cin >> n >> m;
    int x, y;
    cin >> x >> y;
    vector<int> xi(n);
    REP(i,n) cin >> xi[i];
    xi.push_back(x);
    sort(ALL(xi));
    vector<int> yi(m);
    REP(i,m) cin >> yi[i];
    yi.push_back(y);
    sort(ALL(yi));

    if (xi.back() < yi.front()) {
        cout << "No War\n";
    } else {
        cout << "War\n";
    }
    
    return 0;
}

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

#define rep(a,b) for(ll ii=a;ii<b;ii++)
#define ll long long int
#define test() int tt; cin>>tt; while(tt--) 
#define fst_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl '\n'

int main()
{
  ll x, k, d;
  cin>>x>>k>>d;
  x = abs(x);

  if(x>0 && x/d>=k) cout<<x - k*d;
  else
  {
    ll y = x/d;
    x -= y*d;
    k -= y;
    if(k%2 == 0) cout<<abs(x);
    else cout<<min(abs(x-d), abs(x+d));
  }
  return 0;
}

Measured memory_bytes: 3576
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

char s[100];
int main() {
  int n, m;
  int x, y;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf("%s", s);
      if (strcmp(s, "snuke") == 0) {
        x = i;
        y = j;
      }
    }
  }
  printf("%c%d\n", 'A' + y, x + 1);
  return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    int n, y, m, k, i, j;
    cin >> n >> y;
    int flag = 0;

    //1000i + 5000j + 10000k = Y
    //i + j + k = n
    for(i = 0; i <= n; i++) {
        for(j = 0; j <= n - i; j++) {
            k = n - i - j;
            if (10000 * i + 5000 * j + 1000 * k == y) {
                flag++;
                break;
            }
        }
        if (flag)
            break;
    }

    if (flag)
        cout << i << " " << j << " " << k << endl;
    else
        cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256
import itertools

x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

AB = [a + b for (a,b) in list(itertools.product(A,B))]
AB.sort(reverse = True)
ans = [ab + c for (ab,c) in list(itertools.product(AB[:min(3000,x*y*z)],C))]
ans.sort(reverse = True)
for i in range(k):
    print(ans[i])

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

const int MAXN = 2e5+5;
const int INF = 1e9+7;
#define ll long long
#define pb push_back
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll MOD(ll a){
    return ((a%INF)+INF)%INF;
}

vector<pair<int,int> > adjList[MAXN][3];
int dist[MAXN][3];

int main()
{
    fast_io;
    //cout << fixed << setprecision(15);
    int n,m;cin >> n >> m;
    for(int i=0;i<m;++i){
        int c,d;cin >> c >> d;
        adjList[c][0].pb({d,1});
        adjList[c][1].pb({d,2});
        adjList[c][2].pb({d,0});
    }

    int s,t;cin >> s >> t;

    queue<pair<int,int> > dq;
    dq.push({s,0});

    for(int i=1;i<=n;++i) for(int j=0;j<=3;++j) dist[i][j] = INF;

    dist[s][0] = 0;

    while(!dq.empty()){
        pair<int,int> now = dq.front();
        dq.pop();
        for(auto u : adjList[now.first][now.second]){
            if(dist[now.F][now.S] + 1 < dist[u.F][u.S]){
                dist[u.F][u.S] = dist[now.F][now.S] + 1;
                dq.push({u.F,u.S});
            }
        }
    }

    if(dist[t][0] == INF) cout << "-1";
    else cout << dist[t][0] / 3;

}


Measured memory_bytes: 25216
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <fstream>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef vector<PI> VPI;
typedef unsigned long long ull;
typedef long long ll;

#define FOR(i, n) for(int i=0;i<(n);++i)
#define REP(i,s,n) for(int i=s;i<=n;++i)
#define SZ(x) ((int)(x).size())
#define LOOP(i,x) FOR(i,SZ(x))
#define IT(it,x) for(typeof((x).begin()) it = (x).begin();it!=(x).end();++it)
#define ALL(x) (x).begin(), (x).end()
#define ST first
#define ND second
#define MP make_pair
#define PB push_back
#define gc getchar

const int INF = 1e9 + 5;
#define MAXN 100 * 1000 + 7

int a[MAXN], b[MAXN], c[MAXN], dp[3][MAXN];

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

	int n;
	cin >> n;

	for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];

	dp[0][0] = a[0];
	dp[1][0] = b[0];
	dp[2][0] = c[0];

	for (int i = 1; i < n; i++) {
		dp[0][i] = a[i] + max(dp[1][i - 1], dp[2][i - 1]);
		dp[1][i] = b[i] + max(dp[0][i - 1], dp[2][i - 1]);
		dp[2][i] = c[i] + max(dp[1][i - 1], dp[0][i - 1]);

		//cout << dp[0][i] << " " << dp[1][i] << " " << dp[2][i] << endl;
	}

	cout << max(dp[2][n - 1], max(dp[0][n - 1], dp[1][ n -1])) << endl;

	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
struct Point{
    double x,y;
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);  
    int n;
    cin >> n;
    vector<int>A(n);
    int cnt=0;
    int p=1;
    REP(i,n){
        cin >> A[i];
        if(p==A[i]){
            cnt++;
            p++;
        }
    }
    cout << ((cnt!=0)?n-cnt:-1) << endl;

}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int Num = sc.nextInt();
    String BR=sc.next();
    int TotalBlue=0;
    int TotalRed=0;
    char B[]=new char[BR.length()];
    for(int i=0;i<BR.length();i++){
     B[i]=BR.charAt(i);
    }
    for(int i=0;i<BR.length();i++){
     if(B[i]=='R'){
      TotalRed++;
     }else{
      TotalBlue++;
     }
    }
    
    if(TotalRed>TotalBlue){
    System.out.println("Yes");
    }else{
    System.out.println("No");
    }
  }
}



Measured memory_bytes: 22736
#include<stdio.h>
#include<math.h>
int main()
{
    long long int s1,s2=0,min,x;
    int N,i,p=1;
    scanf("%d",&N);
    long long int a[N];
    for(i=0;i<N;i++)
    {
        scanf("%lld",&a[i]);
    }
    s1=a[0];
    for(i=1;i<N;i++)
    {
        s2=s2+a[i];
    }
    min=llabs(s2-s1);
    for(p=1;p<N-1;p++){
    s1=s1+a[p];
    s2=s2-a[p];
    x=llabs(s2-s1);
    if(x<min)
        min=x;
    }
    printf("%lld",min);
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0

ll solve()
{
    ll ans = 0;
    ll M,K;
    cin >> M >> K;
    if (K >= (1 << M)) {
        cout << -1 << endl;
        return -1;
    }
    ll N = 1 << M;
    if (M == 1 && K == 0) {
        cout << "0 0 1 1" << endl;
        return 0;
    }
    if (M == 1 && K != 0) {
        cout << "-1" << endl;
        return 0;
    }
    for1 (i,N) {
        if (i != K) {
            cout << i << " ";
        }
    }
    cout << K << " ";
    for (ll i = N-1; i >= 0; --i) {
        if (i != K) {
            cout << i << " ";
        }
    }
    cout << K << endl;

    return 0;
}

int main()
{
    do {
        solve();
        //cout << solve() << endl;
    } while (DEBUG);
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>

int main()
{
    char s[201], t[101], p[101];

    scanf("%s %s", s, p);
    strcpy(t, s);
    strcat(s, t);

    if (strstr(s, p) == NULL) printf("No\n");
    else printf("Yes\n");

    return 0;
}


Measured memory_bytes: 2756
#include<stdio.h>
#include<math.h>

typedef struct Point{
  double x, y;
}Point;


  void koch(int n, Point a, Point b){
    if(n == 0) return;

    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);

    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);

    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);

    koch(n - 1, t, b);
  }

int main(){
  Point a, b;
  int n;

  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}


Measured memory_bytes: 2108
import sys
sys.setrecursionlimit(100000)

class Graph():
    def __init__(self):
        self.adjacency_dict = {}

    def add_vertex(self, v):
        self.adjacency_dict[v] = []
    
    def add_edge(self, v1, v2, dist):
        self.adjacency_dict[v1].append([v2, dist])
        self.adjacency_dict[v2].append([v1, dist])
    
    def next_edges(self, v):
        return self.adjacency_dict[v]

N = int(input())
dists = [list(map(int, input().split())) for _ in range(N-1)]

graph = Graph()
for i in range(1, N+1):
    graph.add_vertex(i)
for v1, v2, dist in dists:
    graph.add_edge(v1, v2, dist)

def dfs(start, group):
    if visited[start] is not None:
        return
    visited[start] = group
    for v, dist in graph.next_edges(start):
        if dist % 2 == 0:
            dfs(v, group)
        else:
            dfs(v, 1-group)

visited = [None]*(N+1)
dfs(1, 0)
for i in visited[1:]:
    print(i)

Measured memory_bytes: 106856