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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}

void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}

void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

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

int main(){
    int64_t H, W, T;
    cin >> H >> W >> T;

    int64_t gh = gcd(H, T), gw = gcd(W, T);
    int64_t rx = H/gh, ry = W/gw;
    int64_t ans = (power_mod(2, rx) + power_mod(2, ry) + power_mod(2, gcd(rx, ry)) + MOD - 3) % MOD;
    ans = power_mod(ans, gh*gw);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val A = Array.fill(N)(sc.nextInt())
    val M = new Array[Int](N)

    var f = false
    var i = 0
    var sr = 0L
    while (i < N) {
      if (f)
        sr += A(i)
      else
        sr -= A(i)
      f = !f
      i += 1
    }
    val X1 = Math.abs(sr)

    // x1 は山1に降った雨の量
    // x2 = A(1) - x1
    // ...
    // xN = A(N-2) - xN-2
    // xN + x1 == A(N-1)かどうか？
    // solveは, これを達成する時のx1の値を返す.
    def ans(x1: Long): Array[Long] = {
      val arr = new Array[Long](N)
      var nx = x1 / 2
      var i = 0
      while (i < N) {
        arr(i) = nx * 2
        nx = A(i) - nx
        i += 1
      }
      arr
    }

    println(ans(X1).mkString(" "))
  }

}


Measured memory_bytes: 69676
#include <bits/stdc++.h>
#define lowbit(x) (x&-x)
using namespace std;
typedef long long ll;
ll n,l,ch[100010][2],tot=1,Ans; char sd[100010];
inline void dfs(int rt,ll pr)
{
	if(!(ch[rt][0]^ch[rt][1])) return ;
	for(int i=0;i<2;i++) if(ch[rt][i]) 
		dfs(ch[rt][i],pr-1);
		else Ans^=lowbit(pr);
}
int main()
{
	cin >> n >> l; for(int i=1;i<=n;i++)
	{
		scanf("%s",sd); int len=strlen(sd);
		for(int j=0,nw=1;j<len;j++)
			!ch[nw][sd[j]-'0']? ch[nw][sd[j]-'0']=++tot:1,
			nw=ch[nw][sd[j]-'0'];
	}
	dfs(1,l); if(Ans) puts("Alice"); else puts("Bob");
}

Measured memory_bytes: 4992
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		for(int i=2000;i<2010;i++) {
			c=a*c-b;
			if(i>=2000) {
				System.out.println(c);
			}
		}
	}
}


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


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] even = new int[100001];
		int[] odd = new int[100001];
		for (int i=0;i<n;i++) {
			int tmp = sc.nextInt();
			if (i%2==0) {
				even[tmp]++;
			} else {
				odd[tmp]++;
			}
		}
		int [] newEven = new int[100001];
		int [] newOdd = new int[100001];
		System.arraycopy(even, 0, newEven, 0, 100001); 
		System.arraycopy(odd, 0, newOdd, 0, 100001);
		
		Arrays.sort(newEven);
		Arrays.sort(newOdd);
		
		if(newEven[100000]==newEven[99999] || newOdd[100000]==newOdd[99999]) {
			System.out.println(n-newEven[100000]-newOdd[100000]);
		} else {
			int evenMax = 0;
			int oddMax = 0;
			for (int i=0;i<=100000;i++) {
				if (even[i]==newEven[100000]) {
					evenMax = i;
				}
				if (odd[i]==newOdd[100000]) {
					oddMax  = i;
				}
			}
			
			if (evenMax==oddMax) {
				System.out.println(Math.min(n-newEven[100000]-newOdd[99999], n-newEven[99999]-newOdd[100000]));
			} else {
				System.out.println(n-newEven[100000]-newOdd[100000]);
			}
		}
	}
}


Measured memory_bytes: 49792
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

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

  REP(i,n+1){
    REP(j,n+1){
      if(i+j > n) continue;
      if(10000*i + 5000*j + 1000*(n-i-j) == y){
        cout << i SP j SP n-i-j << endl;
        return 0;
      }
    }
  }

  cout << -1 SP -1 SP -1 << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
import re
S = sys.stdin.readline()

ptn = 'R+L+'
ptn = re.compile(ptn)
result = ptn.findall(S)
#print(result)
ans = []
for bl in result:
    len_bl_half = len(bl)//2
    tmp = [0 for _ in range(len(bl))]
    ln = bl.find('L')
    #print(ln)
    if len(bl)%2==0:
        tmp[ln] = len_bl_half 
        tmp[ln-1] = len_bl_half 
    else:
        if ln %2==0:
            tmp[ln] = 1+ len_bl_half 
            tmp[ln-1] =len_bl_half 
        else:
            tmp[ln] =len_bl_half 
            tmp[ln-1] =1 + len_bl_half 
    ans +=tmp
        
print(*ans)

Measured memory_bytes: 9712
import math

def main():
    K = int(input())
    r = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            t = math.gcd(i, j)
            for k in range(1, K+1):
                r += math.gcd(t, k)
    print(r)

if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
	int err = 0;

	int n;
	
	scanf("%d", &n);

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

		scanf("%d", &ai);

		if(ai != i){
			err++;
		}
	}

	if(err <= 2){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 n, k;
    cin >> n >> k;

    vs64 num(1e5 + 1, 0);
    rep (i, n)
    {
        int a, b;
        cin >> a >> b;
        num[a] += b;
    }

    rep (i, 1e5)
    {
        num[i + 1] += num[i];
    }

    cout << lower_bound(num.begin(), num.end(), k) - num.begin() << "\n";
    return 0;
}



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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int lsx, lsy, ltx, lty, rsx, rsy, rtx, rty;
bool dfs(vector<vector<vvi>> &dp, int lx, int ly, int rx, int ry) {
	if (dp[ly][lx][ry][rx] != -1)return dp[ly][lx][ry][rx];
	return true;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int w, h;
	while (cin >> w >> h, w) {
		vector<string> l(h), r(h);
		REP(i, h) cin >> l[i] >> r[i];

		REP(i, h) {
			REP(j, w) {
				if (l[i][j] == '%') {
					ltx = j; lty = i;
				}
				if (l[i][j] == 'L') {
					lsx = j; lsy = i;
				}
			}

		}
		REP(i, h) {
			REP(j, w) {
				if (r[i][j] == '%') {
					rtx = j; rty = i;
				}
				if (r[i][j] == 'R') {
					rsx = j; rsy = i;
				}
			}
		}
		queue<pair<pii, pii>> q;
		vector<vector<vvi>> b(h, vector<vvi>(w, vvi(h, vi(w, 0))));
		q.push(pair<pii, pii>(pii(lsx, lsy), pii(rsx, rsy)));
		b[lsy][lsx][rsy][rsx] = 1;
		while (!q.empty()) {
			auto a = q.front(); q.pop();
			int lx = a.first.first, ly = a.first.second, rx = a.second.first, ry = a.second.second;
			if (lx == ltx&&ly == lty) {
				if (rx == rtx&&ry == rty) {
					cout << "Yes" << endl;
					goto a;
				}
				else continue;
			}
			else if (rx == rtx&&ry == rty)continue;

			REP(i, 4) {
				int lnx = lx + dx[i * 2], lny = ly + dy[i * 2], rnx = rx + dx[(i + 2 ) %4*2], rny = ry + dy[i*2];
				if (lnx < 0 || lnx >= w || lny < 0 || lny >= h ){ 
					lny = ly; lnx = lx;
				}
				else if (l[lny][lnx] == '#') {
					lny = ly; lnx = lx;
				}
				if (rnx < 0 || rnx >= w || rny < 0 || rny >= h ) {
					rny = ry; rnx = rx;
				}
				else if (r[rny][rnx] == '#') {
					rny = ry; rnx = rx;
				}
				if ((lnx!=lx||lny!=ly||rnx!=rx||rny!=ry)&& b[lny][lnx][rny][rnx]!=1) {
				
					q.push(pair<pii, pii>(pii(lnx, lny), pii(rnx, rny)));
					b[lny][lnx][rny][rnx] = 1;

				}
			}
		}
		cout << "No" << endl;

	a:;
	}
}

Measured memory_bytes: 31952
#include <bits/stdc++.h>
#define rep(i, a) for(auto i=0; i<a; i++)
#define rep1(i, a, b) for(auto i=a; i<b; i++)
#define p_b push_back
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef vector<vi> vvi;

int main() {
    ll n, m;
    cin>>n>>m;
    
    vi d(n, 0);
    rep(i, m){
        int x, y;
        cin>>x>>y;
        x--;
        y--;
        d[x]++;
        d[y]++;
    }
    for(auto i:d)
        cout<<i<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b; cin >> a >> b;
  int tower = 0;
  FOR(i, 1, b - a) tower += i;
  cout << tower - a << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
using namespace std;

//ostream& operator << (ostream &out, vector<int> &v) { for(auto a:v) out << a<<" "; out<<endl; }

const int maxn=1e5+5;
int dp[maxn][4];
int main()
{
    fast_cin
    int N;
    cin >> N;
    vector<vi> act(N+1, vi(3));
    for(int i=0;i<N;i++)
    {
        cin >> act[i][0] >> act[i][1] >> act[i][2];
    }
    int n=N;
    for(int i=0;i<3;i++)
    {
        dp[0][i]=act[0][i];
    }
    //0..n-1
    for(int i=1;i<n;i++)
    {
        for(int j:{0,1,2})
        {
            int a=act[i][j];    //act on today
            if(j==0)
            {
                dp[i][j]=max(dp[i][j],dp[i-1][1]+a);    //best act of day before subject to constraint.
                dp[i][j]=max(dp[i][j],dp[i-1][2]+a);
            }
            if(j==1)
            {
                dp[i][j]=max(dp[i][j],dp[i-1][0]+a);
                dp[i][j]=max(dp[i][j],dp[i-1][2]+a);
            }
            if(j==2)
            {
                dp[i][j]=max(dp[i][j],dp[i-1][0]+a);
                dp[i][j]=max(dp[i][j],dp[i-1][1]+a);
            }
        }
    }
    cout << *max_element(dp[n-1],dp[n-1]+3) << endl;

}


Measured memory_bytes: 7296
//TINY_OUNCE911666
// You are not prepared!

#include "bits/stdc++.h"
using namespace std;

long long n, ans;
pair<long long,long long> p = {(long long)(1e18)+7LL,0};

int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n;
	for (long long i = 1; i*i <= n; ++i) {
		if (n % i == 0) {
			if (abs((n/i) - i) < abs(p.first-p.second)) {
				p = make_pair(n/i,i);
			}
		}
	}
	
	ans = (min(p.first,p.second)-1)*2;
	ans += max(p.first,p.second) - min(p.first,p.second);
	cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a;
    int w;
    for(int i=0;i<3;i++){
        cin >> w;
        a.push_back(w);
    }
    sort(a.begin(),a.end());
    cout << a[2]*10+a[1]+a[0] << endl;


    return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF  numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()

using namespace std;
using ll = long long;

int r, D, x_2000;

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

    std::cin >> r >> D >> x_2000;

    int x = x_2000;
    REP(i, 10) {
        x = r * x - D;
        std::cout << x << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
s=input()
flag = "AC"
if s[0] != "A":
    flag = "WA"
else:
    if not "C" in s[2:-1]:
        flag = "WA"
    else:
        ls = [c for c in s]
        ls.remove("A")
        ls.remove("C")
        if not "".join(ls).islower():
            flag = "WA"
        #for c in ls:
            #if c.isupper():
                #flag = "WA"
print(flag)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
int t[MAX],L[MAX],R[MAX],n,ans;
int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",&t[i]);
  L[0]=R[n-1]=1;
  for(int i=1;i<n;i++)L[i]=(t[i]==t[i-1]?1:L[i-1]+1);
  for(int i=n-2;i>=0;i--)R[i]=(t[i]==t[i+1]?1:R[i+1]+1);
  for(int i=1;i<n;i++)ans=max(ans,L[i-1]+R[i]+R[i+R[i]]);
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 2360
#include <stdio.h>

int main(void)
{
  int sec;
  int min;
  int hour;
			 
  sec = 0;
  min = 0;
  hour = 0;
			  
  scanf("%d", &sec);
					   
  if(sec >= 60) {
    min = sec / 60;
    sec = sec % 60;
  }
  if(min >= 60){
    hour = min / 60;
    min = min % 60;
  }

  printf("%d:%d:%d\n", hour, min, sec);
												 
  return 0;
}

Measured memory_bytes: 592
#![allow(unused)]

use std::io::{Read, Stdin, StdinLock};
use std::iter::{FromIterator, Iterator};
use std::str::{FromStr};
use std::string::String;

macro_rules! debug {
    ($($a:expr),*) => {
	eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

struct TokenReader<'a> {
    lock: StdinLock<'a>,
}

impl<'a> TokenReader<'a> {
    fn new(s: &'a Stdin) -> TokenReader<'a> {
        TokenReader { lock: s.lock() }
    }

    fn read_chars<T: FromIterator<char>>(&mut self) -> T {
        self.lock
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<T>()
    }

    fn read_str(&mut self) -> String {
        self.read_chars::<String>()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read_str().parse().ok().unwrap()
    }
}

//==============================================================================
//
// Problem specific code
//
//==============================================================================

fn main() {
    let sin = std::io::stdin();
    let mut tr = TokenReader::new(&sin);

    let s: Vec<usize> = tr.read_chars::<Vec<char>>()
        .into_iter()
        .map(|c| c.to_digit(10).unwrap() as usize)
        .collect();
    let n = s.len();

    let mut dp = vec![vec![0i16; 2019]; n];
    for i in 0..n {
        dp[i][s[i]] += 1;
        if i >= 1 {
            for r in 0usize..2019 {
                dp[i][(r * 10 + s[i]) % 2019] += dp[i - 1][r];
            }
        }
    }

    println!("{}", (0..n).fold(0i64, |a, i| a + dp[i][0] as i64));
}


Measured memory_bytes: 798888
n,t=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
#print(l)
c=1200
for i in l:
    if (i[1])<=t:
        c=min(c,i[0])
if c<=1000:
    print(c)
else:
    print('TLE')

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

#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 rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e8;

void solve()
{
  int w,a,b; cin>>w>>a>>b;
  int ans=0;
  if (b>a+w) ans=b-(a+w);
  else if (a>b+w) ans=a-(b+w);
  else ans=0;
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N,M,X,Y = map(int, input().split())
xn = list(map(int, input().split()))
ym = list(map(int, input().split()))

nowar = False
for Z in range(X+1,Y+1):
    if max(xn) < Z and Z <= min(ym):
        nowar = True

if nowar:
    print('No War')
else:
    print('War')


Measured memory_bytes: 3060
/** author: __nishad__ **/

#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a) for(int i=0; i<a;i++)
#define loop2(i,a,b) for(int i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;
    ll n, ans=0, maxi=0;
    string s, str1, str2;
    cin>>n>>s;
    int sz = s.length();

    for(int i=1; i<sz; i++){
        str1 = s.substr(0, i);
        str2 = s.substr(i, sz-i);

        unq(str1);
        unq(str2);
        ans=0;

        for(int j=0; j<str2.size(); j++){
            if(str1.find(str2[j]) != string::npos)
                ans++;

        }
        maxi = max(maxi, ans);

    }

    cout<<maxi;



}



Measured memory_bytes: 256
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll n , m ;
ll a[10000],b[10000];
ll c[1001][20];

ll solve(){
	ll dp[(1<<(n+1))];
	for(ll i=0;i<(1<<(n+1));i++)dp[i]=inf;
	dp[0]=0;
	for(ll i=0;i<m ;i++){
		ll cur=0;
		for(ll j=0;j<b[i];j++){
			cur=cur|(1<<(c[i][j]-1));
		}
		for(ll j=0;j<(1<<n);j++){
			dp[j|cur]=min(dp[j|cur],dp[j]+a[i]);
		}
	}
	if(dp[(1<<n)-1]==inf)return -1;
	else return dp[(1<<n)-1];
}

int main(){
	//mahakal(),fast;
	cin>> n >> m ;
	for(ll i=0;i<m;i++){
		cin>> a[i] >> b[i];
		for(ll j=0;j<b[i];j++){
			cin>>c[i][j];
		}
	}

	ll ans = solve();
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> p(n),q(n);
	rep(i,n) cin >> p.at(i);
	rep(i,n) cin >> q.at(i);
	vector<int> c(n);
	rep(i,n) c.at(i) = i + 1;
	int a, b;
	int k = 0;
	do{
		bool flg1 = true, flg2 = true;
		rep(i,n){
			if(c.at(i) != p.at(i)) flg1 = false;
			if(c.at(i) != q.at(i)) flg2 = false;
		}
		if(flg1){
			a = k;
		}
		if(flg2){
			b = k;
		}
		k++;
	}while(next_permutation(all(c)));
	cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[205][5][5];
int main() {
	int a, b, n, m, ans = 0;
	cin >> n >> m;
	vector<int>v(n + 1, 4);
	for (int i = 0; i<m; ++i) {
		cin >> a >> b;
		v[a] = b - 1;
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j<3; ++j) {
			if (v[i] != 4 && v[i] != j) continue;
			if (i == 1) {
				dp[i][0][j] = 1; continue;
			}
			a = 0;
			for (int k = 0; k<3; ++k) {
				if (k == j) continue;
				a += dp[i - 1][0][k] + dp[i - 1][1][k];
			}
			dp[i][0][j] = a;
			dp[i][1][j] = dp[i - 1][0][j];
			dp[i][0][j] %= 10000, dp[i][1][j] %= 10000;
		}
	}
	for (int i = 0; i<2; ++i) {
		for (int j = 0; j<3; ++j) {
			ans += dp[n][i][j];
			ans %= 10000;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3116
#include <iostream>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

int main() {
  int a, b, c;

  cin >> a >> b >> c;

  if (a + b >= c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    string s;
    cin >> s;
    if(s <= "2019/0430") cout << "Heisei" << endl;
    else cout << "TBD" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,A,B;
    cin >> N >> A >> B;
    auto check = [&](int x){
        int s = 0;
        while(x){
            s += x%10;
            x /= 10;
        }
        return A<=s && s<=B;
    };

    int ans = 0;
    for(int i=1;i<=N;i++) if(check(i)) ans += i;
    cout << ans << "\n";

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin  >> n;
    ll c[n],s[n],f[n];
    REP(i,n-1){
        cin >> c[i] >> s[i] >> f[i];
    }
    ll answer=0;
    REP(i,n-1){
        answer = 0;
        FOR(j,i,n-1){
            int wait=0;
            if(j==0){
                answer += s[0];
            }
            else{
                int start=s[j];
                if(answer <= start)
                    answer += start-answer;
                else{
                    while(start<answer){
                        start+=f[j];
                    }
                    answer+= start-answer;
                } 
            }
            answer += c[j];
        }
        cout << answer << endl;
    }
    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
class Test
{
	static void Main(string[] args)
	{
		for (int i = 1; i <= 9; i++)
		{
			for (int j = 1; j <= 9; j++)
			{
				Console.WriteLine(i + "x" + j + "=" + (i * j));
			}
		}
	}
}

Measured memory_bytes: 5540
from collections import defaultdict
N, K = map(int, input().split())
balls = defaultdict(int)
for b in input().split():
    balls[b] += 1
types = len(balls.keys())
balls = sorted(balls.values(), reverse=True)
ans = 0
while types > K:
    ans += balls.pop()
    types -= 1
print(ans)


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

#define MAXBOXNUM 1000
void out(int box[], int num);


int main()
{
	int num;
	int box[MAXBOXNUM];
	int i,j;
	int tmp;
	cin >> num;
	
	for(i=0; i < num; i++)
	{
		cin >> box[i];
	}
	
	out(box, num);
	
	for(i=1; i < num; i++)
	{
		tmp = box[i];
		j = i;
		
		while((j > 0) && (box[j-1] > tmp))
		{
			box[j] = box[j-1];
			j--;
		}
		box[j] = tmp;
		out(box, num);
	}
}	
void out(int box[], int num)
{
	for(int i=0; i < num; i++)
	{
		cout << box[i];
		if(!(i == num-1))
		{
			cout << " ";
		}
	}
	cout << endl;
}

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

int main(){
  int A , B , C , X ;
  cin >> A >> B >> C >> X ;
  int count = 0 ;
  
  for(int i = 0 ; i<=A ; i++){
    for(int j = 0 ; j<=B ; j++){
      for(int k = 0 ; k<=C ; k++){
        if(500*i+100*j+50*k==X) count++;
      }
    }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
import fileinput


def who_wins(k, move_list):
    arr = [False] * (k + 1)
    for i in range(1, k + 1):
        for move in move_list:
            if move > i:
                continue
            if arr[i - move] is False:
                arr[i] = True
                break
    return arr[-1]


inp = fileinput.FileInput()
k = int(inp.readline().split(" ")[-1])
move_list = [int(m) for m in inp.readline().split(" ")]

if who_wins(k, move_list):
    print("First")
else:
    print("Second")

Measured memory_bytes: 40212
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,ma,mb;
  cin>>n>>ma>>mb;
  vi a(n),b(n),c(n);
  rep(i,n)
    cin>>a[i]>>b[i]>>c[i];

  map<pii,int> x;
  rep(i,1<<(n/2)){//前半を全列挙                                                                 
    int ta=0,tb=0,tc=0;
    rep(j,n/2)
      if((i&(1<<j))!=0){//iのj桁目が1のとき                                                      
        ta+=a[j];
        tb+=b[j];
        tc+=c[j];
      }
    if(x.count(pii(ta,tb)))//存在するとき                                                        
      x[pii(ta,tb)]=min(x[pii(ta,tb)],tc);
    else
      x[pii(ta,tb)]=tc;
  }

  map<pii,int> y;
  rep(i,1<<(n-n/2)){//後半を全列挙                                                               
    int ta=0,tb=0,tc=0;
    rep(j,n-n/2)
      if((i&(1<<j))!=0){//iのj桁目が1のとき                                                      
        ta+=a[j+n/2];
        tb+=b[j+n/2];
        tc+=c[j+n/2];
      }
    if(y.count(pii(ta,tb)))//存在するとき                                                        
      y[pii(ta,tb)]=min(y[pii(ta,tb)],tc);
    else
      y[pii(ta,tb)]=tc;
  }

  int ans=INF;
  for(map<pii,int>::iterator itr=x.begin();itr!=x.end();itr++){
    int ta=(*itr).first.first;
    int tb=(*itr).first.second;
    for(i=1;i*max(ma,mb)<405;i++)
      if(y.count(pii(i*ma-ta,i*mb-tb)))
        ans=min(ans,(*itr).second+y[pii(i*ma-ta,i*mb-tb)]);
  }
  if(ans<INF)
    cout<<ans<<endl;
  else
    cout<<-1<<endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
using namespace std;

int main()
{
  string command;
  priority_queue<int> PQ;

  while (true)
  {
    cin >> command;
    if (command[0] == 'i')
    {
      int key;
      cin >> key;
      PQ.push(key);
    }
    else if (command[1] == 'x')
    {
      cout << PQ.top() << endl;
      PQ.pop();
    }
    else if (command[0] == 'e')
    {
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 7016
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

int n,k;
vi in;
bool f(int a){
    vi t(n);
    int S=0,s=0;
    rep(i,n)t[i]=in[i]%a,S+=t[i];
    sort(all(t));
    if(!S)return true;
    rep(i,n-1){
        s+=t[i];
        if(s<=k&&s==(n-i-1)*a-S+s)return true;
    }
    return false;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

    cin>>n>>k;
    in=vi(n);
    cin>>in;
    int out=0;
    int s=0;
    rep(i,n)s+=in[i];
    for(int i=1;i*i<=s;i++)if(s%i==0){
        if(f(i))cmax(out,i);
        if(f(s/i))cmax(out,s/i);
    }
    cout<<out<<endl;
}


Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
scores = []
sCards = list(set(s))
for c in sCards:
    scores.append(s.count(c) - t.count(c))
if max(scores) < 0:
    print(0)
else:
    print(max(scores))

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

using namespace std;

int main(){
	
	int a, b;
	
	bool first, first2;
	
	cin >> a >> b;
	
	first2 = true;
	
	while(a != 0 && b != 0){
		
		if(!first2){
			printf("\n");
		}
		
		first2 = false;
		first = false;
		
		for(int i = a; i <= b; i++){
			if(i % 4 == 0){
				if(i % 100 == 0){
					if(i % 400 == 0){
						printf("%d\n", i);
						first = true;
						continue;
					}
					continue;
				}
				printf("%d\n", i);
				first = true;
				continue;
			}
		}
		
		if(!first){
			printf("NA\n");
		}
		
		cin >> a >> b;
	}
	
	return 0;
}

Measured memory_bytes: 1156
import java.io.*;
class Main {
  public static void main(String... args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String s = br.readLine();
    int w = Integer.parseInt(s);
    int[] nums = new int[w];
    for(int i = 0; i < w; i++) {
      nums[i] = i+1;
    }
    s = br.readLine();
    int n = Integer.parseInt(s);
    for(int i = 0; i < n; i++) {
      s = br.readLine();
      String[] arr = s.split(",");
      int a = Integer.parseInt(arr[0])-1;
      int b = Integer.parseInt(arr[1])-1;
      int temp = nums[a];
      nums[a] = nums[b];
      nums[b] = temp;
    }
    for(int i = 0; i < w; i++) {
      System.out.println(nums[i]);
    }
  }
}

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

#define REP(i,n) for(int i =0; i <n; ++i)

#define REPR(i,n) for(int i =n; i >=0; --i)

#define _REP(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    priority_queue<int> q;

    REP(i,n){
        int a;
        cin >> a;
        q.push(a);
    }

    REP(i,m){
        int a = q.top();
        q.pop();
        a /= 2;
        q.push(a);
    }

    long long ans = 0;
    REP(i,n) {
        ans += q.top();
        q.pop();
    }

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

Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll, ll> lltpl;



/******************************************************************************************/


const int IINF = 1e9 + 7;
const ll LINF = 1e18 + 7;
const ll MOD = 1e9 + 7;



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	

	int n;
	cin >> n;
	vector<pii> a(n);
	vector<int> ans(n, 0);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i].first;
		a[i].second = i + 1;
	}
	sort(a.begin(), a.end());

	for (int i = 0; i < n; i++)
	{
		ans[i] = a[i].second;
	}


	

	for (int i = 0; i < n; i++)
	{
		if (i == 0) {
			cout << ans[i];
		}
		else
		{
			cout << " " << ans[i];
		}
	}
	cout << endl;



	

}



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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    string s,t;
    i32 n,m;
    cin >> n >> m;
    rep(i, n+1) {  // kame
        if(i*4 + (n-i)*2 == m) {
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	ll n,k;
	cin>>n>>k;
	ll arr[n+1];
	arr[0] = 0;
	REP(i,1,n+1) cin>>arr[i];
	ll dp[n+1];
	REP(i,1,n+1) dp[i] = 1e12;
	dp[0] = 0;
	dp[1] = 0;

	REP(i,2,n+1){
		REP(j,1,k+1){
			if(i-j <= 0)
				break;
			else
				dp[i] = min(dp[i],dp[i-j] + abs(arr[i] - arr[i-j]));	
		}
	}
	// REP(i,1,n+1) cout<<dp[i]<<" ";
	// cout<<endl;
	cout<<dp[n]<<endl;
	return 0;
}



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

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

  string s[N];
  bool f=false;
  for(int i=0; i<N; i++){
    cin >> s[i];
    if(s[i]=="Y"){
      f = true;
    }
  }
  if(f){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
using namespace std;
struct node
{
	struct node *parent,*left,*right;
	int id,depth;
};
node* nil;
void setdepth(node*,int);
node* getroot(node*);
void printchildren(node*);

int main(){
	int n;
	cin >> n;
	node **N;
	nil = (node*)malloc(sizeof(node));
	N = (node**)malloc(sizeof(node*)*n);
	for(int i=0;i<n;i++) N[i] = (node*)malloc(sizeof(node));
	nil->parent = nil->left = nil->right = nil;
	//cerr << "error01" << endl;
	
	nil -> id = -1;
	N[0]->parent = nil;
	//cerr << "error02" << endl;
	for(int i=0;i<n;i++) N[i]->parent = N[i]->left = N[i]->right = nil;
	//cerr << "error03" << endl;	
	for(int i=0;i<n;i++){
		int id,k;
		cin >> id >> k;
		N[id]->id = id;
		int *c;
		//cerr << "error04" << endl;	
		c = (int*)malloc(sizeof(int)*k);
		for(int j=0;j<k;j++) cin >> c[j];
		//cerr << "error05" << endl;	
		for(int j=0;j<k;j++){
			if(j ==0) N[id]->left = N[c[j]];
			N[c[j]]->parent = N[id];
			//cerr << "error06 " << i << endl;	
			if(j < k-1) N[c[j]]->right = N[c[j+1]];
			else if(j == k-1) N[c[j]]->right = nil;
		}
		if(k == 0) N[id]->left = nil;
		free(c);
	}
	//cerr << "error7" << endl;
	node *root = getroot(N[0]);
	//cerr << "error8" << endl;
	setdepth(root,0);
	//cerr << "error9" << endl;
	for(int i=0;i<n;i++){
		int p,d;
		p = N[i]->parent->id;
		d = N[i] -> depth;
		cout << "node " << N[i]->id << ": parent = " << p << ", depth = " << d << ", ";
		if(N[i] == root) cout << "root, ";
		else if(N[i]->left == nil) cout << "leaf, ";
		else cout << "internal node, ";
		printchildren(N[i]);
		cout << endl; 
	}
	free(nil);
	for(int i=0;i<n;i++) free(N[i]);
	free(N);
	return 0;

}

void setdepth(node* x,int d){
	//cerr << "node:" << x->id << " depth:" << d << endl;
	x->depth = d;
	if(x->right != nil) setdepth(x->right,d);
	if(x->left != nil) setdepth(x->left,d+1);
}

node* getroot(node* x){
	int i=0;
	while(x->parent != nil){
		x = x->parent;
		i++;
		if(i >= 100000){
			//cerr << "ERROR:GETROOT" << endl;
		}
	}
	//cerr << "root: " << x->id << endl;
	return x;
}

void printchildren(node* x){
	node* l = x->left;
	cout << "[";
	while(1){
		if(l != nil)cout << l->id;
		if(l->right == nil) break;
		else cout << ", ";
		l = l->right;
	}
	cout << "]";
}

Measured memory_bytes: 11240
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a>k) cout<<":("<<endl;
  else cout<<"Yay!"<<endl;
}



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

int main() {
  int N;
  string S;
  cin>>N>>S;
  
  int ans=0;
  
  // 000-999のうちSから作ることができるのものをカウント
  for(int i=0;i<1000;++i){
    
    int c[3]={i/100,(i/10)%10,i%10};	// 暗証番号の各桁の数字
    
    // Sの左端から調べて暗証番号の左から一つ目の数字と一致したらカウント
    int f=0;
    for(int j=0;j<N;++j){
      if(S[j]==('0'+c[f]))
        ++f;
      if(f==3){
        ++ans;
        break;
      }
    }
  }
  

  
  cout<<ans<<endl;
}


Measured memory_bytes: 256