akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <iostream>
using namespace std;

int main(){
	int n, j = 0;
	const string table = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	string s, ans;
	while (1){
		cin >> n;
		if (!n)break;
		int k[101];
		for (int i = 0; i<n; ++i)cin >> k[i];
		cin >> s;
		for (int i = 0; i<s.size(); ++i){
			int a = table.find(s[i]) - k[j];
			if (a<0){
				ans += table[52 + a];
				j = (j + 1) % n;
			}
			else{
				ans += table[a];
				j = (j + 1) % n;
			}
		}
		cout << ans << endl;
		j = 0;
		ans.clear();
	}
}

Measured memory_bytes: 3160
read = input 
rn = lambda :map(int, read().split())
n,m = rn()
s = [0 for i in range(n + 10000)]
for i in range(m):
    l,r = rn()
    s[l] += 1
    s[r+1] -= 1
for i in range(1, len(s) - 10):
    s[i] += s[i-1]
ans = 0
for i in range(1, len(s) - 10):
    if s[i] == m:
        ans+=1
print(ans)

Measured memory_bytes: 7184
def main():
    n, m = map(int, input().split())
    count = [0] * n
    for _ in range(m):
        a, b = map(int, input().split())
        count[a-1] += 1
        count[b-1] += 1

    print(*count, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,a) for(int i=0;i<(a);i++)
#define MOD 1000000007

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> v(N);
  for(int i=0;i<N;i++) cin>>v[i];
  sort(v.rbegin(),v.rend());
  int sum=0, ans=N;
  for(int i=0;i<N;i++){
    if(v[i]+sum<K) sum+=v[i];
    else ans=min(ans,N-(i+1));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

ll N, M;

void solve()
{
	ll i=max(M/N+10, N);
	while(M%i || (N*i > M)) i--;
	cout << i << endl;
}

int main()
{
	cin >> N >> M;
	solve();
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b) return gcd(b, a);

    int r;
    while (r=a%b) {
        a = b;
        b = r;
    }
    return b;
}

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

int main()
{
    long long A, B;
    cin >> A >> B;

    cout << lcm(A, B) << endl;
}

Measured memory_bytes: 256
# coding: utf-8


def main():
    x1, y1, x2, y2 = map(int, input().split())
    x_diff = x2 - x1
    y_diff = y2 - y1

    x3 = x2 - y_diff
    y3 = y2 + x_diff

    x4 = x1 - y_diff
    y4 = y1 + x_diff

    print('{} {} {} {}'.format(x3, y3, x4, y4))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n = int(input())
a = map(int, input().split())
ans_lst = []
for ai in a:
    if ai == 1 and len(ans_lst) == 0:
        ans_lst.append(1)
    elif len(ans_lst) > 0 and ans_lst[-1] == ai - 1:
        ans_lst.append(ai)
if len(ans_lst) == 0:
    print(-1)
else:
    print(n - len(ans_lst))

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

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

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

    z = (Node *)malloc(sizeof(Node));
    z->key = key;
    z->left = NIL;
    z->right = NIL;

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

    z->parent = y;

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

    return;
}

Node* find(int key) {
    Node *u = root;
    while (u != NIL && u->key != key) {
        if (key < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

Node* treeMinimum(Node *x) {
    while (x->left != NIL) x = x->left;
    return x;
}

Node* treeSuccessor(Node *x) {
    if (x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while (y != NIL && x == y->right) {
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z) {
    Node *target;
    Node *child;

    if (z->left == NIL || z->right == NIL) target = z;
    else target = treeSuccessor(z);
    
    if (target->left != NIL) child = target->left;
    else child = target->right;

    if (child != NIL) child->parent = target->parent;

    if (target->parent == NIL) root = child;
    else if (target == target->parent->left) target->parent->left = child;
    else target->parent->right = child;

    if (target != z) z->key = target->key;

    free(target);
}

void preorder(Node *u) {
    if (u == NIL) return;
    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
    return;
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
    return;
}

void print() {
    inorder(root);
    cout << "\n";
    preorder(root);
    cout << endl;
    return;
}

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

    string command;
    int key;
    for (int i = 0; i < m; i++) {
        cin >> command;
        if (command == "print") {
            print();
            continue;
        }
        cin >> key;
        if (command == "insert") {
            insert(key);
        } else if (command == "find") {
            if (find(key) != NIL) cout << "yes" << endl;
            else cout << "no" << endl;
        } else {
            treeDelete(find(key));
        }
    }

    return 0;
}


Measured memory_bytes: 21744
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    import copy


    n, k = map(int, input().split())

    vv = list(map(int, input().split()))
    ans = 0

    while k >= 1:
        for l in range((k+1)//2, k+1):
            for i in range(l+1):
                if i <= n-l+i:
                    get_list = vv[:i]+ vv[n-(l-i):]
                    get_list.sort(reverse=True)
                    ans = max([ans, sum(get_list[:2*l-k])])
        k -= 1

    print(ans)


Measured memory_bytes: 3444
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;

long long a, b;

int main() {
  cin >> a >> b;

  if (a * b <= 0) {
    cout << "Zero" << endl;
  }
  else if (a > 0) {
    cout << "Positive" << endl;
  }
  else if (b < 0) {
    if ((b - a) % 2 == 0) {
      cout << "Negative" << endl;
    }
    else {
      cout << "Positive" << endl;
    }
  }
}


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

int main() {
    string s; cin >> s;
    int N = s.size();
    rep2(i, 1, N) {
        if (s[i] == s[i-1]) {
            cout << i << " " << i+1;
            return 0;
        }
    }
    for (int i = 0; i+2 < N; i++) {
        if (s[i] == s[i+2]) {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
/*cout <<"Debug"
cout <<x-30<<' '<<y-30<<endl;
typedef pair<pair<int ,int>, int> P;
vector<pair<pair<int ,int>, int> > v_ans;
vector<int>v_;
vector<long int>v_ansl;
/*taro tenn,hanako_ten,sum*/
/*
bool cmp(P h, P r){
  return h.second < r.second;
}
*/
int v[101];
int main(){
  int N,M;
  int P;

  while(cin >>N>>M>>P){
    if (N == 0 && M == 0 && P == 0) break;
    int NUMP = 0;
    int ans = 0;
    for(int i = 0;i < N ; i++){
      cin >>v[i];
      NUMP += v[i];
    }
    if(v[M-1] == 0){
      ans = 0;
      cout <<ans<<endl;
    }
    else{
    cout <<100*NUMP*(100-P)/(100*v[M-1])<<endl;
  }
  }
  return 0;
}



Measured memory_bytes: 2976
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct list
{
	int key;
	struct list *prev;
	struct list *next;
} list;

list head;
list tail;
	
void Insert(int);
void Delete(int);
void DeleteFirst();
void DeleteLast();
void PrintAllList();

int main()
{
	int i;
	int n;
	int k;
	char command[13];
	
	head.next = &tail;
	tail.prev = &head;
	
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%s", command);
		
		if(strcmp(command, "insert") == 0)
		{
			scanf("%d", &k);
			Insert(k);
		}
		if(strcmp(command, "delete") == 0)
		{
			scanf("%d", &k);
			Delete(k);
		}
		if(strcmp(command, "deleteFirst") == 0)
		{
			DeleteFirst();
		}
		if(strcmp(command, "deleteLast") == 0)
		{
			DeleteLast();
		}
	}
	PrintAllList();
	
	return 0;
}

void Insert(int k)
{
	list *x;
	x = (list*)malloc(sizeof(list));
	
	x->next = head.next;
	head.next->prev = x;
	x->prev = &head;
	head.next = x;
	x->key = k;
}

void Delete(int k)
{
	list *x;
	x = head.next;
	
	while(x != &tail)
	{
		if(x->key == k)
		{
			x->prev->next = x->next;
			x->next->prev = x->prev;
			break;
		}
		x = x->next;
	}
}

void DeleteFirst()
{
	head.next->next->prev = head.next->prev;
	head.next = head.next->next;
}

void DeleteLast()
{
	tail.prev->prev->next = tail.prev->next;
	tail.prev = tail.prev->prev;
}

void PrintAllList()
{
	list *x;
	x = head.next;
	
	while(1)
	{
		printf("%d", x->key);
		if(x->next != &tail)
		{
			printf(" ");
		}
		else
		{
			printf("\n");
			break;
		}
		x = x->next;
	}
}

Measured memory_bytes: 34976
#include <iostream>

using namespace std;

int A;
int B;

int calc(int A, int B){
    int x;
    if(A >= B * 2){
        x = A - B * 2;
    } else {
        x = 0;
    }
    return x;
}

int main(){
    int x;
    cin >> A >> B;
    x = calc(A, B);
    cout << x; 

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a, b, c, i, x, judge, count;

    scanf("%d %d %d",&a, &b, &c);
    for(i = a; i <= b; i++){
        x = c/i;
        judge = c - x*i;
        if(judge == 0) count++;
    }
    printf("%d\n",count);

    return 0;
}


Measured memory_bytes: 2120
n,m = map(int,input().split())
count_list = [0] * n

list = [input() for i in range(m)]

for i in range(m):
    ary = list[i].split()
    count_list[int(ary[0])-1] += 1
    count_list[int(ary[1])-1] += 1

for i in range(n):
  print(count_list[i])

Measured memory_bytes: 9108
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int abc118_a(){
    //入力
    int a,b;
    cin >> a >> b;

    //処理

    //出力
    if(b%a==0) cout << a+b << ENT;
    else cout << b-a << ENT;
    return 0;
}

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


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

class Cmondai
{
    static void Main()
    {
        var array = new int[3,3];
        var max = int.MinValue;
        var min = int.MaxValue;
        for (int i=0;i<3;++i)
        {
            var list = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
            for (int j = 0; j < 3; ++j)
            {
                array[i, j] = list[j];
                if (max < list[j]) max = list[j];
                if (list[j] < min) min = list[j];
            }
        }
        var start = (max - min) * (-1);
        var ans = "No";
        for (int i=start;i<=max;++i)
        {
            var a1 = i;
            var b1 = array[0, 0] - a1;
            var b2 = array[0, 1] - a1;
            var b3 = array[0, 2] - a1;
            var a2 = array[1, 0] - b1;
            var a3 = array[2, 0] - b1;
            if(array[0,0]==a1+b1 && array[0,1]== a1 + b2 && array[0,2]== a1 + b3
                && array[1,0]== a2 + b1 && array[1,1]== a2 + b2 && array[1,2]== a2 + b3
                && array[2,0]== a3 + b1 && array[2,1]== a3 + b2 && array[2, 2] == a3 + b3)
            {
                ans = "Yes";
            }
                        
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define E endl
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(9)

int main()
{
    ll n,m;
    cin>>n>>m;
    string a[m+1];
    ll b[m+1];
    for(ll i=0;i<m;i++)
    cin>>b[i]>>a[i];
    
    if(m==0)
    {
    	cout<<"0 0";
    	return 0;
    }
    
    ll c[100001]={0};
    for(ll i=0;i<m;i++)
    {
    	c[b[i]]++;
    }
    ll ans1=0,ans=0,j;
    ll e[n+1]={0};
    
    for(ll i=0;i<m;i++)
    {
    	if(a[i]=="AC" )
    	{
    	  j=i;
    	  e[b[i]]=1;
    	}
    }
    for(ll i=0;i<=j;i++)
    {
    	if(a[i]=="WA" && e[b[i]]==1)
    	{
        	ans++;
    	}
    	if(a[i]=="AC")
    	e[b[i]]=0;
    }
    for(ll i=0;i<m;i++)
    {
    	if(c[b[i]]>=1 && a[i]=="AC")
    	{
    	  ans1++;
    	  c[b[i]]=0;
    	}
    }
    
    cout<<ans1<<" "<<ans;
}

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

#define MAX_N 3700000

int prime[MAX_N], twin[MAX_N];

void isprime(int c) {
	prime[2] = 1;
	for (int i = 3; i < c; i += 2) {
		for (int j = 3; j <= sqrt(i); j += 2) {
			if (i%j == 0) { 
				goto E; 
			}
		}
		prime[i] = 1;
	E:;
	}
}

void istwin(int d) {
	for (int i = 5; i < d; i++) {
		if (prime[i - 2] + prime[i] == 2) {
			twin[i] = i;
		}
		else {
			twin[i] = twin[i - 1];
		}
	}
}

int n;

int main() {
	isprime(MAX_N);
	istwin(MAX_N);
	while (true) {
		cin >> n;
		if (n == 0) {
			break;
		}
		cout << twin[n] - 2 << ' ' << twin[n] << endl;
	}
}

Measured memory_bytes: 30064
#include <stdio.h>

int main(void)
{
    int n ,m;
    int A[1000];

        scanf("%d" , &n);
    
    for ( m = 0 ; m < n ; m++) {
            scanf("%d" , &A[m]);
    }
    
    /*Buble Sort*/
    int flag = 1;
    int i = 0;
    int j ,temp ,count;
    
    do {
        flag = 0;
        for ( j = n - 1 ; j >= i + 1 ; j-- ) {
            if ( A[j - 1] > A[j] ) {
                /*swap*/
                temp = A[j - 1];
                A[j - 1] = A[j];
                A[j] = temp;
                flag = 1;
                count++;
            }
        }
        i++;
    }while ( flag == 1 );
    
    for (int s = 0 ; s < n - 1 ; s++ )
        printf("%d " , A[s]);
    printf("%d\n" , A[n - 1]);
    printf("%d\n" , count);
    
    return 0;
}



Measured memory_bytes: 2140
#include <stdio.h>
#include <string.h>
char s[200010];
int main(){
	int i,ans=0,n;
	scanf("%s",s+1);
	n=strlen(s+1);
	for(i=1;i<=n;i++)ans+=s[i]-'0';
	if(ans%9)printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1812
def cin():
	return map(int,input().split())

def cino(test=False):
    if not test:
        return int(input())
    else:
        return input()
def cina():
  return list(map(int,input().split()))

a = cino()
l = cina()
ans = 10**18
for i in range(-100,101):
    cost = 0
    for j in range(len(l)):
        cost += (i-l[j])**2
    ans = min(ans,cost)
print(ans)




Measured memory_bytes: 3060
using System;

namespace ABC054B
{
    static class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            long power = 1;
            long mod = 1000000007;
            
            for (int i = 1; i < n + 1; i++)
                power = (power * i) % mod;

            Console.WriteLine(power);
        }
    }
}

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

#define reps(i,j,k) for(int i=j;i<k;i++)
#define rep(i,j) reps(i,0,j)

using namespace std;

typedef vector<int> vi;

int main(){
	
	int n;
	while(cin >> n, n){
		vi v(n);
		rep(i, n) cin >> v[i];
		sort(v.begin(), v.end());
		int m = (1<<29);
		rep(i,n-1){
			m = min(m, v[i+1] - v[i]);
		}
		cout << m << endl;
	}

	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define loop(i, k, n) for (ll i = k; i < n; i += 1)
#define loop2(i, con) for (auto i : con)
#define pb push_back
bool visited[100001];
vector<long long int> v[100001];
int dp[100001];
int size = 0;
bool visit = false;
int main()
{
    
    // int  t;
    // cin>>t;
    
    
    
    // AC, WA, TLE, or RE.
    // //  while(t--)
    //  {
        
        int n;
       cin>>n;
       unordered_map<string,int> M;
       M["AC"]=0;
       M["WA"]=0;
       M["TLE"]=0;
        M["RE"]=0;
       for(int i=0;i<n;i++)
       {
           
           string st;
           cin>>st;
           M[st]++;
       }
        
      cout<<"AC"<<" "<<'x'<<" "<<M["AC"]<<endl;
       cout<<"WA"<<" "<<'x'<<" "<<M["WA"]<<endl;
        cout<<"TLE"<<" "<<'x'<<" "<<M["TLE"]<<endl;
         cout<<"RE"<<" "<<'x'<<" "<<M["RE"]<<endl;
        
        
        
    
    
    
    
    
    
    
    
    
}



Measured memory_bytes: 5980
import sys

def main():
  input = sys.stdin.readline
  n = str(input())
  m = ''
  for i in range(len(n)):
    if n[i] == '1':
      m += '9'
    elif n[i] == '9':
      m += '1'
    else:
      m += n[i]
  print(int(m))

if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
int a,b,c;
int check(int x,int y,int z)
{
	int ans;
	x-=z;
	ans=x/(y+z);
	return ans;
}
int main()
{
    cin>>a>>b>>c;
    cout<<check(a,b,c)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>

#define REP(i, n) for(int i = 0;i < (n); i++)
#define REP2(i, x, n) for(int i = (x); i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

LL gcd(LL a, LL b) {
	if (b > 0) {
		return gcd(b, a % b);
	} else {
		return a;
	}
}

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

//================================================

int main() {
	LL A, B;

	while (cin >> A >> B) {
		cout << gcd(A, B) << " " << lcm(A, B) << "\n";
	}
}

Measured memory_bytes: 2988
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
    int n;
  cin >> n;
  vector<long long> d(n);
  vector<int> weight(n, 1);
  map<long long,int> mp;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    mp[d[i]] = i;
  }
  vector<pair<int,int> > res;
  for (int itt = 0; itt < n - 1; itt++) {
    auto it = mp.rbegin();
    int i = it->second;
    long long want = d[i] - (n - weight[i]) + weight[i];
    if (mp.find(want) == mp.end() || mp[want] == i) {
      cout << -1 << '\n';
      return 0;
    }
    int j = mp[want];
    res.emplace_back(i, j);
    weight[j] += weight[i];
    mp.erase(--mp.end());
  }
  vector<long long> real_dist(n, -1);
  real_dist[0] = 0;
  vector<vector<int> > g(n);
  for (auto &p : res) {
    g[p.first].push_back(p.second);
    g[p.second].push_back(p.first);
  }
  vector<int> que(1, 0);
  for (int b = 0; b < (int) que.size(); b++) {
    for (int j : g[que[b]]) {
      if (real_dist[j] == -1) {
        que.push_back(j);
        real_dist[j] = real_dist[que[b]] + 1;
      }
    }
  }
  if (accumulate(real_dist.begin(), real_dist.end(), 0LL) != d[0]) {
    cout << -1 << '\n';
    return 0;
  }
  for (auto &p : res) {
    cout << p.first + 1 << " " << p.second + 1 << '\n';
  }
	return 0;
}

Measured memory_bytes: 10488
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

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

int main() {
	string S;
	cin >> S;
	cout << S.substr(0, 3);
}


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

int main() {
	long long x;
	cin >> x;
	long long m = 100;
	long long ans = 0;
	while(m<x)
	{
		m *= 1.01;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll t; cin>>t; while(t--)
typedef long long int ll;
set<ll> get(ll x){
    set<ll>ans;
    for(ll i=2;i*i<=x;i++){
        while(x%i==0){
            ans.insert(i);
            x/=i;
        }
    }
    if(x>1){
        ans.insert(x);
    }
    return ans;
}
int main() {
    FIO;
    //test
    {
       ll n;
       cin>>n;
       vector<ll>a(n);
       for(int i=0;i<n;i++){
           cin>>a[i];
       }
       ll ans=a[0];
       set<ll>s;
       bool keep=false;
       for(int i=0;i<n;i++){
           if(i){
               ans=__gcd(ans,a[i]);
           }
           if(!keep){
               set<ll>as=get(a[i]);
               for(auto it:as){
                   if(s.count(it)){
                       keep=true;
                   }
                   s.insert(it);
               }
           }
       }
       if(!keep){
           cout<<"pairwise coprime\n";
       }
       else if(ans==1){
           cout<<"setwise coprime\n";
       }
       else{
           cout<<"not coprime\n";
       }
    }
	return 0;
}


Measured memory_bytes: 11116
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(void) {
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	if (n - k >= 0) cout << k*x + (n - k)*y << endl;
	else cout << n*x << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    rep(i,4) if (s[i] == '2') ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int c=sc.nextInt();
		String s=sc.next();
		boolean[] a=new boolean[n+1];
		for(int i=1; i<=n; i++){
			if(s.charAt(i-1)=='x'){
				a[i]=true;
			}
		}
		boolean[] front=new boolean[n+1];
		boolean[] back=new boolean[n+1];
		int tmp=k;
		for(int i=1; i<=n; i++){
			if(!a[i] && tmp>0){
				front[i]=true;
				tmp--;
				i+=c;
			}
		}
		tmp=k;
		for(int i=n; i>=1; i--){
			if(!a[i] && tmp>0){
				back[i]=true;
				tmp--;
				i-=c;
			}
		}
		int fc=0;
		int bc=0;
		for(int i=1; i<=n; i++){
			if(front[i] && back[i] && fc==bc){
				System.out.println(i);
			}else if(front[i]){
				fc++;
			}else if(back[i]){
				bc++;
			}
		}
	}
}


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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  while (N > 0) {
    ans += N % 10;
    N /= 10;
  }
  if (ans > 1) cout << ans << endl;
  else cout << 10 << endl;
}



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

//Function Macros:
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main()
{
    int n, m;
    cin >> n >> m;
    priority_queue<int> q;
    rep(i, n)
    {
        int a;
        cin >> a;
        q.push(a);
    }
    rep(i, m)
    {
        int a = q.top();
        q.pop();
        q.push(a>>1);
    }
    ll ans = 0;
    rep(i,n) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
const int mod = 1e9 + 7;
set<int>st;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    st.insert(0);
    st.insert(n+1);
    vector<pair<int,int>>v;
    f1(n) {
        int x;
        cin >> x;
        v.pb({x,i});
    }
    sort(all(v));
    reverse(all(v));
    ll ans = 0;
    for (auto &i : v) {
        auto x = st.lower_bound(i.S);
        if (*x != n + 1) {
            ans += (ll)i.F * (*next(x)-*x) * (i.S - *prev(x));
            //cout << *next(x) <<' '<<*x<<' '<<i.S<<' '<<*prev(x)<<endl;
        }
        x = prev(x);
        if (*x != 0) {
            ans += (ll)i.F * (*next(x) - i.S) * (*x - *prev(x));
        }
        st.insert(i.S);
    }
    cout << ans << '\n';
}


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

#define ll long long 
#define pll pair<ll,ll> 
const ll mod=1e9+7;

char A[1005][1005];
ll M[1005][1005];
ll func(ll n,ll m){
	if(n<0 || m<0)
		return 0;
	if(n==0 && m==0)
		return 1;
	if(A[n][m]=='#')
		return 0;

	ll &ans=M[n][m];
	if(ans==-1){
		ans=(func(n,m-1)+func(n-1,m))%mod;
	}

	return ans;
}
	


int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<n;i++)
		for(ll j=0;j<m;j++)
			cin>>A[i][j];
	
	memset(M,-1,sizeof M);
	ll ans=func(n-1,m-1);
	cout<<ans<<endl;

}


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

int main()
{
	int n;
	vector<pair<int,int> > a(100000);
	cin>>n;
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		a[i]=make_pair(t,i+1);
	}
	
	sort(a.begin(),a.begin()+n);
	
	for(int i=0;i<n;i++) cout<<a[i].second<<" ";
	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <unordered_set>
#include <vector>
using namespace std;

int main(void) {
  int N;
  cin >> N;
  string S;
  cin >> S;
  unordered_set<char> countX;
  int answer = 0;
  for (int i = 0; i < N - 1; ++i) {
    countX.emplace(S[i]);
    unordered_set<char> countY;
    int num = 0;
    for (int j = i + 1; j < N; ++j) {
      if (countY.count(S[j])) continue;
      countY.emplace(S[j]);
      if (countX.count(S[j])) ++num;
    }
    answer = max(answer, num);
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cmath>
//#include<queue>
using namespace std;
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define LL long long
#define SZ(x) x.size()
int vis[40000];
int x,k,n,m,s,ans,start,end1,end2,dight;

int bfs()
{
	int q1[40000];int L1=1;int R1=0;	
	int q2[40000];int L2=1;int R2=0;
	q1[++R1]=start;
	q2[++R2]=1;
	vis[start]=1;
	while(q1[L1]!=end1&&q1[L1]!=end2)
	{
		int fr=q1[L1];
		int fv=q2[L2];
		FOR(i,0,n-2)
		{
			if((fr&(1<<i))&&!(fr&(1<<(i+1))))
			{
				ans=fr+(1<<i);
				if(!vis[ans]) {vis[ans]=1;q1[++R1]=ans;q2[++R2]=fv+1;}
			}
			else if(!(fr&(1<<i))&&(fr&(1<<(i+1))))
			{
				ans=fr-(1<<i);
				if(!vis[ans]) {vis[ans]=1;q1[++R1]=ans;q2[++R2]=fv+1;}
			}
		}
		L1++;
		L2++;
	}
	return q2[L2]-1;
}
int main()
{
cin>>n>>m;
dight=1;
FORD(i,n-1,0)
{
	cin>>x;
	start+=x<<i;
}
int c=n;
FOR(i,1,m)
{
	cin>>x;
	FOR(j,1,x)
	{
		c--;
		end1+=dight<<c;
		end2+=(1-dight)<<c;
	}
	dight^=1;
}
cout<<bfs()<<endl;
return 0;
}

Measured memory_bytes: 1348
#include<stdio.h>
int main(void)
{
    int n,m;
    int a[10001],b[10001];
    int flg[10001];
    int i;
    int c;
     
    scanf("%d",&n);
    scanf("%d",&m);
    while(n!=0 && m!=0){
        c=0;
        for(i=2;i<=n;i++){
            flg[i]=0;
        }
        flg[1]=2;
        for(i=1;i<=m;i++){
            scanf("%d %d",&a[i],&b[i]);
            if(a[i]==1){
                c++;
                flg[b[i]]=1;
            }
        }
        for(i=1;i<=m;i++){
            if(flg[a[i]]==1 && flg[b[i]]==0){
                    c++;
                    flg[b[i]]=2;
            }
        }
        for(i=1;i<=m;i++){
            if(flg[a[i]]==0 && flg[b[i]]==1){
                    c++;
                    flg[a[i]]=2;
            }
        }
        printf("%d\n",c);
        scanf("%d",&n);
        scanf("%d",&m);
    }
    return 0;
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i=0; i<n; i++)
 
using namespace std;
const double PI = acos(-1);
using Graph = vector<vector<int>>;
 
int main() 
{
	int n;
	cin >> n;
	int a[n];
	int count = 0;
	rep(i, n)
	{
		int a;
		cin >> a;
		if ((i+1) % 2 == 1 && a % 2 == 1)
			count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
	int  totalMoney=0, totalCount=0, stepCount=0;
	int  unitCost,count;
	while(scanf("%d, %d",&unitCost, &count)==2)
	{
		totalMoney += unitCost*count;
		totalCount += count;
		++stepCount;
	}
	printf("%d\n%.0f\n",totalMoney, (1e-7+totalCount)/stepCount);
	return 0;
}

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

int main()
{
	int n;
	double i=1;
	cin>>n;
	while(floor(i*1.08)<n) i++;
	if(floor(i*1.08)==n) cout<<i<<endl;
	else cout<<":("<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    string s,t;
    cin>>s>>t;
    set<char> sa,st;
    REP(i,s.length())sa.insert(s[i]);
    REP(i,t.length())st.insert(t[i]);
    REP(i,s.length())
    {
        REP(j,t.length())
        {
            if(s[i]<t[j])
            {
                cout<<"Yes";
                return 0;
            }
        }
    }
    if(s.length()<t.length() && sa==st)
    cout<<"Yes";
    else cout<<"No";
  }  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int main(){
int a[6];
for(int i=0;i<5;i++)cin>>a[i];
for(int i=0;i<5;i++)if(!a[i])cout<<i+1;


return 0;}


Measured memory_bytes: 3636
import sys
N,M = map(int, input().split())

sys.maxsize = 10000000000000000


AB = [[0,0] for i in range(N)]
for n in range(N):
    AB[n][0],AB[n][1] = map(int, input().split())

AB.sort(key=lambda x:x[0])
#print(AB)


num = 0
yen = 0
for n in range(N):
    if num+AB[n][1] >= M:
        yen += (M-num)*AB[n][0]
        print(yen)
        break
    else:
        num += AB[n][1]
        yen += AB[n][1]*AB[n][0]

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

struct grid{
  char g[12][12];
  int cnt;
};

void paint(grid &gr,char C,char c,int x,int y){
  
  if(gr.g[y][x] != C){
    return;
  }
  
  gr.g[y][x] = c;
  paint(gr,C,c,x+1,y);
  paint(gr,C,c,x-1,y);
  paint(gr,C,c,x,y+1);
  paint(gr,C,c,x,y-1);
}

bool check(grid &gr,char C,int x,int y){
  bool flag = true;
  for(int i=1;i<=y;i++){
    for(int j=1;j<=x;j++){
      if(C != gr.g[i][j]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}

int main(){
  while(true){
    int x,y;
    cin >> x >> y;
    
    if(x==0 && y==0){
      break;
    }
    
    grid st;
    for(int i=1;i<=y;i++){
      for(int j=1;j<=x;j++){
          cin >> st.g[i][j];
      }
    }

    st.cnt = 0;
    queue<grid> que;
    que.push(st);

    while(true){
      grid data = que.front();
      que.pop();
      
      char C;
      C = data.g[1][1];
      
      if(check(data,C,x,y)){
        cout << data.cnt << endl;
        break;
      }
      
      if(C != 'R'){
        grid tmp = data;
        tmp.cnt += 1;
        paint(tmp,C,'R',1,1);
        que.push(tmp);
      }
      
      if(C != 'G'){
        grid tmp = data;
        tmp.cnt += 1;
        paint(tmp,C,'G',1,1);
        que.push(tmp);
      }
      
      if(C != 'B'){
        grid tmp = data;
        tmp.cnt += 1;
        paint(tmp,C,'B',1,1);
        que.push(tmp);
      }
      
    }
  }
  return 0;
}


Measured memory_bytes: 40184
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int i;
int n;
int max=0;
int max2=0;
int a[100001];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(max<a[i])
{max=a[i];}
}
for(i=0;i<n;i++)
{
if(abs(max-max2*2)>abs(max-a[i]*2))
{max2=a[i];}
}
printf("%d %d",max,max2);
return 0;}


Measured memory_bytes: 512
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    ll n;
    cin>>n;
    string ans;
    while(n){
        n--;
        ll rem = n%26;
        ans+=('a'+rem);
        n = (n-rem)/26;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 3664
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lint;
typedef double ld;

void a(); void b(); void c(); void d(); void e(); void f();

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

	// a();
	// b();
	c();
	// d();
	// e();
	// f();
	return 0;
}


void a(){
	string s, t;
	cin >> s >> t;
	t.erase(t.begin() + s.size());
	if(s == t)puts("Yes");
	else puts("No");
}

void b(){
	lint a, b, c, k;
	cin >> a >> b >> c >> k;
	lint ans = min(a, k);
	k -= min(a, k);
	k -= min(b, k);
	ans -= min(c, k);
	cout << ans;
}

void c(){
	int n, m, x;
	cin >> n >> m >> x;
	vector<lint> a[150], c(150);
	forn(i, n){
		cin >> c[i];
		a[i].resize(150);
		forn(j, m)cin >> a[i][j];
	}
	lint ans = LLONG_MAX;
	for(int i = 0; i < (1 << n); i++){
		vector<lint> sel, A(150, 0);
		for(int j = 0; j < n; j++){
			if(i & (1 << j))sel.pb(j);
		}
		lint cs = 0;
		for(auto j:sel){
			cs += c[j];
			forn(k, a[j].size())A[k] += a[j][k];
		}
		int ct = 0;
		forn(j, m)if(A[j] >= x)ct++;
		if(ct == m){
			ans = min(ans, cs);
		}
	}
	if(ans == LLONG_MAX)cout << -1;
	else cout << ans;
}

void d(){

}

void e(){

}

void f(){

}

Measured memory_bytes: 3672
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

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

#define MAX_H 100
#define MAX_W 100
#define INF 1000000

char s[MAX_H][MAX_W];
int dist[MAX_H][MAX_W];

int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int H, W;
  cin >> H >> W;

  int cnt_blk = 0;
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> s[i][j];

      if (s[i][j] == '#') {
	cnt_blk++;
      }

      dist[i][j] = INF;
      
    }
  }

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

  queue<P> que;
  que.push(P(0, 0));
  dist[0][0] = 0;
  
  bool goal = false;
  int min_dist = INF;

  int di[4] = {1, 0, -1, 0};
  int dj[4] = {0, 1, 0, -1};
  
  
  while (que.size() != 0) {

    P p = que.front();
    que.pop();

    if (p.first == H-1 && p.second == W-1) {
      goal = true;
      min_dist = dist[p.first][p.second];
      break;
    }

    s[p.first][p.second] = '#';
    
    for (int k = 0; k < 4; k++) {
      int ni = p.first + di[k];
      int nj = p.second + dj[k];

      if (dist[ni][nj] == INF && s[ni][nj] != '#' && ni >= 0 && ni < H && nj >= 0 && nj < W) {
	que.push( P(ni, nj) );
	dist[ni][nj] = dist[p.first][p.second] + 1;
      }
      
    }
    
  }

  if (goal) {
    cout << H*W - 2 - cnt_blk - (min_dist-1) << endl;
  } else {
    cout << -1 << endl;
  }
  
  
  return 0;
  
}


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

int main(){
  int k, n;
  int A[A_MAX];
  cin >> k >> n;
  rep(i, n)cin >> A[i];

  int d_max;
  long long int d = 0;
  
  rep(i, n){
    if(i == 0){
      d_max = (k - A[n-1]) + A[0];
      d  += (k - A[n-1]) + A[0];
    }
    else{
      d += A[i] - A[i-1];
      if(A[i] - A[i-1] > d_max)d_max = A[i] - A[i-1];
    }
  }
  cout << d - d_max << endl;

  return 0;
}

Measured memory_bytes: 2944
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int main() {
	char Mark;
	char m[4][2] = { "S","H","C","D" };
	int Card[4][13] = { 0 };
	int num,n,i,mark,j;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf(" %c %d", &Mark, &num);

		if (Mark == 'S') mark = 0;
		else if (Mark == 'H') mark = 1;
		else if (Mark == 'C') mark = 2;
		else if (Mark == 'D') mark = 3;
		else mark = 1;

		Card[mark][num - 1]=1;
	}
	for (i = 0; i < 4; ++i)
		for (j = 0; j < 13; ++j) if (!Card[i][j]) printf("%s %d\n", m[i], j + 1);
	return 0;
}

Measured memory_bytes: 596
a,b,c,x = 4.times.map{
    gets.to_i
}
count = 0
for i in 0..a
for j in 0..b
for k in 0..c
if i * 500 + j * 100 + k * 50 == x
    count += 1
end
end
end
end
puts count

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

namespace Prac
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            int x = 0;
            for (var i = 1; i <= n; i++)
            {
                x = i;
                if (x % 3 == 0)
                {
                    Console.Write(" " + i);
                }
                else
                {
                    while (x != 0)
                    {
                        if ((x % 10) == 3)
                        {
                            Console.Write(" " + i);
                            break;
                        }
                        x /= 10;


                    }
                }
            }
            Console.WriteLine();
            
        }
    }
}

Measured memory_bytes: 19932
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>

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


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

    if (d == 25) {
        cout << "Christmas" << endl;
    } else if (d == 24) {
        cout << "Christmas Eve" << endl;
    } else if (d == 23) {
        cout << "Christmas Eve Eve" << endl;
    } else { 
        cout << "Christmas Eve Eve Eve" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
#define P pair<int,int>
#define PPi pair<P,int>
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int N,x,y,result=0;
	vector<PPi> ve;
	set<int> st;
	
	cin>>N;
	REP(i,2*N){
		cin>>x>>y;
		if(i<N) ve.pb(PPi(P(x,y),0));
		else ve.pb(PPi(P(x,y),1));
	}
	VSORT(ve);

	REP(i,2*N){
		P tem=ve[i].first;
		if(ve[i].second==0) st.insert(-tem.second); //赤い点
		else{
			set<int>::iterator maxy=st.upper_bound(-tem.second);
			if(maxy!=st.end()){
				result++; st.erase(maxy);
			}
		}
	}
	print(result);
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

const ll mod = static_cast<ll>(1e9) + 7;

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;

    const ll lhs = 4 * a * b;

    const ll x = c - a - b;
    const ll rhs = x * x;

    cout << (x >= 0 && lhs < rhs ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
string st;
int a=-1;
int main()
{
	cin>>st;
	for(int i=0;i<st.size();i++)
	{
		if(st[i]=='C')a=i;
		if(st[i]=='F')
		{
			if(a!=-1)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,q;
  char s[100010];
  int sum[100010];
  int l,r;
  scanf("%d%d",&n,&q);
  scanf("%s",s);
  for(int i=0;i<n;i++){
    if(s[i]=='A'&&s[i+1]=='C'){
      sum[i+1]=sum[i]+1;
    }
    else{
      sum[i+1]=sum[i];
    }
  }
  for(int i=0;i<q;i++){
    scanf("%d%d",&l,&r);
    l--;r--;
    printf("%d\n",sum[r]-sum[l]);
  }
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
    int n;
    std::cin >> n;

    std::vector<int> digits;

    bool flg = false;
    int buf, i;
    for(i = n; i <= 999; ++i){
        buf = i;
        digits.resize(3);
        for(int j = 0; j < 3; ++j){
            digits.at(j) = buf % 10;
            buf = buf / 10;
        }

        std::sort(digits.begin(), digits.end());
        digits.erase(std::unique(digits.begin(), digits.end()), digits.end());

        if(1 == digits.size()){
            flg = true;
            break;
        }
    }

    std::cout << i << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()

using namespace std;

int main() {
  set<int> s;
  for (int i = 0; i < 3; ++i) {
    int in;
    cin >> in;
    s.insert(in);
  }

  cout << sz(s) << endl;

  return 0;
}

Measured memory_bytes: 256