akhauriyash/Code-Regression huggingface dataset:
n = gets.strip.to_i

input_lines = n.times.map do
  gets.strip
end

r = input_lines.group_by { |v| v }

puts "AC x #{r['AC'].to_a.length}"
puts "WA x #{r['WA'].to_a.length}"
puts "TLE x #{r['TLE'].to_a.length}"
puts "RE x #{r['RE'].to_a.length}"


Measured memory_bytes: 21736
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    string a;
    cin >> a ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;

    sort(vec.begin(), vec.end());
    //*/
    
    //*
    if( a.at(2) == a.at(3) && a.at(4) == a.at(5) ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    //*/
    
    //cout << ((floor(a / 2) + fmod(a, 2)) / a) << endl;
    
    return 0; 
}


Measured memory_bytes: 3580
<?php

while (($line = trim(fgets(STDIN))) !== '0') {
    $n = (int)$line;
    $line = trim(fgets(STDIN));
    $S = array();
    //キーがSの数値、値が出現回数
    $arr = array();
    foreach (explode(' ', $line) as $i => $m) {
        $m = (int)$m;
        $S[$i] = $m;
        if (!isset($arr[$m])) {
            $arr[$m] = 0;
        }
        $arr[$m]++;
    }

    $cnt = 0;
    while (true) {
        $prev = implode(' ', $S);
        foreach ($S as $i => $s) {
            $S[$i] = $arr[$S[$i]];
        }
        $current = implode(' ', $S);

        //前回と同じ値
        if ($prev === $current) {
            break;
        }

        $arr = array();
        foreach ($S as $m) {
            if (!isset($arr[$m])) {
                $arr[$m] = 0;
            }
            $arr[$m]++;
        }
        $cnt++;
    }

    echo $cnt, PHP_EOL, $current, PHP_EOL;
}

Measured memory_bytes: 6636
h,n = map(int,input().split())
M = []
max_val = 0
for _ in range(n):
    a,b = map(int,input().split())
    max_val = max(max_val,a)
    M.append((a,b))
dp = [float('inf')]*(h+1+max_val)
dp[0] = 0
for i in range(1,h+1+max_val):
    for j in range(n):
            dp[i] = min(dp[i-M[j][0]] + M[j][1],dp[i])
print(min(dp[h:-1]))




Measured memory_bytes: 74192
N = int(input())
p = [[0,0]]*N
for i in range(N):
  p[i] = input().split()
  p[i] = list(map(int,p[i]))
p = sorted(p,key = lambda p:p[1])
s = [0]*N
s[0] = p[0][0]
for i in range(N-1):
  s[i+1] = s[i] + p[i+1][0]
k = 0
for i in range(N):
  if s[i] <= p[i][1]:
    k = k + 1
  else:
    print('No')
    break
if k == N:
  print('Yes')

Measured memory_bytes: 79448
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define fi first
#define se second
const int MAX = 200000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;

int H, W, k;
char M[10][10];

int32_t main()
{
	cin >> H >> W >> k;

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

	int ans = 0;

	for(int i = 0; i < (1 << H); i++)
	{
		for(int j = 0; j < (1 << W); j++)
		{
			int cnt = 0;
			for(int a = 0; a < H; a++)
			{
				for(int b = 0; b < W; b++)
				{
					if((i & (1 << a)) or (j & (1 << b))) continue;
					cnt += M[a][b] == '#';
				}
			}
			if(cnt == k) ans++;

		}

	}

	cout << ans << '\n';


	return 0;
}


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

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

    map<string,int> m;

    for(int i=0;i<n;i++)
    {
        string str;
        cin>>str;
        m[str]++;
    }
   int max=INT_MIN;
   for(auto i=m.begin();i!=m.end();i++)
   {
     if(i->second>max)
       max=i->second;
   }
  
  for(auto i=m.begin();i!=m.end();i++)
  {
    if(i->second>=max)
      cout<<i->first<<endl;
  }
  
   return 0;
}

Measured memory_bytes: 25216
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}
bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i == 0)
			return false;
	}
	return (num < 2) ? false : true;
}



int main() {
	ll N;
	cin >> N;
	if (N == 7 || N == 5 || N == 3)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  vector<string> vec;
  vec = {"a","i","u","e","o"};
  int a=0;
  for(int i=0;i<5;i++){
  	if(s==vec.at(i)) {
      a++;
      break;}
  }
  if(a==1) cout << "vowel" <<endl;
  else cout << "consonant" << endl;
}

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

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    long n,k,q,a;
    cin>>n>>k>>q;
    vector<long> score(n,0);
    for(int i=0;i<q;i++){
        cin>>a;
        a--;
        score[a]++;
    }
    for(int i=0;i<n;i++){
        if(score[i]>q-k)cout<<"Yes\n";
        else{cout<<"No\n";}
    }

}


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

const long long mod = 1000000007;

long powmod(long a, long n){
    if(n == 0) return 1;
    long half = powmod(a, n / 2);
    long ans = half * half % mod;
    if(n % 2 == 1){
        ans *= a;
        ans %= mod;
    }
    return ans;
}

long long nCr(long long n, long long r){
    
    if(r > n - r) return nCr(n, n - r);
    long long mul = 1;
    long long div = 1;
    for(long long i = 0; i < r; i++){
        mul *= n - i;
        mul %= mod;
        div *= i + 1;
        div %= mod;
    }
    long long ans = mul * powmod(div, mod - 2) % mod;
    return ans;
}

int main(){

    int N, M;
    cin >> N >> M;

    long long ans = 1;
    for(int i = 2; i * i <= M; i++){
        long long cnt = 0;
        while(M % i == 0){
            cnt++;
            M /= i;
        }
        if(cnt == 0) continue;
        ans *= nCr(cnt + N - 1, N - 1);
        ans %= mod;
    }

    if(M != 1){
        ans *= N;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> N;
    vi t(N);
    cin >> t;
    cin >> M;
    ans = accumulate(ALL(t), 0LL);
    REP(i, M) {
        cin >> P >> X;
        cout << ans - t[P - 1] + X << endl;
    }
}

Measured memory_bytes: 3624
k,n=map(int,input().split())
a=list(map(int,input().split()))
d=[]
d.append(k-a[-1]+a[0])
for i in range(1,n):
  d.append(a[i]-a[i-1])
ans=10**18
for di in d:
  t=k-di
  ans=min(ans,t)
print(ans)

Measured memory_bytes: 32256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0 ,0 };



int main(void) {
	
	int n, m;
	int count[31] = {};
	int k, a;
	int total = 0;

	cin >> n >> m;
	FOR(i, 1, n) {
		cin >> k;
		FOR(j, 1, k) {
			cin >> a;
			count[a]++;
		}
	}

	FOR(i, 1, m) {
		if (count[i] == n) {
			total++;
		}
	}
	cout << total << endl;
	

	return 0;
}

Measured memory_bytes: 256
from sys import exit, stdin

# import copy
from collections import deque, Counter

# import numpy as np
input = stdin.readline

H, W, M = map(int, input().split())

col = Counter()
row = Counter()
D = Counter()
for i in range(M):
    h, w = map(int, input().split())
    row.update([h])
    col.update([w])
    D.update([str(h) + str(w)])

# rmax = row.most_common(1)
# cmax = col.most_common(1)
# idx = str(rmax[0][0]) + str(cmax[0][0])
# p = D[idx]

# ans = rmax[0][1] + cmax[0][1] - p

rtmp = row.most_common(1)[0][1]
ctmp = col.most_common(1)[0][1]
rmax = []
cmax = []

for r in row.most_common():
    if r[1] < rtmp:
        break
    rmax.append(r)

for c in col.most_common():
    if c[1] < ctmp:
        break
    cmax.append(c)

ridx = str(rmax[0][0])
for d in cmax:
    if D[ridx + str(d[0])] == 0:
        ans = rmax[0][1] + d[1]
        break
else:
    ans = rmax[0][1] + d[1] - 1

cidx = str(cmax[0][0])
for d in rmax:
    if D[str(d[0]) + cidx] == 0:
        ans2 = cmax[0][1] + d[1]
        break
else:
    ans2 = cmax[0][1] + d[1] - 1

print(max(ans, ans2))



Measured memory_bytes: 123028
#include<stdio.h>
int main(){
	int row,collom,N,i= 0;
	int tamp,count =0;
	scanf("%d",&row);
	scanf("%d", &collom);
	scanf("%d", &N);
	if(row>collom){
		tamp=row;
	}else{
		tamp=collom;
	}
	for(i=0;i<N;i=i+tamp){
		count++;
	}
	printf("%d",count);
	
	
	return 0;
}

Measured memory_bytes: 1708
from itertools import permutations
A = list(map(int, input().split()))
res = 10 ** 4
for perm in permutations(list(range(3))):
    tmp = 0
    for i in range(1, 3):
        tmp += abs(A[perm[i]] - A[perm[i-1]])
    res = min(res, tmp)
print(res)

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

using namespace std;
 
int main(void){
  
  int i,j,n,a;
  string s,ans;
  cin >> n;
  
  for(i = 0 ; i < n ; i++ ){  
    
    cin >> s;
    ans = "NA";
    
    if( s[0] == '>'){
      if( s[1] == '\''){
	a = 2;
	int cnt1 = 0,cnt2 = 0;
	if( s[a] == '='){
	  while( s[a] == '='){
	    a++;
	    cnt1++;
	  }
	  if( s[a] == '#' ){
	    a++;
	    if( s[a] == '='){
	      while( s[a] == '='){
		cnt2++;
		a++;
	      }
	      if( s[a] == '~' && a + 1 == s.size() && cnt1 == cnt2) ans = "A";
	    }
	  }
	}
      }
      else if( s[1] == '^'){
	a = 2;
	if( s[a] == 'Q' && s[a + 1] == '='){
	  while( s[a] == 'Q' && s[a + 1] == '=') a += 2;
	  if( s[a] == '~' && s[a + 1] == '~' && a + 2 == s.size()) ans = "B";
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <numeric>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define itr(i, x) for(auto i = (x).begin(); i != (x).end(); i++)
#define ritr(i, x) for(auto i = (x).rbegin(); i != (x).rend(); i++)
#define INF 1010101010
#define MOD 1000000007
#define LL long long

int main() {
    string a, b, c;
    int diff = 'A' - 'a';
    cin >> a >> b >> c;
    cout << (char)(a[0] + diff) << (char)(b[0] + diff) << (char)(c[0] + diff) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	int n, m;
	cin >> n >> m;
	ll a[n+5], sum = 0;
	rep(i, m)
	{
		cin >> a[i], sum += a[i];
	}
	if (sum > n) cout << -1;
	else cout << n - sum;
	return 0;
}


Measured memory_bytes: 3664
N = int(input())
d = dict()

d[0] = 'pon'
d[1] = 'pon'
d[2] = 'hon'
d[3] = 'bon'
d[4] = 'hon'
d[5] = 'hon'
d[6] = 'pon'
d[7] = 'hon'
d[8] = 'pon'
d[9] = 'hon'
print(d[N % 10])


Measured memory_bytes: 9184
import numpy as np

def matmul(A,B):
    N = len(A)
    C = np.eye(N, dtype=int)
    for n in range(N):
        C[n] = (A[n,:][:,None] * B % mod).sum(axis=0) % mod
    return C

def mat_power(A,k):
    N = len(A)
    if k == 0:
        return np.eye(N,dtype=int)
    X = mat_power(A,k//2)
    X = matmul(X,X)
    return matmul(A,X) if k&1 else X

N,K=map(int,input().split())
A = np.array([list(map(int,input().split())) for _ in range(N)],dtype=int)
mod = 10**9+7

print(mat_power(A,K).sum()%mod)

Measured memory_bytes: 27316
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main 
{
	static Scanner scan = new Scanner(System.in);
	
	public static void main(String[] args) 
	{
		int n;
		
		while(true)
		{
			n = scan.nextInt();
			
			if(n == 0)
			{
				return;
			}
			else
			{
				new DataSet(n);
			}
		}
	}
	
	static class DataSet
	{
		int numOfWords;
		List<String> words = new ArrayList<String>();
		
		public DataSet(int numOfWords)
		{
			this.numOfWords = numOfWords;
			
			for(int i = 0; i < numOfWords; i++)
			{
//				System.out.println("Define word.");
				words.add(scan.next());
			}
			
			//now we get to work
			
			for(int sw = 0; sw < numOfWords; sw++) //sw = start word
			{
				if(checker(sw) == true)
				{
					//do away with this
					System.out.println(sw+1);
					return;
				}
			}
			System.out.println("0");
			
		}
		
		boolean checker(int startWord)
		{
			int curWord = startWord;
			//can he do it?
			for(int i = 1; i <= 5; i++)
			{
				//set requirements
				int reqLet;
				if(i == 1 || i == 3) {reqLet = 5;}else {reqLet = 7;}
				
				//fill the bucket.
				int bucket = 0;
				
				while(bucket < reqLet)
				{
					if(curWord+1 > words.size())
					{
						//out of words
						return false;
					}
					bucket += words.get(curWord).length();
					
					if(bucket > reqLet)
					{
						//SPILL!!
						return false;
					}
					
					curWord += 1;
				}
				
			}
			return true;
		}
		
	}

}



Measured memory_bytes: 30960
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

long n,k,i,v[100000],ans=LONG_MAX;
inline void solve(){
  IN2(n,k);
  INS(i,n,v);
  sort(v,v+n);
  k--;
  for(i=0;i<n-k;i++)chmin(ans,v[i+k]-v[i]);
  OUT(ans);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 1024
#![allow(unused_imports)]
    #![allow(dead_code)]
    use std::io::prelude::*;
    use std::cmp::{max, min};
    use std::collections::BinaryHeap;

    const MOD: i64 = 1e9 as i64 + 7; 

    fn main(){
        let s: String = read();
        let ans = match &*s{
            "Sunny" => "Cloudy",
            "Cloudy" => "Rainy",
            "Rainy" => "Sunny",
            _ => "",
        };
        println!("{}", ans);
    }

    fn read<T>() -> T
    where
        T: std::str::FromStr,
    {
        let stdin = std::io::stdin();
        let token: String = stdin
            .lock()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        token.parse().ok().unwrap()
    }


Measured memory_bytes: 4352
import java.util.*;

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

        while(true){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            if(m == -1 || f == -1){
                if(m == -1 && f == -1 && r == -1){
                    break;
                }else{
                    System.out.println("F");
                }
            }else{
                if(m + f < 30){
                    System.out.println("F");
                }else if(m + f < 50){
                    if(r < 50){
                        System.out.println("D");
                    }else{
                        System.out.println("C");
                    }
                }else if(m + f < 65){
                    System.out.println("C");
                }else if(m + f < 80){
                    System.out.println("B");
                }else{
                    System.out.println("A");
                }
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 26452
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    ull N;
    cin >> N;
    string ans;
    for(int i = 1; i < 12; i++){
        if(N <= pow(26, i)){
            N--;
            for(int j = 0; j < i; j++){
                ans.push_back(char('a' + N % 26));
                N /= 26;
            }
            break;
        }else{
            N -= pow(26, i);
        }
    }
    reverse(all(ans));
    cout << ans << endl;
}


Measured memory_bytes: 4016
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
	while(1){
		int r, a, hit=0, blow=0;
		int x[4], y[4]; 
		
		cin >> r >> a;
		if(r==0 && a==0) break;
	
		for(int i=0; i<4; ++i){
			x[i] = (r%(int)pow(10, 4-i) - r%(int)pow(10, 3-i)) / (int)pow(10, 3-i);
			y[i] = (a%(int)pow(10, 4-i) - a%(int)pow(10, 3-i)) / (int)pow(10, 3-i);
		}
	
		for(int i=0; i<4; ++i){
			for(int j=0; j<4; ++j){
				if(x[i]==y[j]){
					if(i==j) ++hit;
					else ++blow;
				}
			}
		}
	
		printf("%d %d\n", hit, blow);
	}

	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007ll
#define mod1 998244353ll
#define endl "\n"
using namespace std::chrono;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    double ar[n];
    for(ll x=0;x<n;x++){
        cin>>ar[x];
    }
    double dp[n][n+1];
    for(ll x=0;x<=n+1;x++){
        dp[0][x]=0;
    }
    dp[0][0]=1-ar[0];
    for(ll x=1;x<n;x++){
        dp[x][0]=dp[x-1][0]*(1-ar[x]);
    }
    dp[0][1]=ar[0];
    for(ll x=1;x<n;x++){
        for(ll y=1;y<=n;y++){
            dp[x][y]=0;
            if(y<=x+1){
                dp[x][y]=dp[x-1][y]*(1-ar[x])+dp[x-1][y-1]*ar[x];
            }
        }
    }
    double ans=0;
    for(ll x=n/2+1;x<=n;x++){
        ans+=dp[n-1][x];
    }
    cout<<setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 70528
#include <iostream>
#include <vector>
#include <limits>

using namespace std;


template<typename M>
struct segment_tree {
    using monoid = M;
    using value_type = typename monoid::value_type;
    
    size_t size;
    vector<value_type> data;
    
    segment_tree(size_t n = 0) {
        size = 1;
        while(size < n) size *= 2;
        data.assign(size*2, monoid::id());
        //init();
    }
    
    template<typename InputIter>
    segment_tree(InputIter first, InputIter last) {
        size_t n = distance(first, last);
        size = 1;
        while(size < n) size *= 2;
        data.assign(size*2, monoid::id());
        copy(first, last, data.begin()+size);
        build();
    }
    
    void fill(const value_type& x) {
        data.assign(size*2, x);
        std::fill(data.begin()+size, data.end(), x);
        build();
    }
    
    template<typename Function>
    void init_with(Function f) {
        for(size_t i=0; i<size; ++i) {
            data[size+i] = f(i);
        }
        build();
    }
    
    
    void build() {
        for(size_t i = size - 1; i>0; --i) {
            data[i] = monoid::op(data[2*i], data[2*i+1]);
        }
    }
    
    void update(size_t i, const value_type& x) {
        data[i += size] = x;
        while(i/=2) {
            data[i] = monoid::op(data[2*i], data[2*i+1]);
        }
    }
    
    value_type accumulate(size_t l, size_t r) const {
        value_type al = monoid::id(), ar = monoid::id();
        for(l+=size, r+=size; l<r; l/=2, r/=2) {
            if(l&1) al = monoid::op(al, data[l++]);
            if(r&1) ar = monoid::op(data[--r], ar);
        }
        return monoid::op(al, ar);
    }
    
    value_type operator[](size_t i) const {
        return data[size+i];
    }
    
};

struct sum_monoid {
    using value_type = int;
    static constexpr value_type id() { return 0; }
    static constexpr value_type op(const value_type& lhs, const value_type& rhs) { return lhs + rhs; }
};

struct min_monoid {
    using value_type = int;
    static constexpr value_type id() { return numeric_limits<int>::max(); }
    static constexpr value_type op(const value_type& lhs, const value_type& rhs) { return min(lhs, rhs); }
};

using rsq = segment_tree<sum_monoid>;
using rmq = segment_tree<min_monoid>;

constexpr int MAX = 2147483647;

int main() {
    int n, q;
    cin >> n >> q;
    rmq segtree(n+1);
    segtree.fill(MAX);
    while(q--) {
        int c, x, y;
        cin >> c >> x >> y;
        if(c) {
            cout << segtree.accumulate(x, y+1) << endl;
        } else {
            segtree.update(x, y);
        }
    }
    
    return 0;
}



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

class Calc_Mod{//calculate mod
    public:
        unsigned int mod=1000000007;
        ll plus_mod(ll a,ll b){
            return (a+b)%mod;
        }
        ll minus_mod(ll a,ll b){
            return (a-b)%mod;
        }
        ll multi_mod(ll a,ll b){
            return a*b%mod;
        }
        ll LSM(ll a,int b){//a^b%mod
            queue<int> q;
            while(b>=1){
                q.push(b%2);
                b/=2;
            }
            ll ans=1;
            while(!q.empty()){
                if(q.front()==1){
                    ans=multi_mod(ans,a);
                }
                a=multi_mod(a,a);
                q.pop();
            }
            return ans;
        }
        ll div_mod(ll a,ll b){// a/b
            return multi_mod(a,LSM(b,mod-2));
        }
        ll combi(ll a,ll b){//aCb
            ll ans=1;
            ll kaijo=1;
            rep(i,b){
                ans=multi_mod(ans,a-i);
                kaijo=multi_mod(kaijo,b-i);
            }
            ans=div_mod(ans,kaijo);
            return ans;
        }
};

int main()
{
    Calc_Mod mod;
    
    int N;
    cin >> N;
    vector<ll> a;
    vector<int> count_bit;
    count_bit.resize(60);
    a.resize(N);
    rep(i,N)cin>> a[i];
    vector<queue<int>> bin;
    bin.resize(N);
    rep(i,60)count_bit[i]=0;
    ll val;

    ll two_=1;
    rep(i,N){
        val=a[i];
        while(val>=1){
            bin[i].push(val%2);
            val/=2;
        }
    }
    int j;
    rep(i,N){
        j=0;
        while(!bin[i].empty()){
            count_bit[j++]+=bin[i].front();
            bin[i].pop();
        }
    }
    ll ans=0;
    rep(i,60){
        ans=mod.plus_mod(ans,mod.multi_mod(two_,mod.multi_mod(N-count_bit[i],count_bit[i])));
        two_=mod.multi_mod(two_,2);
    }
    cout << ans << endl;
}

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

using namespace std;

const int maxn = 105;

char mp[maxn][maxn];

int main()
{
    int a,b;
    scanf("%d%d",&b,&a);
    a--;
    b--;
    cout<<"100 100"<<endl;
    for(int i=0; i<100; i++)
    {
        for(int j=0; j<100; j++)
        {
            if(i<50)
            {
                mp[i][j] = '.';
            }
            else
                mp[i][j] = '#';
        }
    }

    for(int i=0; a>0; i+=2)
    {

        for(int j=0; j<100 && a>0; j+=2,a--)
        {
            mp[i][j] = '#';

        }
    }

    for(int i=51; b>0; i+=2)
    {

        for(int j=0; j<100&&b>0; j+=2,b--)
        {
            mp[i][j] = '.';
        }
    }
    for(int i=0; i<100; i++)
    {
        for(int j=0; j<100; j++)
        {
            cout<<mp[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
a, b, k = map(int, input().split())
for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        b += a // 2
        a //= 2
    else:
        if b % 2 == 1:
            b -= 1
        a += b // 2
        b //= 2
print(a, b)

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>

#define INF 10000

int t_rail[101][101],c_rail[101][101];
int ans[101],used[101];

using namespace std;
int main(void)
{
   int m,n;
   int a,b,cost,time;
   int call,s,g,r;
   while(scanf("%d%d",&m,&n),m+n)
   {
      for(int i = 0;i < 101;i++)
         for(int j = 0;j < 101;j++)
            {
               t_rail[i][j] = INF;
               c_rail[i][j] = INF;
            }

      for(int i = 0;i < m;i++)
      {
         scanf("%d%d%d%d",&a,&b,&cost,&time);
         t_rail[a][b] = time;
         t_rail[b][a] = time;
         c_rail[a][b] = cost;
         c_rail[b][a] = cost;
      }

      scanf("%d",&call);
      for(int j = 0;j < call;j++)
      {
         scanf("%d%d%d",&s,&g,&r);
         fill(ans,ans+101,INF);
         fill(used,used+101,0);
         ans[s] = 0;
         if(r == 0)
         {
            while(1)
            {
               int v = -1;
               for(int k = 0;k < 101;k++) if(used[k] == 0 && (v == -1 || ans[v] > ans[k]))v = k;
               if(v == -1) break;
               used[v] = 1;
               for(int k = 0;k < 101;k++) ans[k] = min(ans[k],ans[v]+c_rail[v][k]);
            }
         }
         else
         {
            while(1)
            {
               int v = -1;
               for(int k = 0;k < 101;k++) if(used[k] == 0 && (v == -1 || ans[v] > ans[k])) v = k;
               if(v == -1) break;
               used[v] = 1;
               for(int k = 0;k < 101;k++) ans[k] = min(ans[k],ans[v]+t_rail[v][k]);
            }
         }
         printf("%d\n",ans[g]);
      }
   }
   return 0;
}

Measured memory_bytes: 1268
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    A,B,X = map(int, lines.pop(0).split(' '))
    if ( A <= X and A + B >= X ):
        print('YES')
    else:
        print('NO')

#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

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

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

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int N;
	int eo[2] = {};

	cin >> N;
	int in;
	for(int i = 0; i < N; i++){
		cin >> in;
		eo[in&1]++;
	}
	eo[0] += eo[1]/2;

	if(eo[1]%2 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

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

flg = 100
for i in range(1,n):
    a = n- i
    b = i
    sum_a = sum([int(x) for x in list(str(a))])
    sum_b = sum([int(x) for x in list(str(b))])
    if flg > sum_a + sum_b:
        flg = sum_a + sum_b

print(flg)   


Measured memory_bytes: 42344
<?php
  $c[] = explode(" ",trim(fgets(STDIN)));
  $c[] = explode(" ",trim(fgets(STDIN)));
  $c[] = explode(" ",trim(fgets(STDIN)));
  
  for($i=1; $i<3; $i++){
      for($j=1; $j<3; $j++){
          if($c[0][$j]-$c[0][0] != $c[$i][$j]-$c[$i][0]){
              echo "No";
              exit;
          }
      }
  }
  echo "Yes";

Measured memory_bytes: 4604
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define forin(x,y) for(ll i=x;i<y;i++)
#define vii vector<ll>
#define pii  pair<ll,ll>
#define pb push_back
#define mp make_pair
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>;

void evaluate()
{
    ;
}
int main()
{
    ios::sync_with_stdio(false);    cin.tie(0);     cout.tie(0);
    ll n,k,temp=0,ans=0;    cin>>n>>k;
    vii v(n,0);
    vector<bool> dp(k+1,0);
    forin(0,n)
    {
        cin>>v[i];
    }
    forin(1,k+1)
    {
        for(auto j:v)
        {
            if(i>=j && dp[i-j] == false)
            {
                dp[i] = true;
            }
        }
    }
    cout<<(dp[k]? "First" : "Second" )<<endl;
}



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

int main(){
    int n,k;
    cin>>n>>k;
    double ans=0;
    for(int i=1;i<=n;i++){
        double x=1.0/n;
        double c=i;
        while(c<k){
            c*=2;
            x/=2;
        }
        ans+=x;
    }
    cout<<fixed<<setprecision(16);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3792
#include <cstdio>
#include <algorithm>
#include <cstdlib>
using namespace std;
#define F (1000000003)

int main(){
    int i,j,n,cf,ct,nanf,cnt;
    char s[12];

    while(1){
        scanf("%d",&n);
        if(!n){break;}
        int l[n],sg[n];
        fill(sg,sg+n,1);
        for(i=0;i<n;i++){
            scanf("%s",s);
            if(s[0]!='x'){
                l[i]=atoi(s);
            }
            else{
                l[i]=0;
                sg[i]=0;
            }
        }
        cf=-F;ct=F;nanf=0;
        if((l[0]>l[1] && sg[1] && sg[0]) || (!sg[0]&&!sg[1])){nanf=1;}
        else if(!sg[0] && sg[1]){ct=l[1]-1;}
        for(i=1;i<n-1&&!nanf;i++){
            if(i%2){
                if((sg[i] && sg[i+1] && l[i]<l[i+1]) || (!sg[i]&&!sg[i+1])){nanf=1;}
                else if(!sg[i]){
                    if(!sg[i-1] && sg[i+1]){
                        cf=max({cf,l[i+1]+1});
                    }
                    else if(sg[i-1] && !sg[i+1]){
                        cf=max({cf,l[i-1]+1});
                    }
                    else if(sg[i-1] && sg[i+1]){
                        cf=max({cf,l[i-1]+1,l[i+1]+1});
                    }
                }
            }
            else{
                if((sg[i] && sg[i+1] && l[i]>l[i+1]) || (!sg[i]&&!sg[i+1])){nanf=1;}
                else if(!sg[i]){
                    if(!sg[i-1] && sg[i+1]){
                        ct=min({ct,l[i+1]-1});
                    }
                    else if(sg[i-1] && !sg[i+1]){
                        ct=min({ct,l[i-1]-1});
                    }
                    else if(sg[i+1] && sg[i-1]){
                        ct=min({ct,l[i-1]-1,l[i+1]-1});
                    }
                }
            }
        }
        if(!sg[n-1] && sg[n-2]){
            if((n-1)%2){
                cf=max({cf,l[n-2]+1});
            }
            else{
                ct=min({ct,l[n-2]-1});
            }
        }
        if(nanf || cf>ct){printf("none\n");}
        else if(cf==ct){printf("%d\n",cf);}
        else{printf("ambiguous\n");}
    }
    return 0;
}



Measured memory_bytes: 2692
#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL n,a,b,S1,S2;
int main()
{
	cin>>n>>a>>b;
	if(n==1){ printf("%d",(a==b)); return 0;}
	if(a>b){ printf("0"); return 0;}
	S1=a+b+(n-2)*a;
	S2=a+b+(n-2)*b;
	cout<<S2-S1+1;
	return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

N =  int(readline())
HP = [tuple(map(int, readline().split())) for _ in range(N)]
HP.sort(key = lambda x: x[0] + x[1])
INF = 1<<64

dp = [0]
for i in range(N):
    hi, pi = HP[i]
    dp += [INF]
    for j in range(i+1, 0, -1):
        if dp[j-1] > hi:
            continue
        dp[j] = min(dp[j], dp[j-1]+pi)
for ans in range(N+1):
    if dp[ans] == INF:
        ans -= 1
        break
print(ans)



Measured memory_bytes: 45060
#include<stdio.h>

int main(void)
{
	int a, b;
	int i, j;
	int ans[10000];
	char op;
	
	for (i = 0; i < 10000; i++) {
		scanf("%d %c %d", &a, &op, &b);
		
		if (op == '+') {
			ans[i] = a + b;
		}
		else if (op == '-') {
			ans[i] = a - b;
		}
		else if (op == '*') {
			ans[i] = a * b;
		}
		else if (op == '/') {
			ans[i] = a / b;
		}
		else if (op == '?') {
			break;
		}
	}
	
	for (j = 0; j < i; j++) {
		printf("%d\n", ans[j]);
	}
	
	return (0);
}

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

struct UF{
	int par[100];
	int rank[100];

	void init(int n){
		rep(i,n){
			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 n, m;
int ans = INF;
int a[10000], b[10000], w[10000], ww[10000];

int main(){
	while(true){
		ans = INF;
		scanf("%d%d",&n,&m);
		if(n == 0 && m == 0) break;
		if(m == 0){
			cout << "-1" << endl;
			continue;
		}
		rep(i,m){
			scanf("%d%d%d",a+i,b+i,w+i);
			a[i]--; b[i]--;
			ww[i] = w[i];
		}
		sort(ww,ww+m);
		int st = 0, en = 0;
		while(true){
			if(st > en){
				en++;
				if(en >= m) break;
			}
			int mm = ww[st], MM = ww[en];
			if(MM-mm > ans){
				st++;
				continue;
			}
			UF uf;
			uf.init(n);
			rep(i,m){
				if(mm <= w[i] && w[i] <= MM){
					uf.unite(a[i],b[i]);
				}
			}
			int cnt = 0;
			rep(i,n) if(uf.par[i] == i) cnt++;
			if(cnt > 1) en++;
			else{
				ans = min(ans,MM-mm);
				st++;
			}
			if(en >= m) break;
		}
		if(ans == INF) cout << "-1" << endl;
		else cout << ans << endl;
	}
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll n, k;
	cin >> n >> k;

	vector<ll> a(n);
	for (auto &v : a) {
		cin >> v;
	}
	sort(begin(a), end(a));

	ll score = 0, ans = n;
	for (ll i = n - 1; i >= 0; i--) {
		if (score + a[i] < k) {
			score += a[i];
		} else {
			ans = min(ans, i);
		}
	}

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


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

int main()
{
	int zhuan(string x);
	string a,b,s;
	cin>>a>>b;
	s=a+b;
	if(sqrt(zhuan(s))==int(sqrt(zhuan(s))))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;	
}

int zhuan(string x)
{
	int num=0;
	for(int i=0;i<x.size();i++)
		num=num*10+(x[i]-'0');
	return num;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  string s;
  cin >> s;
  ll k;
  cin >> k;
  for(ll i=0;i<k;i++) {
    if(s[i]!='1') {
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}

Measured memory_bytes: 256
/**
   Author      : Md Jubayer Hossen Jame
   Study       : CSE, BRUR
   Date        : 22 November 2k19
   Source      : AtCoder Beginner Contest 145
   Problem link: https://atcoder.jp/contests/abc145/tasks/abc145_a
   Algorithm   :

**/

#include "bits/stdc++.h"
using namespace std;
int main()
{
    int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B;
    cin >> A >> B;
    int x=abs(A-B);
    int y=max(A,B);
    if(x%2==0) cout << y-x/2 << endl;
    else cout << "IMPOSSIBLE" << endl;



}


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

using namespace std;
using namespace atcoder;
typedef long long ll;

/*
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
void Add(ll &pos,ll val){pos=mod(pos+val);}
void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
*/

#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

typedef long double dd;
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
dd EPS=1E-12;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second

#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;


//using mint = modint998244353;
using mint = modint1000000007;
//////////////////////////


ll n,d;
bool out(ll i,ll j){
    if(abs(i-j)>=d)return false;
    return true;
}

int main(){fastio
    cin>>n>>d;
    ll x[n],y[n];
    rep(i,0,n-1)cin>>x[i]>>y[i];
    two_sat ts(n);
    rep(i,0,n-1){
        rep(j,i+1,n-1){
            if(out(x[i],x[j])){
                ts.add_clause(i,false,j,false);
            }
            if(out(x[i],y[j])){
                ts.add_clause(i,false,j,true);
            }
            if(out(y[i],x[j])){
                ts.add_clause(i,true,j,false);
            }
            if(out(y[i],y[j])){
                ts.add_clause(i,true,j,true);
            }
        }
    }
    if(ts.satisfiable()){
        cout<<"Yes"<<endl;
        vector<bool>ans=ts.answer();
        rep(i,0,n-1){
            if(ans[i])cout<<x[i]<<endl;
            else cout<<y[i]<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3800
#include <iostream>
#include <vector>
#include <climits>

using namespace std;
struct Drag{
    int a, b, c;
};
int gcd(int a, int b){
    int r = a%b;
    return r==0 ? b : gcd(b, r);
}
int main(){
    int n, ma, mb;
    cin >> n >> ma >> mb;
    vector<vector<vector<int>>> dp(n+1, vector<vector<int>>(n*10+1, vector<int>(n*10+1, INT_MAX)));
    dp[0][0][0]=0;
    // vector<Drag> drag(n);
    int a, b, c;
    int ans=INT_MAX;
    for(int i=1;i<=n;++i){
        // cin >> drag[i].a >> drag[i].b >> drag[i].c;
        cin >> a >> b >> c;
        for(int x=n*10;x>=0;--x){
            for(int y=n*10;y>=0;--y){
                if(x-a>=0 && y-b>=0 && dp[i-1][x-a][y-b]!=INT_MAX)
                    dp[i][x][y]=dp[i-1][x-a][y-b]+c;
                dp[i][x][y] = min(dp[i][x][y], dp[i-1][x][y]);
                if(ans>dp[i][x][y] && x!=0){
                    int g = gcd(x, y);
                    if(x/g==ma && y/g==mb)
                        ans=dp[i][x][y];
                }
            }
        }
    }
    cout << (ans==INT_MAX ? -1 : ans);
    return 0;
}

Measured memory_bytes: 27264
import java.util.*;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);
    int wallet = sc.nextInt();
    int cake   = sc.nextInt();
    int donut  = sc.nextInt();
    int result = wallet-cake;

    while(donut <= result){
      result -= donut;    
}
    System.out.println(result);
    }
}

Measured memory_bytes: 21844
# -*- coding: utf-8 -*-
from itertools import product
def inpl(): return map(int, input().split())
H, W = inpl()
S = [list("."*(W+2))]
for _ in range(H):
    S.append(list("." + input() + "."))
S.append(list("."*(W+2)))

for h, w, in product(range(1, H+1), range(1, W+1)):
    if S[h][w] == ".":
        continue
    ok = False
    for dh, dw in [[0, 1], [0, -1], [1, 0], [-1, 0]]:
        if S[h+dh][w+dw] == "#":
            ok = True
            break
    if not ok:
        print("No")
        break
else:
    print("Yes")

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

int main(){
  int n;
  long long k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }

  long long ans=0;
  for (int i = 0; i < n; i++)
  {
    for (int j = i+1; j < n; j++)
    {
      if(a[i]>a[j]){
        ans+=k;
        ans%=1000000007;
      }
    }
  }

  int cnt=0;
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < n; j++)
    {
      if(a[i]>a[j])cnt++;
    }
  }
  ans+=k*(k-1)/2 % 1000000007 * (long long)cnt;
  ans%=1000000007;
  cout << ans << endl;
}

Measured memory_bytes: 256
//
// ~oisín~ C++ Template
//

#include                <bits/stdc++.h>
#define MX_N            5001
#define mp              make_pair
#define mod7            1000000007
#define modpi           314159
#define PI              3.141592653589793238
#define pb              push_back
#define FastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define All(a)          a.begin(),a.end()
#define fi              first
#define se              second
#define ll              long long int
#define ull             unsigned long long int

int kx[8]  =            {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8]  =            {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] =            {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] =            {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] =            {+0, +0, +1, -1};
int dy4[4] =            {+1, -1, +0, +0};

ll gcd(ull a, ull b){
    return (a==0)?b:gcd(b%a,a);
}

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

const long long INF = 1e18;

using namespace std;

bool board[8][8];
int row_count[8];
int col_count[8];

bool biton(int x, int pos){
    return (x & (1 << pos));
}

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    int ans = 0;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            char tmp;
            cin >> tmp;
            board[i][j] = (tmp == '#');
        }
    }
    int state = 0;
    while(state < (1 << h)){
        int state2 = 0;
        while(state2 < (1 << w)){
            int left = 0;
            for(int i=0;i<h;++i){
                for(int j=0;j<w;++j){
                    if(biton(state, i) || biton(state2, j)){
                        continue;
                    }else{
                        left += (board[i][j]);
                    }
                }
            }
            ans += (left == k);
            ++state2;
        }
        ++state;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	int n;
	cin >> n;
	
	map<int,bool> mp;
	vector<int> v;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		if(mp.find(a) == mp.end()){
			mp[a] = true;
			v.push_back(a);
		}else{
			mp[a] = !mp[a];
		}
	}
	
	int ans = 0;
	for(int i = 0;i < v.size();i++){
		if(mp[v[i]]) ans++;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5368