akhauriyash/Code-Regression huggingface dataset:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    sa = input()
    sb = input()
    sc = input()
    la, lb, lc = len(sa), len(sb), len(sc)
    ia, ib, ic = 0, 0, 0
    turn = 'a'
    while True:
        if turn == 'a':
            if ia == la:
                print('A')
                break
            turn = sa[ia]
            ia += 1
        elif turn == 'b':
            if ib == lb:
                print('B')
                break
            turn = sb[ib]
            ib += 1
        else:
            if ic == lc:
                print('C')
                break
            turn = sc[ic]
            ic += 1

if __name__ == '__main__':
    main()

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  LL r,d,x;
  cin >> r >> d >> x;
  rep(i,10){
    x = r*x - d;
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <string.h>
using namespace std;


int main() {
    long long n,a,b;
    cin>>n>>a>>b;
    if (n==1&&a!=b||a>b)
        cout<<0<<endl;
    else {
        long long l = (n-1)*a+b;
        long long h = (n-1)*b+a;
        long long num = h-l+1;
        cout<<num<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n; cin>>n;
	vector<string> s(n);
	int l=0, r=n;
	cout<<l<<endl; cin>>s[l];
	if(s[l]=="Vacant") return 0;

	rep(i,20){
		int m=(l+r)/2; cout<<m<<endl; cin>>s[m];
		if(s[m]=="Vacant") return 0;

		if((l+m)%2){
			if(s[l]==s[m]) r=m;
			else l=m;
		}else{
			if(s[l]!=s[m]) r=m;
			else l=m;
		}
	}
	return 0;
}


Measured memory_bytes: 1620
#include "bits/stdc++.h"
using namespace std;

class Timer {
	std::chrono::high_resolution_clock::time_point m_start;
public:
	Timer() 
	: m_start(std::chrono::high_resolution_clock::now()) {}

	~Timer() {
		auto end = std::chrono::high_resolution_clock::now();
  		auto duration_s = std::chrono::duration<double>(end - m_start).count();
  		cerr << "Completed in " << duration_s << endl;
  	}
};

template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
#define LOCAL
struct debug {
#ifdef LOCAL
	~debug() { cerr << endl; }
	template < class c > typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) { cerr << boolalpha << i; return *this; }
	template < class c > typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) { return *this << range(begin(i), end(i)); }
	template < class c, class b > debug & operator <<(pair < b, c > d) {
	  return * this << "(" << d.first << ", " << d.second << ")";
	}
	template < class c > debug & operator <<(rge<c> d) {
	  *this << "[";
	  for (auto it = d.b; it != d.e; ++it)
	    *this << ", " + 2 * (it == d.b) << *it;
	  return * this << "]";
	}
#else
	template < class c > debug & operator <<(const c&) { return * this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#include <iostream>

void solve() {
	int n;
	cin >> n;
	{
		cout << n*n*n << endl;
		Timer timer;
	}
}

int main() {
	FAST
	int t = 1;
	// cin >> t;

	for (int i = 0; i < t; ++i) {
		solve();
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt(); int m = scan.nextInt();
        int [][] arr1 = new int[n+1][m+1];
          
        
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                arr1[i][j] = scan.nextInt();
            } 
        }
        
        for (int i = 0; i < n; i++) {
            int row = 0;
            for (int j = 0; j < m; j++) {
                row += arr1[i][j];
            }
            arr1[i][m] =row;
        }
        
        for (int i = 0; i < m +1; i++) {
            int column = 0;
            for (int j = 0; j < n; j++) {
                column += arr1[j][i];
            }
            arr1[n][i] =column;
            
        }
        
        for (int i = 0; i < n+1; i++) {
            for (int j = 0; j < m+1; j++) {
                System.out.print(arr1[i][j]);
                if (j < m) {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
        
    }
}


Measured memory_bytes: 42136
n, a, b = map(int, input().split())

num_lists = list(range(1, n+1, 1))
sum_lists = []
for i in num_lists:
  count = 0
  j = i
  while j >0:
    ans = j%10
    count += ans
    j = j//10
  if a <= count and count <= b:
    sum_lists.append(i)

answer = 0
for i in sum_lists:
  answer += i

print(answer)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
//#define ivorysi
#define MAXN 100005
typedef long long int64;
using namespace std;
template<class T>
void read(T &res) {
	res = 0;char c = getchar();T f = 1;
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
int64 N,M;
char S[MAXN],T[MAXN];
int64 gcd(int64 a,int64 b) {
	return b == 0 ? a : gcd(b,a % b);
}
int64 lcm(int64 a,int64 b) {
	return a * b / gcd(a,b);
}
void Solve() {
    read(N);read(M);
	scanf("%s",S + 1);scanf("%s",T + 1);
	int64 c = lcm(N,M);
	int64 a = c / M,b = c / N;
	for(int i = 0 ; i <= N ; ++i) {
		if(i * a + 1 > N || i * b + 1 > M) break;
		if(S[i * a + 1] != T[i * b + 1]) {puts("-1");return;}
	}
	out(c);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
	return 0;
}


Measured memory_bytes: 384
f1, f2, f3, f4, f5, f6 = map(int, input().split())

dice = {'f_top':f1, 'f_front':f2,'f_back':f5,'f_left':f4,'f_right':f3,'f_bottom':f6}

def roll(command, d):
    if command=='E':
        tmp = d['f_right']
        d['f_right'] = d['f_top']
        d['f_top'] = d['f_left']
        d['f_left'] = d['f_bottom']
        d['f_bottom'] = tmp
    elif command=='W':
        tmp = d['f_left']
        d['f_left'] = d['f_top']
        d['f_top'] = d['f_right']
        d['f_right'] = d['f_bottom']
        d['f_bottom'] = tmp
    elif command=='N':
        tmp = d['f_back']
        d['f_back'] = d['f_top']
        d['f_top'] = d['f_front']
        d['f_front'] = d['f_bottom']
        d['f_bottom'] = tmp
    elif command=='S':
        tmp = d['f_front']
        d['f_front'] = d['f_top']
        d['f_top'] = d['f_back']
        d['f_back'] = d['f_bottom']
        d['f_bottom'] = tmp
    return d
    
commands = input()
for s in commands:
    dice = roll(s, dice)

print(dice['f_top'])
        


Measured memory_bytes: 5604
n, k = map(int, input().split())
hl = []
for i in range(n):
  h = int(input())
  hl.append(h)
hl.sort()
mhl = []
for i in range(n - k + 1):
  mh = hl[i + k - 1] - hl[i]
  mhl.append(mh)
print(min(mhl))

Measured memory_bytes: 11288
n, m, Q = map(int, input().split())
A = [[0]*(n) for i in range(n)]
C = [[0]*(n+1) for i in range(n)]
for i in range(m):
    l, r = map(int, input().split())
    A[r-1][l-1] += 1

for i in range(n):
    a = A[i]
    c = C[i]
    for j in range(n):
        c[j+1] = c[j] + a[j]

for i in range(Q):
    p, q = map(int, input().split())
    ans = 0
    for i in range(p-1, q):
        ans+=C[i][q] - C[i][p-1]
    print(ans)


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    long double w,h,x,y; cin >> w >> h >> x >> y;
    int ans=0;
    if (w/2==x && h/2==y)
        ans=1;
    cout << w*h/2 << " " << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// https://atcoder.jp/contests/abc166/tasks/abc166_a
int main()
{
    int n,k,d;
    cin >> n >> k;
    vector<int> person;

    for(int i=1;i<=n;i++)
    {
        person.push_back(i);
    }

    for(int i=0;i<k;i++)
    {
        cin>>d;
        for(int j=0;j<d;j++)
        {
            int a;
            cin>>a;
            for(int ii=0;ii<n;ii++)
            {
                if(a==person[ii])
                {
                    person.erase(person.begin()+ii);
                    ii--;
                    n--;
                }
            }
        }
    }
    printf("%d\n",person.size());
    return 0;
}


Measured memory_bytes: 3728
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <array>
#include <vector>

using namespace std;

int main(int argc, const char *argv[])
{
  int n, q;
  string s;
  array<set<int>, 26> char_positions;
  cin >> n >> s >> q;
  for (int i = 0; i < s.size(); i++) {
    char_positions[s[i] - 'a'].insert(i);
  }

  for (int i = 0; i < q; i++) {
    int type;
    cin >> type;
    if (type == 1) {
      int p1;
      char p2;
      cin >> p1 >> p2;
      p1--;
      char_positions[s[p1] - 'a'].erase(p1);
      s[p1] = p2;
      char_positions[s[p1] - 'a'].insert(p1);
    } else {
      int p1, p2;
      cin >> p1 >> p2;
      p1--;
      p2--;
      int cnt = count_if(char_positions.begin(), char_positions.end(),
          [&](auto &positions) {
            auto pos_it = positions.lower_bound(p1);
            return pos_it != positions.end() && *pos_it <= p2;
          });
      cout << cnt << "\n";
    }
  }

  return 0;
}

Measured memory_bytes: 24196
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = "";

		long n = scanner.nextLong();
		while (n-- > 0){
			s = (char)('a' + (n%26)) + s;
			n /= 26;
		}
		System.out.println(s);
	}

}


Measured memory_bytes: 39324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
/* ちゃんと考えてわかって実装 */

int main(void){
    ll d, g;
    cin >> d >> g;
    vector<P> pc;
    for(int i=0; i<d; i++){
        ll tmpp, tmpc;
        cin >> tmpp >> tmpc;
        pc.push_back(P(tmpp, tmpc));
    }

    ll ans = 10000000000000000;
    for(int i=0; i<(1<<d); i++){
        ll tmp_ans = 0;
        ll tmp_score = 0;
        priority_queue<ll> mada;
        for(int j=0; j<d; j++){
            if(i>>j & 1){
                tmp_ans += pc[j].first;
                tmp_score += 100 * (j+1) * pc[j].first;
                tmp_score += pc[j].second;
            }
            else{
                for(int k=0; k<pc[j].first-1; k++){
                    mada.push(100 * (j+1));
                }
            }
        }
        while(tmp_score < g && !mada.empty()){
            tmp_score += mada.top();
            mada.pop();
            tmp_ans++;
        }
        if(tmp_score >= g){
            ans = min(ans, tmp_ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

if abs(N - K) >= N:
    print(N)
    exit()


dec = N - abs(N - K)
q, r = divmod(N, dec)

n = abs(r - K)
while n < r:
    r = n
    n = abs(r - K)

print(r)



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

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

    vector<int> a(N);
    for (int i = 0; i<N; i++) {
        cin >> a.at(i);
    }

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    int A = 0;
    int B = 0;
    int x;
    for (int i = 0; i<N; i++) {
        x = i%2;
        if (x <= 0) {
            A += a.at(i);
        }
        else if (x>0){
            B += a.at(i);
        }
    }

    cout << A-B << endl;
}

Measured memory_bytes: 256
package main
 
import (
  "fmt"
)
 
func main() {
  var O, E string
  fmt.Scan(&O)
  fmt.Scan(&E)
  
  ans := ""
  for i := 0; i < len(E); i++ {
    ans += O[i:i+1] + E[i:i+1]
  }
  if len(O) != len(E) {
  	ans += O[len(O)-1:len(O)]
  }
  fmt.Printf("%s\n", ans)
}

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

int main(void){
  int N, x, a[100], i, j, save, sum = 0, count = 0;
  scanf("%d %d", &N, &x);
  for(i=0; i<N; i++) scanf("%d",&a[i]);
  for(i=0; i<N; i++){
    for(j=i+1; j<N; j++){
      if(a[i] > a[j]){
        save = a[i];
        a[i] = a[j];
        a[j] = save;
      }
    }
  }
  for(i=0; i<N; i++){
    if(i == N - 1){
      if(sum + a[i] == x) count++;
      else ;
    }
    else{
      if(sum + a[i] < x){
        sum = sum + a[i];
        count++;
      }
      else if(sum + a[i] == x){
        count++;
        break;
      }
      else break;
    }
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 1728
#include <stdio.h>
int main(int argc, char const *argv[])
{
    unsigned long num753;
    int i, n, nc, keta;
    int ans = 0;
    int c7, c5, c3;
    num753 = i = 0;
    scanf("%d", &n);
    while (1)
    {
        i++;
        nc = i;
        num753 = 0;
        keta = 1;
        c3 = c5 = c7 = 0;
        const int sinsu = 4;
        for (; nc;)
        {
            switch (nc % sinsu)
            {
            case 0:
                // putchar('N');
                goto out;
            case 1:
                num753 += 3 * keta;
                c3 = 1;
                break;
            case 2:
                num753 += 5 * keta;
                c5 = 1;
                break;
            case 3:
                num753 += 7 * keta;
                c7 = 1;
                break;
            }
            nc /= sinsu;
            keta *= 10;
        }
        if(num753 > n){
            break;
        }
        if (c3 + c5 + c7 == 3)
        {
            ans++;
            // printf("%ld\t", num753);
        }
    out:;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

/*
 * @author Tanzim Ibn Patowary
 * Created  Apr 25, 2020 3:55:23 AM
 */
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner mScanner = new Scanner(System.in);
		int N = mScanner.nextInt();
		int M= mScanner.nextInt();
		int sum = 0;
		for (int i = 0; i < M; i++) {
			int a = mScanner.nextInt();
			sum+=a;
			
		}
		if (sum>N) {
			System.out.println(-1);
		}else {
			System.out.println(N-sum);
		}
	}

}


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

using namespace std;

vector<int> pri;

struct UnionFind
{
	vector<int> data;

	UnionFind(int size)
	{
		data.resize(size, -1);
	}

	void unite(int x, int y)
	{
		x = find(x), y = find(y);
		if (x != y)
		{
			if (data[x] > data[y])
				swap(x, y);
			data[x] += data[y];
			data[y] = x;
		}
	}

	int find(int x)
	{
		if (data[x] < 0)
			return x;
		return data[x] = find(data[x]);
	}
};

void get_pri(int m)
{
	vector<bool> tmp(m + 1, true);
	for (int i = 2; i <= sqrt(m); i++)
		if (tmp[i])
			for (int j = 0; i * (j + 2) <= m; j++)
				tmp[i * (j + 2)] = false;
	for (int i = 2; i <= m; i++)
		if (tmp[i])
			pri.push_back(i);
}

int main()
{
	int n;
	cin >> n;
	vector<int> a(n), aft;
	int m = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		m = max(m, a[i]);
	}
	aft = a;
	sort(aft.begin(), aft.end());
	get_pri(m);
	int psize = pri.size();
	UnionFind UF(n);
	vector<int> p(m + 1, -1);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < psize && pri[j] <= a[i]; j++)
			if (a[i] % pri[j] == 0)
				if (p[pri[j]] == -1)
					p[pri[j]] = i;
				else
					UF.unite(p[pri[j]], i);
	bool ok = true;
	vector<int> use(m + 1, 0);
	for (int i = n - 1; 0 <= i; i--)
		use[aft[i]] = i;
	for (int i = 0; i < n; i++)
	{
		int it = use[a[i]];
		if (UF.find(i) != UF.find(it))
			ok = false;
		use[a[i]]++;
	}
	cout << (ok ? 1 : 0) << endl;

	return 0;
}



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

using namespace std;

typedef long long ll;

ll n;
ll a[100005];
ll ans;
ll mx, mn;

ll f(ll p)
{
    for(ll i = 1; i <= n; i++)
    {
        p = p / a[i] * a[i];
    }
    return p;
}

int main()
{
    scanf("%lld", &n);
    for(ll i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
    }
    ll lt, rt, mid, ans;
    lt = 2;
    rt = 4e18;
    while(lt <= rt)
    {
        mid = (lt + rt) / 2;
        if(f(mid) > 2) rt = mid - 1;
        else ans = mid, lt = mid + 1;
    }
    mx = ans;
    lt = 2;
    rt = 4e18;
    while(lt <= rt)
    {
        mid = (lt + rt) / 2;
        if(f(mid) < 2) lt = mid + 1;
        else ans = mid, rt = mid - 1;
    }
    mn = ans;
    if(mn > mx) printf("-1\n");
    else printf("%lld %lld\n", mn, mx);
    return 0;
}


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

//#include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// using cint = cpp_int;
//#pragma GCC optimize("", on)
//#pragma GCC optimization_level 3

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)
#define input(a) scanf("%lld", &(a))
#define print(a) printf("%lld\n", (a))

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

#define dump(a, h, w)                                                          \
    {                                                                          \
        cerr << __LINE__ << ": " << #a << " = [" << endl;                      \
        rep(i, h) {                                                            \
            rep(j, w) cerr << a[i][j] << space;                                \
            cerr << endl;                                                      \
        }                                                                      \
        cerr << "]" << endl;                                                   \
    }

#define lldump(a, n) dump(vector<vector<ll>>{a}, 1, n)

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)
#define loop() for (;;)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }
func sign(ll a) { return a ? abs(a) / a : 0; }

def in() {
    ll A;
    cin >> A;
    return A;
}

string S;
ll D[26];
signed main() {
    cin >> S;
    rep(i, S.size()) D[S[i] - 'a']++;
    rep(i, 26) if (D[i] & 1) return puts("No") & 0;
    return puts("Yes") & 0;
}

// for compilation: g++ -Ofast -march=native -o _ _.cpp -std=c++17


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

#define A 1
#define B 2
#define C 3
#define D 4
#define E 5
#define F 6

int judge(int mid_score, int fin_score, int re_score)
{
    if(mid_score == -1 || fin_score == -1) return F;
    
    if(mid_score + fin_score >= 80) return A;
    if(mid_score + fin_score >= 65 && mid_score + fin_score < 80) return B;
    if(mid_score + fin_score >= 50 && mid_score + fin_score < 65) return C;

    if(mid_score + fin_score >= 30 && mid_score + fin_score < 50) {
        if(re_score >= 50) return C;
        else return D;
    }

    if(mid_score + fin_score < 30) return F;

    return 0;
}

int main()
{
    // ???????????\???
    int m, f, r;
    int mid_score[512], fin_score[512], re_score[512]; // ??¨???????????????????????????512
    int si = 0;
    while(cin >> m >> f >> r) {
        mid_score[si] = m;
        fin_score[si] = f;
         re_score[si] = r;
        if(m == -1 && f == -1 && r == -1) break;
        si++;
    }

    for(int i = 0; i < si; i++) {
        int result;
        result = judge(mid_score[i], fin_score[i], re_score[i]);

        if(result == A) cout << "A" << endl;
        else if(result == B) cout << "B" << endl;
        else if(result == C) cout << "C" << endl;
        else if(result == D) cout << "D" << endl;
        else if(result == E) cout << "E" << endl;
        else if(result == F) cout << "F" << endl;
        else cout << "error: unknown result" << endl;
    }

    return 0;
}

Measured memory_bytes: 1156
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            String a = Console.ReadLine();
            String[] array = a.Split(' '); //???????????????????????£??\

            //??°???????????´????????£??\
            int w = int.Parse(array[0]);
            int h = int.Parse(array[1]);
            int x = int.Parse(array[2]);
            int y = int.Parse(array[3]);
            int r = int.Parse(array[4]);

            if((x-r < 0 || x+r > w)||(y-r < 0 || y+r > h ))
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }

           

         }
    }
}

Measured memory_bytes: 8972
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
using namespace std;
const int MAX=1e9+7;
int a[400020],b[400020],l,r,mid,ans,n;
bool cmp(int x,int y){
	return x<y;
} 
int check(int x){
	int p=0;
	int m=n;
	int last;
	int len=0;
	int now;
	if(a[m]>=x) last=1;
	else last=0;
	int w1=MAX,w0=MAX;
	for(int i=m+1;i<=2*n-1;i++){
		if(a[i]>=x) now=1;
		else now=0;
		if(now==last){
			if(now==1){
				w1=i-m;
			}
			else{
				w0=i-m;
			}
			break;
		}
		if(i==2*n-1) p++;
		last=now;
	}
	if(a[m]>=x) last=1;
	else last=0;
	for(int i=m-1;i>=1;i--){
		if(a[i]>=x) now=1;
		else now=0;
		if(now==last){
			if(now==1){
				w1=m-i;
			}
			else{
				w0=m-i;
			}
			break;
		}
		if(i==1) p++;
		last=now;
	}
	if(p==2){
		if(a[1]>=x) return 1;
		else return -1;
	}
	if(w1<=w0) return 1;
	else return -1;
}
int main(){
    //freopen("find.in","r",stdin);
    //freopen("find.out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=2*n-1;i++){
    	scanf("%d",&a[i]);
    	b[i]=a[i];
    }
    sort(b+1,b+2*n,cmp);
    l=1;
    r=2*n-1;
    //
    //printf("%d %d\n",l,r);
    //
    while(l<=r){
    	mid=(l+r)/2;
    	if(check(b[mid])==1){
    		ans=b[mid];
    		l=mid+1;
    		//
    		//printf("%d %d  1\n",l,r);
    		//
    	}
    	else{
    		r=mid-1;
    		//
    		//printf("%d %d  -1\n",l,r);
    		//
    	}
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main() { int k; scanf("%d", &k); printf("%d\n", arr[k - 1]); }

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val S = next().map { it - '0' }
    fun count(v: List<Int>, d: Int): Int {
        var c = 0
        v.forEachIndexed { index, n -> c += if (index % 2 == d) n else 1 - n }
        return c
    }
    println(Math.min(count(S, 0), count(S, 1)))
}
fun next() = readLine()!!

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

int main(){
  string A,B,C;
  cin >> A >> B >> C;
  if((A.back()==B.front())&&(B.back()==C.front())){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int a[10]={0,1,2,3,4,5,6,7,8,9};
 int n,s;
 int count_2;
 
 void dfs(int step,int i,int sum)
 {
   if(sum>s||step>n) return;
   if(i==10)
   {
     if(step==n&&i==10&&sum==s)
     {
       count_2++;
       return;                          
     }
     else return; 
   }    
   dfs(step,i+1,sum); 
   dfs(step+1,i+1,sum+a[i]);
   return;
 }
  
 int main()
 {
   while(cin>>n>>s)
   {
     if(n==0&&s==0) break;
     else
     {
       count_2=0;
       dfs(0,0,0);    
     } 
     cout<<count_2<<endl;               
   }
   //while(1);     
   return 0;  
 }
 

Measured memory_bytes: 3088
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=jp
 */
import java.util.*;

class Task {
	String name;
	int time;
	int endTime;
	Task(String name, int time) {
		this.name = name;
		this.time = time;
	}
	void setEndTime(int x) {
		this.endTime = x;
	}
}

public class Main {
	
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int q = scan.nextInt();
		//Task[] tasks = new Task[n];
		LinkedList<Task> tasks = new LinkedList<Task>();
		for (int i = 0; i < n; i++) {
			String name = scan.next();
			int time = scan.nextInt();
			//tasks[i] = new Task(name, time);
			tasks.add(new Task(name, time));
		}

		Task[] result = new Task[n];
		int topOfResult = 0;
		
		int time = 0;
		int idx = 0;
		while (topOfResult < n) {
			Task task = tasks.pop();
			if (task.time > q) {
				task.time -= q;
				time += q;
				tasks.add(task);
			} else if (task.time > 0) {
				time += task.time;
				task.time = 0;
				task.setEndTime(time);
				result[topOfResult++] = task;
			}
			if (++idx >= n) idx = 0;
		}
		
		for (int i = 0; i < result.length; i++) {
			System.out.println(result[i].name + " " + result[i].endTime);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

}



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

using namespace std;

set<int> g[100005], dg[100005];
bool vis[100005]={};
int out=0;

void dfs(int u, int par){
	vis[u]=1;
	for(auto v:g[u]){
		if(!vis[v])
			dfs(v, u);
	}
	
	int ind=0, la;
	for(auto v:dg[u]){
		if(v!=par){
			if(ind&1){
				cout << u << " " << la << endl;
				cout << u << " " << v << endl;
				dg[la].erase(u);
				dg[v].erase(u);
				out+=2;
			}
			la=v;
			ind++;
		}
	}
	if((((dg[u].size())&1)==0) && (u!=1)){
		cout << u << " " << la << endl;
		cout << u << " " << par << endl;
		out+=2;
		dg[la].erase(u);
		dg[par].erase(u);
	}
}

int main(){
	int n,m; cin >> n >> m;
	for(int i=0,u,v;i<m;i++){
		cin >> u >> v;
		g[u].insert(v);
		g[v].insert(u);
		dg[u].insert(v);
		dg[v].insert(u);
	}
	
	if(m&1){
		cout << -1 << endl;
		return 0;
	}
	dfs(1,-1);
	return 0;
}

Measured memory_bytes: 37376
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = N / 1000;
    int B = (N % 1000) / 100;
    int C = (N % 100) / 10;
    int D = N % 10;
    String op[] = {"+", "+", "+"};
    if (A + B + C + D != 7) {
      if (A + B + C - D == 7) {
        op[2] = "-";
      } else if (A + B - C + D == 7) {
        op[1] = "-";
      } else if (A + B - C - D == 7) {
        op[1] = "-";
        op[2] = "-";
      } else {
        op[0] = "-";
        if (A - B + C + D != 7) {
          if (A - B + C - D == 7) {
            op[2] = "-";
          } else if (A - B - C + D == 7) {
            op[1] = "-";
          } else {
            op[1] = "-";
            op[2] = "-";
          }
        }
      }
    }
    System.out.println(A + op[0] + B + op[1] + C + op[2] + D + "=7");
  }
}


Measured memory_bytes: 21844
import math  # noqa: F401
from typing import Dict, List, Optional, Set, Tuple, Union  # noqa: F401


def main(N: int, K: int, D: List[int], A: List[List[int]]) -> None:
    ans: Set[int] = {i for i in range(1, N + 1)}
    for a in A:
        for a_ in a:
            ans -= {a_}
    print(len(ans))


if __name__ == "__main__":
    N, K = map(int, input().split())
    D = []
    A = []
    for _ in range(K):
        d = int(input())
        D.append(d)
        a = list(map(int, input().split()))
        A.append(a)
    main(N, K, D, A)


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


int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //-----------------------------------------
    int N, M;
    cin >> N >> M;
    
    int ans=0;
    ans = N*(N-1)/2 + M*(M-1)/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) //[l, r)
#define rep(i,n) REP(i,0,n)           //[0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showslr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i];}cerr<<endl //[l, r))

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

void _DEBUG(){cerr<<endl;}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<",";_DEBUG(b...);}

template<typename T> inline void in(T &e){cin>>e;}
template<typename H,typename... T>void in(H &a, T&... b){in(a);in(b...);}
template<typename T> inline void out(T e){cout<<e<<endl;}
template<typename H,typename... T> void out(H a, T... b){out(a);out(b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

string s;
vi num;

signed main(){
    io();

    in(s);
    rep(i,4){
        num.pb(s[i]-'0');
    }
    rep(i,(1<<3)){
        int ans=num[0];
        rep(j,3){
            //show(1<<j);
            if(i&(1<<j)){
                ans+=num[j+1];
            }else{
                ans-=num[j+1];
            }
        }
        //show(i,ans);
        if(ans==7){
            cout<<num[0];
            rep(j,3){
                char c=(i&(1<<j))?'+':'-';
                cout<<c<<num[j+1];
            }
            cout<<"=7"<<endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll N, red = 0, cnt = 0;
  cin >> N;
  vector<char> c(N);
  for(ll i = 0; i < N; i++) {
    cin >> c.at(i);
    if(c.at(i) == 'R') red++;
  }
  for(ll i = 0; i < red; i++) {
    if(c.at(i) == 'W') cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;



signed main(){
	int X,N;
	cin>>X>>N;
	vector<int>a(N);
	vector<int>cnt(100010);
	REP(i,N){
		cin >> a[i];
		++cnt[a[i]];
	}
	vector<pair<int,int>>ans;
	REP(i,100010){
		if(!cnt[i])ans.emplace_back(abs(i-X),i);
	}
	sort(ALL(ans));
	out(ans[0].second);
}

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

int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                if(i*500+j*100+k*50 == x) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

//??°?????????lowlink???????????????????????¢????????¨??????????????????
//?¨??????? O(|V|+|E|)
void lowlink(vector<int>graph[], int n, vector<int>&low, vector<pair<int, int>>&br, vector<int>&jnt) {
	low.resize(n);
	vector<int>ord(n);//DFS?????????
	vector<bool>vis(n);//?¨???????????????????
	//?????°????????????
	function<void(int, int, int&)>dfs = [&](int v, int p, int &k) {
		vis[v] = true;
		ord[v] = k++;
		low[v] = ord[v];
		bool joint = false;
		int cnt = 0;
		for (auto nxt : graph[v]) {
			if (!vis[nxt]) {
				cnt++;
				dfs(nxt, v, k);
				low[v] = min(low[v], low[nxt]);
				if (p >= 0 && ord[v] <= low[nxt]) joint = true;
				if (ord[v] < low[nxt])br.push_back({ min(v,nxt),max(v,nxt) });
			}
			else if (nxt != p) {
				low[v] = min(low[v], ord[nxt]);
			}
		}
		if (p < 0 && cnt > 1) joint = true;
		if (joint) jnt.push_back(v);
	};
	int k = 0;
	for (int i = 0; i < n; ++i)
		if (!vis[i])dfs(i, -1, k);
}

int N, M;
vector<int>graph[123456];

int main(void)
{
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int s, t;
		cin >> s >> t;
		graph[s].push_back(t);
		graph[t].push_back(s);
	}
	vector<int>low, jnt;
	vector<pair<int, int>>br;
	lowlink(graph, N, low, br, jnt);
	sort(br.begin(), br.end());
	for (auto i : br) {
		cout << i.first << " " << i.second << endl;
	}
	return 0;
}

Measured memory_bytes: 7728
import collections

N = int(input())
S = list(input())

dic = collections.Counter(S)

# RGBの選び方
cnt = 1
c = 0
for k, v in dic.items():
    c += 1
    cnt *= v

if v == 0 or c != 3:
    print(0)
else:
    for j in range(1, N - 1):
        mm = min(j, N - j - 1)
        for d in range(1, mm + 1):
            if S[j - d] != S[j] and S[j] != S[j + d] and S[j - d] != S[j + d]:
                cnt -= 1

    print(cnt)


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

long long int c[10005];
int main(){
    string S;
    long long int N,P,i;
    long long int tmp = 0;
    long long int count = 0;
    long long int ten=1;
    cin >> N >> P;
    cin >> S;
    if(P==2 || P==5){
        for(i=0;i<S.length();i++)if((S[i]-'0')%P==0)count+=(i+1);
    }
    else{
        for(i=0;i<S.length();i++){
            tmp=tmp+ten*(S[N-1-i]-'0');
            tmp%=P;
            ten=(ten*10)%P;
            c[tmp]++;
        }
        count=c[0];
        for(i=0;i<P;i++)count+=c[i]*(c[i]-1)/2;
    }
    cout << count << endl;
}

Measured memory_bytes: 644
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n = ni()
a = sorted(nl())
ans = a.pop()
i = n - 2
while i > 0:
    if i == 1:
        ans += a.pop()
        break
    else:
        i -= 2
        ans += a.pop()*2
print(ans)

Measured memory_bytes: 31296
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    int wa,sa,seki;
    wa=a+b;
  sa=a-b;
  seki=a*b;
  int max;
    if(wa>sa) max=wa;
      else max=sa;
  if(max>seki) max=max;
  else max=seki;
    cout <<max <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

string S;

int main(){
    cin>>S;

    int bw=S[0];
    int ans=0;
    for(int i=1;i<S.size();i++){
        if(i%2==1 && S[i]==bw){
            ans++;
        }
        if(i%2==0 && S[i]!=bw){
            ans++;
        }
    }

    cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, w;
    cin >> n >> w;
    ll v[n], p[n], dp[n + 1][w + 1];
    for(int i = 0; i < n; i++) cin >> p[i] >> v[i];

    for(int i = 0; i <= n; i++) dp[i][0] = 0;
    for(int i = 0; i <= w; i++) dp[0][i] = 0;

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= w; j++){
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if(j - p[i - 1] >= 0) dp[i][j] = max(dp[i][j], dp[i - 1][j - p[i - 1]] + v[i - 1]);
        }

    cout << dp[n][w] << endl;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
long long int mod=1e9 +7;

long long int fast_exp(long long int base,long long int ex) {
    long long int res=1;
    while(ex>0) {
       if(ex%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       ex/=2;
    }
    return res%mod;
}
long long int gcd(long long int a, long long int b)
{
    if(b==0)return a;
    else return gcd(b,a%b);
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int a,b;
cin>>a>>b;
int ar=a*b;
ar-=(a+b-1);
cout<<ar<<"\n";
  
   return 0;
}


Measured memory_bytes: 384
n, m = map(int, input().split())
s = input()
dp = [-1 for _i in range(n+1)]
dp[0] = 0
f = 0
from collections import deque
q = deque([0])
c = 0
for i in range(1, n+1):
    if s[i]=="0":
        c = 0
        while i-f > m:
            f = q.popleft()
        dp[i] = f
        q.append(i)
    elif c < m-1:
        c += 1
    else:
        break

if dp[n] >= 0:
    r = []
    p = n
    while p > 0:
        nex = dp[p]
        r.append(p-nex)
        p = nex
    print(*r[::-1])
else:
    print(-1)

Measured memory_bytes: 10560
while True:
    s_m = 0
    n = int(input())
    if n == 0:
        break
    for i in range(n):
        x,y,h,w = map(int,input().split())
        if x + y + h <= 60 and w <= 2:
            s_m += 600
        elif x + y + h <= 80 and w <= 5:
            s_m += 800
        elif x + y + h <= 100 and w <= 10:
            s_m += 1000
        elif x + y + h <= 120 and w <= 15:
            s_m += 1200
        elif x + y + h <= 140 and w <= 20:
            s_m += 1400
        elif x + y + h <= 160 and w <= 25:
            s_m += 1600
    print(s_m)

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

int a[8005];
int dp[8005][16005];
string s;
int x,y;

int main(){
	cin>>s;
	cin>>x>>y;
	
	int k=0;
	int w=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='T'){
			k++;
			a[k]=w;
			w=0;
		}
		else{
			w++;
		}
	}
	k++;
	a[k]=w;
	
	dp[1][a[1]+8000]=1;
	
	for(int i=3;i<=k;i+=2)
	   for(int j=0;j<=16000;j++){
	   	   if(j+a[i]<=16000){
	   	   	  dp[i][j]=dp[i-2][j+a[i]];
	   	   }
	   	   if(j-a[i]>=0){
	   	   	  dp[i][j]=dp[i][j] || dp[i-2][j-a[i]];
	   	   }
	   }
	
	dp[0][8000]=1;
	
	for(int i=2;i<=k;i+=2)
	   for(int j=0;j<=16000;j++){
	   	   if(j+a[i]<=16000){
	   	   	  dp[i][j]=dp[i-2][j+a[i]];
	   	   }
	   	   if(j-a[i]>=0){
	   	   	  dp[i][j]=dp[i][j] || dp[i-2][j-a[i]];
	   	   }
	   }
	   
	int ans;
	
	if(k%2==1) ans=dp[k][x+8000] && dp[k-1][y+8000];
	else ans=dp[k][y+8000] && dp[k-1][x+8000];
	
	if(ans) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 497792
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  int cnt = 0;
  rep(i, n){
    int p;
    cin >> p;
    if(p != i + 1) cnt++;
  }
  if(cnt > 2) cout << "NO" << endl;
  else cout << "YES" << endl;
}

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

void fnInput(vector<int>& rvnSeq)
{
  int nSeqSiz;
  cin >> nSeqSiz;
  rvnSeq.resize(nSeqSiz);

  for (int& rnSeq : rvnSeq)
    cin >> rnSeq;
}
  
void fnSeqMaxNum(const vector<int>& cnrvnSeq, vector<int>& rvnMax)
{
  vector<int> vnSrtSeq(cnrvnSeq);
  sort(begin(vnSrtSeq), end(vnSrtSeq));

  for (int i = 0; i < cnrvnSeq.size(); i++)
    if (cnrvnSeq[i] == vnSrtSeq[vnSrtSeq.size() - 1])
      rvnMax.push_back( vnSrtSeq[vnSrtSeq.size() - 2] );
    else
      rvnMax.push_back( vnSrtSeq[vnSrtSeq.size() - 1] );
}
  
int main()
{
  vector<int> vnSeq, vnMax;

  fnInput(vnSeq);
  fnSeqMaxNum(vnSeq, vnMax);

  for (int nMax : vnMax)
    cout << nMax << endl;

  return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n,k;
	cin>>n>>k;

	map<lli,lli> d;
	REP(i,0,n){
		lli a,b;
		cin>>a>>b;
		d[a]+=b;
	}

	lli cnt=0;
	for(auto &e:d){
		cnt += e.second;
		if(cnt>=k){
			cout<<e.first<<endl;
			return 0;
		}
	}

	return 0;
}

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

struct pk{
int a,b,c;
};

int main()
{
int n;
cin>>n;
pk p[n];
for(int i=0;i<n;i++)
cin>>p[i].a>>p[i].b>>p[i].c;
int dp[n+1][3];
dp[0][0]=dp[0][1]=dp[0][2]=0;
for(int i=1;i<=n;i++)
{
dp[i][0]=max(dp[i-1][1],dp[i-1][2])+p[i-1].a;
dp[i][1]=max(dp[i-1][0],dp[i-1][2])+p[i-1].b;
dp[i][2]=max(dp[i-1][1],dp[i-1][0])+p[i-1].c;
}
cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
return 0;
}

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

int main() {
  int num;
  cin >> num;
  vector<int> scores(num);

  for (int i = 0; i < num; i++) {
    int score;
    cin >> score;
    scores[i] = score;
  }
  sort(scores.begin(), scores.end(), [](int a, int b) -> bool { return (a > b); } );

  int sum_score = 0, min_score = 101;
  for (auto score : scores) {
    sum_score += score;
    min_score = min_score > score && score % 10 != 0 ? score : min_score;
  }

  cout << (min_score == 101 ? 0 : sum_score % 10 == 0 ? sum_score - min_score : sum_score) << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        int pien=1000;
        int otsuri=0;
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int amari = N%pien;
        if(amari != 0){
             otsuri = pien-amari;
        }else{
            otsuri = amari;
        }
        System.out.println(otsuri);
    }
}


Measured memory_bytes: 35524
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,M=2e6+5,MOD=1e9+7,OO=1e9;


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


	ll n;
	scanf("%lld",&n);
	int ans = 1<<30;
	for(ll i = 1;i*i<=n;i++){
		if(n%i==0){
			ll x = n/i;
			ll y = i;
			int cnt1=0,cnt2=0;
			while(x)cnt1++,x/=10;
			while(y)cnt2++,y/=10;
			ans = min(ans,max(cnt1,cnt2));
		}
	}
	printf("%d\n",ans );
}


Measured memory_bytes: 256
BIG_NUM = 2000000000
 
table = [[[0]*10 for i in range (0,3)] for k in range (0,4)]
 
N = int(input())
 
for loop in range(N):
    house_id,floor,room,add = map(int,input().split())
    table[house_id-1][floor-1][room-1] += add
 
 
x = 0
 
for i in range(4):
    if x != 0:
        print("#"*20)
    x += 1
 
    for a in range(3):
        for b in range(10):
            print(" %d"%(table[i][a][b]),end = "")
        print()


Measured memory_bytes: 5628
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

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() {
	string s, t;
	cin >> s >> t;

	

	cout << t+s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    
ll a,b,c,d;
cin>>a>>b>>c>>d;
if(d>a)
{
    d=d-a;
    d=d-b;
    if(d<=0)
    {
        cout<<a<<endl;
    }
    else
    {
        cout<<""<<a-d<<endl;
    }
}
else
{
    cout<<""<<d<<endl;
}

}

Measured memory_bytes: 3636