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

int main () {
  string S;
  cin >> S;
  
  if(S[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }
  
  int c = 0;
  for (int i = 2; i <= S.size() - 2; i++) {
    if(S[i] == 'C') c++;
  }
  if(c != 1) {
    cout << "WA" << endl;
    return 0;
  }
  
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'A' || S[i] == 'C') continue;
    if((S[i] >= 'A') && (S[i] <= 'Z')) {
      cout << "WA" << endl;
      return 0;
    }
  }
  
  cout << "AC" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
	int n, P[20],i,j,k,count=0,f=0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d",& P[i]);
	}

	for (i = 0; i <= n - 3; i++) {
		f = 0;
		k = 1;
		for (j = i + 2; f==0; j++) {
			if ( (P[i + k]<P[j] && P[i + k]>P[i]) || (P[i+k]>P[j] && P[i+k]<P[i]) ) {
				count++;
			}
			f = 1;
			k++;
		}
	}

	printf("%d", count);
    return 0;
}



Measured memory_bytes: 128
#include<cstdio>
#include<vector>
#include<algorithm>

#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	vector<int> a(n);
	r(i, n) a[i] = i + 1;
	
	do{
		r(i, n)
			printf(i < n - 1 ? "%d " : "%d\n", a[i]);
	} while (next_permutation(a.begin(), a.end()));
	return 0;
}


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

string s;
int k, n;

int main() {
  cin >> s >> k;
  n = s.size();
  for (int i = 0; i < n; ++i) {
    int now = (26 - (s[i] - 'a')) % 26;
    if (k >= now) {
      k -= now;
      s[i] = 'a';
    }
    if (i == n - 1) s[i] = (s[i] - 'a' + k) % 26 + 'a';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)

ll gcd(ll a,ll b){ // 高速ユークリッド互除法
    if(a<0) a = -1*a;
    if(b<0) b = -1*b;
    if(a==0) return b;
    if(b==0) return a;
    if(a==b) return a;
    ll c;
    if(a<b){
        c = b-(b/a)*a;
        if(c<a/2) return gcd(a,c);
        else return gcd(a,c-a);
    } else{
        c = a-(a/b)*b;
        if(c<b/2) return gcd(c,b);
        else return gcd(c-b,b);
    }
}

ll binary_method(ll a,ll b,ll m){
    // a^b mod m
    if(b==0) return 1;
    ll ans=1;
    ll ori_b = b;
    ll b_length = 0;
    while(b!=0){
        b = b/2;
        b_length++;
    }

    for(int i=b_length-1;i>-1;i--){
        if((ori_b>>i)&1) ans = (((ans * a) % m) * ans)%m;
        else ans = (ans * ans) % m;
        // cout<<ans<<endl;
    }
    return ans;
}

ll inv(ll a, ll m){
    // a^{-1} mod m, m : 素数
    // cout<<a<<" "<<binary_method(a, m-1, m)<<endl;
    return binary_method(a, m-2, m);
}

ll factorial(ll a, ll m){
    // a! mod m
    if(a<0){
        std::cout<<"factorial error. negative input"<<std::endl;
        return 0;
    }
    ll ans=1;
    for(int i=1;i<a+1;i++){
        ans = (ans * i) % m;
    }
    return ans;
}

ll comb(ll n,ll a,ll m){
    ll bunbo = 1;
    ll bunshi = 1;
    for(ll i=0;i<a;i++){
        bunbo = (bunbo * (n-i))%mod;
        bunshi = (bunshi * (i+1))%mod;
    }
    return (bunbo * inv(bunshi,m))%mod;
}

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans;
    ans = binary_method(2,n,mod);
    ans += mod - 1;
    ans += mod - comb(n,a,mod);
    ans += mod - comb(n,b,mod);
    cout<<(ans%mod)<<endl;
    return 0;
}

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

int gojo(long long int x,long long int y){
    long long int a=x,b=y;
  if(a<b){int i=a;a=b;b=i;}
  long long int r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  return b;
}

int main(){
  long long int A,B,C,D,E,ans,Cmax=0,Cmin=0,Dmax=0,Dmin=0,Emax=0,Emin=0;
  cin>>A>>B>>C>>D;
  E=C*D/gojo(C,D);
  ans=B-A+1;
  ans-=B/C-(A-1)/C+B/D-(A-1)/D-B/E+(A-1)/E;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
import math
import fractions
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


# Nの素因数分解を辞書で返す
def prime_fact(n, ela):
    if n == 1:
        return {1: 1}

    prime_dict = {}
    for i in ela:
        cnt = 0
        while n % i == 0:
            cnt += 1
            n = n // i
        if cnt:
            prime_dict[i] = cnt
        if n == 1:
            break
    if n != 1:
        prime_dict[n] = 1
    return prime_dict


def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):
        if not input_list[serial]:
            continue

        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial):
            input_list[s] = False


def main():
    N = NI()
    A = NLI()
    ela = sieve_of_erastosthenes(1001)
    ela = [i for i, b in enumerate(ela) if b]

    if max(A) == 1:
        print("pairwise coprime")
        exit()

    g = A[0]
    for a in A:
        g = math.gcd(g, a)
    if g > 1:
        print("not coprime")
        exit()

    SA = set(A)
    if len(SA) >= 90000:
        print("setwise coprime")
        exit()

    p_cnt = defaultdict(int)
    PD_list = defaultdict(dict)
    cnt = 0
    for a in A:
        if a == 1:
            continue

        if PD_list[a]:
            AP = PD_list[a]
        else:
            AP = prime_fact(a, ela)
            PD_list[a] = AP
        for apk in AP.keys():
            p_cnt[apk] += 1

    max_p = max(p_cnt.values())
    if max_p == 1:
        print("pairwise coprime")
    else:
        print("setwise coprime")


if __name__ == "__main__":
    main()


Measured memory_bytes: 240036
#include<iostream>
using namespace std;
int x, a, b;
int main(){
  cin >> x >> a >> b;
  if(a >= b)
    cout << "delicious" << endl;
  else if(a + x >= b)
    cout << "safe" << endl;
  else
    cout << "dangerous" << endl;
  return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <algorithm>  
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(long long int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;
vector<ll>g[1000001];
ll vis[1000005]={0};
map<ll,ll>y;
queue<ll>q ;
ll gcd(ll a, ll b){
    if(b%a==0) return a;
    else return gcd(b%a,a);
}
ll power(ll a, ll b){
    ll res=1;
    while(b)
    {
        if(b%2!=0) res=res*a;
        a=a*a;
        b=b/2;
    }
    return res;
}
/*void bfs(ll s)
{
       vis[s]=1;
       q.push(s);
       ll curr=q.front(); vis[curr]=1;
       while(!q.empty())
       {
              curr=q.front(); q.pop(); // vis[curr]=1;
              for(ll i=0;i<g[curr].size();i++)
              {
                     ll child=g[curr][i];
                     if(vis[child]==0) 
                     { 
                            q.push(child); 
                            vis[child]=1;
                     }
              }
       }
}*/

void dfs(ll curr)
{
       vis[curr]=1;
       for(ll i=0;i<g[curr].size();i++)
       {
              ll child=g[curr][i];
              if(vis[child]==0)
              {
                     dfs(child);
              }
       }
}
signed main() 
{
    fast
    ll n,m;
    cin>>n>>m;
    ll c=0;
    while(m--)
    {
        ll a,b;
        cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    for(ll i=1;i<=n;i++)
    {
        if(vis[i]==0) {c++; dfs(i);}
    }
    cout<<c-1<<"\n";
}

Measured memory_bytes: 32200
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdint>
#include <utility>
#include <tuple>
#include <map>    
#include <queue> 
#include <set>  
#include <stack> 
#include <deque>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset>

using namespace std;

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

	if (A - B > C) {
		cout << "0" << endl;
	}
	else {
		cout << C - (A - B) << endl;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> board(H);
  
  rep(i, H) cin >> board[i];
  
  int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
  int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
  
  rep(i, H){
  	rep(j, W){
      if(board[i][j] == '#') continue;
      
      int num = 0;
      for(int d=0; d<8; d++){
      	int nj = j + dx[d];
        int ni = i + dy[d];
        
        if(nj < 0 || W <= nj) continue;
        if(ni < 0 || H <= ni) continue;
        if(board[ni][nj] == '#') num++;
      }
      
      board[i][j] = char(num + '0');
    }
  }
  
  rep(i, H){
    cout << board[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;

const int INF = 1001001001;
int main() {
  int h, n;
  cin >> h >> n;
  vi a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];

  vi dp(h+1, INF);
  dp[0] = 0;
  rep(i, n){
    // printf("%d: ", i);
    rep(j, h+1){
      int magic = b[i];
      if (j >= a[i]){
        magic += dp[j-a[i]];
      }
      dp[j] = min(magic, dp[j]);
      // printf("%d, ", dp[j]);
    }
    // cout << endl;
  }
  cout << dp[h] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int cnt = 1;
	int n;
	while(cin >> n,n){
		cout << "Case " << cnt << ": " << n << endl;
		cnt++;
	}
	
}

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

int R, C;
int map[10][10000];
int bit[10];
int ans;

#define max(a,b) (a>b?a:b)

void search(int c, int xorf) {
	if(c==R) {
		int cnt, sum = 0;
		for(int i=0; i<C; ++i) {
			cnt = 0;
			for(int j=0; j<R; ++j) {
				if((map[j][i]^bit[j])==0) cnt++;
			}
			sum += (cnt>R/2?cnt:R-cnt);
		}
		ans = max(ans, sum);
		return;
	}
	bit[c] = xorf;
	search(c+1, 0);
	search(c+1, 1);
}

int main() {
	while(1) {
		cin >> R >> C;
		if(!R&&!C) break;
		ans = 0;
		for(int i=0; i<R; ++i) {
			for(int j=0; j<C; ++j) {
				cin >> map[i][j];
			}
		}
		search(0, 0); search(0, 1);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1548
import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)

main :: IO ()
main = breads >>= main'
    where
        main' [n, a, b] = replicateM n readLn >>= print . solve a b . sort

solve :: Int -> Int -> [Int] -> Int
solve a b hs = search 0 maxv maxv
    where
        maxv = last hs
        admg = a - b

        search under upper prev
            | upper > under = check hs
            | otherwise = upper
            where
                fdmg = b * upper

                check = nextSearch . fst . foldl' ff (0, True)
                    where
                        ff accs@(acc, flag) x
                            | flag && fdmg >= x = (acc, flag)
                            | otherwise = count accs x

                        count (acc, _) x
                            | m > 0 = (acc + r + 1, False)
                            | otherwise = (acc + r, False)
                            where
                                (r, m) = (x - fdmg) `divMod` admg

                nextSearch d
                    | d > upper = search upper prev prev
                    | d < upper && next /= upper = search under next upper
                    | otherwise = upper
                    where
                        (r, m) = (upper + under) `divMod` 2
                        next
                            | m > 0 = r + 1
                            | otherwise = r


Measured memory_bytes: 70652
#include <iostream>

int main()
{
	int H, W;
	while (true) {
		std::cin >> H >> W;
		if ( H == 0 && W == 0 ) break;
		
		for (int i=0; i<H; i++) {
			for (int j=0; j<W; j++) {
				if ( ((i+j)&1) == 0 ) std::cout << "#";
				else std::cout << ".";
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
	return 0;
}

	



Measured memory_bytes: 3084
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
using ll =long long;
const ll maxn=2e5+5,inf=1e18+18;
ll n,ans,a[maxn];
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ans=ans^a[i];
	}
	for(int i=0;i<n;i++){
		ans=ans^a[i];
		cout<<ans<<endl;
		ans=ans^a[i];
	}
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1


#ifndef ONLINE_JUDGE
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
						 stringstream _ss(_s); \
						 istream_iterator<string> _it(_ss); \
						 err(_it, args); }
#else
#define error(args...)		42
#endif


void err(istream_iterator<string> it) { cerr << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "; ";
	err(++it, args...);
}


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
#endif
}

int ceil2(int a, int b){
    int c = a / b;
    if (c * b < a) c++;
    return c;
}

const int sz = 3005;
int mem[sz][sz];
int psum[sz];

int a[sz];

int n;

int solve(int i, int j)
{
	
	if(mem[i][j] != -1)
		return mem[i][j];

	if(i == j)
	{
		mem[i][j] = a[i];
	}
	else
	{
		int temp = a[i] + (i+1 < n ? ((psum[j] - psum[i+1] + a[i+1]) - solve(i+1, j)) : 0);
		int temp2 = a[j] + (j-1 >= 0 ? ((psum[j-1] - psum[i] + a[i]) - solve(i, j-1)) : 0);
		mem[i][j] = max(temp, temp2);
	}

	error(i,j, mem[i][j]);

	return mem[i][j];
}


int32_t main()
{
	c_p_c();

	cin>>n;

	for (int i = 0; i < sz; ++i)
	{
		for (int j = 0; j < sz; ++j)
		{
			mem[i][j] = -1;
		}
	}

	

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

		if(i==0)
			psum[i] = a[i];
		else
			psum[i] = psum[i-1] + a[i];
	}

	solve(0,n-1);

	cout << 2*mem[0][n-1] - psum[n-1];

	// for (int i = 0; i < n; ++i)
	// {
	// 	cout << psum[i] << " " ;
	// }

	// cout << "\n";

	// for (int i = 0; i < n; ++i)
	// {
	// 	for (int j = 0; j < n; ++j)
	// 	{
	// 		cout << mem[i][j] << " ";
	// 	}
	// 	cout << "\n";
	// }
	
	return 0;
}

Measured memory_bytes: 74364
from collections import defaultdict, deque, Counter
def inpl(): return list(map(int, input().split()))

R, G, B, N = inpl()
ans = 0
for r in range(N//R + 1):
    for g in range(N//G + 1):
        tmp = N - R*r - G*g
        if tmp >= 0 and (tmp%B == 0):
            ans += 1
print(ans)


Measured memory_bytes: 40812
#include<iostream>

using namespace std;

int main()
{
	int a, b, c;
	int i = 0;

	while (true)
	{
		cin >> a >> b >> c;

		if (a <= b)
			break;

	}

	for (int j = a; j <= b; j++)
	{
		if ((c % j) == 0)
			i++;
	}

	cout << i << endl;
}

Measured memory_bytes: 3124
#include<stdio.h>

int main (void) {
   int a, b;
   scanf("%d %d", &a, &b);

   if (a<b)
    printf("a < b\n");
   else if (a>b)
    printf("a > b\n");
   else
    printf("a == b\n");
    
   return 0;
}


Measured memory_bytes: 2132
n = int(input())
abc = [list(map(int, input().split())) for x in range(n)]

# dp = [[None] * n for _ in range(3)]
# def dfs(ng, depth=n - 1):
#     if dp[ng][depth] != None:
#         return dp[ng][depth]
#
#     if depth == 0:
#         dp[ng][0] = max([abc[depth][x] for x in range(3) if x != ng])
#         return dp[ng][0]
#     dp[ng][depth] = max(dfs(x, depth - 1) + abc[depth][x] for x in range(3) if x != ng)
#     return dp[ng][depth]
#
# print(dfs(0))
# print(dfs(1))
# print(dfs(2))
# print(dp)


dp = [[None] * n for _ in range(3)]
for ng in range(3):
    dp[ng][0] = max([abc[0][x] for x in range(3) if x != ng])

for depth in range(1, n):
    for ng in range(3):
        dp[ng][depth] = max(dp[x][depth - 1] + abc[depth][x] for x in range(3) if x != ng)
print(max(dp[i][-1] for i in range(3)))


Measured memory_bytes: 73816
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int main()
{      
  int n,k,i,j;
  string s;
  cin>>s>>k;
  n=s.size();
  set<string> ans;
  for(i=0;i<n;i++)
  	for(j=1;j<=6;j++)
  		ans.insert(s.substr(i,j));
  i=0;
  for(string st:ans)
  {
  	i++;
  	if(i==k)
  	{
  		cout<<st;
  		return 0;
  	}	
  }
}

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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int N;
    cin >> N;
    vector<int> cards(N);
    REP(i, N) cin >> cards[i];

    sort(cards.rbegin(), cards.rend());

    int ans = 0;
    REP(i, N) if (i%2==0) ans += cards[i]; else ans -= cards[i];
    
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  
  public static void main(String[] args) {
  	Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    if (x < a) {
    	System.out.println(0);
    } else {
      	System.out.println(10);
    }
  }
  
}

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

int main(){
    while(1){
        int n,k;
        cin >> n >> k;
        if(n==0) break;
        vector<int> blood(k);
        for(int i=0; i<k; i++) cin >> blood[i];
        for(int i=0; i<n; i++){
            for(int j=0; j<k; j++){
                int a;
                cin >> a;
                blood[j] -= a;
            }
        }
        bool success = true;
        for(int i=0; i<k; i++){
            if(blood[i] < 0) success = false;
        }
        if(success){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
lld N;
vector<lld> v;
lld dp[555555][2];

lld solve(lld id, lld taken)
{
    if(id > N) {
        return 0;
    }
    if(id == N - 1) {
        return (taken == 0) ? v[id] : (-v[id]);
    }
    if(dp[id][taken] != -1) {
        return dp[id][taken];
    }

    lld ans = 0;
    if(taken == 0) {
        lld temp = v[id] + solve(id + 1, 0);
        ans += max(temp, -v[id] + solve(id + 1, 1));
    } else {
        lld temp = -v[id] + solve(id + 1, 0);
        ans += max(temp, v[id] + solve(id + 1, 1));
    }
    return dp[id][taken] = ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin >> N;
    v.resize(N);
    for(lld i = 0; i < N; i++) {
        cin >> v[i];
    }
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0);
}

Measured memory_bytes: 14464
#include<bits/stdc++.h>
#define h "\n"
#define ll long long

using namespace std;

int main()
{
    vector <int> v;

    for(int i=1;i<=5;i++)
    {
        ll a;
        cin>>a;
        if(a==0)
            cout<<i<<h;

    }

    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>

#define ll long long

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

    for(int i=0; i < K; i++) {
        std::cout << "ACL";
    }
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{ 
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var num = Input.num;var N = 1001;
        var imos = new int[N, N];
        for(var i = 0; i < num; i++)
        {
            var st = Input.ar;
            imos[st[0], st[1]]++;
            imos[st[0], st[3]]--;
            imos[st[2], st[1]]--;
            imos[st[2], st[3]]++;
        }
        for (var i = 0; i < N; i++)
            for (var j = 1; j < N; j++)
                imos[i, j] += imos[i, j - 1];
        for (var i = 1; i < N; i++)
            for (var j = 0; j < N; j++)
                imos[i, j] += imos[i - 1, j];
        var max = 0;
        for (var i = 0; i < N; i++)
            for (var j = 0; j < N; j++)
                max = Max(max, imos[i, j]);WriteLine(max);
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public  static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}



Measured memory_bytes: 25828
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include<algorithm>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n);

    for (int i = 0; i < n;++i){
        cin >> p[i];
    }

    sort(p.begin(), p.end());

    int ans = 0;

    for (int i = 0; i < k;++i){
        ans += p[i];
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
typedef long long ll;
ll a, b, c, d, e, f, g;
int main(void){
    // Your code here!
    cin >> a >> b >> c >> d >> e >> f >> g;
    if (a == 0 || d == 0 || e == 0){
        cout << a - (a % 2) + b + d - (d % 2) + e - (e % 2) << endl;
        return 0;
    }
    cout << a + b + d + e - ((((a % 2) + (d % 2) + (e % 2) == 1) || ((a % 2) + (d % 2) + (e % 2) == 2)) ? 1 : 0) << endl;
}


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

using namespace std;

int main() {
	int tarou = 0, hanako = 0, n;
	string t_card, h_card;

	cin >> n;

	for(int i = 0;i < n;i++) {
		cin >> t_card >> h_card;

		if(t_card == h_card) {
			tarou++;
			hanako++;
		} else if(t_card > h_card) {
			tarou += 3;
		} else {
			hanako += 3;
		}
	}

	cout << tarou << " " << hanako << endl;

	return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
string s;
int n;
int main()
{
	scanf("%d",&n);
	cin>>s;
	int x=s.size();
	for(int i=0;i<x;++i) {
		int a=s[i]-'A';
		a=(a+n)%26;
		s[i]='A'+a;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		puts("a < b");
	}else if(a>b){
		
		puts("a > b");
	}else{
		
		puts("a == b");
	}
	return 0;
}


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

int main() {
    int N, C, K;
    cin >> N >> C >> K;

    vector<int> time(N);
    rep(i, N) cin >> time[i];

    sort(time.begin(), time.end());

    int bus_num = 0, wait_start = 0, wait_people = 0;
    rep(i, N) {
        if (wait_people > 0 && time[i] - wait_start > K) {
            bus_num++;
            wait_people = 0;
        }

        if (wait_people == 0) wait_start = time[i];
        wait_people++;
        
        if (wait_people == C) {
            bus_num++;
            wait_people = 0;
        }
    }

    if (wait_people > 0) bus_num++;

    cout << bus_num << endl;

    return 0;
}

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

int a[5000];
int main() {
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n * 2; i++) {
        scanf("%d", &a[i]);
    }
    sort(a, a + n + n);
    reverse(a, a + n + n);
    int ans = 0;
    for(int i = 0; i < n * 2; i += 2) {
        ans += min(a[i], a[i + 1]);
    }
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

void merge_sort(int *t1, int *s1, int left, int right){//t1に基づいて。
    if(left==right){
        ;
    }
    else{
        int n2=(right-left+1)/2;
        int n3=right-left+1-n2;
        int i=0,j=0,k=0;

        // rep(p,n2+n3){
        //   printf("t1[%d] = %p, t1[%d][0] = %d, t1[%d][1] = %d\n", p, t1[p], p, t1[p][0], p, t1[p][1]);
        // }

        merge_sort(t1, s1, left, left+n2-1);
        merge_sort(t1, s1, left+n2, right);

        int *t2=(int *)malloc(sizeof(int)*n2);
        int *t3=(int *)malloc(sizeof(int)*n3);
        int *s2=(int *)malloc(sizeof(int)*n2);
        int *s3=(int *)malloc(sizeof(int)*n3);

        for(i=0;i<n2;i++){
          t2[i]=t1[left+i];
          s2[i]=s1[left+i];
        }
        for(i=0;i<n3;i++){
          t3[i]=t1[left+n2+i];
          s3[i]=s1[left+n2+i];
        }

        // printf("t2[0] = %d, t3[0] = %d\n", t2[0], t3[0]);
        // printf("s2[0] = %d, s3[0] = %d\n", s2[0], s3[0]);

        //ここの実装にn時間かかった。定義されていない領域にアクセスしないの重要。
        for(i=0;i<n2+n3;i++){
            if(k==n3 || (j<n2 && t2[j]<t3[k])){
                t1[left+i]=t2[j];
                s1[left+i]=s2[j];
                j++;
            }
            else{
                t1[left+i]=t3[k];
                s1[left+i]=s3[k];
                k++;
            }
        }
    }
}


int main(){
  char buf[1024];
  int N;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d", &N);

  int *A=(int *)malloc(sizeof(int)*N);
  int *B=(int *)malloc(sizeof(int)*N);
  rep(i,N){
    fgets(buf,sizeof(buf),stdin);
    sscanf(buf, "%d %d", &A[i], &B[i]);
  }

  merge_sort(B, A, 0, N-1);

  long *sum=(long *)malloc(sizeof(long)*N);
  sum[0]=A[0];
  srep(i, 1, N){
    sum[i]=sum[i-1]+A[i];
  }

  int flag=0;
  rep(i,N){
    if(sum[i]>B[i]){
      flag=1;
      break;
    }
  }

  if(flag==1){
    printf("No\n");
  }
  else{
    printf("Yes\n");
  }

  return 0;


}


Measured memory_bytes: 49152
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int i;
  int m;
  for(i=1;i<=n;i++){
    m = i;
    if(m%3==0)
      printf("%s%d"," ",i);
    else if(m%10==3)
      printf("%s%d"," ",i);
    else if((m/10)%10==3)
      printf("%s%d"," ",i);
    else if((m/10/10)%10==3)
      printf("%s%d"," ",i);
    else if((m/10/10/10)%10==3)
      printf("%s%d"," ",i);
    else if((m/10/10/10/10)%10==3)
      printf("%s%d"," ",i);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N;
 cin >> N;
 int ninzu =0 ;
 int l;
 int r;
 for(int i=0; i<N ;i++){
   cin >> l;
   cin >> r;
   ninzu += r-l+1;
 }
  cout << ninzu;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <limits>

#define INF_I std::numeric_limits<int>::max()
#define MAX_N 100000

int main(){
    int N;
    int L[MAX_N];
    scanf("%d", &N);
    std::fill(L, L + N + 1, INF_I);
    for(int i = 0; i < N; ++i){
        int A;
        scanf("%d", &A);
        *std::lower_bound(L, L + N + 1, A) = A;
    }
    printf("%d\n", std::lower_bound(L, L + N, INF_I) - L);
    return 0;
}

Measured memory_bytes: 1420
#include <bits/stdc++.h>
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;

int n;
string s;

void go(char mx){
    if(s.size() == n){
        cout<<s<<'\n';
        return;
    }
    for(char c = 'a'; c <= mx+1; c++){
        s.push_back(c);
        go(max(mx, c));
        s.pop_back();
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    go('a'-1);
    return 0;
}

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

int main(int argc, char const *argv[])
{
    int n,k;cin>>n>>k;
    if(k==1)cout << 0 << endl;
    else
    {
        cout << n-k << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define MAX_N 4000
#define MAX_E 40000
#include<algorithm>
using namespace std;

struct edge {int u,v,cost;};

int ans[MAX_N],cnt;

bool comp(const edge& e1, const edge& e2){
  return e1.cost<e2.cost;
}

edge es[MAX_E];
int V,E;



int par[MAX_E];
int rank[MAX_E];
void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    rank[i]=0;
  }
}
int find(int x){
  if(par[x]==x)return x;
  else return par[x] = find (par[x]);
}
void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return ;
  if(rank[x]<rank[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}
bool same(int x,int y){
  return find(x)==find(y);
}



int kruskal(){
  sort(es,es+E,comp);
  init(V);
  int res = 0;
  for(int i=0;i<E;i++){
    edge e = es[i];
    if(!same(e.u,e.v)){
      ans[cnt++]=e.cost;
      unite(e.u,e.v);
      res += e.cost;
    }
  }
  return res;
}
int main(){
  int a,b,c;
  while(cin>>V>>E&&V&&E){
    
    for(int i=0;i<E;i++){
      cin>>a>>b>>c;
      a--;
      b--;
      es[i].u=a;
      es[i].v=b;
      es[i].cost=c;
      /*
      es[E+i].u=b;
      es[E+i].v=a;
      es[E+i].cost=c;
      */
    }
    //E*=2;
    cnt=0;
    int x =kruskal();
    //cout<<x/(V-1)<<endl;
    if(cnt%2==0){
      cout<<(ans[cnt/2]+ans[cnt/2-1])/2<<endl;
    }
    else cout<<ans[cnt/2]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1324
N = int(input())
AB = [list(map(int,input().split())) for _ in [0]*N ]

mod = 1000000007

def gcd(x,y):
    if y==0:return x
    return gcd(y,x%y)

c = {}
n0 = 0
for a,b in AB:
    if a==b==0:
        n0 += 1
    elif a==0:
        c[(0,1)] = c.get((0,1),0) +1
    elif b==0:
        c[(1,0)] = c.get((1,0),0) +1
    else:
        g = gcd(a,b)
        a,b = a//g,b//g
        if a<0:
            a *= -1
            b *= -1
        c[(a,b)] = c.get((a,b),0) +1

ans = 1
done = set()
for k,n in c.items():
    if k in done: continue
    a,b = k
    if b>0:
        an,bn = b,-a
    else:
        an,bn = -b,a
    m = c.get((an,bn),0)
    ans *= (pow(2,n,mod) + pow(2,m,mod) - 1)%mod
    ans %= mod
    done.add((a,b))
    done.add((an,bn))

ans = ans -1 +n0
ans %= mod
print(ans)

Measured memory_bytes: 203732
#include <stdio.h>
#include <string.h>

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]){

    long long key, i, h;
	key = getKey(str);
	for(i=0;; i++){
		h = (h1(key) + i*h2(key)) % M;
		if(strcmp(H[h], str) == 0) return 1;
		else if(strlen(H[h]) == 0) return 0;
	}
	return 0;
}


int insert(char str[]){
	long long key, i, h;
	key = getKey(str);
	for(i=0;; i++){
		h = (h1(key) + i*h2(key)) % M;
		if(strcmp(H[h], str) == 0) return 1;
		else if(strlen(H[h]) == 0)
		{
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}


Measured memory_bytes: 15412
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B;
  cin >> A >> B;
  
  if(A!=1 &&B!=1 &&A<B){
    cout << "Bob" << endl;
  }
  else if(A!=1 && B!=1 && A>B){
    cout << "Alice" << endl;
  }
  else if(A!=1 && B==1){
    cout << "Bob" << endl;
  }
  else if (A==1&&B!=1){
    cout << "Alice" << endl;
  }
  else{
    cout << "Draw" << endl;
  }
}


Measured memory_bytes: 256
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_D
  * Structured Program I - Structured Programming
  */
object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    //Memory Limit Exceeded
    //    val result = (1 to n).filter(i => i % 3 == 0 || i.toString.contains('3'))
    //      .foldLeft("") { (str, i) => str + s" $i" }
    val result = " " + (1 to n).filter(i => i % 3 == 0 || i.toString.contains('3')).mkString(" ")
    println(result)
  }
}

Measured memory_bytes: 47856
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

static const int N = 500000;
static const int NIL = -1;

class Point {
public:
    int id;
    int x;
    int y;

    Point() {}

    Point(int id, int x, int y) : id(id), x(x), y(y) {};

    bool operator<(const Point &p) const
    {
        return id < p.id;
    }

    void print()
    {
        printf("%d\n", id);
    }
};

struct Node {
    int location;
    int left;
    int right;
};

int node_num = 0;
Point P[N];
Node T[N];

int make2DTree(int range_l, int range_r, int depth)
{
    if (!(range_l < range_r))
        return NIL;

    int mid = (range_l + range_r) / 2;
    int t = node_num++;

    if (depth % 2 == 0)
        sort(P + range_l, P + range_r,
             [](const Point &p1, const Point &p2) { return p1.x < p2.x; });
    else
        sort(P + range_l, P + range_r,
             [](const Point &p1, const Point &p2) { return p1.y < p2.y; });

    T[t].location = mid;
    T[t].left = make2DTree(range_l, mid, depth + 1);
    T[t].right = make2DTree(mid + 1, range_r, depth + 1);

    return t;
}

void find(int root, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans)
{
    int x = P[T[root].location].x;
    int y = P[T[root].location].y;

    if (sx <= x && x <= tx && sy <= y && y <= ty)
        ans.push_back(P[T[root].location]);

    if (depth % 2 == 0)
    {
        if (T[root].left != NIL && sx <= x)
            find(T[root].left, sx, tx, sy, ty, depth + 1, ans);
        if (T[root].right != NIL && x <= tx)
            find(T[root].right, sx, tx, sy, ty, depth + 1, ans);
    } else
    {
        if (T[root].left != NIL && sy <= y)
            find(T[root].left, sx, tx, sy, ty, depth + 1, ans);
        if (T[root].right != NIL && y <= ty)
            find(T[root].right, sx, tx, sy, ty, depth + 1, ans);
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    int x, y;
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d", &x, &y);
        P[i] = Point(i, x, y);
        T[i].left = NIL;
        T[i].right = NIL;
    }

    int root = make2DTree(0, n, 0);

    int query;
    scanf("%d", &query);
    int sx, tx, sy, ty;
    vector<Point> ans;
    for (int q = 0; q < query; q++)
    {
        scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
        ans.clear();
        find(root, sx, tx, sy, ty, 0, ans);
        sort(ans.begin(), ans.end());
        for(int i = 0; i < ans.size(); i++)
            ans[i].print();
        printf("\n");
    }
}


Measured memory_bytes: 13980
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int N, count = 0;
    string S;
    cin >> N >> S;
    for (int i = 0; i <= 999; i++) {
        int numbers[3] = { i / 100, (i / 10) % 10, i % 10 };
        int n = 0;
        for (int j = 0; j < N; j++) {
            if (n < 3 && '0' + numbers[n] == S[j]) {
                n++;
            }
        }
        if (n == 3) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}



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

#define ll long long int
#define loop(a,b,c) for(ll a=b; a<c; a++)
#define eloop(a,b,c) for(ll a=b; a<=c; a++)
#define nl prllf("\n");

using namespace std;

int main(){
    ll T = 1; //cin >> T;
    while(T--){
        ll n; cin >> n; 
      //  vector<ll> v(n);
        ll sum =0;
        eloop(i,1,n){
            if(i % 3 == 0 || (i%5 ==0 )) {}
            else {
                sum += i;
            }   

        }
        cout << sum << endl;
       /* ll t = N;
        bool flag = false;
        while(t){
            int d = t % 10;
            if(d==7){
                flag = true;
                break;
            }
            t = t /10;

        }
        if(flag)cout <<"Yes" << endl;
        else cout <<"No" << endl;
        */
        


        
        
        

    }
}
/*

*/

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iterator>
#include <cstring>
using namespace std;

int n;
int a[305][305];
long long sol;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

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

	// validate?
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=n; j++) {
			bool ok = true;
			bool needed = true;
			for (int k=1; k<=n; k++) {
				if (k == i || k == j) {
					continue;
				}
				if (a[i][k] + a[k][j] < a[i][j]) {
					ok = false;
					break;
				} else if (a[i][k] + a[k][j] == a[i][j]) {
					needed = false;
				}
			}
			if (!ok) {
				cout << -1;
				return 0;
			}
			if (needed) {
				sol += a[i][j];
			}
		}
	}

	cout << sol / 2 << '\n';

	// mcst

}

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

int main()
{
  	int cnt = 0;
  	string w,t;
  
 	cin >> w >> t;
   	
  	while(t != "END_OF_TEXT"){
      for(int i = 0;i < t.length();i++){
        if(isalpha(t.at(i)))
          t.at(i) = tolower(t.at(i));
      }
      if(t == w)
        cnt++;
      cin >> t;
  	}
  	
	cout << cnt << endl;
  
}


Measured memory_bytes: 3156
N, K = map( int, input().split() )
x = list( map( int, input().split() ))
 
ret = 10 ** 18
for i in range( N - K + 1 ):
  l, r = x[i], x[ K + i - 1 ]
  ret = min( ret, abs( l - r ) + min( abs( r ), abs( l ) ) )
print( ret )

Measured memory_bytes: 14384
import java.util.Scanner;

//JPEG Compression
public class Main{

	public static boolean c(int i, int j, int n){
		return 0<=i&&i<n&&0<=j&&j<n;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int Case = 1;
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[][] a = new int[n][n];
			//mode: m
			//0: a right forward
			//1: down diagonal
			//2: down -> 4
			//3: right
			//4: up diagonal
			//5: right ->1
			//6: down -> 1
			//7: halt
			int m = 0;
			int s = 1;
			int i = 0;
			int j = 0;
			a[i][j] = s++;
			while(m!=7){
				switch(m){
				case 0:
					if(c(i,j+1,n)){
						a[i][j+1]=s++;
						j++;
						m=1;
					}
					else m=7;
					break;
				case 1:
					if(c(i+1,j-1,n)){
						a[++i][--j]=s++;
					}
					else{
						m=2;
					}
					break;
				case 2:
					if(c(i+1,j,n)){
						a[++i][j]=s++;
						m=4;
					}
					else m=3;
					break;
				case 3:
					if(c(i,j+1,n)){
						a[i][++j]=s++;
						m=4;
					}
					else m=7;
					break;
				case 4:
					if(c(i-1,j+1,n)){
						a[--i][++j]=s++;
					}
					else m=5;
					break;
				case 5:
					if(c(i,j+1,n)){
						a[i][++j]=s++;
						m = 1;
					}
					else m = 6;
					break;
				case 6:
					if(c(i+1,j,n)){
						a[++i][j]=s++;
						m=1;
					}
					else m=7;
					break;
				default:break;
				}
			}
			System.out.println("Case " + Case++ + ":");
			for(int y=0;y<n;y++){
				for(int x=0;x<n;x++){
					System.out.printf("%3d", a[y][x]);
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
ll n,res=0,i;
cin>>n;
for(i=1;i<=1000000;i++)
{
	res=res*10+7;
	res=res%n;
//	cout<<res<<endl;
	if(res==0)
	break;
}

if(i==1000001)
cout<<"-1"<<endl;
else
cout<<i<<endl;
}

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

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

const char O = '#';
const char F = '.';

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};


int main(void) {
	int H, W;
	cin >> H >> W;
	vec<string> MAP;
	resize(MAP, H);

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

	vec<UnionFind> uW(H, UnionFind(W));
	vec<UnionFind> uH(W, UnionFind(H));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W - 1; ++j) {
			if (MAP[i][j] == F && MAP[i][j + 1] == F) {
				uW[i].unite(j, j + 1);
			}
		}
	}

	for (int j = 0; j < W; ++j) {
		for (int i = 0; i < H - 1; ++i) {
			if (MAP[i][j] == F && MAP[i + 1][j] == F) {
				uH[j].unite(i, i + 1);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int sum = uH[j].size(i) + uW[i].size(j);
			ans = max(ans, sum);
		}
	}

	cout << ans - 1 << endl;
	return 0;

}

Measured memory_bytes: 35968
#include<bits/stdc++.h>
#define MN 2000
using namespace std;
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*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,cnt,ans=1e9,head[MN+5],f[MN+5],g[MN+5],mx[MN+5],from[MN+5];
char s[MN+5];
struct edge{int to,next;}e[MN*2+5];
inline void ins(int f,int t)
{
    e[++cnt]=(edge){t,head[f]};head[f]=cnt;
    e[++cnt]=(edge){f,head[t]};head[t]=cnt;
}
void dfs(int x,int fa)
{
    f[x]=0;g[x]=s[x]=='1';mx[x]=0;from[x]=0;
    for(int i=head[x];i;i=e[i].next)
        if(e[i].to!=fa)
        {
            dfs(e[i].to,x);
            int v=f[e[i].to]+g[e[i].to];f[x]+=v;
            g[x]+=g[e[i].to];
            if(v>mx[x]) mx[x]=v,from[x]=e[i].to;
        }
}
bool Solve(int x,int y)
{
    if(!x||y*2>f[x]) return false;
    if(y<=f[x]-mx[x]) return true;
    return Solve(from[x],y-(f[x]-mx[x]));
}
int main()
{
    n=read();scanf("%s",s+1);
    for(int i=1;i<n;++i) ins(read(),read());
    for(int i=1;i<=n;++i)
    {
        dfs(i,0);if(f[i]/2>=ans||(f[i]&1)) continue;
        if(Solve(i,f[i]/2)) ans=f[i]/2;
    }
    cout<<(ans>100000000?-1:ans);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int a, b;
  scanf("%d %d", &a, &b);
  
  int in_mouth = 1;
  int cnt_a = 0;
  
  while(in_mouth < b){
    in_mouth += a-1;
    cnt_a++;
  }
  
  printf("%d", cnt_a);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
inline int gcd(int a,int b) {
    while(b^=a^=b^=a%=b);
    return a;
}
int main()
{
    int k,ans=0,temp;
    string s;
    cin>>k;
    
    for(int a=1;a<=k;a++)
        for(int b=1;b<=k;b++)
            for(int c=1;c<=k;c++)
                ans=ans+gcd(a,gcd(b,c));
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3628