akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

class MyClass
{
    static void Main(string[] args)
    {
        string str = "";
        while ((str = Console.ReadLine()) != "0 0")
        {
            int h = int.Parse(str.Split(' ')[0]);
            int w = int.Parse(str.Split(' ')[1]);
            string[] room = new string[h];
            bool[,] check = new bool[w, h];
            int x = 0;
            int y = 0;
            for (int i = 0; i < h; i++)
            {
                room[i] = Console.ReadLine();
                for (int j = 0; j < w; j++)
                {
                    check[j, i] = false;
                }
            }
            do
            {
                check[x, y] = true;
                char c = room[y][x];
                if (c == '>')
                {
                    x++;   
                }
                if (c == '<')
                {
                    x--;
                }
                if (c == 'v')
                {
                    y++;
                }
                if (c == '^')
                {
                    y--;
                }
                if (c == '.')
                {
                    Console.WriteLine("{0} {1}", x, y);
                    break;
                }
                if (check[x, y])
                {
                    Console.WriteLine("LOOP");
                    break;
                }
            } while (!check[x, y]);
        }
    }
}


Measured memory_bytes: 5716
#include<bits/stdc++.h>
using namespace std;
     
#define int long long
#define ll long long
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define Outerloop int q;cin>>q;while(q--)
#define Mod 1000000007
#define N 1e5

    int32_t main()
    {
    	int n;
    	cin >> n;
    	int a[n],dp[n]={0};
    	
    	f(i,0,n) cin >> a[i];
    	
    	dp[1]=abs(a[1]-a[0]);
    	
    	f(i,2,n)
    	{
    		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    	}
    	cout<<dp[n-1];
    return 0;
    }

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

int main(void) {
  int A, P;
  cin >> A >> P;

  cout << (A*3 + P)/2 << endl;
 
  return 0;
}

Measured memory_bytes: 256
import math

k = int(input())
al = [int(x) for x in input().split()]

pmax = 2
pmin = 2
for a in reversed(al):
    pmin = a*math.ceil(pmin/a)
    pmax = a*math.floor(pmax/a) + a -1

if pmin > pmax:
    print(-1)
else:
    print(pmin, pmax)

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

const int vmax=210;

int X,Y,M;
vector<int> graph[vmax];
int match[vmax];
bool used[vmax];

bool dfs(int v){
	used[v]=true;
	for(auto &u:graph[v]){
		int w=match[u];
		if(w < 0 || (!used[w] && dfs(w)) ){
			match[v]=u;
			match[u]=v;
			return true;
		}
	}
	return false;
}

int bipartite_matching(){
	int res=0;
	rep(i,vmax) match[i]=-1;
	rep(v,X+Y){
		if(match[v]<0){
			rep(i,vmax) used[i]=0;
			if(dfs(v)) res++;
		}
	}
	return res;
}

int main(void){
	cin >> X >> Y >> M;
	rep(i,M){
		int a,b;
		cin >> a >> b;
		b+=X;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	cout << bipartite_matching() << endl;
	return 0;
}

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

int main(){
    long long n,m,l,a[100][100],b[100][100],c[100][100]={0};
    cin >> n >> m >> l;
    for(int i=0;n>i;i++)
        for(int j=0;m>j;j++) cin >> a[i][j];
    for(int i=0;m>i;i++)
        for(int j=0;l>j;j++) cin >> b[i][j];
    for(int i=0;n>i;i++)
        for(int j=0;l>j;j++)
            for(int k=0;m>k;k++)
                c[i][j]+=a[i][k]*b[k][j];
    for(int i=0;n>i;i++){
        for(int j=0;l>j;j++){
            cout << c[i][j];
            if((l-1)!=j) cout << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3256
#include <iostream>

using namespace std;

class B {
	int a, b, c;
public:
	void solve()
	{
		cin >> a >> b >> c;
		bool flag{ false };
		for (int n{ a }; n <= a * b; n += a)
		{
			if ((n % b) == c)
			{
				flag = true;
				break;
			}
		}

		if (flag) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    string s;cin>>s;
    cout<<s.substr(0,(int)s.size()-8)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int prime(int);
int main(){
    int a,sum;
    int b[999999];
    b[0]=0;
    for(int i=1;i<999999;i++){
        b[i]=prime(i+1);
    }
    while ( cin >> a){
        sum =0;
        for (int i=1;i<a;i++){
            sum +=b[i];
        }
        cout << sum << endl;
    }
}
int prime(int x){
    if(x==1)
        return 0;
    if(x==2)
        return 1;
    for (int i=2;i<=sqrt(x)+1;i++){
        if(x%i==0)
            return 0;
    }
    return 1;
}

Measured memory_bytes: 5064
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n, a[101], b[101];

int main(){
	cin >> n;
	int cnt = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
		cnt += max(0, a[i] -b[i]);
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

for p in range(1,4):
    print("{0:.6f}".format(pow(sum([pow(abs(x[i] - y[i]), p) for i in range(n)]) ,1/p)))
print("{0:.6f}".format(pow(pow(max([abs(x[i] - y[i]) for i in range(n)]),n),1/n)))

Measured memory_bytes: 7796
#include <stdio.h>

int main(){
    int i,j,a,b;
    
    while(1){
        
        scanf("%d %d",&a,&b);
        if(a!=0&&b!=0){
            for(i=0;i<a;i++){
                for(j=0;j<b;j++){
                    printf("#");
                }
            printf("\n");
            }
        printf("\n");
        }
        
        else goto lobel1;
    }
    lobel1:
    return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const LL INF=300000000;
const LL MOD=1000000007;

int  f(LL a,LL b){
    LL c=max(a,b);
    int ans=0;
    while(c){
        c/=10;
        ans++;
    }
    return ans;
}

int main(){
    LL n;
    cin>>n;
    LL a=sqrt(n);
    P p;
    for(LL i=a;i>0;i--){
        if(n==i*(n/i)){
            p.first=i;
            p.second=n/i;
            break;
        }
    }
    cout<<f(p.first,p.second)<<endl;
}

Measured memory_bytes: 256
from collections import deque
h,w=[int(x) for x in input().split()]
c=[]
b=0
for i in range(h):
  C=input()
  b+=C.count("#")
  c.append(C)

dist=[[0]*w for i in range(h)]
dist[0][0]=1
d=deque()
d.append([0,0])

dydx=[[1,0],[0,1],[-1,0],[0,-1]]

while d:
  y,x=d.popleft()
  if y==h-1 and x==w-1:
    break
  for i in range(4):
    ny,nx=y+dydx[i][0],x+dydx[i][1]
    if not(0 <= ny < h) or not(0 <= nx < w) or dist[ny][nx]!=0 or c[ny][nx]=="#":
      continue
    dist[ny][nx]=dist[y][x]+1
    d.append([ny,nx])

if dist[h-1][w-1]==0:
  print(-1)
else:
  ans=h*w-b-dist[h-1][w-1]
  print(ans)

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

int		main(void)
{
	vector<pair<int, bool>> bingoSheet(9);
	for (int i = 0; i < 9; i++)
	{
		cin >> bingoSheet.at(i).first;
		bingoSheet.at(i).second = false;
	}
	int		N;
	cin >> N;
	set<int> num;
	for (int i = 0; i < N; i++)
	{
		int		a;
		cin >> a;
		if (!num.count(a))
		{
			num.insert(a);
			for (auto &j : bingoSheet)
			{
				if (j.first == a)
					j.second = true;
			}
		}
	}
	int		count = 0;
	bool	bingo = false;
	for (int i = 0; i < 9; i++)
	{
		if (i % 3 == 0) count = 0;
		if (bingoSheet.at(i).second == true) count++;
		if (count == 3) bingo = true;
	}
	count = 0;
	for (int i = 0; i < 9; i += 3)
	{
		if (i == 6 || i == 7)
		{
			i -= 5;
			count = 0;
		}
		if (bingoSheet.at(i).second == true) count++;
		if (count == 3) bingo = true;
	}
	count = 0;
	for (int i = 0; ; i += 4)
	{
		if (bingoSheet.at(i).second == true) count++;
		if (count == 3) bingo = true;
		if (i == 8)
		{
			count == 0;
			for (int i = 6; i > 0; i -= 2)
			{
				if (bingoSheet.at(i).second == true) count++;
				if (count == 3) bingo = true;
			}
			break ;
		}
	}
	if (bingo == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

a, b = map(int, input().split())
c, d = map(int, input().split())
e, f = map(int, input().split())

abcdef = [a,b,c,d,e,f]

from collections import Counter

cc = Counter(abcdef)

ccm = cc.most_common()

if ccm[0][1]==2 and ccm[1][1]==2 and ccm[2][1]==1 and ccm[3][1]==1:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3316
n=int(input())
s=input()
k=0
if n%2==1:
    print('No')
else:
    for i in range(len(s)//2):
        if s[i]==s[i+len(s)//2]:
            k=1
        else:
            print('No')
            exit()
if k== 1:
    print('Yes')

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

int main() {
  int a,b,x=0,y=0;
  string A,B;
  cin >> a >> b;
  for(int i=0;i<a;i++){
    x=x*10+b;
  }
  for(int i=0;i<b;i++){
    y=y*10+a;
  }
  A=to_string(x);
  B=to_string(y);
  if(A>B){
    cout << B << endl;
  }else{
    cout << A << endl;
  }
}

Measured memory_bytes: 256
import sys


h = {}
for i in range(1, 101):
    h[i] = 0


#input_file = open(sys.argv[1], 'r')

for line in sys.stdin:
    n = int(line)
    h[n] += 1

m = max(h.values())
for i in range(1, 101):
    if h[i] == m:
        print i
    else:
        pass

Measured memory_bytes: 4232
//rotateも何も知らず、また頂いたPDFもまともに読まないまま知っている知識のみで解いた結果です。
//少なくとも提出してAcceptは出ています。
//「きれいなプログラム」がどんなものかまだ把握できていないため、この点に関してもご指摘等頂ければと思います。
//千田 直輝

#include<iostream>

#define R input[0][1]

using namespace std;

int getTop() {
	int input[51][2];

	/*入力*/
	cin >> input[0][0] >> input[0][1];								//まずnとrを受け取る。
	if (input[0][0] == 0 && input[0][1] == 0) {						//n=r=0なら0を返して関数終了。
		return 0;
	}
	for (char pos = 1; pos <= R; pos++) {							//シャッフルの仕方をr回分入力
		cin >> input[pos][0] >> input[pos][1];
	}

	/*シャッフルもどし*/
	int whtop = 1;													//最後一番上にいるカードは、今何番目にいる？
	if (R==0)return input[0][0];									//一回もシャッフルしないならコレ
	while (R != 0) {	
		if (whtop <= input[R][1]) whtop = whtop + input[R][0] - 1;
		else if ((input[R][0] + input[R][1] - 1) < whtop) whtop = whtop;
		else whtop = whtop - input[R][1];
		R--;
	}
	return input[0][0] - whtop + 1;

}


int main()
{
	while (1) {
		int check;
		check = getTop();
		if (check == 0)break;
		else cout << check << endl;
	}
}


Measured memory_bytes: 2984
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <cmath>
#include <limits>
#define ll long long
using namespace std;
int main(){
    int H,W;
    cin >> H >> W;
    char s[W+2][H+2];
    for(int i=0;i<W+2;i++){
        for(int j=0;j<H+2;j++){
            s[i][j] = 'w';
        }
    }
    for(int i=1;i<=W;i++){
        for(int j=1;j<=H;j++){
            cin >> s[i][j];
        }
    }
    int count=0;
    int dy[4] = {0,1,0,-1};
    int dx[4] = {1,0,-1,0};
    for(int i=0;i<W+2;i++){
        for(int j=0;j<H+2;j++){
            if(s[i][j]=='#'){
                for(int k=0;k<4;k++){
                    if(s[i+dy[k]][j+dx[k]]=='.'||s[i+dy[k]][j+dx[k]]=='w')count++;
                }
                if(count==4){
                    cout << "No" << endl;
                    return 0;
                }
                count=0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
while 1:
    h,w = map(int, input().split())
    if h==w==0:break
    for y in range(h):
        for x in range(w):
            if (x+y)%2==0:print('#',end='')
            if (x+y)%2==1: print('.',end='')
        print()
    print()

Measured memory_bytes: 9136
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        String N = sc.next();
        System.out.println(solveDP(N));
    }

    private static long solve(String N) {
        long count = 0;

        int[] convert = {
                0, 1, 2, 3 ,4, 5, 4, 3, 2, 1
        };

        int keta = 0;
        for (int i=0; i<N.length(); i++) {
            int val = N.charAt(N.length()-i-1) - '0';

            if (val+keta == 5 && i != N.length()-1) {
                int nextVal = N.charAt(N.length()-i-2) - '0';
                if (nextVal >= 5) {
                    keta = 1;
                    count += 5;

                    continue;
                }
            }

            count += convert[(val+keta)%10];
            if (val+keta >= 6) {
                keta = 1;
            } else {
                keta = 0;
            }
            // System.err.println("val=" + val + ", keta=" + keta + ", count=" + count);
        }
        if (keta == 1) {
            count += 1;
        }

        return count;
    }

    private static long solveDP(String N) {
        // dp[1桁上の紙幣でまとめて払う][i桁目まで]
        int[][] dp = new int[2][N.length()+2];
        dp[0][0] = 0;
        dp[1][0] = Integer.MAX_VALUE/2;

        int len = N.length();
        N = '0' + N;
        for (int i=0; i<=len; i++) {
            int val = N.charAt(N.length() - i - 1) - '0';

            dp[0][i+1] = Math.min(dp[0][i] + val,      dp[1][i] + val+1);
            dp[1][i+1] = Math.min(dp[0][i] + 10 - val, dp[1][i] + 10 - (val+1));
        }

        return dp[0][len+1];
    }
}

Measured memory_bytes: 51268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string s = in<string>();
    int count = 0;
    REP(i,s.size()){
        if(i % 2 == 0){
            if(s[i] == 'p')count--;
        }else{
            if(s[i] == 'g')count++;
        }
    }
    cout << count << "\n";
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct EdmondsKarp{
    struct edge{
        int to,cap,rev;
        edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
    };

    const int INF=1001001001;
    vector<vector<edge>>G;
    vector<int>used,prevv,preve;
    EdmondsKarp(int v):G(v),used(v),prevv(v),preve(v){}

    void addEdge(int from,int to,int cap){
        G[from].push_back(edge(to,cap,G[to].size()));
        G[to].push_back(edge(from,0,G[from].size()-1));
    }

    int maxFlow(int s,int t){
        int flow=0;
        while(true){
            fill(used.begin(),used.end(),0);

            queue<int>que;
            que.push(s);
            used[s]=true;

            while(que.size()){
                int v=que.front();
                que.pop();

                for(int i=0;i<G[v].size();i++){
                    edge &e=G[v][i];
                    if(used[e.to]||e.cap==0)continue;
                    used[e.to]=true;
                    prevv[e.to]=v;
                    preve[e.to]=i;
                    que.push(e.to);
                }
            }


            if(!used[t])return flow;
            int f=INF;

            for(int v=t;v!=s;v=prevv[v])f=min(f,G[prevv[v]][preve[v]].cap);

            flow+=f;
            for(int v=t;v!=s;v=prevv[v]){
                edge &e=G[prevv[v]][preve[v]];
                e.cap-=f;
                G[e.to][e.rev].cap+=f;
            }
        }
    }
};

signed main(){
    int V,E;
    scanf("%lld%lld",&V,&E);

    EdmondsKarp ek(V);
    rep(i,E){
        int a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        ek.addEdge(a,b,c);
    }
    cout<<ek.maxFlow(0,V-1)<<endl;
    return 0;
}

Measured memory_bytes: 3232
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int d = sc.nextInt(), n = sc.nextInt();
        int base;
        if (d == 0) {
            base = 1;
        } else if (d == 1) {
            base = 100;
        } else {
            base = 10000;
        }
        int ans = base * n;
        if (d == 0 && ans % 100 == 0) {
            ans++;
        }
        if (d == 1 && ans % 10000 == 0) {
            ans += 100;
        }
        if (d == 2 && ans % 1000000 == 0) {
            ans += 10000;
        }
        System.out.println(ans);
    }
}


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

int main(){

	int  N;
	int  W;
	int vi[1000];
	int wi[1000];
	int DP[1001][1001];

	cin>>N>>W;

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

	for(int j=0;j<=W;j++){
		DP[N][j]=0;
	}
	
	for(int i=N-1;i>=0;i--){
		for(int j=0;j<=W;j++){
			if(j<wi[i]){
				DP[i][j]=DP[i+1][j];
			}else{
				if(DP[i+1][j]>DP[i][j-wi[i]]+vi[i]){
					DP[i][j]=DP[i+1][j];
				}else{
					DP[i][j]=DP[i][j-wi[i]]+vi[i];
				}
			}
		}
	}

	cout<<DP[0][W]<<endl;
	
	return 0;
}


	

Measured memory_bytes: 3508
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
typedef long long int ll;
const ll N = 2e5+9;
const ll p = 31;
// const ll m = 1e9 + 7;
const ll inf= 1e5;
const ll mod =1e9+7	;
#define x first
#define y second
#define pb push_back
#define mp make_pair
using pii = pair<int, int>;
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
string k;ll d;
std::vector<std::vector<ll>> dp;


int main(){   
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);                      
    ll T= 1;
    // cin >> T;
   
    while(T--){
    	cin>>k;cin>>d;
    	ll n = k.size();
    	// cout<<n<<'\n';
    	dp.resize(d,vector<ll>(2));
    	dp[0][0] = 1;
    	for(int i = 0;i<n;i++){
    		std::vector<std::vector<ll>> ndp(d,vector<ll>(2));
    		for(int j = 0;j<10;j++){
    			for(int l = 0;l<d;l++){
    				ndp[(l+j)%d][1] += dp[l][1];
    				ndp[(l+j)%d][1]%=mod;
    			}
    		}
    		for(int j = 0;j<(k[i]-'0');j++){
    			for(int l = 0;l<d;l++){
    				ndp[(l+j)%d][1] += dp[l][0];
    				ndp[(l+j)%d][1]%=mod;
    			}
    		}
    		for(int l = 0;l<d;l++){
				ndp[(l+(k[i]-'0'))%d][0] += dp[l][0];
				ndp[(l+(k[i]-'0'))%d][0]%=mod;
			}
			// for(int j = 0;j<d;j++){
			// 	cout<<ndp[j][1]<<" ";
			// }
			// cout<<'\n';

			// for(int j = 0;j<d;j++){
			// 	cout<<ndp[j][0]<<" ";
			// }
			// cout<<"\n\n";
			dp=ndp;

    	}
    	ll ans = dp[0][0]+dp[0][1]-1 +mod;
    	ans%=mod;
    	cout<<ans<<'\n';
    }
}

Measured memory_bytes: 256
N = int(input())

existed_dict = {}
max_count = 0
max_text_list = []
for _ in range(N):
    text = input()
    if existed_dict.get(text):  # ここか
        existed_dict[text] += 1
    else:
        existed_dict[text] = 1
    if existed_dict[text] == max_count:
        max_count = existed_dict[text]
        max_text_list.append(text)
    elif existed_dict[text] > max_count:
        max_count = existed_dict[text]
        max_text_list = []
        max_text_list.append(text)
    else:
        pass

for text in sorted(max_text_list):  # ここ
    print(text)


Measured memory_bytes: 98648
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
using namespace std;
typedef long long int lli;
int main(void)
{
    int N;
    cin >> N;
    lli ans = 0;
    lli y;
    lli gnum;
    for (int i = 1; i <= N; i++)
    {
        y = (lli)(N / i);
        gnum = (y * (y + 1) * i) / 2;
        ans += gnum;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n, p;
    while(cin >> n >> p, n) {
        const int total_p = p;
        int current_player = 0;
        vector<int> v(n);
        int winner = 0;
        while(true) {
            if(p > 0) {
                ++v[current_player];
                --p;
                current_player = (current_player+1)%n;
            } else if(p == 0) {
                if(v[current_player] == total_p) {
                    winner = current_player;
                    break;
                } else {
                    p += v[current_player];
                    v[current_player] = 0;
                    current_player = (current_player+1)%n;
                }
            }
        }
        cout << winner << endl;
    }
}

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

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

// 自動でmodを取ってくれる整数型
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint f(int n){ // 2のn乗
    if(n==0) return 1;
    mint x=f(n/2);
    x*=x;
    if(n%2==1) x*=2;
    return x;
}

// a^n mod を計算する
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//////////////////////////
int h,w;
vector<string> a;
vector<vector<ll> > memo;

ll dp(int x, int y){
    if(memo[x][y]>=0) return memo[x][y];
    if(x==w-1 && y==h-1){ 
        memo[x][y]=1;
        return 1;
        }
    ll ret=0;
    if(x+1!=w && a[y][x+1]!='#') {
        ret+=dp(x+1, y);
        ret%=mod;
    }
    if(y+1!=h && a[y+1][x]!='#'){
        ret+=dp(x, y+1);
        ret%=mod;
    }
    memo[x][y]=ret;
    return ret;
}

int main(){
    cin>>h>>w;
    a.resize(h);
    rep(i,h) cin>>a[i];
    memo.resize(w);
    rep(i,w) memo[i].resize(h,-1);
    cout<<dp(0,0)<<endl;
    return 0;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009

void solve()
{
	ll n,k;
	rl2(n,k);
	VL h(n);
	fr(i,0,n)
	{
		rl(h[i]);
	}
	VL ans(n,0);
	fr(i,0,n)
	{
		ll ct=INT_MAX;
		int flag=0;
		fr(j,1,k+1)
		{
			if(i-j>=0)
			{
				flag=1;
				ct=min(ct,ans[i-j]+abs(h[i]-h[i-j]));
			}
		}
		if(flag)
			ans[i]=ct;
	}
	wl(ans[n-1]);
	NL;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
 
ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
 
ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}
int add(int x){
	return ((x+9)/10)*10;
}

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int a[5];
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	int ans=0;
	int mint=0;
	REP(i,5){
		ans+=add(a[i]);
		mint=max(mint,add(a[i])-a[i]);
	}
	cout << ans-mint << endl;

/////////////////////////////////////////////
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbgvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
  int N, Q; cin >> N >> Q;
  vvi out(N + 1); vi val(N + 1); // 1-ind
  rep(i, N - 1) {
    int a, b; cin >> a >> b;
    out.at(a).push_back(b);
    out.at(b).push_back(a);
  }
  rep(i, Q) {
    int p, x; cin >> p >> x;
    val.at(p) += x;
  }
	vector<bool> r(N + 1);
	queue<int> q;
	q.push(1); r.at(1) = true;		
	while (q.size()) {
  int u = q.front(); q.pop();
    for (int v : out.at(u)) {
      if (r.at(v)) continue;
      q.push(v); r.at(v) = true;
      val.at(v) += val.at(u);
    }  
	}
  rep2(i, 1, N + 1) {
    if(i - 1) cout << " ";
    cout << val.at(i);
  }
  cout << endl;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
    set<string> dic;
    int n;
    cin >> n;
    REP(i,n){
        string q,s;
        cin >> q >> s;
        if(q=="insert")dic.insert(s);
        else{
            if(dic.find(s)!=dic.end())cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 32180
//
//  main.cpp
//  spiner spin
//
//  Created by RMBP on 2019/10/20.
//  Copyright 漏 2019 RMBP. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    string a,b,e;
    int c,i,j,d;

    d=0;
    c=0;
    cin>>a>>b;
    for (i=0;i<a.size();i++){
        e+=a[i];
        
    }
    
    if (a.size()==b.size()){
        for (i=0;i<a.size();i++){
            for (j=0;j<a.size();j++){
                if (e[j]==b[j]){
                    c=c+1;
                }
            }
            if (c==a.size()){
                cout<<"Yes";
                break;
            }
            for (j=0;j<a.size()-1;j++){
                e[j+1]=a[j];
            }
            
            e[0]=a[a.size()-1];
            c=0;
            d=d+1;
            
            for (j=0;j<a.size();j++){
                a[j]=e[j];
            }
        }
        
    }
    else{
        cout<<"No";
    }
    
    if (d==a.size()){
        cout<<"No";
    }
    
    return 0;
}

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

using namespace std;

char solve(vector<string> &words) {
	vector<int> pos(300);
	char curr = 'a';
	while (pos[curr] != words[curr].size()) {
		curr = words[curr][pos[curr]++];
	}
	return curr - ('a' - 'A');
}

int main() {
	ios_base::sync_with_stdio(false);
	vector<string> words(300);
	cin >> words['a'] >> words['b'] >> words['c'];
	cout << solve(words) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long double A, B, H, M, X;
  cin  >> A >> B >> H >> M;
  X = H * 3600.0 + M *60.0;
  long double a, b;
  a = 360.0 * X / 43200.0;
  b = 360.0 * M * 60.0 / 3600.0;


  long double c , C;
  if(abs(a - b) <= 180.0){
  	c = abs(a - b);
  	C = sqrt(A*A + B*B - 2.0*A*B*cos(2.0*M_PI*c/360.0));
    cout << fixed << setprecision(20);
  	cout << C << endl;
  }
  if(abs(a - b) > 180.0){
    long double ma, mi;
    ma = max(a,b);
    mi = min(a,b)+360.0;
    c = abs(ma - mi);
  	C = sqrt(A*A + B*B - 2.0*A*B*cos(2.0*M_PI*c/360.0));
    cout << fixed << setprecision(20);
  	cout << setprecision(15) << C << endl;
  }
}
  
  

Measured memory_bytes: 4188
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

void dfs ( string a, int n, char max_char ) {
    if ( (int)a.length() == n ) {
        cout << a << endl;
        return;
    }
    for ( char c = 'a'; c <= max_char; ++c ) {
        string next = a + c;
        dfs ( next, n, ((c==max_char) ? max_char+1 : max_char) );
    }
    return ;
}

int main(){
    int n;
    cin >> n;
    dfs("", n, 'a');
    return 0;
}


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

int num[26];

int main()
{
		int i, alph;
		char c;
		string s, str;
		while (1) {
				getline(cin, str);
				if (str[str.size()-1]=='\0') break;
				else s+=str;
		}
		for (i=0; i<s.size(); i++) {
				c = tolower(s[i]);
				if (isalpha(c)) num[(int)c-97]++;
		}
		for (i=0; i<26; i++) {
				alph = i+97;
				cout << (char)alph << " : " << num[i] << "\n";
		}
}

Measured memory_bytes: 3144
import java.util.Scanner;

public class Main {
    public static final int MAX_COST = 1000;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int w = scanner.nextInt();
        int[] dp = new int[n*MAX_COST+1];
        int s = 0;
        for (int i = 0; i < n; i++) {
            int wi = scanner.nextInt();
            int vi = scanner.nextInt();
            s+=vi;
            for (int j = s, k = s-vi; k>0 ; j--,k--) {
                if(dp[k]!=0){
                    int val = dp[k]+wi;
                    if(val<=w){
                        if(dp[j]==0) dp[j]=val;
                        else dp[j] = Math.min(dp[j], val);
                    }
                }
            }
            if(dp[vi]==0) dp[vi]=wi;
            else dp[vi] = Math.min(dp[vi], wi);
        }
        for (int i = s; i >=0 ; i--) {
            if(dp[i]!=0){
                System.out.println(i);
                return;
            }
        }
        System.out.println(0);
    }
}


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

int main(){
  string s, t, u;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  cin >> u;

  if(u == s){
    a -= 1;
  }else{
    b -=1;
  }
  cout << a << " " << b;
}


Measured memory_bytes: 3608
# import sys
# input = sys.stdin.readline

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

s = input()
t = input()
ans = 100000
for i in range(len(s)-len(t)+1):
    u = s[i:i+len(t)]
    cnt = 0
    for j in range(len(t)):
        if u[j] != t[j]:
            cnt += 1
    ans = min(ans,cnt)
print(ans)



Measured memory_bytes: 67736
#include<iostream>
using namespace std;
int X[100];
int main()
{
  int N,cnt=0;
  cin>>N;
  for(int i=1;i<=N;i++)
  {
    cin>>X[i];
    if(X[i]!=i)
      	cnt++;
  }
  if(cnt<=2)
    	puts("YES");
  else	puts("NO");
  return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
	ll N, K, S;
	scanf("%lld %lld %lld", &N, &K, &S);
	
	for(ll i = 0; i < N; i++){
		if(i < K ){
			printf("%lld", S);
		}
		else{
			if(S < 1000000000){
				printf("%lld", S+1);
			}else{
				printf("%lld", S-1);
			}
		}
		
		if(i < N-1){
			printf(" ");
		}else{
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1280
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=Integer.parseInt(sc.next());
int[] a=new int[n];
for(int i=0;i<n;i++){
a[i]=Integer.parseInt(sc.next());
}
  int alice=0;
  int bob=0;
  Arrays.sort(a);
  int i=0;
  while(i<n){
  if(n%2==0){
  if(i%2==0){bob+=a[i];}else{alice+=a[i];}
  }else{if(i%2==0){alice+=a[i];}else{bob+=a[i];}}
  i++;}
System.out.println(alice-bob);
}}


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

int main() {
    cout << fixed << setprecision(15);
    for(;;) {
        int N; cin >> N;
        if(N == 0) break;

        int sum    = 0;
        int sum_sq = 0;
        for(int i = 0; i < N; ++i) {
            int a; cin >> a;
            sum    += a;
            sum_sq += a*a;
        }

        double mean     = double(sum) / N;
        double variance = double(sum_sq)/N - mean*mean;
        double stddev   = sqrt(variance);

        cout << stddev << "\n";
    }
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
//-------------------------------------------------------------------------------

intl n,k;
intl a[200000];

void input_var(){
    cin >> n >> k;
    rep(i,n)cin >> a[i];
}
//-------------------------------------------------------------------------------

signed main(){
    cout << fixed << setprecision(10);
    input_var();
    if(n < k){
        bool f[200000];
        m0(f);
        intl cnt = 0;
        intl i = 0;
        f[0] = true;
        while(true){
            i = a[i] -1;
            cnt++;
            if(f[i]){
                k -= cnt;
                cnt = 0;
                intl idx = i;
                while(true){
                    i = a[i] - 1;
                    cnt++;
                    if(i == idx)break;
                }
                break;
            }
            f[i] = true;
        }
        intl b = k % cnt;
        rep(j,b){
            i = a[i] - 1;
        }
        cout << i + 1 << endl;    
    }
    else {
        intl i = 0;
        intl cnt = 0;
        while(true){
            i = a[i] - 1;
            cnt++;
            if(cnt == k)break;
        }
        cout << i + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 5344
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [n, k]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const p: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    return `${p.slice(0, n).sort((a, b) => a - b).slice(0, k).reduce((acc, a) => acc + a, 0)}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


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

DP=[-1 for _ in range(f+1)]
DP[a]=0
if b<=f:DP[b]=0
for i in range(f+1):
    if DP[i]==-1:continue
    for j in a,b:
        if i+j<=f:DP[i+j]=DP[i]
    for j in c,d:
        if i+j<=f and 100*(DP[i]+j)/(i+j)<=100*e/(100+e):
            DP[i+j]=DP[i]+j

ans,water=0,[a,0]
for i,j in enumerate(DP):
    if i==0 or j==-1:continue
    if ans<100*j/i:
        ans=100*j/i
        water=[i,j]
print(*water)

Measured memory_bytes: 73936
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <limits.h>
#include <assert.h>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long int
#define db double
#define ldb long double
#define MOD 1000000007
#define FI first
#define SE second
#define INF INT_MAX
#define NINF INT_MIN
#define L_INF LLONG_MAX
#define L_NINF LLONG_MIN
#define gc getchar
#define sz size

void fsscan()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void scan(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

int main()
{
    //Write Your Code Here
    int n,a,b;
    cin>>n>>a>>b;
    int c=b-a-1;
    if(c==0)
    {
        cout<<"Borys";
    }
    else
    if(c%2!=0)
    cout<<"Alice";
    else
    if(c%2==0)
    cout<<"Borys";
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    int dp[n+1][4][4][4]={};
    dp[0][3][3][3]=1;
    rep(i,n){
        rep(j,4){
            rep(k,4){
                rep(l,4){
                    rep(a,4){
                        if(k==0&&l==2&&a==1)continue;
                        if(k==0&&l==1&&a==2)continue;
                        if(k==2&&l==0&&a==1)continue;
                        if(j==0&&l==2&&a==1)continue;
                        if(j==0&&k==2&&a==1)continue;
                        dp[i+1][k][l][a]=(dp[i+1][k][l][a]+dp[i][j][k][l])%mod;
                    }
                }
            }
        }
    }
    int ans=0;
    rep(i,4){
        rep(j,4){
            rep(k,4){
                ans=(ans+dp[n][i][j][k])%mod;
            }
        }
    }
    cout<<ans<<endl;
}

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

int K;
char S[101];

int main()
{
    int i=0;
    scanf("%d",&K);
    scanf("%s",S);

    if(strlen(S)<=K)
	printf("%s\n",S);
    else{
	while(i<K){
	    printf("%c",S[i]);
	    i++;
	}
	printf("...\n");
    }

    return 0;
}



Measured memory_bytes: 1664
unittest
{
	assert( [ "2 3", "0 1 1", "1 0 1", "1 4 0", "1 2", "3 3" ].solve == 3 );
	assert( [ "4 3", "0 12 71", "81 0 53", "14 92 0", "1 1 2 1", "2 1 1 2", "2 2 1 3", "1 1 2 2" ].solve == 428 );
	
	assert( [ "2 4", "100 100 100 100", "100 0 1 1", "100 1 0 1", "100 1 4 0", "2 3", "4 4" ].solve == 3 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto c = 0L;
	input.front.formattedRead!"%s %s"( n, c );
	auto dss = new long[][]( c, c );
	foreach( ref ds; dss )
	{
		input.popFront;
		ds = input.front.split.to!( long[] );
	}
	auto css = new long[][]( n, n );
	foreach( ref cs; css )
	{
		input.popFront;
		cs = input.front.split.to!( long[] );
		cs[] -= 1;
	}
	
	// 同色にしなければいけないマスごとに塗り替えた後の違和感の合計を計算
	auto ts = new long[][]( 3, c );
	foreach( x; 0L .. n )
	{
		foreach( y; 0L .. n )
		{
			foreach( z; 0L .. c )
			{
				ts[ ( x + y ) % 3 ][ z ] += dss[ css[ x ][ y ] ][ z ];
			}
		}
	}
	
	// 違和感の合計の最小を計算
	auto ans = long.max;
	foreach( i; 0L .. c )
	{
		foreach( j; 0L .. c )
		{
			if( i == j ) continue;
			foreach( k; 0L .. c )
			{
				if( i == k || j == k ) continue;
				ans = min( ans, ts[ 0 ][ i ] + ts[ 1 ][ j ] + ts[ 2 ][ k ] );
			}
		}
	}
	return ans;
}


Measured memory_bytes: 8104
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll n;
	cin>>n;
	vector<ll> v(n);
	rep(i, n) cin>>v[i];
	sort(all(v));
	reverse(all(v));
	ll res = 1;
	rep(i, n/2){
		if(v[2*i]!=v[2*i+1] || v[2*i]!=n-2*i-1) res = 0;
	}
	if(n%2 && v[n-1]!=0) res = 0;
	n /= 2;
	while(n--) (res<<=1)%=mod;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
 
using namespace std;
typedef long long ll;

ll ans,mn=1e8,mx,sum;
int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	for(int t=1; t<=n; t++){
		sum=0,ans=0;
		for(int i=0; i<t; i++)
			sum+=a[i];
		for(int i=t; i<n; i++)
			ans+=a[i];
		mn = min(mn,abs(sum-ans));
	}
	cout<<mn<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll a[100001];
ll x[100001]={};
ll total=0;
int main() {

	int n;
	cin>>n;
	rep(i,n){
		cin>>a[i];
		x[a[i]]++;
	}
	ll r=0;
	rep(i,n){
		r=x[a[i]]+x[a[i]-1]+x[a[i]+1];
		total=max(r,total);
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 1792