akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int ta[1010],to[1000010],nt[1000010],co[1000010],F[1010];
int MF(int s,int t,int e,int min){
  if(s==t||min==0)return min;
  int i,r;
  F[s]=1;
  for(i=ta[s];i+1;i=nt[i]){
    if(F[to[i]])continue;
    r=MF(to[i],t,e,MIN(min,co[i]));
    co[i]-=r;
    co[(i+e)%(2*e)]+=r;
    if(r)return r;
  }
  return 0;
}
int Flow(int s,int t,int v,int e,int min){
  while(v--)F[v]=0;
  return MF(s,t,e,min);
}
int maxf(int v,int e,int s,int t){
  int f,r;
  for(f=0;r=Flow(s,t,v,e,1e9);f+=r);
  return f;
}
int main(){
  int n,m,q,l,ans,e,r=0,i,a,b,k;
  scanf("%d %d %d",&n,&m,&q);
  e=m+q;
  for(i=0;i<=n;i++)ta[i]=-1;
  for(i=0;i<m;i++){
    scanf("%d %d",&a,&b);
    nt[r  ]=ta[to[r+e]=a];
    nt[r+e]=ta[to[r  ]=b];
    co[ta[b]=r+e]=co[ta[a]=r]=1;
    r++;
  }/*printf("a\n");
  for(i=0;i<=n;i++){printf("%d:",i);
    for(k=ta[i];k+1;k=nt[k])printf(" %d",to[k]);
    printf("\n");
    }//*/
  ans=maxf(n+1,e,1,n);//printf("%d\n",ans);
  while(q--){
    scanf("%d %d %d",&k,&a,&b);
    if(k==1){
      for(i=ta[a];i+1;i=nt[i]){
	if(to[i]==b)break;
      }
      if(i==-1){
	nt[r  ]=ta[to[r+e]=a];
	nt[r+e]=ta[to[r  ]=b];
	co[ta[b]=r+e]=co[ta[a]=r]=1;
	r++;
      }
      else co[i]=co[(i+e)%(2*e)]=1;
      ans+=Flow(1,n,n+1,e,1);
    }
    else{
      for(k=ta[a];to[k]-b;k=nt[k]);
      if(co[k]==2){
	i=a;
	a=b;
	b=i;
	k=(k+e)%(2*e);
      }
      if(co[k]==1);//co[i]=co[(i+e)%(2*e)]=0;
      else if(Flow(a,b,n+1,e,1)==0){
	Flow(n,b,n+1,e,1);
	Flow(a,1,n+1,e,1);
	ans--;
      }
      co[k]=co[(k+e)%(2*e)]=0;
    }
    printf("%d\n",ans);
  }
  return 0;
}



Measured memory_bytes: 2288
//This is getting accepted!
#include<bits/stdc++.h>
#define ll long long
#define oo 1000000009
#define isset(x, i) (((x)>>(i))&1)
#define setbit(x, i) ((x)^(1ll<<(i)))
#define clearbit(x, i) ((x)&(~(1ll<<(i))))
#define twoexp(i) (1ll<<(i))

using namespace std;

const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = 2 * acos(0);
const int MAXN = 16;

int n, d;
int a[MAXN][MAXN];

bool input() {
	
	cin >> n >> d;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= d; ++j)
			cin >> a[i][j];
	
	return !cin.fail();
}

void clear_input() {
	n = 0;
}

void preprocess() {
	
	
	
}

void process(int itest) {
	
	int res = 0;
	for (int u = 1; u <= n; ++u)
		for (int v = u+1; v <= n; ++v) {
			int dist2 = 0;
			for (int i = 1; i <= d; ++i)
				dist2 += (a[u][i] - a[v][i]) * (a[u][i] - a[v][i]);
			int sq = sqrt(dist2);
			if (sq*sq == dist2)
				res++;
		}
	
	cout << res << endl;
	
}

void oneTest() {
	
	while(input()) {
		preprocess();
		process(0);
		clear_input();
	}
	
}

void multiTest() {
	
	int t;
	cin >> t;
	
	for (int it = 1; it <= t; ++it) {
		input();
		preprocess();
		process(it);
	}
}

int main(){
    #ifndef ONLINE_JUDGE
//    freopen("../out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	oneTest();
//	multiTest();

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int iabs(int x) {
    return x < 0 ? -x : x;
}
int main() {
    int n, x, y;
    cin >> n >> x >> y;
    if (x > y) swap(x, y);
    vector<i64> cnt(n);
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            int k = min({
                j - i,
                iabs(x - i) + iabs(y - j) + 1,
                iabs(y - i) + iabs(x - j) + 1
            });
            cnt[k]++;
        }
    }    
    for (int k = 1; k < n; ++k) cout << cnt[k] << '\n';
    return 0;
}

Measured memory_bytes: 256
h,n=map(int,input().split())
magics=[list(map(int,input().split())) for i in range(n)]

#import numpy as np

#dp = np.full((n+1, h+1), 10**10)
dp=[[10**10 for _ in range(h+1)]for _ in range(n+1)]
dp[0][0]=0
for i in range(0,n):
  damage = magics[i][0]
  cost = magics[i][1]
  for j in range(0,h+1):
    dp[i+1][j] = min( dp[i+1][j], dp[i][j] )

    to = min( j+damage, h )
    dp[i+1][to] = min( dp[i+1][j]+cost, dp[i+1][to] )
                                                 
print(dp[n][h])

Measured memory_bytes: 162084
X = int(input())

if 400 <= X <= 599 :
  ret = 8
elif 600 <= X <= 799 :
  ret = 7
elif 800 <= X <= 999 :
  ret = 6
elif 1000 <= X <= 1199 :
  ret = 5
elif 1200 <= X <= 1399 :
  ret = 4
elif 1400 <= X <= 1599 :
  ret = 3
elif 1600 <= X <= 1799 :
  ret = 2
elif 1800 <= X <= 1999 :
  ret = 1

print(ret)


Measured memory_bytes: 61628
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n;
		Map<String, List<Button>> map = new HashMap<String, List<Button>>();
		LinkedList<String> pre = new LinkedList<String>();
		LinkedList<String> next = new LinkedList<String>();
		String now = "";
		while ((n = in.nextInt()) != 0) {
			map.clear();
			pre.clear();
			next.clear();
			int w = in.nextInt();
			int h = in.nextInt();
			for (int page_info = 0; page_info < n; page_info++) {
				String pageName = in.next();
				if (page_info == 0) {
					now = pageName;
				}
				int bt_count = in.nextInt();
				List<Button> buttons = new ArrayList<Button>();
				for (int i = 0; i < bt_count; i++) {
					buttons.add(new Button(in.nextInt(), in.nextInt(), in
							.nextInt(), in.nextInt(), in.next()));
				}
				map.put(pageName, buttons);
			}
			int m = in.nextInt();
			for (int i = 0; i < m; i++) {
				String command = in.next();
				if ("click".equals(command)) {
					int x = in.nextInt();
					int y = in.nextInt();
					for (Button bt : map.get(now)) {
						if (bt.c(x, y)) {
							pre.addLast(now);
							now = bt.target;
							next.clear();
							break;
						}
					}
				} else if ("back".equals(command)) {
					if (!pre.isEmpty()) {
						next.addFirst(now);
						now = pre.pollLast();
					}
				} else if ("forward".equals(command)) {
					if (!next.isEmpty()) {
						pre.addLast(now);
						now = next.pollFirst();
					}
				} else if ("show".equals(command)) {
					assert true;
					System.out.println(now);
				}
			}
		}

	}
}

class Button {
	final int minX, minY, maxX, maxY;
	final String target;

	Button(int minX, int minY, int maxX, int maxY, String target) {
		this.minX = minX;
		this.minY = minY;
		this.maxX = maxX;
		this.maxY = maxY;
		this.target = target;
	}

	boolean c(int x, int y) {
		return (minX <= x && x <= maxX && minY <= y && y <= maxY);
	}
}

Measured memory_bytes: 28560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String[] diceNumber = br.readLine().split("\\s");
			Dice01 dice01 = new Dice01(diceNumber);
			
			char[] order = (br.readLine()).toCharArray();
			for (int i = 0; i < order.length; i++) {
				dice01.rollDice(order[i], diceNumber.length);
			}
			System.out.println(dice01.takeTopNumber());
			
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}

}


class Dice01 {
	private int number[];
	private int work[];

	public Dice01() {

	}

	public Dice01(String[] args) {
		number = new int[args.length];
		work = new int[args.length];
		// サイコロの初期化
		for (int i = 0; i < args.length; i++) {
			number[i] = Integer.parseInt(args[i]);
		}
	}

	public void rollDice(char action, int num) {
		for (int i = 0; i < num; i++) {
			this.work[i] = this.number[i];
		}

		switch (action) {
		case 'E':
			// West→Top, South→South, Top→East, Bottm→West, North→North, East→Bottom
			setNumber(work[3], work[1], work[0], work[5], work[4], work[2]);
			break;
		case 'N':
			// South→Top, Bottom→South, East→East, West→West, Top→Nouth, Nouth→Bottom
			setNumber(work[1], work[5], work[2], work[3], work[0], work[4]);
			break;
		case 'S':
			// North→Top, Top→South, East→East, West→West, Bottom→North, South→Bottom
			setNumber(work[4], work[0], work[2], work[3], work[5], work[1]);
			break;
		case 'W':
			// East→Top, South→South, Bottom→East, Top→West, North→North, West→Bottom
			setNumber(work[2], work[1], work[5], work[0], work[4], work[3]);
			break;
		default :
			break;
		}
	}

	public void setNumber(int n1, int n2, int n3, int n4, int n5, int n6) {
		this.number[0] = n1;
		this.number[1] = n2;
		this.number[2] = n3;
		this.number[3] = n4;
		this.number[4] = n5;
		this.number[5] = n6;
	}

	public int takeTopNumber() {
		return this.number[0];
	}
}



Measured memory_bytes: 24528
/* به نام یزدان */
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 50 + 3, MOD = 1e9 + 7;
long long k;
int n;

struct matrix {
	int a[MAX_N][MAX_N];
	
	matrix(int val = 0) {
		memset(a, 0, sizeof a);
		for (int i = 0; i < MAX_N; i++)
			a[i][i] = val;
	}

	void operator*=(const matrix &t) {
		matrix res;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				for (int l = 0; l < n; l++)
					res.a[i][l] = (res.a[i][l] + 1LL * a[i][j] * t.a[j][l]) % MOD;
		*this = res;
	}
	
	void operator^=(long long pw) {
		matrix res(1), tmp = *this;
		for (; pw; pw >>= 1, tmp *= tmp)
			if (pw & 1)
				res *= tmp;
		*this = res;
	}
} mt;

void read_input() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> mt.a[i][j];
}

void solve() {
	mt ^= k;
}

void print_output() {
	int ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			(ans += mt.a[i][j]) %= MOD;
	cout << ans;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
	print_output();
}


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

int main()
{   
    int X, A;
    cin >> X >> A;
    if(A > X){
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
    return 0;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();

        long maxA = 0;
        long maxB = long.MaxValue;

        for (int i = 0; i < n; i++)
        {
            long a = sc.NextLong();
            long b = sc.NextLong();

            if (a > maxA)
            {
                maxA = a;
                maxB = b;
            }
        }

        long answer = maxA + maxB;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 45428
N=input()

a=int(N[0:1])
b=int(N[1:2])
c=int(N[2:3])
d=int(N[3:4])
if a+b+c+d==7:
    print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
    exit()
if a-b+c+d==7:
    print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
    exit()
if a+b-c+d==7:
    print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
    exit()
if a+b+c-d==7:
    print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
    exit()
if a-b-c+d==7:
    print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
    exit()
if a-b+c-d==7:
    print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
    exit()
if a+b-c-d==7:
    print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
    exit()
if a-b-c-d==7:
    print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
    exit()
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a[1010];
int main()
{
	int n, m;
	scanf("%d",&n);
	int i;
	for(i=0; i<n; i++) scanf("%d",&a[i]);
	scanf("%d",&m);
	while(m--)
	{
		int x, l, r;
		scanf("%d%d%d",&x,&l,&r);
		if(x == 0) printf("%d\n",*min_element(a+l, a+r));
		else printf("%d\n",*max_element(a+l, a+r));
	}
	return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>

typedef long long ll;
using namespace std;



bool isPrime(ll n){
    if(n < 2){
        return 0;
    }
    if(n%2 == 0){
        return n==2;
    }
    for(ll i=3;i*i<=n;i++){
        if(n%i == 0) return 0;
    }
    return 1;
}

string toBinary(int x){
    string s = "";
    while(x > 0){
        if(x%2) s += "1";
        else s += "0";
        x /= 2;
    }
    string h = "";
    for(int i=s.size();i<31;i++){
        h += "0";
    }
    reverse(s.begin(),s.end());
    //cout<<"x "<<x<<" "<<(h+s)<<endl;
    return (h+s);
}

int toInt(string s){
    int h =0;
    for(int i=s.size()-1;i>=0;i--){
        if(s[i] ==  '1') h += pow(2,i);
    }
    return h;
}
int main() {
  // int n,m;
   //freopen("test.txt","w",stdout);
//   while(cin>>n){
//       cin>>m;
//       vector<int> v(n);
//       ll maxy = 0;
//       ll miny = 10e10;
//       for(int i=0;i<n;i++) { cin >> v[i];maxy= max(maxy,(ll)v[i]); }
//       int h = n-m+1;
//      // vector<int> vv;
//       ll k = 0;
//       int nn = 0;
//        int prevIndx = 0;
//        for(int i=0;i<h;i++) k += v[i];
//       for(int i=h;i<n;i++){
//          /* int j = i+1;
//            k += v[i];
//            nn++;
//           while(j<n && nn < h){
//               k += v[j];
//               j++;
//               nn++;
//           }
//         //  vv.push_back(k);
//         if(k < miny) miny = k;
//           k -= v[prevIndx];
//           i = j-1;
//           prevIndx++;
//           nn--;
//           */
//           if(k < miny) miny = k;
//           k -= v[prevIndx];
//           prevIndx++;
//           k += v[i];
//
//       }
//       cout<<max(miny,maxy)<<endl;
//
//   }
    ios_base::sync_with_stdio(false);
    cin.tie(0);
ll n;
cin>>n;
int indx= 1;
string s = "";
while(n > 0){
    n--;
    s += ('a'+(n%26));
    n /= (26);
}
reverse(s.begin(),s.end());
cout<<s<<endl;
return 0;
}


Measured memory_bytes: 3620
a,b=map(int,input().split())

jud=False

if a%3==0:
    jud=True
elif b%3==0:
    jud=True
elif (a+b)%3==0:
    jud=True
else:
    jud=False

if jud==True:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
//vvi(n, vector<int>(m, -1))
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(a) (a).begin(), (a).end()
#define out(x) cout << (x) << endl;

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> i >> j >> k ;

	if(i <= k && k <= j){
		out("Yes");
	}
	else if(j <= k && k <= i){
		out("Yes");
	}
	else{
		out("No");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s, t;
    int ans = 0;
    cin>>s>>t;
    for(int i = 0; i < 3; i++) {
        if(s[i] == t[i]) {
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

int main(void){
    int a, b, k;
    cin >> a >> b >> k;
    int ansa=0;
    int ansb=0;
    int small[k];
    int large[k];
    for(int i = 0; i < k; i++){
        small[i]=a+i;
        large[i]=b-i;
        ansa++; ansb++;
        if(small[i]>large[i]){
            ansa--; ansb--;
            break;
        }
        else if(small[i]==large[i]){
            ansa--;
            break;
        }
    }
    for(int i = 0; i < ansa; i++)
        cout << small[i] << endl;
  for(int i = ansb-1; i >= 0 ; i--)
       cout << large[i] << endl;
    
    return 0;
}

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

static const int INF = (1 << 30);
static const int MAX = 100010;

int main()
{
  int N;
  int DP[MAX + 1];
  int A[MAX];

  cin >> N;
  for (int i = 0; i < N; ++i)
  {
    cin >> A[i];
    DP[i] = INF;
  }

  DP[0] = 0;
  DP[N] = INF;

  for (int i = 0; i < N - 1; ++i)
  {
    DP[i + 1] = min(DP[i + 1], DP[i] + abs(A[i + 1] - A[i]));
    DP[i + 2] = DP[i] + abs(A[i + 2] - A[i]);
  }

  cout << DP[N - 1] << endl;

  return 0;
}


Measured memory_bytes: 1024
import sys
import heapq
input = sys.stdin.readline
hq = []
heapq.heapify(hq)

N, M = map(int, input().split())
# AでsortされたA, Bのペアを格納
P = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x:x[0])
j = 0
ans = 0
for i in range(1, M+1):  # M - i日後にするバイトを考える
    while j < N and P[j][0] <= i:
        heapq.heappush(hq, -P[j][1])  # 候補の追加
        j += 1
    if len(hq):
        ans += -heapq.heappop(hq)
print(ans)


Measured memory_bytes: 75612
#include <stdio.h>
 
#define MAX 1000000
 
struct Node{int p, l, r; };
 
struct Node T[MAX];
int n, D[MAX];
 
void print(int u);
int rec(int u, int p);
 
int main(){
  int i, j, k, d, v, c, l, r;
 
  scanf("%d", &n);
 
  for(i=0; i<n; i++){
    T[i].p=-1;
    T[i].l=-1;
    T[i].r=-1;
}
 
  for(i=0; i<n; i++){
    scanf("%d%d", &v, &d);
    for(j=0; j<d; j++){
      scanf("%d", &c);
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l=c;
      T[c].p=v;
    }
  }
  for(i=0; i<n; i++){
    if(T[i].p==-1) r=i;
  }
 
  rec(r, 0);
 
  for(i=0; i<n; i++) print(i);
 
  return 0;
}
 
void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);
 
  if(T[u].p==-1) printf("root, ");
  else if(T[u].l==-1) printf("leaf, ");
  else printf("internal node, ");
 
  printf("[");
  for(i=0, c=T[u].l; c!=-1; i++, c=T[c].r){
    if(i) printf(", ");
    printf("%d", c);
}
  printf("]\n");
 
}
 
int rec(int u, int p){
  D[u]=p;
  if(T[u].r!=-1) rec(T[u].r, p);
  if(T[u].l!=-1) rec(T[u].l, p+1);
}

Measured memory_bytes: 8224
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

inline bool isOk(const string& s)
{
    int head = 0;
    int tail = s.length()-1;
    bool ok = true;
    while (ok && head < tail) {
        if (s[head] == s[tail]) {
            ++head;
            --tail;
        } else {
            ok = false;
        }
    }
    return ok;
}

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

    string S;
    cin >> S;

    string T = S.substr(0, S.length() / 2);
    cout << ((isOk(S) && isOk(T)) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define maxn 200005
#define LL long long
#define INF 0x3f3f3f3f
#define mset(p,v) memset(p,v,sizeof(p))
using namespace std;
int k,n;
int dis[maxn];
int d[maxn];
LL ans;
int main()
{
    while(~scanf("%d%d",&k,&n))
    {
        ans=0;
        for(int i=0;i<n;i++)
            scanf("%d",&dis[i]);
        sort(dis,dis+n);
        for(int i=0;i<n-1;i++)
        {
            d[i]=dis[i+1]-dis[i];
        }
        d[n-1]=k-dis[n-1]+dis[0];
        sort(d,d+n);
        for(int i=0;i<n-1;i++)
            ans+=d[i];
        printf("%lld\n",ans);


    }

    return 0;
}


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

int main(){
    str s; cin >> s;
    istringstream ss1;
    ss1 = istringstream(s.substr(0, 2));
    int early, later;
    ss1 >> early;
    ss1 = istringstream(s.substr(2, 2));
    ss1 >> later;
    bool early_year = false, later_year = false;
    if((early <= 12) && (1 <= early)){
        early_year = true;
    }
    if((later <= 12) && (1 <= later)){
        later_year = true;
    }
    if(early_year && later_year){
        cout << "AMBIGUOUS" << endl;
        return 0;
    }
    if(early_year){
        cout << "MMYY" << endl;
        return 0;
    }
    if(later_year){
        cout << "YYMM" << endl;
        return 0;
    }
    cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/ruby
OutputMode=:AIZU #:NEWICK(CODEIQ debug),:CODEEVAL,:AIZU,:CODEIQ

CODES=OutputMode==:CODEEVAL||OutputMode==:AIZU ? ['0','1'] : ['r','g','b']
WIDTH=CODES.size
def dfs(str,code) #assign code
	r=[]
	c=i=0
	while str[i,1]!=')'
		if str[i,1]=='('
			r+=dfs(str[i+1..-1],code+CODES[c])
			x=1
			while x>0
				x+=1 if str[i+1,1]=='('
				x-=1 if str[i+1,1]==')'
				i+=1
			end
		else
			r+=[str[i,1]+(OutputMode==:CODEEVAL||OutputMode==:AIZU ? ': ' : ':')+code+CODES[c]]
		end
		c+=1
		i+=1
	end
	return r
end

def huffman(h)
	#build huffman tree
	a=h.map{|k,v|[v,k]}.sort
	if a.size==1
		a=[[1,'('+a[0][1]+')']]
	else
		if (h.size-WIDTH)%(WIDTH-1)>0
			b=a.shift(WIDTH-(h.size-WIDTH)%(WIDTH-1)).transpose
			a=(a+[[b[0].reduce(:+),'('+b[1]*(OutputMode==:NEWICK ? ',' : '')+')']]).sort
		end
		while a.size>1
			b=a.shift(WIDTH).transpose
			raise if b[0].size!=WIDTH
			a=(a+[[b[0].reduce(:+),'('+b[1]*(OutputMode==:NEWICK ? ',' : '')+')']]).sort
		end
	end
	# a => [[9371, "((O(((Q(XZ)J)VB)YW)I)(AT(U(PFK)L))(E(DRS)(N(GMC)H)))"]]
	if OutputMode==:NEWICK
		# ((O,(((Q,(X,Z),J),V,B),Y,W),I),(A,T,(U,(P,F,K),L)),(E,(D,R,S),(N,(G,M,C),H)));
		puts a[0][1]+';'
		exit
	end
	r=dfs(a[0][1][1..-1],'')
	#r.sort_by{|e|e.split(':')[1].size}.each{|e|
	if OutputMode==:CODEEVAL
		puts r.sort*'; '+';'
	elsif OutputMode==:AIZU
		p r.map{|e|x,y=e.split(': ');h[x]*y.size}.reduce(:+)
	else
		puts r.sort
	end
end

if OutputMode==:CODEEVAL||OutputMode==:AIZU
	$<.each{|e|
		h=Hash.new(0)
		e.chomp.chars{|c|h[c]+=1}
		huffman(h)
	}
elsif OutputMode==:NEWICK||OutputMode==:CODEIQ
	h={}
	DATA.each{|e|
		s,n=e.split
		h[s]=n.to_i
	}
	huffman(h)
end


Measured memory_bytes: 9064
class UnionFind():
    def __init__(self, n):
        self.parent = list(range(n))
        self.rank = [0] * n

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)

        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


while True:
    n, m = (int(s) for s in input().split())
    if not n:
        break

    result = 0
    bridges = sorted(
        (tuple(int(s) for s in input().split()) for i in range(m)),
        key=lambda x: x[2])
    tree = UnionFind(n)

    for a, b, cost in bridges:
        if not tree.same(a, b):
            result += cost
            tree.unite(a, b)
    print(result)

Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll K; cin >> K;
    ll i = 7;
    ll cnt = 1;
    ll M = i % K;
    set<ll> MS;
    while (1) {
        MS.insert(M);
        if (M == 0) break;
        M = (M * 10 + 7) % K;
        cnt++;
        if (MS.count(M) > 0) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 50480
n, m = map(int, input().split())
p = [0 for _ in range(m)]
s = ["" for _ in range(m)]
for i in range(m):
    pi, si = input().split()
    p[i] = int(pi)
    s[i] = si
ac = set()
acc = set()
wa = 0
for i in range(m):
    if s[i] == "AC" and p[i] not in ac:
        acc.add(p[i])
for i in range(m):
    if s[i] == "AC" and p[i] not in ac:
        ac.add(p[i])
    elif s[i] == "WA" and p[i] not in ac and p[i] in acc:
        wa += 1

print(len(ac), wa)



Measured memory_bytes: 24216
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>

using namespace std;


int main()
{
	int a, b;
	cin >>a >> b;
	int ans = 0;
	for (int i = a; i <=b; i++)
	{
		string s = to_string(i);
		string d = s;
		reverse(s.begin(), s.end());
		if (s == d)
		{
			ans++;
			
		}
	}
	cout << ans << endl;
}

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

int main(){
  long long int X;
  cin >> X;
  long long int money = 100;
  int ans = 0;
  for(int i = 1;; i++){
    money *= 1.01;
    if(money >= X){
      ans = i;
      break;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<class Z> V<Z> divisor(Z n) {
  V<Z> res;
  Z i;
  for (i = 1; i * i < n; ++i) if (n % i == 0) res.push_back(i), res.push_back(n / i);
  if (i * i == n) res.push_back(i);
  sort(rbegin(res), rend(res));
  return res;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  V<> a(n); for (auto&& e : a) cin >> e;
  for (int d : divisor(accumulate(begin(a), end(a), 0))) {
    V<> r;
    for (int e : a) {
      int t = e % d;
      if (t) r.push_back(t);
    }
    sort(begin(r), end(r));
    int m = r.size();
    lint s = 0, sr = accumulate(begin(r), end(r), 0LL);
    for (int i = 0; i <= m; ++i) {
      if (i) s += r[i - 1];
      lint t = (lint)d * (m - i) - (sr - s);
      if (s == t and s <= k) return cout << d << '\n', 0;
    }
  }
}


Measured memory_bytes: 3676
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define INF 20000000000000
#define PI 3.14159265359
#define ull unsigned long long

int main(){
    int h_1,h_2,m_1,m_2,k,time=0;
    scanf("%d%d%d%d%d",&h_1,&m_1,&h_2,&m_2,&k);
    time=h_2*60+m_2-m_1-h_1*60-k;
    printf("%d",time);
    return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) { cin >> a[i]; }
  int c = 0, num = 1;
  bool ok = false;
  rep(i, n) {
    if (a[i] == num) {
      num++;
      ok = true;
    } else {
      c++;
    }
  }
  if (ok) {
    cout << c << endl;
  } else {
    cout << -1 << endl;
  }
}

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

int main() {
	int n, count=0; cin>>n;
	if(n==100000) n-=1;
	if(n>=10000) count+=n-10000+1;
	if(n>=1000) n=999;
	if(n>=100) count+=n-100+1;
	if(n>=10) n=9;
	count+=n;
	cout<<count;
	
	return 0;
}

Measured memory_bytes: 256
program main
  implicit none
  character(len=1) :: b
  
  read *, b
  select case (b)
  case ('A')
    print '(a1)', 'T'
  case ('T')
    print '(a1)', 'A'
  case ('G')
    print '(a1)', 'C'
  case ('C')
    print '(a1)', 'G'
  end select
end program

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

int main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    if(A1+A2+A3>=22)
        cout<<"bust"<<endl;
    else
        cout<<"win"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>

using namespace std;

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

  vector<int> A(50,0);
  vector<int> B(50,0);
  vector<int> C(50,0);

  for (int n=0; n<N; ++n)
    cin >> A[n];

  for (int n=0; n<N; ++n)
    cin >> B[n];

  for (int n=0; n<N-1; ++n)
    cin >> C[n];

  int ans = 0;
  for (int n=0; n<N; ++n) {
    int a = A[n];
    ans += B[a-1];
    if (n>0 && A[n] == A[n-1]+1) {
      ans += C[a-2];
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(void) {
  int N, Q, i, *AC, *l, *r;
  char *S;
  scanf("%d%d",&N,&Q);
  AC = (int*)malloc(sizeof(int)*N);
  assert(AC);
  S = (char*)malloc(sizeof(char)*(N+1));
  assert(S);
  l = (int*)malloc(sizeof(int)*Q);
  assert(l);
  r = (int*)malloc(sizeof(int)*Q);
  assert(r);
  for (scanf("%s",S), AC[0] = 0, i = 1; i < N; i++) {
    if (S[i-1] == 'A' && S[i] == 'C') {
      AC[i] = AC[i-1]+1;
    } else {
      AC[i] = AC[i-1];
    }
  }
  for (i = 0; i < Q && scanf("%d%d",&l[i],&r[i]); i++);
  for (i = 0; i < Q; i++) {
    printf("%d\n",AC[r[i]-1]-AC[l[i]-1]);
  }
  free(l);
  free(r);
  free(AC);
  free(S);
  return 0;
}

Measured memory_bytes: 2048
#include <iostream>

using namespace std;

int main() {
    int count = 0;

    string W;
    cin >> W;

    string s;
    while (true) {
        cin >> s;
        if (s == "END_OF_TEXT")
            break;
        for (int i = 0; i < s.size(); i++)
            if (s[i] >= 'A' && s[i] <= 'Z')
                s[i] = static_cast<char>('a' + s[i] - 'A');
        if (s == W)
            count++;
    }

    cout << count << endl;
    return 0;
}



Measured memory_bytes: 3204
# include<cstdio>
using namespace std;
long long n,a,b;
int main()//AT2739
{
	scanf("%lld%lld%lld",&n,&a,&b);
	if(a>b) return !printf("0\n");
	if(n==1)
	{
		if(a!=b)printf("0\n");
		else printf("1\n");
		return 0;
	}
	printf("%lld\n",(b-a)*(n-1)+(a-b+1));
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include<math.h>

#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define ll long long

int main(void)
{
    char c;
    while((c=getchar())!=EOF)
    {
        if(isupper(c))
        {
            c = tolower(c);
        }
        else if(islower(c))
        {
            c = toupper(c);
        }
         putchar(c);
    }
    return 0;
}




Measured memory_bytes: 2476
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] d = S.toCharArray();
        long answer = 0;
        StringBuilder current = new StringBuilder();
        StringBuilder prev = new StringBuilder();
        for (int i = 0; i < d.length; i++) {
            current.append(d[i]);
            if (!prev.toString().equals(current.toString())) {
                answer += 1;
                prev = current;
                current = new StringBuilder();
                continue;
            }
        }
        System.out.println(answer);
    }
}


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

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2")

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;

int p[maxn][2];

int get_sum(int i, int l) {
    if (i < 0) return 0;
    return p[i][l];
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n, k;
    cin >> n >> k;
    int l = 0, r = 1;

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (i == 0) {
            for (int j = 0; j <= k; j++) {
                p[j][r] = get_sum(j - 1, r) + (j <= x);
            }
            swap(l, r);
            continue;
        }
        for (int j = 0; j <= k; j++) {
            p[j][r] = get_sum(j - 1, r)  + (get_sum(j, l) - get_sum(j - x - 1, l) + mod) % mod;
            p[j][r] %= mod;
        }
        swap(l, r);
    }
    cout << (get_sum(k, l) - get_sum(k - 1, l) + mod) % mod << "\n";



    return 0;
}

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

int main(){
  string S;
  string model = "abcdefghijklmnopqrstuvwxyz";
  vector<bool> s(26, false);
  int d = 0;
  
  cin >> S;
  
  for(int i = 0; i < S.size(); i++){
    if(d == 26)break; 
    for(int j = 0; j < model.size(); j++){
      if(s.at(j))continue;
      if(S.at(i) == model.at(j)){
        s.at(j) = true;
        d++;
        break;
      }
    }
  }
  
  if(d == 26){
    cout << "None" << endl;
  }else{
    for(int i = 0; i < s.size(); i++){
      if(s.at(i))continue;
      cout << model.at(i) << endl;
      break;
    }
  }
  
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int h, w;
    char c[110];
    cin >> h >> w;
    imfor(i, h) {
        cin >> c;
        cout << c << endl;
        cout << c << endl;
    }
}

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

int main() {
  int N,X,Y,A;
  cin>>N;
  X=64;
  	for(int i=0;i<N;i++){
      cin>>A;
      Y=0;
      	while(A/2==(A+1)/2){
            Y++;
            A/=2;
          }
          if(X>=Y){
            X=Y;
          }
        }
  cout<<X<<endl;
}


Measured memory_bytes: 256
N, Q = [int(i) for i in input().split()]
S = input()

cs = [0]
for i in range(1, N):
  if S[i-1] + S[i] == 'AC':
    cs.append(cs[i-1] + 1)
  else:
    cs.append(cs[i-1])

for l, r in ([int(i) for i in input().split()] for _ in range(Q)):
  print(cs[r - 1] - cs[l - 1])


Measured memory_bytes: 11588
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
bool isPalin(string s)
{
	string a=s;
	reverse(s.begin(),s.end());
	return a==s;
}
int main()
{
	string s;
	cin>>s;
	ll N=s.length();
	string f=s.substr(0,N/2);
	string se=s.substr(N/2+1,N/2);
	if(isPalin(s)&&isPalin(f)&&isPalin(se))
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}	

Measured memory_bytes: 256
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]

s2=s[:]
set(s2)
ans=0
for i in s2:
    if ans<s.count(i)-t.count(i):
        ans=s.count(i)-t.count(i)
print(ans)


Measured memory_bytes: 3060
//in the name of allah
#include<iostream>
#include<string>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    string s;cin >> s;
    int cnt=0 , ans=0;
    for(int i=0 ; i<s.size() ; i++)
        if(s[i] == 'S')
            cnt ++;
        else{
            ans += cnt>0;
            cnt = max(cnt-1 , 0);
        }
    cout << int(s.size())-2*ans << "\n";
    return 0;
}


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

int main()
{
    string W, w, T = "";
    cin >> W;
    for (int i = 0; i < W.size(); i++)
    {
        w += tolower(W[i]);
    }
    int ans = 0;
    while (T != "END_OF_TEXT")
    {
        cin >> T;
        string t;
        for (int i = 0; i < T.size(); i++)
        {
            t += tolower(T[i]);
        }
        if (w == t)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3172
import java.util.Scanner;

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

		int w = sc.nextInt();
		int h = sc.nextInt();

		int[] ary = new int[w];
		for (int i = 0; i < w; i++)
		{
			ary[i] = i + 1;
		}

		for (int i = 0; i < h; i++)
		{
			String ab = sc.next();
			int a = Integer.parseInt(ab.split(",")[0]) - 1;
			int b = Integer.parseInt(ab.split(",")[1]) - 1;

			int temp = ary[a];
			ary[a] = ary[b];
			ary[b] = temp;
		}

		for (int a :
				ary)
		{
			System.out.println(a);
		}
	}
}



Measured memory_bytes: 26044
import sys
class Node:
    def __init__(self, data):
        self.data = data
        self.left = self.right = None

rt = None


def inorder(node):
    return inorder(node.left) + f' {node.data}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.data}' + preorder(node.left) + preorder(node.right) if node else ''



def insert(data):
    global rt
    x, y = rt, None
    while x: x, y = x.left if data < x.data else x.right, x
    if y is None: rt = Node(data)
    elif data < y.data: y.left = Node(data)
    else: y.right = Node(data)

n = int(input())
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    else: print(inorder(rt)); print(preorder(rt))



Measured memory_bytes: 115104
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int l; cin >> l;
  double len = l / 3.0;
  cout << len * len * len << '\n';
  return 0;
}


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

int main() {
  long long num;
  long long index = 0;
  long long tmp;
  long long cnt = 0;
  
  cin >> num;
  
  vector<long long> vec(num);
  for(int i = 0; i < num; i++){
    cin >> vec.at(i);
  }
  
  while(index < num){
    if(index == num-1){
      cnt++;
      break;
    }
    
    if(vec.at(index) == vec.at(index+1)){
      index++;
      continue;
    }
    
    if(vec.at(index) > vec.at(index+1)){
      while(index < num-1){
        if(vec.at(index) < vec.at(index+1)){
          break;
        }
        index++;
      }
    }else if(vec.at(index) < vec.at(index+1)){
      while(index < num-1){
        if(vec.at(index) > vec.at(index+1)){
          break;
        }
        index++;
      }
    }
    
    index++;
    cnt++;
  }
  
  cout << cnt;
}


Measured memory_bytes: 1024
#include<stdio.h>
main()
{
  int H=1,W=1,i,j,h,w;
  char com[102][102];
 
  while(scanf("%d %d",&H,&W)!=EOF && H!=0 &&W!=0){
  
    h=w=0;
    for(i=0;i<H;i++){
    
      scanf("%s",com[i]);
  
    }
  
    while(com[h][w]!='.' && com[h][w]!='!'){
      if(com[h][w]=='>'){
	com[h][w]='!';
	w++;
      }
      if(com[h][w]=='v'){
	com[h][w]='!';
	h++;
      }
      if(com[h][w]=='<'){
	com[h][w]='!';
	w--;
      }
      if(com[h][w]=='^'){
	com[h][w]='!';
	h--;
      }
    }
    if(com[h][w]=='!'){
      puts("LOOP");
    }else{
      printf("%d %d\n",w,h);
    }
  

  }
  return 0;
}

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

int main(){
  int n;
  int m=100000;
  cin>>n;
  for(int i=0;i<n;i++){
    m *=1.05;
    if(m%1000>0) m = (m/1000+1)*1000;
  }
  cout<<m<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define Max(a,b) ((a) < (b) ? (b) : (a))
#define Min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

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


int main() {
	int i, j, k;
	
	int N, M, K;
	string S;
	cin >> K >> S;

	if (S.size() <= K) {
		cout << S << endl;

	}
	else {
		rep(i, 0, K) {
			cout << S[i];
		}
		cout << "...";
	}


	return 0;

}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

const li mod = 1e9 + 7;

int main() {
    li n;
    cin >> n;
    vector<li> xs(n);
    for (int i = 0; i < n; ++i) {
        cin >> xs[i];
    }

    vector<li> operations;
    for (int i = 0; i < n; ++i) {
        int index = -1;
        for (int j = xs.size() - 1; j >= 0; --j) {
            if (xs[j] == j + 1) {
                index = j;
                break;
            }
        }
        if (index == -1) {
            cout << -1 << endl;
            return 0;
        }
        operations.push_back(index + 1);
        vector<li> newxs;
        for (int j = 0; j < xs.size(); ++j) {
            if (j != index) {
                newxs.push_back(xs[j]);
            }
        }
        xs = newxs;
    }

    reverse(operations.begin(), operations.end());
    for (int i = 0; i < n; ++i) {
        cout << operations[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

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

  if((H == 1) || (W == 1)){
    cout << 1 << endl;
  } else{
    cout << (H * W / 2) + ((H * W) % 2) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int t[4], n[4], i, co;

  for(i = 0; i < 4; i++){
    scanf("%d%d", &t[i], &n[i]);
  }

  for(i = 0; i < 4; i++){
    if(t[i] == 1) co = 6000;
    if(t[i] == 2) co = 4000;
    if(t[i] == 3) co = 3000;
    if(t[i] == 4) co = 2000;
    printf("%d\n", n[i] * co);
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>

using namespace std;

int main(){
    int A,B,C,K;
    bool flag=false;
    cin>>A>>B>>C>>K;
        for(int i=0;i<=K;++i){
            for(int j=0;j<=K;++j){
                for(int l=0;l<=K;++l){
                    int x=A*(1<<i),y=B*(1<<j),z=C*(1<<l);
                        if(x<y&&y<z&&i+j+l<=K)flag=true;
                }
            
            }
        }

            if(flag==true)cout<<"Yes";
            else cout<<"No";
}

Measured memory_bytes: 3136
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
// vector : vector <int> vector;
// array : int array[size];
// set : set<int>set;
// map : map<init , int> map;

using namespace std;

int main()
{
    char a;
    cin >> a;
    if (isupper(a))
    {
        cout << 'A' << endl;
    }
    else
    {
        cout << 'a' << endl;
    }
    return 0;
}


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

int H, W;

void f(auto &A, auto q, int &n, int &ans) {
  if(n == H*W) return;
  queue<pair<int,int>> next;
  while(!q.empty()) {
    int i=q.front().first, j=q.front().second;
    q.pop();
    if(i>0 && !A[i-1][j]) {
      A[i-1][j] = true;
      next.push(make_pair(i-1, j));
      n++;
    }
    if(j>0 && !A[i][j-1]) {
      A[i][j-1] = true;
      next.push(make_pair(i, j-1));
      n++;
    }
    if(i<H-1 && !A[i+1][j]) {
      A[i+1][j] = true;
      next.push(make_pair(i+1, j));
      n++;
    }
    if(j<W-1 && !A[i][j+1]) {
      A[i][j+1] = true;
      next.push(make_pair(i, j+1));
      n++;
    }
  }
  ans++;
  
  f(A, next, n, ans);
}

signed main() {
  cin >> H >> W;
  vector<vector<bool>> A(H, vector<bool>(W));
  queue<pair<int,int>> q;
  int n=0, ans=0;
  rep(i, H) rep(j, W) {
    char k; cin >> k;
    A[i][j] = (k == '#' ? true : false);
    if(A[i][j]) {
      n++;
      q.push(make_pair(i, j));
    }
  }
  
  f(A, q, n, ans);

  cout << ans << endl;
}

Measured memory_bytes: 33204
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<stdio.h>

using namespace std;


bool unablem(int x){
    return (x == 0) || (x >= 13);
}

int main(){
    string s;
    cin >> s;
    string s1 = s.substr(0, 2);
    string s2 = s.substr(2);
    int a = stoi(s1);
    int b = stoi(s2);
    string ans;
    if (unablem(a) && unablem(b))
        ans = "NA";
    else if (unablem(a))
        ans = "YYMM";
    else if (unablem(b))
        ans = "MMYY";
    else
        ans = "AMBIGUOUS";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	string S, T;
	cin >> S >> T;
	rep(i, 26) {
		string s;
		s = S;
		char c = 'a' + i;
		s.push_back(c);
		if (s == T) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 3600