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

using namespace std;

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

typedef long long ll;

char num[maxn][maxn];

ll dp[maxn][maxn];

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

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			cin >> num[i][j];
	
	dp[1][1] = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (num[i][j] == '#') continue;

			dp[i][j] = (dp[i][j]+dp[i-1][j])%mod;
			dp[i][j] = (dp[i][j]+dp[i][j-1])%mod;
		}
	}

	cout << dp[n][m] << "\n";
}

Measured memory_bytes: 9216
#include<iostream>
#include<vector>
using namespace std;
string s;
long K;
main()
{
	cin>>s>>K;
	vector<pair<char,int> >A;
	A.push_back(make_pair(s[0],1));
	for(int i=1;i<s.size();i++)
	{
		if(A.back().first==s[i])A.back().second+=1;
		else A.push_back(make_pair(s[i],1));
	}
	if(A.size()==1)
	{
		long T=K*A[0].second;
		cout<<T/2<<endl;
		return 0;
	}
	long ans=0,T=0;
	ans+=A[0].second/2;
	for(int i=1;i+1<A.size();i++)T+=A[i].second/2;
	ans+=T*K;
	ans+=A.back().second/2;
	if(A[0].first==A.back().first)
	{
		ans+=(K-1)*((A[0].second+A.back().second)/2);
	}
	else
	{
		ans+=(K-1)*(A[0].second/2+A.back().second/2);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 764
N, M, C = map(int,input().split())
B = list(map(int,input().split()))
A_list = [list(map(int,input().split())) for _ in range(N)]

correct = 0
for A in A_list:
    sum_ab = C
    for a, b in zip(A, B):
        sum_ab += a*b
    if sum_ab > 0:
        correct += 1

print(correct)

Measured memory_bytes: 62300
import java.util.Scanner;

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

        int a, b, c, d, ans = 0;
        a = scan.nextInt();
        b = scan.nextInt();
        c = scan.nextInt();
        d = scan.nextInt();

        if(a <= c){
            if(b > c){
                if(b <= d) {
                    ans = b - c;
                }else{
                    ans = d - c;
                }
            }
        }else{
            if(d > a){
                if(d <= b) {
                    ans = d - a;
                }else{
                    ans = b - a;
                }
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23636
#include<iostream>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    int c=0;
    for(int i = 0;i<a.size();i++){
        if(a[i]!=b[i]){
            c++;
        }
    }
    cout << c <<endl;
    return 0;
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
bool f(const string &s, int i, int j) {
    if (i >= j) return true;
    if (s[i - 1] != s[j - 1]) return false;
    return f(s, i + 1, j - 1);
}
int main() {
    string S; cin >> S;
    int N = S.size();
    bool b = (f(S, 1, N) && f(S, 1, (N - 1) / 2) && f(S, (N + 3) / 2, N));
    cout << (b ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, a, b, cnt=0, fcnt=0;
  string s;
  cin >> n >> a >> b;
  cin >> s;
  for(int i=0;i<n;i++){
    if(s[i] == 'a'){
      if(cnt < a+b){
        cout << "Yes" << endl;
        cnt++;
      }else cout << "No" << endl;
    }else if(s[i] == 'b'){
      if(cnt < a+b && fcnt < b){
        cout << "Yes" << endl;
        cnt++;fcnt++;
      }else cout << "No" << endl;      
    }else cout << "No" << endl;
  }
}

Measured memory_bytes: 896
#include <iostream>
#include <string>

using namespace std;

int main(){
    string S;
    cin >> S;
    int year = stoi(S.substr(0, 4));
    int month = stoi(S.substr(5, 2));
    int day = stoi(S.substr(8, 2));
    if(year >= 2020 || (year == 2019 && month >= 5)){
        cout << "TBD" << endl;
    }else{
        cout << "Heisei" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
li = list(map(int,input().split()))
num = li[0]
num_max = li[1]
sub = li[2]
numbers = list(map(int,input().split()))
total = 0
for i in range(num):
	num_list = list(map(int,input().split()))
	cnt = 0
	for j in range(num_max):
		cnt += num_list[j] * numbers[j]
	if cnt + sub > 0:
		total += 1
	else:
		continue
print(total)

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans  = 0;
  for(int i = 1; i <= n-1; i++){
    set<char> a;
    string x = s.substr(0,i);
    string y = s.substr(i,n-1);
    rep(j,x.size())rep(k,y.size())if(x.at(j) == y.at(k)) a.insert(x.at(j));
    ans = max((int)a.size(),ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<pii>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
void chmax(int &x,int y){if(x < y) x = y;}
void chmin(int &x,int y){if(x > y) x = y;}
int n,c[200005],cnt,in[200005],out[200005];ll ans[200005];
vector<int> v[200005];
set<pii> s[200005];
void dfs1(int x,int fa){
    in[x] = ++cnt;
    rap(i,0,v[x].size()){
        int to = v[x][i];
        if(to == fa) continue;
        dfs1(to,x);
    }
    out[x] = cnt;
}
void dfs(int x,int fa){
    rap(i,0,v[x].size()){
        int to = v[x][i];
        if(to == fa) continue;
        dfs(to,x);
        int cur = out[to] - in[to] + 1;
        sit l = s[c[x]].lower_bound(mpr(in[to],0)), r = s[c[x]].lower_bound(mpr(out[to]+1,0));
        vector<pii> del;
        for(;l != r;l++) {
            cur -= l -> se;
            del.pb(*l);
        }
        ans[c[x]] -= (ll)cur * (cur + 1) / 2;
        while(del.size()){s[c[x]].erase(del.back());del.pop_back();}
    }
    s[c[x]].insert(mpr(in[x],out[x] - in[x] + 1));
}
int main()
{
    scanf("%d",&n);
    rep(i,1,n) scanf("%d",c+i);
    rap(i,1,n){
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        v[t1].pb(t2);
        v[t2].pb(t1);
    }
    dfs1(1,0);
    rep(i,1,n) ans[i] = (ll)n * (n + 1) / 2;
    dfs(1,0);
    rep(i,1,n) if(c[1] != i){
        int cur = n;
        for(sit it = s[i].begin();it != s[i].end();it++) cur -= it -> se;
        ans[i] -= (ll)cur * (cur + 1) / 2;
    }
    rep(i,1,n) printf("%lld\n",ans[i]);
    return 0;
}

Measured memory_bytes: 68128
dp = [1]*(10**5+1) #エラトステネスの篩
dp[0],dp[1] = 0, 0
for i in range(2, 10**5+1):
    if dp[i] == 0:
        continue
    j = i
    while j + i <= 10**5:
        j += i
        if dp[j] == 1:
            dp[j] = 0

ni = [0]*(10**5+1) #2012_like check
for i in range(2, 10**5+1):
    if dp[i] == 1 and dp[(i+1)//2] == 1:
        ni[i] = 1

ru = [0]*(10**5+1)
for i in range(1, 10**5+1):
    ru[i] = ru[i-1] + ni[i]

q = int(input())
for i in range(q):
    l, r = map(int,input().split())
    print(ru[r] - ru[l-1])

Measured memory_bytes: 13516
#include <stdio.h>
int main()
{
  int i,n,j; 
  int flag,temp;
  int cnt=0;

  scanf("%d",&n);

  int a[n];  

  for(i=0;i<n;i++){

    scanf("%d",&a[i]);
    
  }

  flag=1;
  i=0;

  while(flag==1){

    flag=0;

    for(j=n-1;j>=i+1;j--){

      if(a[j]<a[j-1]){

	temp=a[j-1];
	a[j-1]=a[j];
	a[j]=temp;

	flag=1;

	cnt++;

      }

    }

    i++;

  }

  for(i=0;i<n-1;i++){

    printf("%d ",a[i]);

  }

  printf("%d",a[i]);

  printf("\n%d", cnt);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2104
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	k, x := getInt(), getInt()

	for i := max(-1000000, x-k+1); i <= min(1000000, x+k-1); i++ {
		fmt.Println(i)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
#include <iostream>
using namespace std ;
int main () {
	int i = 1, x ;
	cin >> x ;
    while ( x != 0 ) {
    	cout << "Case" << " " << i << ":" << " " << x << endl ; 
    	i = i+1 ;
		cin >> x ;
	}
    return 0;
}


Measured memory_bytes: 2992
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
using namespace std;
 
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;
 
template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
    while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}
 
template <typename T>
void print(T x) {
    if (x < 0) putchar('-'), x = -x;
    if (x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}
 
template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 105;

int f[N][N];
char c[N][N];
int n, m;

int main() {
    memset(f, 0x7f, sizeof(f));
    read(n); read(m);
    for (int i = 1; i <= n; i++) scanf("%s", c[i] + 1);
    f[1][1] = (c[1][1] == '#');
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (i != n) f[i + 1][j] = min(f[i + 1][j], f[i][j] + (c[i][j] != c[i + 1][j] && c[i + 1][j] == '#'));
            if (j != m) f[i][j + 1] = min(f[i][j + 1], f[i][j] + (c[i][j] != c[i][j + 1] && c[i][j + 1] == '#'));
        }
    }
    print(f[n][m], '\n');
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n - 1];
    int ans[n] = {};

    for(int i = 0; i < n - 1; i++) {
        cin >> a[i];
        a[i]--;
        ans[a[i]]++;
    }

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




    
    return 0;
}

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

using namespace std;

typedef pair<int, int> P;

int question(int u, int v){
    cout << "? " << u << " " << v << endl;
    int res;
    cin >> res;
    return res;
}

int main(){
    int n, s, t, d, g[2][305];
    cin >> n >> s >> t;

    d = question(s, t);
    for(int i=1;i<=n;i++){
        g[0][i] = question(s, i);
    }
    for(int i=1;i<=n;i++){
        g[1][i] = question(t, i);
    }
    vector<P> ls;
    for(int i=1;i<=n;i++){
        if(g[0][i]+g[1][i] == d)ls.push_back({g[0][i], i});
    }
    sort(ls.begin(), ls.end());
    int now = s;
    vector<int> ans;
    ans.push_back(s);
    for(int i=1;i<int(ls.size());i++){
        int to = ls[i].second;
        int tmp = question(now, to);
        if(g[0][to]-g[0][now] == tmp){
            ans.push_back(to);
            now = to;
        }
    }
    cout << "!";
    for(auto x : ans){
        cout << " " << x;
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 4648
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  string a;
  cin >> a;
  if(a=="ABC"){cout << "ARC" << endl; return 0;}
  else  cout << "ABC" <<endl;
  return 0;
}

Measured memory_bytes: 3628
def resolve():
    n, m = map(int, input().split())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))
    x0 = x[0]
    y0 = y[0]
    x = list(map(lambda i:i-x0, x))
    y = list(map(lambda i:i-y0, y))
    sumx = sum(x)
    totalx = sumx
    for i in range(1,n):
        sumx -= (x[i]-x[i-1])*(n-i)
        totalx += sumx
        totalx %= ((10**9)+7)
    sumy = sum(y)
    totaly = sumy
    for i in range(1,m):
        sumy -= (y[i]-y[i-1])*(m-i)
        totaly += sumy
        totaly %= ((10**9)+7)
    print((totalx*totaly)%((10**9)+7))
resolve()

Measured memory_bytes: 87396
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef pair<int, pii> pip;
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
 



int main(){
	int n, ans = 0;
	string s, t;
	bool f;
	cin>>n>>s;
	for(int i = 0; i < n; i++){
		cin>>t;
		f = true;
		for(int j = 0; j < t.size() && f; j++){//jmojimewokitennisuru
			for(int k = 0; k < t.size() && f; k++){//kannkakuwokimeru
				for(int l = 0; l < s.size() && f; l++){
					if(j + k * l >= t.size() || t[j + k * l] != s[l]) break;
					if(l == s.size() -1) {
						ans++;
						f = false;
					}
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define ti tuple<int, int, int>

int main() {

    ll H, W;
    cin >> H >> W;

    string M[22];
    for (int i = 0; i < H; i++) {
        cin >> M[i];
    }

    int max_d = 0;
    int x, y;
    for (int sx = 0; sx < W; sx++) {
        for (int sy = 0; sy < H; sy++) {
            queue<ti> q;
            q.push(make_tuple(sx, sy, 0));
            int checked[22][22] = {0};
            checked[sx][sy] = 1;
            if (M[sy][sx] == '#') continue;
            while (!q.empty()) {
                ti t = q.front();
                q.pop();
                for (pair<int, int> p: {make_pair(get<0>(t)-1, get<1>(t)), make_pair(get<0>(t)+1, get<1>(t)), make_pair(get<0>(t), get<1>(t)-1), make_pair(get<0>(t), get<1>(t)+1)}) {
                    x = p.first;
                    y = p.second;
                    if (x >= 0 && x < W && y >= 0 && y < H) {
                        if (M[y][x] == '.' && checked[x][y] == 0) {
                            checked[x][y] = 1;
                            q.push(make_tuple(x, y, get<2>(t)+1));
                            max_d = max(get<2>(t)+1, max_d);
                        }
                    }
                }
            }
        }
    }

    cout << max_d << endl;

    return 0;
}


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

is_odd = False
for c in range(1, 4, 1):
    # print(a, b, c)
    sum = a * b * c
    if sum % 2 == 1:
        is_odd = True

if is_odd:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
cho_n = 0
hishi_n = 0
while str = gets do
    a, b, c = str.chomp.split(",").map(&:to_i)
    if a == b
        hishi_n += 1
    end
    if a * a + b * b == c * c
        cho_n += 1
    end
end
puts cho_n
puts hishi_n

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

using namespace std;

int main(int argc, char *argv[])
{
	int n;
	string s, t, r;
	cin >> n >> s >> t;
	for (int i = 0; i < n; i++)
		r += s[i], r += t[i];
	cout << r << endl;

	return 0;
}


Measured memory_bytes: 256
//In The Name Of Allah// 
#include <bits/stdc++.h>
using namespace std;
const long long int mod=1e9+7;
const int maxn=505*1001;
const int Base=199;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define Right(x) (x*2+1)
#define Left(x) (2*x)
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;


int mark[maxn];
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n, m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		cin>>u>>v;
		mark[u]++;
		mark[v]++;
	}
	for(int i=1;i<=n;i++)
		if(mark[i]%2==1)
			return cout<<"NO",0;
	cout<<"YES";
	return 0;
}

//I will succeed,
//Maybe not immediately,
//BUT DEFIANTLY.

Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h> 
#include <string.h>
#include <bitset>
using namespace std;

const int m = 8000000;

int ChangeToNumber(char str[]){
    int key = 0;
    int size = 0;
    for(int i=0; str[i]!='\0'; i++){
        key *= 4;
        size++;

        // if文よりswitch文を使ったほうが見やすい。
        switch(str[i]){
            case 'A':
                key += 0;
                break;
            case 'C':
                key += 1;
                break;
            case 'G':
                key += 2;
                break;
            case 'T':
                key += 3;
                break;
        }
    }
    key += size << 24;
    return key;
}

/*
void Insert(bitset<268435456> T[], int key){
    T[key] = true; 
    return;
}

void Search(bitset<268435456> T[], int key){
    if(T[key]) printf("yes\n");
    else printf("no\n");
    return;
}
*/

bitset<268435456> T;
//static bool T[268435456] = { 0 };
// 4文字のアルファベット(A, C, G, T)
// 文字列の最大の長さは12文字
int main(void){
    // メモ：cのバージョンの話。(今回は使ってない)
    // mallocは初期化されないメモリが渡される。
    // memsetで初期化をすること
    int n;
    scanf("%d", &n);

    char order[7];
    char str[13];
    int key;
    for(int i=0; i<n; i++){
        scanf("%s%s", order, str);

        key = ChangeToNumber(str);
//        printf("%s %d\n", str, key);
        if(order[0]=='i') {
          T[key] = true;
        }
        else {
          if (T[key])
            printf("yes\n");
          else
            printf("no\n");
        }
    }

    return 0;
}



Measured memory_bytes: 35388
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#include <bitset>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    map<int,int> cnt;
    int i;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        cnt[tmp]++;
    }

    vector<int> a;
    auto it=cnt.begin();
    for(; it!=cnt.end(); ++it) {
        a.push_back(it->second);
    }
    sort(a.rbegin(), a.rend());

    int siz=(int)a.size();
    vector<int> sa(siz+1);
    sa[0]=n;
    for(i=0; i<siz; i++) {
        sa[i+1]=sa[i]-a[i];
    }

    vector<int> ans(siz+1,INF);

    for(i=0; i<siz; i++) {
        int sq = (int)sqrt((double)sa[i]);
        int j;
        for(j=1; j<=sq; j++) {
        //for(j=1; j<=siz-i; j++) {
            int tmp=sa[i]/j;
            if(i+j<=siz) ans[i+j]=MIN(ans[i+j],tmp);
        }

        for(j=1; j<=sq; j++) {
            int tmp = sa[i]/(j+1);
            if(i+(tmp+1)<=siz) ans[i+(tmp+1)]=MIN(ans[i+(tmp+1)],j);
        }
    }

    for(i=1; i<=siz; i++) {
        ans[i]=MIN(ans[i-1],ans[i]);
    }

    for(i=1; i<=n; i++) {
        if(i>siz) {
            printf("0\n");
        }
        else {
            printf("%d\n", ans[i]);
        }
    }

    return 0;
}


Measured memory_bytes: 17904
n,y = gets.strip.split.map(&:to_i)
y /=1000

(0..n).each do |i|
    (0..n-i).each do |j|
        k = n-i-j
        if  10*i + 5*j + k == y
            puts "#{i} #{j} #{k}"
            exit
        end
    end
end
puts '-1 -1 -1'

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

l = inputSL()

print(l[0][0].upper()+l[1][0].upper()+l[2][0].upper())

Measured memory_bytes: 63980
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <bitset>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;



//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int i = 1; i < N; i++) cout << ", " << v[i]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()


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

	lint L[87] = {};

	L[0] = 2; L[1] = 1;
	for (int i = 2; i <= 86; i++) L[i] = L[i - 1] + L[i - 2];

	cout << L[N] << endl;

	return 0;
}

int main()
{
	//clock_t start, end;
	//start = clock();

	ProblemB();
	
	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
  string S;
  cin >> S;

  int N = S.length();
  rep(i,(N-1)/2-1) {
    if (S[i] != S[(N-1)/2-1-i]) {
      cout<< "No" << endl;
      return 0;
    }
  }
  for(int i = (N+3)/2; i<N; i++) {
    if (S[i] != S[N-1-i]) {
      cout<< "No" << endl;
      return 0;
    }
  }
  cout<< "Yes" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<algorithm> 

using namespace std;

int main()
{
    int n;

    cin>>n;
    int dp[n][3];
    int a,b,c;
    cin>>a>>b>>c;
    
    dp[0][0]=a;
    dp[0][1]=b;
    dp[0][2]=c;
    

    for(int i=1;i<n;i++){
        cin>>a>>b>>c;

        dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
        


    }

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

}


Measured memory_bytes: 4316
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int d,t,s;
	cin>>d>>t>>s;
	
	int k= d/s;
      	if( d%s!=0) k++;
	
	if( k>t) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define print(x) cout << x << endl

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

ll MOD = 1000000007;


int main()
{
    ll N;
    cin >> N;
    vector<vector<ll>> mat(10, vector<ll>(10, 0));
    rep(i, N)
    {
        string tmp = to_string(i + 1);
        ll s = tmp[0] - '0';
        ll e = tmp.back() - '0';
        mat[s][e]++;
    }
    ll sum = 0;
    rep(i, 10) {
        rep(j, 10) {
            sum += mat[i][j] * mat[j][i];
        }
        cout << endl;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <list>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);

typedef vector<ll> vl;

int main() {
	ll n;

	while(cin >> n, n) {
		vector<vl> table(n, vl(31));
		vvi date(n, vi(31));

		int f, d;
		REP(i, n) {
			cin >> f;
			REP(j, f) {
				cin >> d;
				date[i][d] = 1;
			}
		}

		REP(i, n) {
			table[i][0] = ((ll)1<<i);
		}

		const ll comp = ((ll)1<<n)-1;
		int ans = -1;

		FOR(d, 1, 30) {
			ll now = 0;
			REP(m, n) {
				if(date[m][d]) {
					now |= table[m][d-1];
				}
			}

			if(now == comp) {
				ans = d;
				break;
			}

			REP(m, n) {
				if(date[m][d]) {
					table[m][d] = now;
				} else {
					table[m][d] = table[m][d-1];
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for (int i=0; i < int(n); i++)


// 素集合データ構造
struct UnionFind
{
  vector<int> par;
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }

  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return sizes[find(x)];
  }
};


int main(){
  long long n,m;cin>>n>>m;
  vector<long long> a(m);
  vector<long long> b(m);
  for(int i=0;i<m;i++){
    cin>>a[i]>>b[i];a[i]--,b[i]--;
  }
  UnionFind uf(n);
  for(int i=0;i<m;i++){
    int A=a[i],B=b[i];
    if(uf.same(A,B))continue;
    uf.unite(A,B);
  }
  long long max=0;
  for(int i=0;i<n;i++){
    //cout<<uf.size(i)<<endl;
    if(max<uf.size(i)){
      max=uf.size(i);
    }
  }
  cout<<max<<endl;
}

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

const int ALPHABET = 26;
int main() {
	int64_t pat;
	int alpha[ALPHABET];
	string s;
	cin >> s;
	pat = (int64_t)s.length() * (s.length() - 1) / 2 + 1;
	for (int i = 0;i < ALPHABET;i ++) {
		alpha[i] = 0;
	}
	for (int i = 0;i < s.length();i ++) {
		alpha[s[i] - 'a'] ++;
	}
	for (int i = 0;i < ALPHABET;i ++) {
		pat -= (int64_t)alpha[i] * (alpha[i] - 1) / 2;
	}
	cout << pat;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n; cin >> n;
    vector<map<char, int>> s(n);
    rep(i, n) {
        string t; cin >> t;
        map<char, int> m;
        rfor(c, t) {
            m[c] ++;
        }
        s[i] = m;
    }
    map<char, int> ans;
    for(char c = 'a'; c <= 'z'; ++c) {
        int min = INT_MAX;
        rfor(m, s) {
            chmin(min, m[c]);
        }
        ans[c] = min;
    }
    rfor(p, ans) {
        if(p.second != 0) {
            rep(i, p.second) cout << p.first;
        }
    }
    cout << endl;


    return 0;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string S;
  cin >> S;
  ll year = stoi(S.substr(0, 4));
  ll month = stoi(S.substr(5, 2));
  ll date = stoi(S.substr(8, 2));
  string ans="TBD";
  if(year<=2018){
    ans = "Heisei";
  }else if(year==2019 and month<=4){
    ans = "Heisei";
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int>vec(N);
    for(int i=0;i<N;i++){
        cin >> vec.at(i);
    }
    if(N%2==1||N==0){
        cout << 0 <<endl;
    }
    else{
        sort(vec.begin(),vec.end());
        if(vec.at(N/2-1)==vec.at(N/2)){
            cout << 0 << endl;
        }
        else{
            cout <<vec.at(N/2)-vec.at(N/2-1)<<endl;
        }

    }
}

Measured memory_bytes: 3764
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=1000000, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }


int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int co[n+1],ad[n+1];
    fill(co, 0);
    fill(ad, 0);
    int ar[n];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        ad[ar[i]]+=co[ar[i]];
        co[ar[i]]++;
    }
    int s=0;
    for(int i=0;i<=n;i++)
    s+=ad[i];
    for(int i=0;i<n;i++)
    cout<<s-co[ar[i]]+1<<"\n";
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e5)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m;
    cin >> n >> m;
    vi c(m);
    rep(i, m) cin >> c[i];
    vi dp(n+1, INF);
    dp[0] = 0;
    rep1(i, n) {
        rep(j, sz(c)) {
            if (c[j] > i) continue;
            dp[i] = min(dp[i], dp[i-c[j]]+1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}



Measured memory_bytes: 3168
import sys
h,w = map(int, sys.stdin.readline().split())
s = list(input() for _ in range(h))

dx_list = [-1, 0, 1]
dy_list = [-1, 0, 1]

for i in range(h):
    for j in range(w):
        count = 0
        if s[i][j] == "#":
            print("#", end="")
            continue
        for dx in dx_list:
            for dy in dy_list:
                x = i + dx
                y = j + dy
                if 0 <= x < h and 0 <= y < w and s[x][y] == "#":
                    count += 1
        print(count, end="")
    print()

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

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

void dispCurState(int n, int a[]){
    for(int i = 0; i < n; i++){
        if(i) cout << " ";
        cout << a[i];
    }
    cout << endl;
}

int main(void){
    int n, a[100], cur, j;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    dispCurState(n, a);

    for(int i = 1; i < n; i++){
        cur = a[i];
        j = i - 1;
        while(j >= 0 && a[j] > cur){
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = cur;
        dispCurState(n, a);
    }
    return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
struct data
{
    int a;
    int b;
    int c;
    int d;
};
data mark[110000];
priority_queue<pair<int,int >  > PQ;

int main()
{
    double d1,d2,d3;
    int n,a,b,c,d,m,t;
   scanf("%d",&n);
   scanf("%d",&t);
   scanf("%d",&m);
   d2=m;
   double  mn=10000000.00;
   int idx=-1;
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a);
        d1=a;
        d1=d1*0.006;
        d1=(t-d1);
        d1=fabs(d1-d2);
        if(d1<mn)
        {
           mn=d1;
           idx=i+1;
        }
    }
        cout<<idx<<endl;

}


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

int main (void)
{
  char str[500],ans[500];
  int m,i,j,k,l,len;
  int h[100];

  for(;;){
    scanf("%s", str);
    if(strcmp(str,"-")==0) break;
    scanf("%d", &m);
    len=strlen(str);

    for(i=0;i<m;i++){
      scanf("%d", &h[i]);
      strncat(str,str,h[i]);
      for(j=0;j<len;j++){
	str[j]=str[j+h[i]];
      }
      strncpy(ans,str,len);
      strcpy(str,ans);
    }
    printf("%s\n", ans);
    
    for(l=0;l<201;l++){
      ans[l]='\0';
    }
  }

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
const double PI = acos(-1.);
const int MOD = 1000 * 1000 * 1000 + 7;

ll get(int r, vector<ll> &bit) {
    ll res = 0;
    for (; r > -1; r = r & -r) {
        res += bit[r];
    }
    return res;
}

void upd(int i, vector<ll> &bit, int delta) {
    for (; i < bit.size(); i = i & -i) {
        bit[i] += delta;
    }
    return;
}

int main() {
    //ios_base::sync_with_stdio(0);
    int N;
    ll ans = 1;
    cin >> N;
    ll x;
    stack<ll> st;
    for (int i = 1; i <= N; ++i) {
        cin >> x;
        st.push(x);
        if (x < st.size() * 2 - 1) {
            ans *= (ll) st.size();
            ans %= MOD;
            st.pop();
        }
    }
    for (ll i = 2; i <= st.size(); ++i) {
        ans *= i;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

int main()
{
    string S;
    input(S);

    cout << ((S[2] == S[3]) && (S[4] == S[5]) ? "Yes" : "No") << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    ll n, a, dist = 100000000, mindist = 11111111100000, S;
    cin >> n;
    vector<ll>stick(n+1);
    stick[0] = 0;
    rep(i, n) {
        cin >> a;
        stick[i+1] = stick[i]+ a;
    }
    S = stick[n];
    stick.erase(stick.begin());

    rep(i, n-1) {
        mindist = min(mindist, abs(stick[i] - (S - stick[i])));
    }
    cout << mindist << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define MM(arr,x) memset(arr,x,sizeof(x))
const int Mod = 1e9 + 7;
using namespace std;
ll Pow(int x,int n)
{
	ll ans = 1;
	for(int i=0;i<n;i++)
	{
		ans *= x;
		ans %= Mod;
	}
	return ans;
}
int main()
{
	ll n,res=0;
	cin >> n;
	res = (Pow(10,n)-Pow(9,n)*2+Pow(8,n))%Mod;
	if(res<0) res+=Mod;
	cout<<res;
	return 0;
} 

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

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    if (b == 1) {
        printf("0");
        return 0;
    }
    if (a > b) {
        printf("1");
        return 0;
    }
    int c = b - a;
    int d;
    if (c % (a - 1) == 0) {
        d = c / (a - 1);
    } else {
        d = c / (a - 1) + 1;
    }
    printf("%d", d + 1);
    return 0;
}

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

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

int c[15], a[15][15];
int main(void)
{
  int n, m, x;
  cin >> n >> m >> x;
  rep(i, n) {
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }
  int ans = -1;
  int itr[12];
  int k[12];
  rep(i, 12) k[i] = i < n ? 2 : 1;
  for(itr[0] = 0; itr[0] < k[0]; itr[0] ++) {
    for(itr[1] = 0; itr[1] < k[1]; itr[1] ++) {
      for(itr[2] = 0; itr[2] < k[2]; itr[2] ++) {
	for(itr[3] = 0; itr[3] < k[3]; itr[3] ++) {
	  for(itr[4] = 0; itr[4] < k[4]; itr[4] ++) {
	    for(itr[5] = 0; itr[5] < k[5]; itr[5] ++) {
	      for(itr[6] = 0; itr[6] < k[6]; itr[6] ++) {
		for(itr[7] = 0; itr[7] < k[7]; itr[7] ++) {
		  for(itr[8] = 0; itr[8] < k[8]; itr[8] ++) {
		    for(itr[9] = 0; itr[9] < k[9]; itr[9] ++) {
		      for(itr[10] = 0; itr[10] < k[10]; itr[10] ++) {
			for(itr[11] = 0; itr[11] < k[11]; itr[11] ++) {
			  int p = 0;
			  int s[15];
			  rep(j, m) s[j] = 0;
			  for(int i = 0; i < n; i++) {
			    if(itr[i] == 1) {
			      rep(k, m) {
				s[k] += a[i][k];
			      }
			      p += c[i];
			    }
			  }
			  bool ok = true;
			  rep(i, m) {
			    if(s[i] < x) ok = false;
			  }
			  if(ok && (ans < 0 || ans > p)) ans  = p;
			} // itr[11]
		      } // itr[10]
		    } // itr[9]
		  } // itr[8]
		} // itr[7]
	      } // itr[6]
	    } // itr[5]
	  } // itr[4]
	} // itr[3]
      } // itr[2]
    } // itr[1]
  } // itr[0]
  cout << ans << endl;
}


Measured memory_bytes: 3596
import java.io.PrintWriter;
import java.util.Scanner;
import static java.lang.Math.*;

public class Main {

    static double[] d;
    static double[][] cost;
    static short n;
    static final double INF = Double.MAX_VALUE/4;
    static short[] x,y;

    public static void main(String[] args) {

        PrintWriter out = new PrintWriter(System.out);
        Scanner scan = new Scanner(System.in);
        while(true){
            n = scan.nextShort();
            if(n==0) break;
            x = new short[n];
            y = new short[n];
            for (int i = 0; i < n; i++) {
                short id = scan.nextShort();
                x[id-1] = scan.nextShort();
                y[id-1] = scan.nextShort();
            }
            cost = new double[n][n];
            for (int i = 0; i < n; i++) {
                for (int j = i+1; j < n; j++) {
                    cost[j][i]=cost[i][j] = sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
                    if(cost[i][j]>50) cost[j][i]= cost[i][j] = INF;
                }
            }
            short m = scan.nextShort();
            while(m-->0){
                out.println(dk(scan.nextShort()-1,scan.nextShort()-1));
            }
        }
        out.flush();
    }

    public static String dk(int s,int g){
        d = new double[n];
        for (int i = 0; i < n; i++) d[i] = INF;
        d[s] = 0;
        short[] prev = new short[n];
        prev[s] = -1;
        boolean[] used = new boolean[n];
        while(true){
            short v = -1;
            for (short i = 0; i < n; i++) {
                if(!used[i] && (v==-1 || d[i]<d[v])) v = i;
            }
            if(v==-1) break;
            used[v]=true;
            for (short i = 0; i < n ; i++) {
                if(d[i]>d[v]+cost[v][i]){
                    prev[i] = v;
                    d[i] = d[v]+cost[v][i];
                }
            }
        }

        if(d[g]==INF) return "NA";

        String ans = String.valueOf(g+1);
        int pos = prev[g];
        do{
            ans = (pos+1) + " " + ans;
            pos=prev[pos];
        }while(pos!=-1);
        return ans;
    }
}

Measured memory_bytes: 21280