akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
long N, ans=0; cin >> N; string S; long A[5]={};
REP(i, N){
  cin >> S;
  if(S[0]=='M'){ A[0]++; }
  if(S[0]=='A'){ A[1]++; }
  if(S[0]=='R'){ A[2]++; }
  if(S[0]=='C'){ A[3]++; }
  if(S[0]=='H'){ A[4]++; }
}
ans+=A[0]*A[1]*A[2];ans+=A[0]*A[1]*A[3];ans+=A[0]*A[1]*A[4];
ans+=A[0]*A[2]*A[3];ans+=A[0]*A[2]*A[4];ans+=A[0]*A[3]*A[4];
ans+=A[1]*A[2]*A[3];ans+=A[1]*A[2]*A[4];ans+=A[1]*A[3]*A[4];
ans+=A[2]*A[3]*A[4];
cout << ans << "\n";
}

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

using namespace std;

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

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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a + b) % 2 == 0) {
    cout << (a + b) / 2 << endl;
  } else {
    cout << (a + 1 + b) / 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll double
void solution(){
    ll n,d;
    cin>>n>>d;
    ll counter = 0,p=0;
    for(ll i=0;i<n;++i){
        ll x,y;
        cin>>x>>y;
        p = sqrt(pow(x,2)+pow(y,2));
        if(p <= d)
            counter++;
    }
    cout<<counter<<'\n';

}
int main(){
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cerr.tie(0);
        /*ll t;
        cin>>t;
        while(t--)*/
        solution();
        return 0;
}

Measured memory_bytes: 3860
#約数を列挙
def make_divisor(n):
    divisor = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisor.append(i)
    divisor.append(n)
    return divisor

N = int(input())
a = make_divisor(N)

ans = 100
for i in range(len(a)):
    F = max(len(str(a[i])), len(str(N // a[i])))
    ans = min(ans, F)

print(ans)


Measured memory_bytes: 3188
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()

for i in range(1, 1000):
	if (X*i)%360 == 0:
		print(i)
		exit()


Measured memory_bytes: 10588
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

int a,b;
signed main(){
  cin>>a>>b;
  cout<<(a+b)/2<<en;
}



Measured memory_bytes: 3104
c = []
for i in range(3):
    c_i = [int(a) for a in input().split()]
    c.append(c_i)
if (
    c[0][0] + c[1][1] + c[2][2]
    == c[0][1] + c[1][2] + c[2][0]
    == c[0][2] + c[1][0] + c[2][1]
):
    print("Yes")
else:
    print("No")


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

int main(){
    using ll = long long;
    ll a,b,k; cin>>a>>b>>k;

    if(a>k){
        a -= k;
    }else if(a+b>=k){
        b -= k-a;
        a = 0;
    }else{
        a = 0;
        b = 0;
    }

    cout << a << " " << b << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
 
int key[500001];
int left[500001];
int right[500001];
int root;
int head;
 
void printpre(int i){
    if(i == -1) return;
    printf(" %d", key[i]);
    printpre(left[i]);
    printpre(right[i]);
}
 
void printin(int i){
    if(i == -1) return;
    printin(left[i]);
    printf(" %d", key[i]);
    printin(right[i]);
}
 
void insert(int z){
    int y = -1;
    int x = root;
    while(x != -1){
        y = x;
        if(z < key[x])
            x = left[x];
        else
            x = right[x];
    }
 
    if(y == -1) {
        root = head;
    } else if(z < key[y]) {
        left[y] = head;
    } else {
        right[y] = head;
    }
    key[head] = z;
    left[head] = -1;
    right[head] = -1;
    head++;
}
 
int main(void){
    int n;
    scanf("%d", &n);
    root = -1;
    while(n--){
        char cmd[8];
        scanf("%s", cmd);
        if(cmd[0] == 'i'){
            int z;
            scanf("%d", &z);
            insert(z);
        } else {
            printin(root);
            puts("");
            printpre(root);
            puts("");
        }
    }
}


Measured memory_bytes: 7552
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void push(int);
int pop(void);
int top=0;
int O[100];
  int main(){
    int x,y,z,i=0;
    char s[100];
    
    while(scanf("%s",s)!=EOF){
      if(s[0]=='+'){
	x=pop();
	y=pop();
	z=x+y;
	push(z);
      }
      else if(s[0]=='-'){
	x=pop();
	y=pop();
	z=y-x;
	push(z);
	
      }
      else if(s[0]=='*'){
	x=pop();
	y=pop();
	z=x*y;
	push(z);
	
      }
      else{
	z=atoi(s);
	push(z);
      }
    }
    printf("%d\n",pop());

  return 0;
}

void push(int z){
  top++;
  O[top]=z;
}

int pop(){
  int a;
  if(top==0){
    printf("underflow\n");
    exit(1);
  }
  else{
    top--;
    a=O[top+1];
  }
  return a;
}



Measured memory_bytes: 2108
import java.util.Scanner;

class Main
{

    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int f = sc.nextInt();
        if (1 * a + 5 * b + 10 * c + 50 * d + 100 * e + 500 * f >= 1000){
            System.out.println("1");
        }else{
            System.out.println("0");
        }

    }

}



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

int main() {
	
	int N, vet[112], res=0;


	scanf("%d", &N);
	rep(0,N) scanf("%d", vet+i);

	for (int i = 0;i < N-2;i++) {
		for (int j = i+1;j < N-1;j++) {
			for (int k = j+1;k < N;k++) {
				if (vet[i] != vet[j] and vet[i] != vet[k] and vet[j] != vet[k]) {
					if (vet[i] + vet[j] > vet[k] and vet[i] + vet[k] > vet[j] and vet[j] + vet[k] > vet[i]) {
						res++;
					}
				}
			}
		}
	}

	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 3824
#include <stdio.h>
int main ()
{
    int H,W,i,j;
    
    while(1){
        scanf("%d %d",&H , &W);
        
        if(H == 0 && W == 0) break;
        for (i = 1; i <= H; i++){
            if (i == 1 || i == H){
                for (j = 1; j <= W; j++){
                    printf("#");
                }
                printf("\n");
            }
            else {
                for (j = 1; j<= W; j++){
                    if(j == 1 || j == W){
                        printf("#");
                    }
                    else{
                        printf(".");
                    }
                }
                printf("\n");
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
const int maxn=(1e5+10);
string s;
int dp[maxn][20];
int main()
{
	cin>>s;
	if(s[0]=='?')
	{
		for(int i=0;i<10;i++)
			dp[1][i]=1;
	}
	else
	{
		dp[1][s[0]-'0']=1;
	} 
	for(int i=1;i<s.size();i++)
	{
		for(int j=0;j<13;j++)
		{
			if(!dp[i][j])
				continue;
			if(s[i]=='?')
			{
				for(int k=0;k<10;k++)
					dp[i+1][(j*10+k)%13]=(dp[i+1][(j*10+k)%13]+dp[i][j])%MOD;
			}
			else
			{
				dp[i+1][(j*10+s[i]-'0')%13]=(dp[i+1][(j*10+s[i]-'0')%13]+dp[i][j])%MOD;
			}
		}
	}
	cout<<dp[s.size()][5]<<endl;
	return 0;
}

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

int main(){
 const LL M = 1000000007;
 LL ans = 0;
 LL d = 0;
 int N; scanf("%d",&N);
 rep(i,N){
  LL a; scanf("%lld",&a);
  ans += d*a%M;
  d = (d+a)%M;
 }
 ans %= M;
 printf("%lld\n",ans);
 return 0;
}

Measured memory_bytes: 3824
import numpy as np
import collections
N, X = list(map(int,input().split()))

l = [1]
p = [1]
for i in range(N):
    l.append(2*l[i] + 3)
    p.append(2*p[i] + 1)

def f(N, X):
    if N == 0 and X > 0:
        return 1
    elif N == 0 and X <= 0:
        return 0
    elif X <= l[N-1] + 1:
        return f(N-1, X-1)
    else: # X > l[N-1] + 2:
        return p[N-1] + f(N-1, X - 2 - l[N-1]) + 1
    #elif X == l[N-1] + 2:
    #    return p[N-1] + 1

print(f(N, X))    


Measured memory_bytes: 12488
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  int xa = a, xb = b;
  for (int i = 0; i < a-1; ++i) {
    xb = xb * 10 + b;
  }
  for (int i = 0; i < b-1; ++i) {
    xa = xa * 10 + a;
  }
  cout << max(xa, xb) << '\n';
}


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

static class CodeJam
{
    class Node
    {
        public readonly List<Node> next = new List<Node>();
        public int d = int.MaxValue / 2;
    }

    static int Solve(int N, int M, int[][] edges, int s, int t)
    {
        const int INF = int.MaxValue / 2;
        var nodes = new Node[N][];
        for (int i = 0; i < N; ++i)
        {
            nodes[i] = new Node[3];
            for (int j = 0; j < 3; ++j) { nodes[i][j] = new Node(); }
        }
        foreach (var edge in edges)
        {
            int u = edge[0];
            int v = edge[1];
            nodes[u][0].next.Add(nodes[v][1]);
            nodes[u][1].next.Add(nodes[v][2]);
            nodes[u][2].next.Add(nodes[v][0]);
        }
        var q = new Queue<Node>();
        nodes[s][0].d = 0;
        q.Enqueue(nodes[s][0]);
        while (q.Count > 0)
        {
            Node a = q.Dequeue();
            foreach (Node b in a.next)
            {
                if (a.d + 1 < b.d)
                {
                    b.d = a.d + 1;
                    q.Enqueue(b);
                }
            }
        }
        return (nodes[t][0].d < INF && nodes[t][0].d % 3 == 0) ? nodes[t][0].d / 3 : -1;
    }

    static void Main(string[] args)
    {
        var V1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int N = V1[0], M = V1[1];
        var edges = new int[M][];
        for (int i = 0; i < M; ++i)
        {
            edges[i] = Array.ConvertAll(Console.ReadLine().Split(), x => int.Parse(x) - 1);
        }
        var V3 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine(Solve(N, M, edges, V3[0] - 1, V3[1] - 1));
    }
}


Measured memory_bytes: 68212
#include<bits/stdc++.h>
#define mod 1000000007
//#define mod 998244353
#define N 1000001
#define ll long long int
#define pr pair<ll,ll>
#define ff first
#define ss second
#define pub push_back
#define pob pop_back
#define f(i,a,b) for(ll i=a;i<=b;i++)
#define r(i,a,b) for(ll i=a;i>=b;i--)
#define ms(a,b) memset(a,b,sizeof(a))
#define line cout<<'\n'
#define all(v) v.begin(),v.end()
#define rev(s) reverse(all(s))
using namespace std;

const double pi = 3.141592653589793238;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll tt = 1;
    //cin>>tt;
    f(t,1,tt){
        ll a,b,h,m;
        cin>>a>>b>>h>>m;
        double d = pi*(60*h - 11*m);
        d /= 360;
        double ans = a*a + b*b -2*a*b*cos(d);
        ans = sqrt(ans);
        cout<<fixed<<setprecision(10)<<ans;
    }
    return 0;
}

Measured memory_bytes: 4108
#include <iostream>
using namespace std;
 
int main(){
  int a[6];
  cin >> a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5];
  int b[4] = {0,0,0,0};
  for(int i=0; i < 6; i++){
    b[a[i]-1]++;
  }
  if(b[0]<3 && b[1]<3 && b[2]<3 && b[3]<3){
    
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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

kz_ls = []
q_ls = ['3', '5', '7']
while True:
    if not q_ls:
        break
    else:
        tmp = q_ls.pop(0)
        kz_ls.append(tmp)
        if len(tmp) < 9:
            q_ls.append(tmp + '3')
            q_ls.append(tmp + '5')
            q_ls.append(tmp + '7')

kazus = []
for item in kz_ls:
    if item.count('3') > 0 and item.count('5') > 0 and item.count('7') > 0:
        kazus.append(int(item))

kazus.sort()

ret = 0
for item in kazus:
    if item <= n:
        ret += 1
print(ret)


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

#define ll long long

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    //vector<int> a(n);
    long long currsum = 0;

    map<int,int> m;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        currsum += a;
        if (m.count(a)) {
            ++m[a];
        } else {
            m[a]=1;
        }
    }

    int q;
    cin >> q;


    for (int i = 0; i < q; ++i) {
        int b,c;
        cin >>b>>c;
        
        //int cc = m[c];
        if (m.count(c) == 0) {
            m[c] = 0;
        }
        if (m.count(b) == 0) {
            m[b] = 0;
        }
        int cb = m[b];
        m[c] += cb;
        m[b] -= cb;
        if (m[b] == 0) {
            m.erase(b);
        }
        /*
        long long sum = 0;
        for (auto it = m.begin(); it != m.end(); ++it) {
            sum += (long long)it->first * (long long)it->second;
        }
        */
        currsum += (long long)((c-b)*cb);
        //currsum -= (long long)cb * (long long)b;
        //currsum += (long long)cb * (long long)c;
        cout << currsum << endl;
    }
    

    return 0;
}

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

int main() {
	int a,b;
	int i,j;
	for(;;){
	cin>>a>>b;
	
	if(a==0&&b==0){
		break;
	}
	
	for(i=0;i<a;i++){
		for(j=0;j<b;j++){
			
			cout<<'#';
			
		}
		cout<<endl;
	}
	cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

typedef long long int ll;

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

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

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

const int mod = 1000000007;

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

  int a, b;
  cin >> a >> b;

  cout << max(0, a-b*2) << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1e9 + 7;
using namespace std;

int main()
{
    IOS
    int d,n;
    cin >> d >> n;
    if(d == 0 && n < 100) cout << n <<'\n';
    else if(d == 0 && n == 100) cout << 101 <<'\n';
    else if(d == 1 && n < 100)
    {
        cout << 100 * n << '\n';
    }
    else if(d == 1 && n==100)
    {
        cout << 10100 << '\n';
    }
    else if(d == 2 && n < 100)
    {
        cout << 100 * 100 * n << '\n';
    }
    else
    {
        cout << 1010000 << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ff(i, x, n, k) for(int i=x;i<n;i+=k)
#define rf(i, x, n, k) for(int i=n-1;i>=x;i+=k)
#define ef(i, x, n, k) for(int i=x;i<=n;i+=k)
#define pb push_back
#define eb emplace_back
#define pp pop_back
#define mp make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int MOD = 1e9+7;
const ll INF = pow(10, 18)+5;

vector <vector <int > > graph(210000);
int maxPath[210000] = {0};
bool visit[210000] = {false};

int dfs(int n)
{
	if (maxPath[n] != 0) return maxPath[n];
	
	for (auto u : graph[n])
	maxPath[n] = max(maxPath[n], dfs(u)+1);

	visit[n] = true;
	if (visit[n] == true){
		return maxPath[n];
	}
}

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

	for (int i = 0; i < m; ++i)
	{
		int x, y; cin >> x >> y;
		graph[x].pb(y);
	}

	int store = 0;
	for (int i = 1; i <= n; ++i)
	{
		store = dfs(i);
	}

	int MAX = 0;

	for (int i = 1; i <= n; ++i)
	{
		MAX = max(MAX, maxPath[i]);
	}

	cout << MAX <<'\n';
	return 0;
}

Measured memory_bytes: 10112
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n, p;
		int k[] = new int[1000000];
		final int max = 10000000;

		int prime[] = new int[max];
		Arrays.fill(prime, 1);
		prime[0] = 0;
		prime[1] = 0;
		for (int i = 2; i < max / 2; i++) {
			for (int j = i * 2; j < max; j += i) {
				prime[j] = 0;
			}
		}

		while (true) {
			n = sc.nextInt();
			p = sc.nextInt();
			if (n == -1 && p == -1) {
				break;
			}
			Arrays.fill(k, Integer.MAX_VALUE);
			int id = 0;
			for (int i = n + 1; i < n + 50 * p; i++) {
				for (int j = i; j < n + 50 * p; j++) {
					if (prime[i] == 1 && prime[j] == 1) {
						k[id++] = i + j;
					}
				}
			}

			Arrays.sort(k);
			System.out.println(k[p - 1]);
		}
	}
}

Measured memory_bytes: 69952
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa

using namespace std;

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  ll d, t, s; cin >> d >> t >> s;
  if (s*t >= d) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> H(N);
  for( int i = 0; i < N; i++ ) cin >> H.at(i);
  
  int saidai = 0;
  int count = 0;
  for( int i = 0; i < N; i++ ){
    if( saidai <= H.at(i) ){
      count++;
      saidai = H.at(i);
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int K, S;
  std::cin >> K >> S;

  int cnt = 0;
  for (int i = 0; i <= K; ++i) {
    for (int j = 0; j <= K; ++j) {
      int k = S - i - j;
      if ( 0 <= k && k <= K ) ++cnt;
    }
  }
  std::cout << cnt << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,x,a=0;
	for(;;){
		cin>>n>>x;
		if(n==0 && x==0){
			break;
		}

		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				for(int k=j+1;k<=n;k++){

					if(x==(i+j+k)){
						a++;
					}

				}
			}
		}

		cout<<a<<endl;
		a=0;
	}
	return 0;
}


Measured memory_bytes: 3084
#include<stdio.h>

int A[100000],n;

int binarySearch(int key){
  int left =0,right = n,mid;

  while(left < right){
    mid = (left+right)/2;
    if(A[mid]==key){
      return mid;
    }
    else if(key<A[mid]){
      right = mid;
    }
    else
      left=mid+1;
  }

  return -1;
}

int main() {

  int i,q,key,sum=0;
 

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

    if(binarySearch(key)!=-1){
      sum++;
    }
  }
  printf("%d\n",sum);

  return 0;
}
    



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

using namespace std;

bool is_acgt(string s) {
    for (char c : s) {
        if (c != 'A' && c != 'C' && c != 'G' && c != 'T') {
            return false;
        }
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        for (int j = 1; j <= (int)s.size() - i; j++) {
            string t = s.substr(i, j);
            if (is_acgt(t) && j > ans) {
                ans = j;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<stdio.h>
#include<string.h>
using namespace std;
#define ll long long
const int maxn=2e6+50;
int QuickPow(int x,int N){
    int res = x;
    int ans = 1;
    while(N){
        if(N&1){
            ans = ans * res;
        }
        res = res*res;
        N = N>>1;
    }
    return ans;
}//矩阵快速幂求  x  的 n  次方
inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}//快读
int main(){
    string ptr;
    cin>>ptr;
    int len=ptr.length();
    int fr=0,en=len-1;
    int sum=0;
    while(fr<=en){
        if(ptr[fr]!=ptr[en]){
            sum++;
        }
        fr++;
        en--;
    }
    cout<<sum<<endl;
    return 0;
}












Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
string s;
int n,p1[100001],maxn=-INF,c[2]={0,1},ans,rk,pp;
void dfs(int t){
	if(t>n){
		maxn=maxn>ans?maxn:ans;
		return;
	}
	if(s[t]=='p'){
		if(rk>pp){
			pp++;
			dfs(t+1);
			pp--;
		}
		else {
			rk++;
			ans--;
			dfs(t+1);
			rk--;
		}
	}
	if(s[t]=='g'){
		if(rk>pp){
			pp++;
			ans++;
			dfs(t+1);
			pp--;
			ans--;
		}
		else {
			rk++;
			dfs(t+1);
			rk--;
		}
	}
}
int main(){
	cin>>s;
	n=s.size();
	s=' '+s;
	dfs(1);
	printf("%d",maxn);
	return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<Pint> p(M);
    int a, b;
    rep(0, i, M)
    {
        cin >> a >> b;
        p.at(i) = make_pair(b, a);
    }
    sort(all(p));
    int ans = 0;
    int right = 0;
    rep(0, i, M)
    {
        if (p.at(i).second < right)
        {
            continue;
        }
        else
        {
            ans++;
            right = p.at(i).first;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int n;
int a,b,c;

map<string,int> mp;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		string str;
		cin>>str;
		mp[str]++;
	}
	int num = 0;
	for(auto it: mp){
		if((it).second > num)
			num = it.second;
	}
	vector<string> ans;
	for(auto it: mp){
		if((it).second == num)
			ans.push_back(it.first);
	}
	sort(ans.begin(),ans.end());
	for(auto s: ans){
		cout<<s<<endl;
	}
}

Measured memory_bytes: 26868
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b)
        if(b<c)
        printf("Yes\n");
        else
        printf("No\n");
    else
    printf("No\n");
    
return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;
ll a, b;
ll h[100100];
ll sum = 0;

bool C(double mid) {
	//cout << "!" << mid << endl;
	ll nm = (ll)(mid + 0.5);
	ll cnt = nm;
	rep(i, n) {
		ll kk = h[i] - nm*b;
		//cout << kk << " ";
		if (kk <= 0)continue;
		cnt -= (kk / (a - b) + (kk % (a - b) != 0));
		if (cnt < 0)return false;
	}
	return true;
}

int main() {
	cin >> n >> a >> b;
	rep(i, n) {
		cin >> h[i];
		sum += h[i];
	}
	double lb = 0, ub = sum / b + (sum%b != 0);
	rep(i, 100) {
		//cout << endl;
		//cout << lb << " " << ub << endl;
		double mid = (ub + lb) / 2;
		if (C(mid))ub = mid;
		else lb = mid;
	}
	//cout << ub << lb << endl;
	cout << (ll)(ub + 0.5) << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define forn(n1,n2) for(ll i=n1;i<n2;i++)
#define w(t) ll t;cin>>t;while(t--)
#define en "\n"
#define mod 1e6+3
#define f first
# define s second
using namespace std;
ll i,n,m,x,y,z,j,k,l,mn=LLONG_MAX,mx=0,c,a[100005],r,cnt=0,sum=0;
string str;char ch;set<ll>s;map<ll,ll>mp;
vector<vector<ll>>g;
vector<ll>v;
void swap(int *xp, int *yp)  
{  
    int temp = *xp;  
    *xp = *yp;  
    *yp = temp;  
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>str;ll len=str.size();
    forn(0,len)
    {sum+=str[i]-48;}
    sum%9==0?cout<<"Yes":cout<<"No";
    return 0;
}

Measured memory_bytes: 3736
#include <iostream>
using namespace std;
int main()
{
    int A,B,X;
    cin >> A>>B>>X;
    if (A > X ){
     cout << "NO"<<endl;   }
    else if (A+B< X ) {
      cout << "NO"<<endl;    }
    else  {
            cout << "YES"<<endl;
    }
    return 0;
}

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

typedef long long LL;

const double PI = acos(-1.0);

int n, m;

int work() {
    scanf("%d%d", &n, &m);
    if (n % 2 == 1) {
        for (int i = 1; i <= m; ++i) {
            printf("%d %d\n", i, n-i);
        }
    } else if (n % 4 == 2) {
        for (int i = 1; i <= m; ++i) {
            if (i <= n/4) printf("%d %d\n", i+1, n/2+1-i);
            else printf("%d %d\n", i+n/4+1, n*5/4+1-i);
        }
    } else {
        for (int i = 1; i <= m; ++i) {
            if (i <= n/4) printf("%d %d\n", i+1, n/2+2-i);
            else printf("%d %d\n", i+n/4+1, n*5/4+1-i);
        }
    }

    return 0;
}

int main() {
    work();
    //while (~scanf("%d", &n)) work();
    //scanf("%d", &T); while (T--) work();

    return 0;
}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    char x, y; cin >> x >> y;

    if (x > y) {
        puts(">");
    } else if (x == y) {
        puts("=");
    } else {
        puts("<");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
	int a, b;
	cin >> a >> b;
	if (b % a == 0) {
		cout << (a + b) << endl;
	} else {
		cout << (b - a) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} 

#include <boost/multiprecision/integer.hpp>

#define MAX 300000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

i64 n, a, b; cin >> n >> a >> b;

COMinit();

i64 ans = boost::multiprecision::powm((i64)2, n, MOD);
(ans -= 1) %= MOD;
i64 coma = finv[a], comb = finv[b];
rep(i, 0, a) (coma *= (n - i)) %= MOD;
rep(i, 0, b) (comb *= (n - i)) %= MOD;

(ans -= coma + comb) %= MOD;

cout << (ans + MOD) % MOD << "\n";
return 0;
}
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    bool good[n];
    fill(good, good + n, true);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if(h[a] >= h[b]) good[b] = false;
        if(h[b] >= h[a]) good[a] = false;
    }
    int ans = 0;
    rep(i, n) ans += good[i];
    cout << ans << endl;
}

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

int main(){
  int a;
  cin>>a;
  int s,result[a];
  for(int i=0;i<a;i++){
    result[i]=0;
  }
  for(int i=1;i<a;i++){
    cin>>s;
    result[s-1]+=1;
  }
  for(int i=0;i<a;i++){
    cout<<result[i]<<endl;
  }
}

Measured memory_bytes: 4372
// グラフ

#include <algorithm>
#include <array>
#include <bitset>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr int INF = 1000000000 + 8;

class Graph {
   private:
    struct edge {
        int to;
        int cost;
        edge(int i, int c = 1) : to(i), cost(c) {}
    };
    vector<vector<edge>> edges;
    vector<int> dists;

   public:
    Graph(int n) { edges.resize(n); };
    int size() const { return edges.size(); };
    int countEdge() const {
        int count = 0;
        for (auto &&i : edges)
            for (auto &&j : i) count++;
        return count;
    }
    void addDirectedEdge(int from, int to, int cost = 1) {
        edges[from].push_back(edge(to, cost));
    }
    void addEdge(int from, int to, int cost = 1) {
        addDirectedEdge(from, to, cost);
        addDirectedEdge(to, from, cost);
    }
    // 頂点sからの最短距離更新
    void dijkstrta(int s) {
        dists.assign(size(), INF);
        priority_queue<P, vector<P>, greater<P>> pq;
        pq.push({0, s});
        dists[s] = 0;

        while (!pq.empty()) {
            // 仮の最短距離と頂点の集合のうち、最短距離が最小の頂点を「最短距離が確定した頂点」とする
            int p = pq.top().second, p_dists = pq.top().first;
            pq.pop();
            // ある経路で仮の最短距離と頂点の集合に追加されたが、別の経路で「最短距離が確定した頂点」は更新しない
            if (dists[p] < p_dists) continue;

            // 「最短距離が確定した頂点」と隣接した頂点の最短距離を更新する
            for (auto &&edge : edges[p]) {
                const int np = edge.to;
                const int cost = edge.cost;
                if (dists[np] > dists[p] + cost) {
                    dists[np] = dists[p] + cost;
                    // 仮の最短距離と頂点の集合に追加する
                    pq.push({dists[np], np});
                }
            }
        }
    }
    int distance(int i) const { return dists[i]; }
    // rから辿りつけない辺を削除する
};

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

    int n, x, y;
    cin >> n >> x >> y;

    Graph g(n);
    for (int i = 1; i < n; i++) {
        g.addEdge(i, i - 1);
    }
    g.addEdge(x - 1, y - 1);

    // counts_dist_pair[d]: 距離がdの組(i,j)の数
    vector<int> counts_dist_pair(n);

    for (int i = 0; i < n; i++) {
        g.dijkstrta(i);
        for (int j = i + 1; j < n; j++) {
            const int d = g.distance(j);
            counts_dist_pair[d]++;
        }
    }

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[100010];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a[i];
	}
	if(m==1){
		cout<<0<<endl;
		return 0;
	}
	sort(a,a+m);
	vector<int> v;
	for(int i=1;i<m;i++){
		v.push_back(a[i]-a[i-1]);
	}
	sort(v.rbegin(),v.rend());
	int cnt=0;
	for(int i=n-1;i<v.size();i++){
		cnt+=v[i];
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll a, v; cin >> a >> v;
  ll b, w; cin >> b >> w;
  ll t; cin >> t;
  ll diff = abs(a - b), x = v - w;
  if(x <= 0) {
    cout << "NO\n";
  } else if(diff / x < t || (diff / x == t && diff % x == 0)) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val s = sc.next
  val t = sc.next
  
  val a = sc.nextInt
  val b = sc.nextInt
  
  val u = sc.next
  
  val ss = if(u == s) a - 1 else a
  val tt = if(u == t) b - 1 else b
  
  val res = s"$ss $tt"
  println(res)
}


Measured memory_bytes: 55436
//min cost of combining a bianry tree
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e18+5;
const int maxm = 405;
int dp[maxm][maxm];
int sum(int l, int r, vector<int> &a){
    int s = 0;
    for(int i = l; i <= r; i++) s += a[i];
    return s;
}
int32_t main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin>>a[i];
    //dp[i][j] = min cost of combining the interval i,j
    for(int l = n-1; l >= 0; l--){
        for(int r = l; r < n; r++){
            if(l == r) dp[l][r] = 0;
            else{
                int s = sum(l,r,a);
                dp[l][r] = INF;
                for(int i = l; i < r; i++){
                    dp[l][r] = min(dp[l][r],dp[l][i]+dp[i+1][r]+s);
                }
            }
        }
    }
    cout<<dp[0][n-1];

}

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

int s[30][5];

P operator+(P a, int d) {
	rep(i, d) {
		if (!~s[a.first][a.second + 1]) {
			a.first++; a.second = 0;
		}
		else a.second++;
	}
	return a;
}
int main() {
	int m;
	while (scanf("%d%*c", &m), m) {
		vector<P>v;
		rep(i, m) {
			memset(s, -1, sizeof(s));
			string S; getline(cin, S);
			stringstream buf(S);
			int id; buf >> id;
			int f = 1; bool b = 0;
			while (f <= 9) {
				buf >> s[f][b];
				if (s[f][b] == 10) {
					f++; b = 0;
				}
				else {
					if (b)f++;
					b = !b;
				}
			}
			buf >> s[10][0] >> s[10][1];
			if (s[10][0] == 10 || s[10][1] == 10 || s[10][0] + s[10][1] == 10)buf >> s[10][2];
			P p(1, 0);
			while (p.first <= 9) {
				if (!p.second&&s[p.first][p.second] == 10) {
					P a = p + 1, b = p + 2;
					s[p.first][p.second] += s[a.first][a.second] + s[b.first][b.second];
				}
				if (p.second&& s[p.first][p.second - 1] + s[p.first][p.second] == 10) {
					P a = p + 1;
					s[p.first][p.second] += s[a.first][a.second];
				}
				p = p + 1;
			}
			int cnt = 0;
			for (int i = 1; i <= 10; i++)rep(j, 3) {
				if (~s[i][j])cnt += s[i][j];
			}
			v.push_back(P(cnt, id));
		}
		sort(v.begin(), v.end(), [](P a, P b) {
			if (a.first != b.first)return a.first > b.first;
			return a.second < b.second;
		});
		for (auto p : v) {
			printf("%d %d\n", p.second, p.first);
		}
	}
}

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

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

    a = s%100;     // xxaa
    b = (s-a)/100; // bbxx

    if(a>=1 && a<= 12){
        if(b>=1 && b<= 12){
            cout << "AMBIGUOUS" << endl;
        }
        else{
            cout << "YYMM" << endl;
        }
    }
    else{
        if(b>=1 && b<= 12){
            cout << "MMYY" << endl;
        }
        else{
            cout << "NA" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int A,B;
  cin>>A>>B;
  if(A==1&&B==2||A==2&&B==1)
  cout<<3;
  if(A==3&&B==2||A==2&&B==3)
  cout<<1;
  if(A==1&&B==3||A==3&&B==1)
  cout<<2;
    return 0;
}


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

int main(){
  int K,X;
  cin >> K >> X;
  for(int i=1-K;i<=K-1;i++){
    cout << X+i;
    if(i<K-1){
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}

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

long long ks(int N, int W) {
    long long w[N+1],v[N+1];
    long long valor[N+1][W+1];


    for(int i=1;i<=N;i++){
        cin >> w[i] >> v[i];
    }

    for(int i=0;i<=N;i++){
        for(int j=0;j<=W;j++){
            if( i==0 or j==0 )
                valor[i][j]=0;  
            else if( w[i] <= j ){
                valor[i][j] = max(v[i] + valor[i-1][j-w[i]],valor[i-1][j]);
            } 
            else if( w[i]>j ){
                valor[i][j] = valor[i-1][j];
            }     
        }   
    }

    return valor[N][W];

}

int main() {
    long long N, W;

    cin >> N >> W;

    cout << ks(N,W) << endl;
}

Measured memory_bytes: 79104
# coding: utf-8
# Your code here!

while True:
   min = 1000
   max = 0
   sum = 0
   
   n = int(input())
   if n == 0:
      break
   for i in range(n):
      s = int(input())
      if s < min:
         min = s
      if s > max:
         max = s
      sum += s
   print((sum - min - max) // (n - 2))


Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define ll long long;
#define dbg(x) cout<<#x<<"--------------"<<x<<endl;
#define dl cout<<"LINE"<<__LINE__<<endl;
using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int k;int a[33]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cin>>k;
	cout<<a[k-1]<<endl;
	
	
	
		
	return 0;
}


Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
INf=float('inf')

Acc=[0]*(n+1)
for i in range(1,n+1):
  Acc[i]=(Acc[i-1]+A[i-1])%mod

ans=0  
for i in range(n):
  s=A[i]*(Acc[n]-Acc[i+1])
  ans+=s%mod

print(ans%mod)

Measured memory_bytes: 105228
if __name__ == "__main__":

    # 入力取得
    d, g = map(int, input().split())

    p = [0]*d
    c = [0]*d
    for i in range(d):
        p[i], c[i] = map(int, input().split())

    result = 99999999

    # 処理
    # ビット全探索(0:一問も解かない、1:全問解く)
    for i in range(1 << d):

        now_answer_count = 0
        now_point = 0

        # まず、全問解く問題を解いた場合の回答数と点数を取得。
        for j in range(d):
            # 全問解く場合
            # 数値 × 文字列 のパターンじゃない場合、判定条件は「i & 1 << j」でＯＫ。
            # この場合は数値 × list。
            if i & 1 << j:
                # 加算する
                # 回答数を加算
                now_answer_count += p[j]
                # 点数を加算
                now_point += p[j] * (j+1) * 100
                # コンプリートポイントを加算
                now_point += c[j]

        # print("--全問回答完了時--")
        # print(bin(i))
        # print("回答数:" + str(now_answer_count))
        # print("点数:" + str(now_point))

        # 2020/03/30 反省点
        # テストパターンb6だけ不正解。
        # 全ての問題に回答する場合の考慮が不足していた。
        # 以下のコードで対応する。
        if now_point >= g:
            result = min(result, now_answer_count)

        # 次に、途中まで回答する問題を回答した場合の検証。
        j = 0
        for j in range(d):

            # print("--一部回答シュミレーション--" + str(j))
            # 全問解く場合(何もしない)
            if i & 1 << j:
                pass
            # 一問も解かない場合
            # Ｘ問回答したらどうなるか？をシュミレーションする。
            else:
                for k in range(p[j] + 1):
                    # print("回答数:" + str(k))
                    # print("加算点数:" + str(100*(j+1)*k))
                    work_now_point = 100*(j+1)*k

                    # 点数が必要点に達した場合
                    if now_point + work_now_point >= g:
                        # print("点数が足りた:")
                        # print("点数が足りた:回答数：" + str(now_answer_count + k))
                        # 回答数を更新する。
                        result = min(result, now_answer_count + k)

    print(result)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>

using namespace std;

const int maxn = 100 + 10;

int main()
{
    int A[maxn];
    int n;
    while (scanf("%d",&n)!= EOF){
        int cot = 0 ;
        for (int i = 1 ; i <= n ; i ++){
            cin >> A[i];
        }
        for (int i = 1 ; i <= n ; i ++){
            int minA = A[i];
            int minj = i;
            for (int j = i + 1 ; j <= n ; j ++){
                if (A[j] < minA){
                    minA = A[j];
                    minj = j;
                }
            }
            if (minj != i){
                cot ++;
                int t = A[i];
                A[i] = A[minj];
                A[minj] = t;
            }
        }
        for (int i = 1 ; i <= n ; i ++){
            cout << A[i];
            if (i != n)
                cout << " ";
        }
        cout << endl;
        cout << cot << endl;
    }
    return 0;
}



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

int main() {
    int N,M,K;
    cin >> N >> M >> K;
    for(int i=0; i<=M; i++) {
        for(int j=0; j<=N; j++) {
            if(i*N + j * (M-2*i) == K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256