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

namespace AtCoder
{
    class Program
    {
        static List<List<char>> squares;

        static void Main(string[] args)
        {
            //[summary]B - Two Switches
            var lines = ReadLines<int>(1).ToList();
            int a = lines[0][0];
            int b = lines[0][1];
            int c = lines[0][2];
            int d = lines[0][3];

            int startTime;
            int endTime;

            if (a > c)
            {
                startTime = a;
            }
            else
            {
                startTime = c;
            }

            if (b > d)
            {
                endTime = d;
            }
            else
            {
                endTime = b;
            }

            int pushedTime = 0;

            if (endTime - startTime > 0)
            {
                pushedTime = endTime - startTime;
            }

            Console.WriteLine(pushedTime);
        }
                               
        static IEnumerable<List<T>> ReadLines<T>(int count = 0, char separator = ' ')
        {
            //[summary]コンソールの値を読み込んで、List<T>のコレクションを返却

            //読み込む行数が未指定のときは、1行目の値を"count"とみなす
            if (count == 0)
            {
                string line = Console.ReadLine().TrimEnd();
                count = int.Parse(line);
            }

            for (int i = 0; i < count; i++)
            {
                //コンソールを1行読み込み
                string line = Console.ReadLine().TrimEnd();

                //char型のときは1文字ずつに分割
                if (typeof(T) == typeof(char))
                {
                    var list = line.ToCharArray().ToList();
                    yield return (List<T>)(object)list;
                }
                else
                {
                    //読み込んだ値を"separator"で区切る
                    var list = line.Split(separator).ToList();

                    //int型のときは数値に変換
                    if (typeof(T) == typeof(int))
                    {
                        var numbers = list.ConvertAll(int.Parse);
                        yield return (List<T>)(object)numbers;
                    }
                    else
                    {
                        yield return (List<T>)(object)list;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 13268
/*================================================
# ~  file:ABC155_B.cpp
# ~~ date:2020-02-16
# ~~~author: SoMnus_L
#        |everybody finds love,in the end|
#   人の運命か,人の希望は悲しみにつづられているね
=================================================*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N=1e6+10;
using namespace std;
typedef pair<int,int>PII;
int n;
int t;
int main(){
 ios::sync_with_stdio(false);
 cin>>n;
 while(n--){
 cin>>t;
 if(t%2==0 && t%3!=0 && t%5!=0){
 cout<<"DENIED"<<endl;
 return 0;
 }
 }
 cout<<"APPROVED"<<endl;
  return 0;
}

Measured memory_bytes: 256
import itertools

N = int(input())

all_list = list(itertools.product([0,1], repeat=N))

xy_list =[]

for i in range(N):
    for j in range(int(input())):
        x, y = map(int, input().split())
        xy_list.append((i+1,x,y))

#print(xy_list)

num_ok = 0
for i in all_list:
    #どの人の証言なのか
    flag = True

    for j in xy_list:
        if i[j[0]-1] == 1:
            if i[j[1]-1] != j[2]:
                flag = False        
    if flag == True:
        if num_ok < i.count(1):
            num_ok = i.count(1)


print(num_ok)


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;cin >> a >> b;
	if(a==2 || b==2) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    static int[][] dp;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int r = sc.nextInt();
		ArrayDeque<Integer> deq = new ArrayDeque<>();
		for (int i = 0; i < r; i++) {
		    deq.add(sc.nextInt() - 1);
		}
		dp = new int[n][n];
		for (int i = 0; i < n; i++) {
		    Arrays.fill(dp[i], Integer.MAX_VALUE / 10);
		    dp[i][i] = 0;
		}
		for (int i = 0; i < m; i++) {
		    int a = sc.nextInt() - 1;
		    int b = sc.nextInt() - 1;
		    int c = sc.nextInt();
		    dp[a][b] = c;
		    dp[b][a] = c;
		}
		for (int i = 0; i < n; i++) {
		    for (int j = 0; j < n; j++) {
		        for (int k = 0; k < n; k++) {
		            dp[j][k] = Math.min(dp[j][k], dp[j][i] + dp[i][k]);
		        }
		    }
		}
		long min = Long.MAX_VALUE;
		for (int i = 0; i < r; i++) {
		    int x = deq.poll();
		    min = Math.min(min, search(x, deq));
		    deq.add(x);
		}
        System.out.println(min);
   }
   
   static long search(int idx, ArrayDeque<Integer> deq) {
       if (deq.size() == 1) {
           return dp[idx][deq.peek()];
       }
       int size = deq.size();
       long min = Long.MAX_VALUE;
       for (int i = 0; i < size; i++) {
           int x = deq.poll();
           min = Math.min(min, dp[idx][x] + search(x, deq));
           deq.add(x);
       }
       return min;
   }
}




Measured memory_bytes: 47508
#include <stdio.h>
int main(void){
  int line[30];
  int i,w,n;
  int a[30],b[30];
  int tmp;
  scanf("%d",&w);
  for(i=0;i<w;i++){
    line[i]=i+1;
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d,%d",&a[i],&b[i]);
  }
  for(i=0;i<n;i++){
    tmp=line[a[i]-1];
    line[a[i]-1]=line[b[i]-1];
    line[b[i]-1]=tmp;
  }
  for(i=0;i<w;i++){
    printf("%d\n",line[i]);
  }
  return(0);
}

Measured memory_bytes: 0
/* Manish Pant - insider_pants */

#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
    #include "debug.h"
#endif

#define F first
#define S second
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main()
{
    fast();
    ll n; cin >> n;
    map<int, int> m;
    ll temp = n;
    for(ll i = 2; i * i <= temp; i++)
    {
        while(n % i == 0)
        {
            m[i]++;
            n /= i;
        }
    }
    if(n > 1)
        m[n]++;

    int ans = 0;    
    for(auto &i : m)
    {
        ll c = 1;
        while((c * (c + 1) / 2) <= i.S)
            c++;
        ans += c - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
N, M = map(int, input().split())
from  bisect import bisect_right
inf = float("inf")
A = sorted(list(map(int, input().split())))
BC = sorted([tuple(map(int, input().split())) for _ in range(M)], key=lambda x: -x[1])
cnt = 0
L, R = 0, N
I = []
for b, c in BC:
    idx = bisect_right(A, c, lo=L, hi=R)
    idx -= L
    if idx == 0:
        I.append((L, R, 0, c))
        break
    elif idx < b:
        I.append((L+idx, R, idx, c))
        break
    elif idx >= b:
        I.append((L+idx, R, b, c))
        tmp = L
        L += b
        R = tmp + idx     

    cnt += 1
    if cnt == M:
        I.append((L, R, 0, c))

S = [0]
for a in A:
    S.append(a+S[-1])
ans = 0
for L, R, x, c in I:
    ans += S[R] - S[L] + x*c

print(ans)




Measured memory_bytes: 91160
from bisect import bisect
GRADE = ["AAA","AA","A","B","C","D","E","NA"]
_500M = [35.5,37.5,40.0,43.0,50.0,55.0,70.0]
_1000M = [71.0,77.0,83.0,89.0,105.0,116.0,148.0]

while True:
    try:
        a,b = map(float,raw_input().split())
    except:
        break
    print GRADE[max(bisect(_500M,a),bisect(_1000M,b))]

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

long int comb[110][10] = {0};

int main () 
{
    for (int hight = 1; hight < 101; hight++) 
    {
        
        for (int thickness = 2; thickness < 11; thickness++) 
        {
            if ( hight < thickness )
            {
                comb[hight][thickness] = (hight + 1) / 2;
            }
            else if ( hight <= thickness + 1 )
            {
                if (hight == 2) comb[2][2] = 2;
                else
                {
                    comb[hight][thickness] = 2 + comb[hight - 2][thickness];
                }
            }
            else // thickness + 1 < hight
            {
                comb[hight][thickness] = 2 + comb[hight - 2][thickness] + comb[hight - thickness - 1][thickness];
            }
        }
        
    }
    
    int l, k;
    std::cin >> l >> k;
    
    std::cout << comb[l][k] << std::endl;
    
    return 0;
}


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

ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

int n;
ll a[200200];
ll fen1[200200],fen2[200200];
pair<ll,ll> s1[200200],s2[200200];

int main(){
	#ifdef LZT
	freopen("in","r",stdin);
	#endif
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	ll pos=1,sum=a[1],sum2=a[1];
	for(int i=2;i<=n-2;i++){
		sum2+=a[i];
		while(pos<i){
			ll nwsum=sum+a[pos+1];
			//cout<<sum2<<' '<<sum<<' '<<nwsum<<endl;
			if(abs(sum2-sum-sum)>abs(sum2-nwsum-nwsum)){
				pos++;
				sum=nwsum;
			}
			else break;
		}
		//cout<<pos<<endl;
		if(pos==i) sum-=a[pos],pos--;
		fen1[i]=pos;
		s1[i].first=sum;
		s1[i].second=sum2-sum;
		//cout<<i<<' '<<sum<<' '<<sum2-sum<<endl;
	}
	pos=n,sum=a[n],sum2=a[n];
	for(int i=n-1;i>2;i--){
		sum2+=a[i];
		while(pos>i){
			ll nwsum=sum+a[pos-1];
			if(abs(sum2-sum-sum)>abs(sum2-nwsum-nwsum)){
				pos--;
				sum=nwsum;
			}
			else break;
		}
		if(pos==i) sum-=a[pos],pos++;
		fen2[i]=pos;
		s2[i].first=sum;
		s2[i].second=sum2-sum;
		//cout<<i<<' '<<sum<<' '<<sum2-sum<<endl;
	}
	ll ans=1e18;
	for(int i=2;i<=n-2;i++){
		ll S1=s1[i].first,S2=s1[i].second,S3=s2[i+1].first,S4=s2[i+1].second;
		ans=min(ans,max(max(max(S1,S2),S3),S4)-min(min(min(S1,S2),S3),S4));
	}
	printf("%lld\n",ans);
	return 0;
}

/*
5
3 2 4 1 2
*/

Measured memory_bytes: 11136
#include<stdio.h>

int n,S[2000];

int solve(int i,int m){
  int res;
  if(m == 0)
    return 1;
  if(i >= n)
    return 0;
  res = solve(i + 1,m) || solve(i + 1,m - S[i]);
  return res;
  }


int main(){
  int i,k,q;

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(solve(0,k) == 1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2108
n,a,b,c,d=map(int,input().split())
s=input()
if c<d:
  if '##' in s[a-1:d]:
    print('No')
  else:
    print('Yes')
else:
  if '...' in s[b-2:d+1]:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 3572
N = int(raw_input())
A = map(long, raw_input().split())

minus_count = 0
min_abs = 10 ** 9
sum = 0
for a in A:
    if a < 0:
        minus_count += 1
    abs_a = abs(a)
    if abs_a < min_abs:
        min_abs = abs_a
    sum += abs_a

if minus_count % 2 > 0:
    sum -= 2*min_abs

print sum

Measured memory_bytes: 12088
import math
from collections import deque
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return map(int, input().split())
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

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

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

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

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

n,m = map(int, input().split())
puted = [True]*(n+1)

ab = [[] for i in range(n+1)]
for i in range(m):
	a,b = map(int, input().split())
	ab[a].append(b)
	ab[b].append(a)

q = deque([1])
flg = [-1]*n
flg[0] = 0

while q:
	item = q.popleft()
	for i in ab[item]:
		if puted[i]:
			flg[i-1]=item
			q.append(i)
			puted[i]=False

if -1 in flg:
	print("No")
	exit()

print("Yes")
for i in range(1,len(flg)):
	print(flg[i])


Measured memory_bytes: 34952
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int x=stoi(s+t);
  string ans="No";
    for(int i=0; i<400; i++){
        if(x==i*i) ans="Yes";
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3612
# https://beta.atcoder.jp/contests/abc112/tasks/abc112_c

N = gets.to_i
XYH = $<.read.split(/\n/).map{|i|i.split.map{|j|j.to_i}}

@memo = Array.new(101).map{Array.new(101).map{Hash.new}}
def check(cx, cy, ch)
  m = @memo[cy][cx][ch.to_s]
  return m unless m.nil?
  XYH.each do |x, y, h|
    if [ch - (x-cx).abs - (y-cy).abs, 0].max != h
      return @memo[cy][cx][ch.to_s] = false
    end
  end
  @memo[cy][cx][ch.to_s] = true
end

(0..100).each do |cy|
  (0..100).each do |cx|
    XYH.each do |i|
      ch = (i[0]-cx).abs + (i[1]-cy).abs + i[2]
      break if ch < 0
      if check(cx, cy, ch)
        puts "#{cx} #{cy} #{ch}"
        exit 
      end
    end
  end
end
puts '0 0 0'



Measured memory_bytes: 77820
import java.io.*;
import java.util.*;
public class Main {
public static void main (String[]args) {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try {
   
    int N = Integer.parseInt(br.readLine());
    String res = "";

    if((N%10 == 2)||(N%10 == 4)||(N%10 == 5)||(N%10 == 7)||(N%10 == 9)) {
        res = "hon";
    }
    else if((N%10 == 0) || (N%10 == 1) || (N%10 == 6) || (N%10==8)) {
        res = "pon";
    } 
    else{
        res = "bon";
    }
    System.out.println(res);
 


       
    }catch (Exception e) {
       }
       }
   }

Measured memory_bytes: 32612
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    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();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const int maxn=150;
int a[maxn][maxn];
int b[maxn],n,vis[maxn][maxn],mp[maxn];
int main()
{
	for(int i=1;i<=3;i++) for(int j=1;j<=3;j++) read(a[i][j]);
	cin>>n;
	for(int i=1;i<=n;i++) read(b[i]),mp[b[i]]=1;
	for(int i=1;i<=3;i++) for(int j=1;j<=3;j++) if(mp[a[i][j]]) vis[i][j]=1;
	int flag=0;
	for(int i=1;i<=3;i++) if(vis[i][1]&&vis[i][2]&&vis[i][3]) flag=1;
	for(int i=1;i<=3;i++) if(vis[1][i]&&vis[2][i]&&vis[3][i]) flag=1;
	if(vis[1][1]&&vis[2][2]&&vis[3][3]) flag=1;
	if(vis[1][3]&&vis[2][2]&&vis[3][1]) flag=1;
	if(flag) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class key, class value, class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

template<class key, class value, class cmp = std::less_equal<key>>
using ordered_multimap = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;

vector <vector<ll>> graph;
vector <vector<ll>> dp;
ll mod = 1e9+7;
// 0 is white 1 is black
void dfs(ll v,ll p){
	for (int z=0;z<graph[v].size();z++){
		if (graph[v][z] == p) continue;
		dfs(graph[v][z],v);
		dp[v][0] *= (dp[graph[v][z]][1]+dp[graph[v][z]][0]);
		dp[v][1] *= dp[graph[v][z]][0];
		dp[v][0] %= mod;
		dp[v][1] %= mod;
	}
}

int main(){
	ll n;
	cin >> n;
	graph.resize(n+1);
	dp.resize(n+1,vector<ll>(2,1));
	for (int z=0;z<n-1;z++){
		ll a,b;
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	dfs(1,0);
	cout << (dp[1][0]+dp[1][1])%mod << endl;
	cin >> n;
}



Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int K;
    cin >> K;
    if(7%K==0){
        cout << 1 << endl;
        return 0;
    }
    int num=7%K;
    int cnt = 1;
    while(true){
        if(cnt>K) break;
        cnt++;
        num=(num*10+7)%K;
        if(num==0){
            cout << cnt << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
const int INF=1e9+5;
int main()
{
    int n,k;
    cin>>n;
    cin>>k;
    vi h(n);
    for(ll i=0;i<n;i++)
    {
        cin>>h[i];
    }
    vi dp(n,INF);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n) dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"

long long int calc(const int type, const long long int l, const long long r) {
	if (type == 0) {
		return l + r;
	}
	else if (type == 1) {
		return l - r;

	}
	else {
		return l*r;
	}
}
long long int calc1(const char type, const long long int l, const long long r) {
	if (type == '+') {
		return calc(0, l, r);
	}
	else if (type == '-') {
		return calc(1, l, r);

	}
	else {
		return calc(2, l, r);
	}
}
int a = 0;
string st;
map<char,int>mp;
long long int getform0();
long long int getnum() {
	long long int num = 0;
	if (st[a] == '(') {
		a++;
		num= getform0();
		a++;
	}
	else {
		while (isdigit(st[a])) {
			num = num * 10 + st[a] - '0';
			a++;
		}
	}
	return num;
	
}
long long int getform2() {
	long long int ans;

	
	ans = getnum();
	
	while (a != st.size()) {
		if (mp[st[a]] == 1) {
			return ans;

		}
		else if (mp[st[a]] == 2) {
			return ans;
		}
		else if (mp[st[a]] == 3) {
			const char type = st[a];
			a++;
			ans = calc1(type, ans, getnum());
		}
		else if (st[a] == ')') {
			return ans;
		}
		else {
			assert(false);
		}
	}
	return ans;
}

long long int getform1() {
	long long int ans;

		ans = getnum();
	
	while (a != st.size()) {
		if (mp[st[a]] == 1) {
			return ans;

		}
		else if (mp[st[a]] == 2) {
			const char type = st[a];
			a++;
			ans = calc1(type, ans, getform2());
		}
		else if (mp[st[a]] == 3) {
			const char type = st[a];
			a++;
			ans = calc1(type, ans, getnum());
		}
		else if (st[a] == ')') {
			return ans;
		}
		else {
			assert(false);
		}
	}
	return ans;
}

long long int getform0(){
	long long int ans;
	
	ans = getnum();
	
	while (a != st.size()) {
		if (mp[st[a]] == 1) {
			const char type = st[a];
			a++;
				ans = calc1(type, ans, getform1());
			
		}
		else if(mp[st[a]] == 2){
			const char type = st[a];
			a++;
			ans = calc1(type, ans, getform2());
		}
		else if (mp[st[a]] == 3) {
			const char type = st[a];
			a++;
			ans = calc1(type, ans, getnum());
		}
		else if(st[a]==')'){
			return ans;
		}
		else {
			assert(false);
		}
	}
	return ans;
}
int main() {
	cin >> st;
	long long int ans = -9223372036854775807;
	for (mp['+'] = 1; mp['+'] < 4; ++mp['+']) {
		for (mp['-'] = 1; mp['-'] < 4; ++mp['-']) {
			for (mp['*'] = 1; mp['*'] < 4; ++mp['*']) {
				a = 0;
				ans = max(ans, getform0());
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3160
fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(java.util.Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: java.util.Scanner, pw: java.io.PrintWriter) {
        val S = sc.next().toCharArray() + CharArray(1) { 'R' }
        val N = S.count() - 1
        val ans = mutableListOf<Int>()
        var nr = 0
        var nl = 0
        var prev = 'R'
        val count = mutableListOf<Pair<Int, Int>>()
        for (i in 0..N) {
            if (prev == 'L' && S[i] == 'R') {
                count.add(Pair(nr, nl))
                nr = 0
                nl = 0
            }
            if (S[i] == 'R') nr++
            if (S[i] == 'L') nl++
            prev = S[i]
        }
        count.forEach {
            val nr = it.first
            val nl = it.second
            repeat(nr - 1) {
                ans += 0
            }
            var a = (nl + nr) / 2
            if (nr % 2 == 1 && nl % 2 == 0) {
                a += 1
            }
            ans += a
            ans += (nl + nr) - a
            repeat(nl - 1) {
                ans += 0
            }
        }
        pw.println(ans.joinToString(" "))
    }
}


Measured memory_bytes: 41520
N,M,X=map(int,input().split())
A=[]
C=[]
for i in range(N):
    tmp=list(map(int,input().split()))
    C.append(tmp[0])
    A.append(tmp[1:])

INF=float("INF")
min_cost=INF

def dfs(i,cost,learn):
    if i==N:
        if min(learn)>=X:
            return cost
        else:
            return INF
    else:
        new_learn=[x+y for (x,y) in zip(A[i],learn)]
        cost=min(dfs(i+1,cost,learn),dfs(i+1,cost+C[i],new_learn))
        return cost

min_cost=dfs(0,0,[0]*M)

if min_cost==INF:
    print(-1)
else:
    print(min_cost)


Measured memory_bytes: 9156
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

int f(int n) {
	if (n % 2 == 0) {
		return n / 2;
	}
	else {
		return 3 * n + 1;
	}
}

int main() {
	int s;
	cin >> s;
	int a[1000000] = {};
	int tmp = s;
	int ans = 1;

	while (true) {
		
		if (a[tmp] == 1) {
			ANS(ans);
			return 0;
		}
		a[tmp] = 1;
		tmp = f(tmp);
		ans++;
	}


	return 0;
}


Measured memory_bytes: 4096
#include <cstdio>
#include <string>
#include<iostream>

using namespace std;

int main(void) {
	

	string s;
	cin >> s;

	string ans;
	for (int i = 0; i < 12; i++) {
		ans += s[i];
		if (i == 3)ans += ' ';
	}
	ans += '\n';
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    s = input()
    ans = [s[0]]
    for i in range(1,n):
        if s[i] == ans[-1][0]:
            ans[-1] = ans[-1]+s[i]
        else:
            ans.append(s[i])
    print(len(ans))    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 5620
//B.java
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] num = new int[3];
        int max = 0;
        for(int i=0; i<3; i++) {
            num[i] = sc.nextInt();
            if(max < num[i]) max = num[i];
        }
        int k = sc.nextInt();

        sc.close();
        double ans = Math.pow(2, k)*max + num[0] + num[1] + num[2] - max;
        System.out.println((int)ans);
    }
}

Measured memory_bytes: 20560
#include <iostream>
#include <math.h>
using namespace std;
int main(){
	int n,x;
	cin >> n;
	int count=0;
	for( int i=1 ; i<=n ; i++ ){
		cin >> x;
		int counter=0;
		if( x%2==0 && x!=2 )continue;
		for( int j=1 ; j<=sqrt(x) ; j++ ){
			if( x%j == 0 )
				counter++;
		}
		if( counter==1 )
			count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 3084
// failed to generate code
#include <bits/stdc++.h>

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

void main_(istream &cin) {
    int N;
    int g[300][300];
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++)
            cin >> g[i][j];
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                if (g[j][i] + g[i][k] < g[j][k]) {
                    cout << -1 << endl;
                    return;
                }
            }
        }
    }
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i; j < N; j++) {
            bool important = true;
            for (int k = 0; k < N; k++) {
                if (i != k && j != k && g[i][k] + g[k][j] == g[i][j]) important = false;
            }
            if (important) ans += g[i][j];
        }
    }
    cout << ans << endl;
}


int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}




Measured memory_bytes: 640
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

fn main() {
    let mut sc = Scanner::new();
    let h: usize = sc.cin();
    let w: usize = sc.cin();
    let n: usize = sc.cin();
    let x: usize = sc.cin::<usize>() - 1;
    let y: usize = sc.cin::<usize>() - 1;
    let s: Vec<char> = sc.cin::<String>().chars().collect();
    let t: Vec<char> = sc.cin::<String>().chars().collect();

    // "L"
    {
        let mut c = y;
        for i in 0..n {
            if s[i] == 'L' {
                if c == 0 {
                    put!("NO");
                    return;
                }
                c -= 1;
            }
            if t[i] == 'R' {
                if c < w - 1 {
                    c += 1;
                }
            }
        }
    }

    // "R"
    {
        let mut c = y;
        for i in 0..n {
            if s[i] == 'R' {
                if c == w - 1 {
                    put!("NO");
                    return;
                }
                c += 1;
            }
            if t[i] == 'L' {
                if c > 0 {
                    c -= 1;
                }
            }
        }
    }

    // "U"
    {
        let mut c = x;
        for i in 0..n {
            if s[i] == 'U' {
                if c == 0 {
                    put!("NO");
                    return;
                }
                c -= 1;
            }
            if t[i] == 'D' {
                if c < h - 1 {
                    c += 1;
                }
            }
        }
    }

    // "D"
    {
        let mut c = x;
        for i in 0..n {
            if s[i] == 'D' {
                if c == h - 1 {
                    put!("NO");
                    return;
                }
                c += 1;
            }
            if t[i] == 'U' {
                if c > 0 {
                    c -= 1;
                }
            }
        }
    }

    put!("YES");
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 6396
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int M=stdIn.nextInt();
		int X[]=new int[M];
		int len[]=new int[M-1];
		int z=0,max1=0;
		for(int i=0;i!=M;i++) {
			X[i]=stdIn.nextInt();//入力～
		}
		Arrays.sort(X);
		for(int i=1;i!=M;i++) {
			len[i-1]=X[i]-X[i-1];
		}//多分差を入れてる
		Arrays.sort(len);//ここで差のそーとね(多分)
		if(M>N) {
			for(int i=0;i!=M-1-(N-1);i++) {
				//M-1→渡らせるべき間
				//N-1→渡んなくてもいい間の数
				//差が小さい順にソートしてるから、最後のN-1個は渡んなくてもいい!!
				max1+=len[i];
			}
		}
		System.out.println(max1);
	}
}

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

using namespace std;

int main()
{
	string str;
	int k;
	cin >> str >> k;

	long long ans = 0;
	long long t = 0;
	long long s = 0;
	switch (k) {
	case 1:
		if (str.length() == 1) {
			cout << (str[0] - 48) << endl;
			return 0;
		}
		ans = (str.length() - 1) * 9;
		ans += (str[0] - 48);
		break;
	case 2:
		if (str.length() == 1) {
			cout << 0 << endl;
			return 0;
		}
		else if (str.length() == 2) {
			t = (str[0] - 48) * 10 + (str[1] - 48);

			for (int i = 11; i <= t; i++) {
				if (i % 10 != 0) {
					ans++;
				}
			}

			break;
		}
		ans = (str.length() - 1) * (str.length() - 2) / 2;
		ans *= 81;
		ans += (str.length() - 1) * 9 * (str[0] - 48 - 1);
		for(int i = 1; i < str.length(); i++) {
			if (str[i] != '0') {
				for (int j = i+1; j < str.length(); j++) {
					ans += 9;
				}
				ans += str[i] - 48;
				cout << ans << endl;
				return 0;
			}
			
		}
		
		break;
	case 3:
		if (str.length() == 1 || str.length() == 2) {
			cout << 0 << endl;
			return 0;
		}
		else if (str.length() == 3) {
			t = (str[0] - 48) * 100 + (str[1] - 48) * 10 + (str[2] - 48);

			for (int i = 100; i <= t; i++) {
				if (i % 10 != 0 && (i / 10) % 10 != 0) {
					ans++;
				}
			}

			break;
		}
		ans = (str.length() - 1) * (str.length() - 2) * (str.length() - 3) / 6;
		ans *= 729;
		ans += ((str.length() - 1) * (str.length() - 2) / 2) * 81 * (str[0] - 48 - 1);
		for (int i = 1; i < str.length(); i++) {
			if (str[i] != '0') {
				t = str.length() - i;
				s = i;
				break;
			}
		}

		if (t == 1) {
			cout << ans << endl;
			return 0;
		}
		else if (t == 2) {
			t = (str[str.length() - 1] - 48) * 10 + (str[str.length() - 2] - 48);

			for (int i = 11; i <= t; i++) {
				if (i % 10 != 0) {
					ans++;
				}
			}

			break;
		}
		
		ans += ((t - 1) * (t - 2) / 2) * 81;
		ans += (t - 1) * 9 * (str[s] - 48 - 1);
		for (int i = s + 1; i < str.length(); i++) {
			if (str[i] != '0') {
				for (int j = i + 1; j < str.length(); j++) {
					ans += 9;
				}
				ans += str[i] - 48;
			}
			cout << ans << endl;
			return 0;
		}

		break;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    sort(all(a));
    map<int,int> mp;
    mp[0]++;
    int cnt=0;
    rep(i,n){
        if(a[i]==0||a[i]==12){
            mp[a[i]]++;
            continue;
        }
        if(cnt%2==0){
            mp[a[i]]++;
        }
        else{
            mp[24-a[i]]++;
        }
        cnt++;
    }

    int ans=24;
    mp[24]++;
    for(auto x:mp){
        if(x.sc>=2) ans=0;
    }
    vec b;
    for(auto x:mp){
        b.pb(x.fs);
    }
    rep(i,b.size()-1){
        chmin(ans,b[i+1]-b[i]);
    }
    cout<<ans<<endl;

    
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 998244353

long long int fact[300001];
long long int factrev[300001];

void getfact(long long int n)
{
	fact[0] = 1;
	for(int i = 1; i <= n; i++){
		fact[i] = (i * fact[i - 1]) % mod;
	}
}

long long int tmp[300001][31];

void getfactrev(int n)
{
	// cout << "hey" << endl;
	for(int i = 0; i <= n; i++){
		tmp[i][0] = fact[i];
	}
	for(int i = 1; i < 31; i++){
		for(int j = 0; j <= n; j++){
			tmp[j][i] = (tmp[j][i - 1] * tmp[j][i - 1]) % mod;
		}
	}
	for(int i = 0; i <= n; i++){
		factrev[i] = 1;
		long long int rest = mod - 2;
		for(int j = 30; j >= 0; j--){
			long long int now = 1 << j;
			if(rest >= now){
				rest -= now;
				factrev[i] = (factrev[i] * tmp[i][j]) % mod;
				// cout << i << " " << rest << " " << factrev[i] << " " << tmp[i][j] << endl;
			}
		}
	}
}

long long int comb(long long int n, long long int k)
{
	// cout << "comb " << n << " " << k << endl;
	// cout << fact[n] << " " << factrev[k] << " " << factrev[n - k] << endl;
	return (fact[n] * ((factrev[k] * factrev[n - k]) % mod)) % mod;
}

int main()
{
	long long int n, a, b, k;
	cin >> n >> a >> b >> k;
	getfact(n);
	getfactrev(n);
	long long int ans = 0;
	for(long long int p = 0; p <= n && a * p <= k; p++){
		if((k - a * p) % b > 0 || (k - a * p) / b > n) continue;
		ans += (comb(n, p) * comb(n, (k - a * p) / b)) % mod;
		ans %= mod;
		// cout << p << " " << ans << endl;
	}
	cout << ans << endl;
}

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

namespace ConsoleApp1
{
    static class ATransfer
    {
        static void Main(string[] args)
        {
            var abc = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            int a = abc[0];
            int b = abc[1];
            int c = abc[2];

            int ans = c - (a - b);

            Console.WriteLine(ans < 0 ? 0 : ans);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, string> PS;

vector<ll> a, b;

ll INF = 5844674407370955161;
int main() {
  ll n, k;
  cin >> n >> k;
  REP(i, n) {
    ll p;
    cin >> p;
    if (p < 0) {
      a.pb(-1 * p);
    } else {
      b.pb(p);
    }
  }
  ll ret = INF;
  sort(b.begin(), b.end());
  sort(a.begin(), a.end());
  REP(i, b.size()) {
    if (k - i - 2 >= a.size() || k - i - 2 < 0) {
      if (i + 1 >= k)
        ret = min(ret, b[i]);
      continue;
    }
    ret = min(ret, b[i] * 2 + a[k - i - 2]);
    ret = min(ret, b[i] + a[k - i - 2] * 2);
  }
  if (a.size() >= k) {
    ret = min(ret, a[k - 1]);
  }
  cout << ret << endl;
}

Measured memory_bytes: 1656
n=int(input())
a=list(map(int,input().split()))
q=int(input())
A=[0]*(10**5+1)
for i in a:
    A[i]+=1
a_sum=sum(a)
for j in range(q):
    b,c=map(int,input().split())
    x=(c-b)*A[b]
    a_sum+=x
    A[c]=A[c]+A[b]
    A[b]=0
    print(a_sum)

Measured memory_bytes: 84604
def solve(n, s_list):
    # time O(N log(N))
    sorted_list = sorted(s_list)

    ans = 0
    key = 0
    # time O(N)
    while key < n - 1:
        group_cnt = 0
        target = sorted_list[key]
        while key < n - 1 and target == sorted_list[key + 1]:
            group_cnt += 1
            key += 1
        if group_cnt:
            ans += group_cnt * (group_cnt + 1) // 2
        key += 1

    return ans


def main():
    n = int(input())

    s_list = []
    # time O(N)
    for i in range(n):
        s = "".join(sorted(input()))
        s_list.append(s)

    ans = solve(n, s_list)
    print(ans)


main()


Measured memory_bytes: 11408
n = gets.to_i
h = gets.chomp.split.map(&:to_i).reverse
max = 0
len = 0
tmp = -0xffffffff
h.each.with_index do |hi, i|
  if hi >= tmp
    len += 1
  else
    max = [max, len].max
    len = 1
  end

  tmp = hi
end

puts [max, len].max - 1

Measured memory_bytes: 12804
#include<iostream>


using namespace std;


typedef struct struct_input
{
	//欲しい肉の量
	int niku;
	//予算
	int yosan;
	//地鶏の値段
	int didori_nedan;
	//普通の
	int normal_tori;
	//地鶏を最大で買える数
	int didori_max;
}S_input;


S_input s_input;




int main(void)
{
	while (true){
		int aizu = 0;
		int normal = 0;
	
		cin >> s_input.niku;
		if (s_input.niku == 0){
			return 0;
		}

		cin >> s_input.yosan >> s_input.didori_nedan >> s_input.normal_tori >> s_input.didori_max;

		for (int i = 0; i < s_input.didori_max; i++){
			if (s_input.didori_nedan > s_input.yosan){
				break;
			}
			s_input.yosan -= s_input.didori_nedan;
			aizu++;
		}

		normal = s_input.yosan / s_input.normal_tori;
		s_input.yosan %= s_input.normal_tori;

		if (aizu + normal >= s_input.niku && aizu >= 1){
			cout << aizu << " " << normal << endl;
			continue;
		}

		while (s_input.niku > aizu + normal){
			if (aizu <= 1){
				break;
			}
			s_input.yosan += s_input.didori_nedan;
			aizu--;

			while (s_input.yosan > s_input.normal_tori){
				s_input.yosan -= s_input.normal_tori;
				normal++;
			}
		}

		if (aizu + normal >= s_input.niku && aizu >= 1){
			cout << aizu << " " << normal << endl;
			continue;
		}
		cout << "NA" << endl;
	}

	return 0;
}

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

int main() {
  string s;
  int count = 0, countc = 0;
  cin >> s;
  for (int i=2; i<s.size()-1; i++) {
    if (isupper(s[i])) {
      count++;
      if (s[i]=='C') countc++;
    }
  }
  if (s[0]=='A' && islower(s[1]) && islower(s[s.size()-1]) && count==1 && countc==1) cout << "AC";
  else cout << "WA";
  return 0;
}

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

int main()
{
    int i=0,j,x=0,n,id=3070,sum=7,bin[33],y=8;
    cin>>n;
    n%=1000;
    if(n==0){
        printf("0\n");
        return 0;
    }
    n=1000-n;
    cout<<n<<endl;

    return 0;
}


Measured memory_bytes: 3640
using System;

namespace kozaiyApp
{
    public class C
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            string[] inputA = Console.ReadLine().Split(' ');
            int[] buka = new int[N];

            for (int i = 0; i < N - 1; i++)
            {
                int A = int.Parse(inputA[i]);
                buka[A - 1]++;
            }

            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(buka[i]);
            }
        }
    }
}


Measured memory_bytes: 42024
def max(a,b); a > b ? a : b; end
def min(a,b); a < b ? a : b; end

def extract_cycle(s, used)
  cycle = []
  u = s
  until used[u]
    used[u] = true
    cycle << u  
    u = P[u]
  end
  return cycle
end

N, K = gets.split.map(&:to_i)
P = gets.split.map(&:to_i).tap{|array| array.unshift(0) }
C = gets.split.map(&:to_i).tap{|array| array.unshift(0) }

used = Array.new(N + 1)
ans = (1 .. N).inject(-1e20) do |max_score, s|
  next max_score if used[s]
  # sを始点とする閉路を抽出
  cycle = extract_cycle(s, used)
  z = cycle.size
  
  # 閉路の各頂点から最大1周分のスコアを計算できるように事前準備
  score = Array.new(3 * z + 1, 0)
  (1 .. z * 3).each do |i|
    v = cycle[i % z]
    score[i] = score[i - 1] + C[v]
  end

  # 閉路上の任意の点 s を始点としたときの最大スコアを 
  # セグ木を使って O(N log N) で計算
  
  sz = max(0, score[z])
  k = min(K, z + K % z)
  r = (K - k) / z

  cycle_score = (0 ... z).map{|s| r * sz + score[s + 1, k].max - score[s]}.max

  max(max_score, cycle_score)
end

puts ans


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

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

    cout << (char)(a[0] - 32) << (char)(b[0] - 32) << (char)(c[0] - 32) << endl;
}


Measured memory_bytes: 256
package main

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

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	ds := make([]int, n)
	for i := 0; i < len(ds); i++ {
		ds[i] = eGetInt(scanner)
	}
	bucket := make([]int, 100+1)
	for i := 0; i < len(ds); i++ {
		bucket[ds[i]]++
	}
	sum := 0
	for i := 0; i < len(bucket); i++ {
		if bucket[i] != 0 {
			sum++
		}
	}
	fmt.Println(sum)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}

func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
  int id;
  struct node *next;
} *nodePointer;
nodePointer *stackHead;
nodePointer *queueTail;
void push(int,int);
void top(int);
void pop(int);
void init(int);
nodePointer make1node(int);
int main(void)
{
  int i;
  int n,q;
  int x1,x2,x3;
  scanf("%d",&n);
  init(n);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&x1);
      switch(x1)
        {
        case 0:
          scanf("%d%d",&x2,&x3);
          push(x2,x3);
          break;
        case 1:
          scanf("%d",&x2);
          top(x2);
          break;
        case 2:
          scanf("%d",&x2);
          pop(x2);
          break;
        }
    }
  return 0;
}
void push(int t,int x)
{
  nodePointer p=make1node(x);
  if(stackHead[t]==NULL) stackHead[t]=p;
  else
    {
      p->next=stackHead[t];
      stackHead[t]=p;
    }
}
void top(int t)
{
  if(stackHead[t]!=NULL) printf("%d\n",stackHead[t]->id);
}
void pop(int t)
{
  if(stackHead[t]!=NULL) stackHead[t]=stackHead[t]->next;
}
void init(int n)
{
  int i;
  stackHead=(nodePointer*)malloc(sizeof(nodePointer)*n);
  for(i=0;i<n;i++) stackHead[i]=NULL;
}
nodePointer make1node(int x)
{
  nodePointer p=(nodePointer)malloc(sizeof(struct node));
  p->id=x;
  p->next=NULL;
  return p;
}


Measured memory_bytes: 7984
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
   string s;
   cin>>s;
   if(s.at(s.size()-1)=='2'||s.at(s.size()-1)=='4'||s.at(s.size()-1)=='5'||s.at(s.size()-1)=='7'||s.at(0)=='9'){
       cout<<"hon"<<endl;
   }
   else{
       if(s.at(s.size()-1)=='3'){
           cout<<"bon"<<endl;
       }
       else{
           cout<<"pon"<<endl;
       }
   }
}



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

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

    int n; cin >> n;
    string s; cin >> s;

    int count = 0;
    REP(i, n)
        if (s[i] != s[i + 1]) count++;
    cout << count << '\n';
    return 0;
}


Measured memory_bytes: 512