akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  string s;
  int x,y;
  cin >> s >> x >> y;
  int N = s.size();
  s = s + "T";

  vector<int> dx;
  vector<int> dy;
  bool sta = 0;
  int cnt = 0;

  for(int i=0;i<=N;i++){
    if(s[i] == 'F'){
      cnt++;
    }
    else if(s[i] == 'T'){
      if(!sta && cnt!=0) dx.push_back(cnt);
      if(sta && cnt!=0) dy.push_back(cnt);
      cnt = 0;
      sta = !sta;
    }
  }

  int sumx = 0;
  int sumy = 0;
  for(int i=0;i<(int)dx.size();i++) sumx += dx[i];
  for(int i=0;i<(int)dy.size();i++) sumy += dy[i];

  /*for(int i=0;i<dx.size();i++){
    cout << dx[i] << endl;
  }
  cout << endl;
  for(int i=0;i<dy.size();i++){
    cout << dy[i] << endl;
  }*/

  int szx = dx.size();
  int szy = dy.size();

  bool dpx[szx+1][2*sumx+1];
  fill(dpx[0],dpx[szx+1],false);
  dpx[0][sumx] = true;
  if(szx > 0){
    if(s[0] == 'F'){
      dpx[1][sumx+dx[0]] = true;
    } else {
      dpx[1][sumx-dx[0]] = true;
      dpx[1][sumx+dx[0]] = true;
    }
  }
  for(int i=2;i<=szx;i++){
    for(int j=0;j<=2*sumx;j++){
      if(dpx[i-1][j]){
        dpx[i][j-dx[i-1]] = true;
        dpx[i][j+dx[i-1]] = true;
      }
    }
  }

  /*for(int i=0;i<=szx;i++){
    for(int j=0;j<=2*sumx;j++){
      cout << dpx[i][j] << " ";
    }
    cout << endl;
  }*/

  bool dpy[szy+1][2*sumy+1];
  fill(dpy[0],dpy[szy+1],false);
  dpy[0][sumy] = true;
  for(int i=1;i<=szy;i++){
    for(int j=0;j<=2*sumy;j++){
      if(dpy[i-1][j]){
        dpy[i][j-dy[i-1]] = true;
        dpy[i][j+dy[i-1]] = true;
      }
    }
  }

  /*for(int i=0;i<=szy;i++){
    for(int j=0;j<=2*sumy;j++){
      cout << dpy[i][j] << " ";
    }
    cout << endl;
  }
  cout << "aa" << endl;*/
  if(-sumx <= x && x <= sumx && -sumy <= y && y <= sumy){
    if(dpx[szx][sumx+x] && dpy[szy][sumy+y]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else cout << "No" << endl;
  return 0;


}

Measured memory_bytes: 15872
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){
    int i,j,n,count;
    int a[200010];
    int b[200010] = {0};
    a[0] = 0;
    a[1] = 0;
    scanf("%d",&n);

    for(i = 2;i<=n;i++){
        scanf("%d",&a[i]);
        b[a[i]]++;
    }
    for(i=1;i<=n;i++){
        printf("%d\n",b[i]);
    }
    return 0;
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define yes "Yes"
#define no "No"
using namespace std;
int main() {
  int n,flag = 0;
  cin >> n;
  rep(i,10){
    rep(j,10){
      if(i*j == n){
        flag = 1;
      }
    }
  }
  if(flag == 1) {
    cout << yes << endl;
  }else{
    cout << no << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

using namespace std;



int main()

{
	int N,a;

	cin >> N>>a;
	vector<int> data(N);

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

	ll ans = 0;

	for (int i = 1; i < N; i++)
	{
		if (data[i - 1] + data[i] > a)
		{
			ll diff = data[i - 1] + data[i] - a;
			if (diff <= data[i])
			{
				data[i] -= diff;
			}
			else
			{
				data[i] = 0;
				data[i - 1] -= diff - data[i];
			}
			ans += diff;

		}
	}

	
		cout << ans<<endl;

	
	
	return 0;
	
}

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

int main(){
  int A,B,c;
  c=0;
  cin>>A>>B;
  for(int i=A;i<B+1;i++){
    if(i/10000==i%10 && i/1000%10==i/10%10){
      c++;
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
import math

n = input()
for i in range(n):
    xa, ya, ra, xb, yb, rb = map(float, raw_input().split())
    r = ((xa-xb)**2 + (ya-yb)**2)**.5
    if ra+rb<r: print 0
    elif abs(ra-rb)<=r: print 1
    elif ra-rb>r: print 2
    else: print -2

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

int main(){
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;

    if(U == S && U == T){
        cout << A - 1 << " " << B - 1 << endl;
    }
    else if(U == S){
        cout << A - 1 << " " << B << endl;
    }
    else{
        cout << A << " " << B - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
const ll MOD = 998244353;

int main() {
    ll n, k;
    cin >> k >> n;
    vector<ll> A(n);
    for (auto & a: A) {
        cin >> a;
    }
    ll m = 0;
    for (ll i = 0; i < n - 1; ++i) {
        m = max(m, A[i+1] - A[i]);
    }
    m = max(m , A[0] + (k - A[n-1]));
    cout << k - m << endl;
}


Measured memory_bytes: 1920
#include <stdio.h>
 
int main(){
     
char num[1001];
 
    while(1){
        int i=0,sum=0;
 
        scanf("%s", num);
        if(num[0]-'0'==0) break;
         
        while(num[i]){
        sum+=num[i]-'0';
        i++;
        }
    printf("%d\n",sum);
    }
     
    return 0;
}

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

int main(){
  string str;
  int n,pos;
  while(1){
    cin>>str;
    if(str=="-") break;
    cin>>n;
    for(int i=0;i<n;i++){
      cin>>pos;
      str = str + str;
      str = str.substr(pos,str.length()/2);
    }
    cout<<str<<endl;
  }
  return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    ll X; cin >> X;
    ll MAX = 1000000;
    vb isPrime(MAX+1);
    fill(ALL(isPrime), true);
    isPrime[0] = isPrime[1] = false;
    for(ll i = 2; i * i <= MAX; i++)
    {
        if(isPrime[i])
        {
            for(ll j = i*2; j <= MAX; j += i)
            {
                isPrime[j] = false;
            }
        }
    }

    for(ll i = X; i <= MAX; i++)
    {
        if(isPrime[i])
        {
            cout << i << endl;
            return;
        }
    }
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
int costout(a1,a2,a3)
{
    int i, cost;
     i= (a2<a3)?a2:a3;

    cost = abs(i-a1);
    if(a2==i)

    {
        cost += abs(a3-a2);
    }
    else
        cost += abs(a2-a3);

    return cost;

}

int main()
{
    int cost,k,l,j, i, a1, a2, a3;
    scanf("%d %d %d",&a1, &a2, &a3);
    j = costout(a1, a2, a3);
    k = costout(a2, a3, a1);
    l = costout(a3, a1, a2);
    cost = (j<k)?j:k;
    cost = (cost<l)?cost:l;

    printf("%d\n",cost);

   return 0;
}



Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

int main() {

	while(true) {
		int n;
		cin >> n;
		if(!n) break;

		int l = 1, h = 2, num = 1, ans = 0;
		while(l <= h && h < n) {
			if(num < n) {
				num += h;
				h++;
			} else if(num > n) {
				num -= l;
				l++;
			}
			if(num == n) {
				if(h - l >= 2) ans++;
				num -= l;
				l++;
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3e5+10;
const ll mod =   1e9+7;

int main()
{  fast
int n;
cin>>n;
if(n%10==3)
cout<<"bon";
else if(n%10==0||n%10==1||n%10==6||n%10==8)
cout<<"pon";
else
cout<<"hon";



}

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

static const int MAX = 10000;
static const int NIL = -1;

struct Node{
    int p, l, r;
};

Node t[26];
int root, pre[26], in[26], post[26], cnt1, cnt2, cnt3;

void solve(int v){
    pre[cnt1++] = v;
    if(t[v].l != NIL) solve(t[v].l);
    in[cnt2++] = v;
    if(t[v].r != NIL) solve(t[v].r);
    post[cnt3++] = v;
}


int main(){
    int n;

    for(int i=0; i<26; ++i) t[i].p = t[i].l = t[i].r = pre[i] = in[i] = post[i] = NIL;

    cin >> n;
    int v;
    for(int i=0; i<n; ++i){
        cin >> v;
        cin >> t[v].l >> t[v].r;
        if(t[v].l != NIL) t[t[v].l].p = v;
        if(t[v].r != NIL) t[t[v].r].p = v;
    }

    for(int i=0; i<n; ++i){
        if(t[i].p == NIL) root = i;
    }

    solve(root);
    
    cout << "Preorder" << endl;
    for(int i=0;pre[i] != NIL; ++i) cout << " " << pre[i];

    cout << endl << "Inorder" << endl;
    for(int i=0;in[i] != NIL; ++i) cout << " " << in[i];

    cout << endl << "Postorder" << endl;
    for(int i=0;post[i] != NIL; ++i) cout << " " << post[i];
    cout << endl;
}



Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		if (d >= Math.abs(a - c)) {
			System.out.println("Yes");
		}

		else if (d >= (Math.abs(a - b)) && (d >= (Math.abs(b - c)))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22612
/*  -*- coding: utf-8 -*-
 *
 * 2932.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_P = 1000000 + 50;

/* typedef */

typedef long long ll;

/* global variables */

bool primes[MAX_P + 1];
int pnums[MAX_P + 1];

/* subroutines */

int gen_primes(int maxp, int pnums[]) {
  memset(primes, true, sizeof(primes));
  primes[0] = primes[1] = false;

  int p, pn = 0;
  for (p = 2; p * p <= maxp; p++)
    if (primes[p]) {
      pnums[pn++] = p;
      for (int q = p * p; q <= maxp; q += p) primes[q] = false;
    }
  for (; p <= maxp; p++)
    if (primes[p]) pnums[pn++] = p;
  return pn;
}

/* main */

int main() {
  int pn = gen_primes(MAX_P, pnums);
  //printf("pn=%d\n", pn);

  ll n;
  scanf("%lld", &n);

  int maxc = 0;
  for (ll p = 1; p * p <= n; p++)
    if (n % p == 0) {
      ll q = n / p;
      maxc += (p != q) ? 2 : 1;
    }

  ll r = n;
  int minc = 0;
  for (int i = 0; (ll)pnums[i] * pnums[i] <= r; i++) {
    int &pi = pnums[i];
    if (r % pi == 0) {
      minc++;
      while (r % pi == 0) r /= pi;
    }
  }
  if (r > 1) minc++;

  printf("%d %d\n", minc, maxc - 1);
  return 0;
}



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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int n, m, _s = 0;
	cin >> n >> m;
	int e;
	while (cin >> e) _s += e;
	cout << max(-1, n-_s) << ende;
  return 0;
}


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

int main(void){
    int N,X;
    cin >> N >> X;
    vector<long long> A(N);
    for(int i = 0; i < N;i++)cin >> A[i];
    long long ans = 0;
    long long b = 0;
    for(int i =1; i < N;i++){
       b = max(0LL,A[i-1]+A[i]-X);
       ans += b;
       A[i]= max(0LL,A[i]-b);
    }
    cout << ans << endl;
    
    
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
using namespace std;
int main() {
	int n;
	string s;
	cin >> n;
	map<string, int> m;
	for (int i = 0; i < n; i++) {
		cin >> s;
		m[s] += 1;
	}
	int max = 0;
	for (const auto& x : m) {
		int v = x.second;
		if (v > max) max = v;
	}
	for (map<string,int>::iterator it = m.begin(); it != m.end(); it++) {
		if (it->second == max) {
			cout << it->first << endl;
		}
	}
}

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

void out(int n, int a[]){
    int i = 0;
    while (i < n - 1) {
        cout << a[i] << ' ';
        i++;
    }
    cout << a[n - 1] << endl;
}

int cnt = 0;
#define SENTINEL 2e9

void merge(int a[], int left, int mid, int right);
void mergesort(int a[], int left, int right);

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    mergesort(a, 0, n);
    out(n, a);
    cout << cnt << endl;
}

void merge(int a[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int l[n1 + 1];
    int r[n2 + 1];
    rep(i, n1) l[i] = a[left + i];
    rep(i, n2) r[i] = a[i + mid];
    l[n1] = r[n2] = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++){
        cnt++;
        if (l[i] <= r[j]) {
            a[k] = l[i];
            i++;
        }
        else {
            a[k] = r[j];
            j++;
        }
    }
}

void mergesort(int a[], int left, int right) {
    if (left + 1 < right){
        int mid = (left + right) / 2;
        mergesort(a, left, mid);
        mergesort(a, mid, right);
        merge(a, left, mid, right);
    }
}


Measured memory_bytes: 6984
# -*- coding: utf-8 -*-

N = int(input())
vN = list(map(int, input().split()))

even = {}
odd = {}
# 奇数番目と偶数番目に分けて集計
for i in range(N):
    if i % 2 == 0:
        even[vN[i]] = even.get(vN[i], 0) + 1
    else:
        odd[vN[i]] = odd.get(vN[i], 0) + 1

# 集計数の多い順ソート
even_sorted = sorted(even.items(), key=lambda x: x[1], reverse=True)
odd_sorted = sorted(odd.items(), key=lambda x: x[1], reverse=True)

# 1番多い数字が同じだった場合の別処理
if even_sorted[0][0] == odd_sorted[0][0]:
    # 偶奇それぞれ数字が1種類しかない場合の別処理
    if len(even_sorted) == 1 and len(odd_sorted) > 1:
        print(N - even_sorted[0][1] - odd_sorted[1][1])
    elif len(even_sorted) > 1 and len(odd_sorted) == 1:
        print(N - even_sorted[1][1] - odd_sorted[0][1])  
    elif len(even_sorted) == 1 and len(odd_sorted) == 1:
        print(N // 2)
    else:
        # 偶奇それぞれを2番目にしてみて、数の大きい方
        print(N - max(even_sorted[1][1] + odd_sorted[0][1], even_sorted[0][1] + odd_sorted[1][1]))
else:
    print(N - even_sorted[0][1] - odd_sorted[0][1])

Measured memory_bytes: 20764
#include<bits/stdc++.h>
#define int long long int
using namespace std;
const int N = 1e5+50;

int32_t main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("atcode.txt", "r", stdin);
	int tc = 1;
	for(int T=1; T<=tc; T++){
		string s; cin>>s;
		vector<char> v(s.begin(),s.end());
		int q; cin>>q;
		int toggle = 0;
		for(int i=0; i<q; i++){
			int op; cin>>op;
			if(op == 1){
				toggle++;
			}
			if(op == 2){
				int idx; char ch;
				cin>>idx>>ch;
				if(toggle%2 == 1){
					if(idx == 1) idx = 2;
					else idx = 1;
				}
				if(idx == 2){
					v.push_back(ch);
				}
				else{
					v.insert(v.begin(), ch);
				}
			}
		}
		//cout<<toggle<<"\n";
		if(toggle%2 == 1) reverse(v.begin(), v.end());
		int l = v.size();
		for(int i=0; i<l; i++){
			cout<<v[i];
		}
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1036
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String S = stdIn.next();
		int ans = 0;
		for(int i = 0; i < S.length(); i++){
			if((i+1) % 2 == 1){
				if(S.charAt(i) == 'R' || S.charAt(i) == 'U' || S.charAt(i) == 'D'){

				}
				else{
					ans++;
				}
			}
			else{
				if(S.charAt(i) == 'L' || S.charAt(i) == 'U' || S.charAt(i) == 'D'){

				}
				else{
					ans++;
				}
			}
		}
		if(ans > 0){
			System.out.println("No");
		}
		else{
			System.out.println("Yes");
		}
		stdIn.close();
	}
}


Measured memory_bytes: 35684
#include <bits/stdc++.h>
using namespace std;
 
int a,b;
int main(){
  cin>>a>>b;
  if(a<=0&&b>=0)cout<<"Zero";
  else if(a<0 && (a+b)%2==0) cout<<"Negative";
  else cout<<"Positive";
  cout<<endl;
  return 0;
}

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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n);
    cinv(v,0,n);
    sortAl(v);
    ll mi=1e9;
    FOR(i,0,n-k+1){
      mi=min(mi,v[i+k-1]-v[i]);
    }
    cout<<mi<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = LLONG_MAX/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll a,b; cin >> a >> b;
    a--;b--;
    bitset<3> bs(0);
    bs[a] = 1;bs[b] = 1;
    ll ret = 0;
    rep(i,3)if(bs[i] == 0)ret = i+1;
    cout << ret << endl;
}

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

int main(){
	unsigned long long a,b;
	cin >> a >> b;
	if(a == 1 || b == 1){
		cout << 1 << endl;
		return 0;
	}
	if(a % 2 == 0 || b % 2 == 0){
		cout << a*b/2ll << endl;
	}else{
		cout << (a*b+1ll)/2ll << endl;
	}
}

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

int main() {
  vector<int> vec(5);
  for (int i = 0; i < 5; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < 5; i++) {
    if (vec.at(i) == 0) {
      cout << i + 1 << endl;
    }
  }
}

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

using namespace std;

typedef long long ll;

int main(){
  ll n;
  cin>>n;
  ll a[n];
  ll ans=100*200*200;
  ll min=101;
  ll max=-min;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]>max){
     max=a[i]; 
    }
    if(a[i]<min){
      min=a[i];
    }
  }
  while(min<=max){
    ll tans=0;
    for(int j=0;j<n;j++){
      tans+=(a[j]-min)*(a[j]-min);
    }
    if(tans<ans){
      ans=tans;
    }
    min++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> aoeui, pair<int, int> boeui){return aoeui.se < boeui.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; i++)
#define foris(i, a, b) for(ll i = a; i < b; i++)
#define forise(i, a, b) for(ll i = a; i <= b; i++)
#define ford(i, n) for(ll i = n; i >= 0; i--)
#define fords(i, a, b) for(ll i = a; i >= b; i--)
#define fordse(i, a, b) for(ll i = a; i > b; i--)
#define forr(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

int N;

int main() {
  io();
  
  cin >> N;
  
  int arr[N];
  
  fori(i, N) cin >> arr[i];
  
  int ret = 0;
  int prev = 0;
  
  fords(i, N-2, 0) {
    if(arr[i+1] <= arr[i]) ++prev;
    else prev = 0;
    ret = max(prev, ret);
  }
  
  cout << ret;
  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  ll n,a,b; cin >> n >> a >> b;
  if(abs(a-b)%2==0) cout << abs(a-b)/2LL << endl;
  else{
    ll edgedis = min(a-1,n-b);
    cout << edgedis + (b-a-1)/2 + 1 << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    ll cost[6] = {0};
    cost[2] = A;
    cost[3] = B;
    cost[5] = C;
    ll ans = LINF;
    map<ll, ll> memo;
    priority_queue<LP, vector<LP>, greater<LP>> pq;
    pq.emplace(0, N);
    while(!pq.empty()){
        auto [v, n] = pq.top(); pq.pop();
        if(v >= ans) continue;
        if(n <= 2 * LINF / D) chmin(ans, v + n * D);
        for(int d : {2, 3, 5}){
            int r = n % d;
            ll nv = v + r * D + cost[d];
            if(nv < ans && (!memo.count(n / d) || nv < memo[n/d])){
                pq.emplace(nv, n / d);
                memo[n / d] = nv;
            }
            nv = v + (d - r) * D + cost[d];
            if(nv < ans && (!memo.count(n / d + 1) || nv < memo[n/d + 1])){
                pq.emplace(nv, n / d + 1);
                memo[n / d + 1] = nv;
            }
        }
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // solve();
    int T; cin >> T; REP(t,T) solve();
}

Measured memory_bytes: 4624
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad.State.Strict
import qualified Data.ByteString.Char8      as B
import qualified Data.ByteString.Unsafe     as B
import           Data.Char                  (isSpace)
import qualified Data.Vector.Unboxed        as V

main :: IO ()
main = do
  n <- readLn
  txys <- V.unfoldrN n parseInt3 <$> B.getContents
  putStrLn $ if solve n txys then "Yes" else "No"

solve :: Int -> V.Vector (Int, Int, Int) -> Bool
solve _ txys = travelable (0, 0, 0) (V.head txys) && V.and (V.zipWith travelable txys (V.tail txys))

travelable :: (Int, Int, Int) -> (Int, Int, Int) -> Bool
travelable (t, x, y) (t', x', y') = dx + dy <= dt && even (dt - dx - dy) where
  dx = x' - x
  dy = y' - y
  dt = t' - t

type Parser a = B.ByteString -> Maybe (a, B.ByteString)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
  (,,) <$> StateT (B.readInt . B.dropWhile isSpace)
  <*> StateT (B.readInt . B.unsafeTail)
  <*> StateT (B.readInt . B.unsafeTail)


Measured memory_bytes: 6780
const main = (input) => {
  const [x, y] = input.trim().split(' ')

  let ans = 'No'

  for (let i=0; i<=x; i++) {
    const turtle = (x-i) * 4
    const crane = i * 2
    if (turtle + crane === Number(y)) ans = 'Yes'
  }
  console.log(ans)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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


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

	set<ll> s, ms;
	for(int i=0;i<A;i++) {
		ll e;
		cin >> e;
		s.insert(e);
		ms.insert(-e);
	}

	set<ll> t, mt;
	for (int i = 0; i<B; i++) {
		ll e;
		cin >> e;
		t.insert(e);
		mt.insert(-e);
	}

	for(int i=0;i<Q;i++) {
		ll x;
		cin >> x;

		ll ans = 1LL << 60;
		// move right (s)
		{
			auto it = s.lower_bound(x);
			if(it != s.end()) {
				ll xs = *it;
				// move right
				{
					auto nit = t.lower_bound(xs);
					if(nit != t.end()) {
						ans = min(ans, abs(*nit - x));
					}
				}
				// move left
				{
					auto nit = mt.lower_bound(-xs);
					if(nit != mt.end()) {
						ans = min(ans, abs(xs - x) + abs(xs - -*nit));
					}
				}
			}
		}
		// move right (t)
		{
			auto it = t.lower_bound(x);
			if (it != t.end()) {
				ll xt = *it;
				// move right
				{
					auto nit = s.lower_bound(xt);
					if (nit != s.end()) {
						ans = min(ans, abs(*nit - x));
					}
				}
				// move left
				{
					auto nit = ms.lower_bound(-xt);
					if (nit != ms.end()) {
						ans = min(ans, abs(xt - x) + abs(xt - -*nit));
					}
				}
			}
		}
		// move left (s)
		{
			auto it = ms.lower_bound(-x);
			if (it != ms.end()) {
				ll xs = -*it;
				// move right
				{
					auto nit = t.lower_bound(xs);
					if (nit != t.end()) {
						ans = min(ans, abs(x - xs) + abs(*nit - xs));
					}
				}
				// move left
				{
					auto nit = mt.lower_bound(-xs);
					if (nit != mt.end()) {
						ans = min(ans, abs(x - xs) + abs(-*nit - xs));
					}
				}
			}
		}
		// move left (t)
		{
			auto it = mt.lower_bound(-x);
			if (it != mt.end()) {
				ll xt = -*it;
				// move right
				{
					auto nit = s.lower_bound(xt);
					if (nit != s.end()) {
						ans = min(ans, abs(x - xt) + abs(*nit - xt));
					}
				}
				// move left
				{
					auto nit = ms.lower_bound(-xt);
					if (nit != ms.end()) {
						ans = min(ans, abs(x - xt) + abs(-*nit - xt));
					}
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}


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

using namespace std;

struct okashi{
    int p;
    int q;
    int r;
    int co;
    okashi(int a,int b,int c){
        p=a;q=b;r=c;
        co=a*4+b*9+c*4;
    }
};

int main(){
    int n;
    while(true){
        cin>>n;
        if(n==0)break;
        vector<pair<int,okashi>> o;
        for (int i = 0; i < n; ++i) {
            int a,b,c,d;
            cin>>a>>b>>c>>d;
            o.emplace_back(a,okashi(b,c,d));
        }
        int p,q,r,c;
        cin>>p>>q>>r>>c;
        vector<int> ans;
        for (int i = 0; i < n; ++i) {
            if(o[i].second.p>p)continue;
            if(o[i].second.q>q)continue;
            if(o[i].second.r>r)continue;
            if(o[i].second.co>c)continue;
            ans.emplace_back(o[i].first);
        }
        if(ans.size()==0)cout<<"NA"<<endl;
        else {
            for(auto i:ans)cout<<i<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3200
# AC by Pypy not Python
# Pythonで通すためには,  npで配列毎まるっと処理する必要あり

N, W = map(int, input().split())

dp = [0] * (W+1) # DP枠_重さ’0’～'W'まで準備

for i in range(N):
    w, v = map(int, input().split()) # 商品, 各々重さと価値
    tmp = dp[:] # ひとつ前の商品までのDP枠を参照用にコピー
    for j in range(1, W+1): # 各商品のDP枠への落とし込み
        if j  >= w and tmp[j] < tmp[j-w] + v: # 商品の重さよりDP枠の重さが重い場合で...
            dp[j] = tmp[j-w] + v # この商品を加え, 合計価値が up する場合は replace
        else: # 商品の重さよりDP枠の重さが軽い場合と, ↑で価値が up しない場合は...
            dp[j] = tmp[j] # ↑ 参照データをそのままコピー
    
print(dp[-1])


Measured memory_bytes: 58760
n,m=map(int,input().split())
ab=sorted([tuple(map(int,input().split())) for i in range(n)])
i,ans=0,0
while ab[i][1] < m:
    m-=ab[i][1]
    ans+=ab[i][1]*ab[i][0]
    i+=1
ans+=ab[i][0]*m
print(ans)

Measured memory_bytes: 17772
h1,m1,h2,m2,k=map(int,input().split())
if(h1==h2):
    print(m2-m1-k)
elif(m2<m1):
    print((h2-h1-1)*60+(60-m1)+m2-k)
else:
    print((h2-h1)*60+(m2-m1)-k)

Measured memory_bytes: 61748
N = int(input())
L = []
for i in range(N):
  L.append((int(input()),'a'))
for i in range(N):
  L.append((int(input()),'b'))
L.sort()
res = 1
cc = 0
nowcol = None
mo = 1000000007
for i in range(2*N):
  if cc == 0:
    nowcol=L[i][1]
  if nowcol == L[i][1]:
    cc += 1
  else:
    res *= cc
    res %= mo
    cc -= 1
print(res)


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

int main(){
    int i = 0;
    string s, day[] = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
    cin >> s;
    while(day[i] != s){
        i++;
    }
    cout << i+1;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
	long long n,i,k,j,sum=0,count=0,ans=0,m,w,mx=0,l,r;
	string s;
	cin>>s;
	n=s.length();
	if(s[2]==s[3] && s[4]==s[5])
	cout<<"Yes";
	else
	cout<<"No";
	
}

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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = 1e18 + 7;


signed main(){
    i64 n;
    cin >> n;
    struct Data{
        i64 play_time, power_time, p1, p2;
    };
    vector<Data> v;
    for(i64 i = 0; i < n; ++i){
        i64 r, a, w, t;
        cin >> r >> a >> w >> t;
        Data d{r, t, a, w};
        v.emplace_back(move(d));
    }
    sort(v.begin(), v.end(), [](auto x, auto y){return x.play_time + x.power_time > y.play_time + y.power_time;});

    vector<vector<i64>> dp(5000, vector<i64>{-INF, -INF});
    dp[4999][0] = 0;
    for(i64 i = 0; i < n; ++i){
        decltype(dp) nex(5000, vector<i64>{-INF, -INF});
        for(i64 j = 4999; j >= 0; --j){
            i64 nex_time = min(j - v[i].play_time, v[i].power_time);
            if(nex_time > 0 && dp[j][0] != -INF)
                dp[nex_time][1] = max(dp[nex_time][1], dp[j][0] + v[i].p1);
            nex_time = j - v[i].play_time;
            if(nex_time > 0 && dp[j][1] != -INF){
                dp[nex_time][1] = max(dp[nex_time][1], dp[j][1] + v[i].p2);
            }
            nex[j][0] = max(dp[j][0], dp[j][1]);
        }
        dp = move(nex);
    }
    i64 ans = 0;
    for(i64 i = 1; i < 5000; ++i){
        ans = max({ans, dp[i][0], dp[i][1]});
    }
    cout << ans << endl;
}




Measured memory_bytes: 3476
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

final class Main {

    private Main() {
    }

    public static void main(final String[] argv) throws IOException {
        final BufferedReader inputReader =
                new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String input = inputReader.readLine();
            if (input == null) {
                break;
            }
            int weight = Integer.parseInt(input);
            int n = 1;
            StringBuilder out = new StringBuilder();
            while (n < 1024) {
                if ((weight & n) > 0) {
                    out.append(n).append(" ");
                }
                n = n << 1;
            }
            System.out.println(out.toString().trim());
        }
    }
}

Measured memory_bytes: 9372
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  NodePointer pre = t->prev, nex = t->next;
  pre->next = nex;
  nex->prev = pre;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  NodePointer tmp = nil->prev;
  nil->prev = tmp->prev;
  deleteNode(tmp);
}

void delete(int key){
  /* your code */
  NodePointer cur = nil->next;

  while(1){
    if(cur==nil) break;
    if(cur->key == (unsigned int)key){
      deleteNode(cur);
      break;
    }
    cur = cur->next;
  }
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  /* 

   your code 


  */
  x->prev = nil;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  if(nil->prev == nil) nil->prev = x;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 31788
#include <bits/stdc++.h>
using namespace std;
#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 ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x);
#define CMIN(m, x)  m = min(m,x);
#define itn int
typedef long long lint;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    
    int n;
    cin >> n;
    vector<int> buka(n);
    REP(i,n - 1){
        int jousi;
        cin >> jousi;
        (buka[jousi - 1])++;
    }
    REP(i,n){
            cout << buka[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4048
#include <stdio.h>

int main(){
  long long int K;
  int N=1;
  long long int S=7LL;
  scanf("%lld",&K);
  if(K%2LL==0 || K%5LL==0){
    printf("-1\n");
  }else{
    while(S%K!=0){
      S=(S*10LL+7LL)%K;
      N++;
    }
    printf("%d\n",N);
  }
  return 0;
}

Measured memory_bytes: 1736
int main()
{
    int N, T, i, menor = 999999999, u = 0;

    scanf ("%d%d", &N, &T);

    int c[N], t[N];

    for (i = 0; i < N; i ++){
        scanf ("%d%d", &c[i], &t[i]);
    }

    for (i = 0; i < N; i ++){
        if (t[i] <= T){
            if (menor > c[i]){
            menor = c[i];
            }
            u ++;
        }
    }

    if (u == 0)
        printf ("TLE");
    else 
        printf ("%d", menor);

    return 0;
}

Measured memory_bytes: 128
///           _____                  _______                  _____                   _____
///          /\    \                /::\    \                /\    \                 /\    \
///         /::\    \              /::::\    \              /::\____\               /::\    \
///        /::::\    \            /::::::\    \            /:::/    /              /::::\    \
///       /::::::\    \          /::::::::\    \          /:::/    /              /::::::\    \
///      /:::/\:::\    \        /:::/~~\:::\    \        /:::/    /              /:::/\:::\    \
///     /:::/__\:::\    \      /:::/    \:::\    \      /:::/    /              /:::/__\:::\    \
///    /::::\   \:::\    \    /:::/    / \:::\    \    /:::/    /              /::::\   \:::\    \
///   /::::::\   \:::\    \  /:::/____/   \:::\____\  /:::/    /      _____   /::::::\   \:::\    \
///  /:::/\:::\   \:::\    \|:::|    |     |:::|    |/:::/____/      /\    \ /:::/\:::\   \:::\    \
/// /:::/  \:::\   \:::\____|:::|____|     |:::|____|:::|    /      /::\____/:::/  \:::\   \:::\____\
/// \::/    \:::\  /:::/    /\:::\   _\___/:::/    /|:::|____\     /:::/    \::/    \:::\  /:::/    /
///  \/____/ \:::\/:::/    /  \:::\ |::| /:::/    /  \:::\    \   /:::/    / \/____/ \:::\/:::/    /
///           \::::::/    /    \:::\|::|/:::/    /    \:::\    \ /:::/    /           \::::::/    /
///            \::::/    /      \::::::::::/    /      \:::\    /:::/    /             \::::/    /
///            /:::/    /        \::::::::/    /        \:::\__/:::/    /              /:::/    /
///           /:::/    /          \::::::/    /          \::::::::/    /              /:::/    /
///          /:::/    /            \::::/____/            \::::::/    /              /:::/    /
///         /:::/    /              |::|    |              \::::/    /              /:::/    /
///         \::/    /               |::|____|               \::/____/               \::/    /
///          \/____/                 ~~                      ~~                      \/____/
//I am aqua
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define speed  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fo for(int i=0;i<n;i++) cin>>a[i];
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define l first
#define r second
#define input.txt ifstream fin("input.txt"); ofstream fout("output.txt");
using namespace std;
///--------------------------------------------------------------------------------------------------------------------

///--------------------------------------------------------------------------------------------------------------------

///--------------------------------------------------------------------------------------------------------------------
int main()
{
    int a,b;
    cin>>a>>b;
    if(a+b==3)
        cout<<3;
    if(a+b==4)
        cout<<2;
    if(a+b==5)
        cout<<1;
}
///I know that ;
///I know where I am
///Do not think I don't


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{
    int r;
    double pi=acos(-1);
    cin >> r;
    double ans=2*r*pi;
    cout << setprecision(20) << ans << endl; //桁数指定//
    return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,j;
    cin>>n>>k;
    long long h[n];
    long long cost[2*n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    cost[0]=0;
    for(int i=1;i<n;i++){
        cost[i]=1e9+5;
        j=1;
        while(j<=k && i-j>=0){
            cost[i]=min(cost[i],abs(h[i]-h[i-j])+cost[i-j]);
            j++;
        }
    }
    cout<<cost[n-1];
    return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(void){
    string s; cin >> s;
    cout << "ABC" + s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int> pi;
const int maxn=505;
int n,a[maxn*maxn],d[maxn][maxn],f[maxn][maxn],ans;
bool valid(int x,int y){
    return x>=1&&x<=n&&y>=1&&y<=n;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    cin >> n;
    for (int i=1;i<=n*n;i++) cin >> a[i];
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
            d[i][j]=min(min(i-1,n-i),min(j-1,n-j));
    for (int i=1;i<=n*n;i++){
        int x=(a[i]-1)/n+1,y=(a[i]-1)%n+1;
        ans+=d[x][y];
        queue <pi> tmp;
        tmp.push((pi){x,y}); f[x][y]=1;
        while (!tmp.empty()){
            pi w=tmp.front(); tmp.pop();
            int x=w.F,y=w.S;
            int res=d[x][y]+(!f[x][y]);
            for (int j=0;j<4;j++){
                int nx=x+dx[j];
                int ny=y+dy[j];
                if (valid(nx,ny)&&d[nx][ny]>res) d[nx][ny]=res,tmp.push((pi){nx,ny});
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6564
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int N, w[110];
int accum[110];

int main() {
    cin >> N;
    rep(i, N) cin >> w[i];
    accum[0] = w[0];
    for(int i=1; i<N; i++) accum[i] = accum[i-1] + w[i];

    int left=0, right=0, diff;
    int ans = INT_INF;
    for(int i=0; i<N-1; i++) {
        left = accum[i];
        right = accum[N-1] - accum[i];
        diff = abs(left-right);
        if (diff<ans) ans = diff;
    }
    cout << ans << endl;
}


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

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

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;


long depths[100005];

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

  long k;
  cin >> k;

  cout << 50 << endl;
  vector<long> res(50);
  rep(i, 50) {
    res[i] = i;
    res[i] += k/50;
  }
  rep(i, k%50) {
    res[49-i]++;
  }
  rep(i, 50) {
    cout << res[i] << endl;
  }
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	h1 := nextInt()
	m1 := nextInt()
	h2 := nextInt()
	m2 := nextInt()
	k := nextInt()

	ans := (h2 * 60 + m2) - (h1 * 60 + m1) - k

	fmt.Println(ans)
}

Measured memory_bytes: 1788
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
using namespace std;

int main(){
  ll x;
  cin>>x;
  ll syoki=100;
  long double b=101;
  b/=100;
  int ans;
  for(int n=1;n<=4000;n++){
    syoki=floor(syoki*b);
    if(syoki>=x){
      ans=n;
      break;
    }
  }
  cout<<ans;
}

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

int main()
{
    string s,t; cin>>s>>t;
    int a,b; cin>>a>>b;
    string u; cin>>u;
    if(u==s){
        cout<<a-1<<" "<<b<<endl;
    }
    else if(u==t){
        cout<<a<<" "<<b-1<<endl;
    }

}


Measured memory_bytes: 3588
def ranlength(A):
    num = list(A)
    count = 1
    result = ''
    table = []
    for i in range(len(num)):
        try:
            if num[i] == num[i+1]:
               count = count + 1
            else:
                result += str(num[i]) + str(count)
                table.append(count)
                count = 1
        except:
            result += str(num[i]) + str(count)
            table.append(count)
    return(table)

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

print(len(ranlength(S)))

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

#define mod 1000000007

int main()
{
    int n;
    char s[2][64]{};
    scanf("%d", &n);
    for (int i = 0; i < 2; i++)
        scanf("%s", s + i);
    
    long long pattern_sum{1};
    int pre_pattern{2}, reaction[3][2]{{3, 1}, {2, 2}, {6, 3}};
    for (int i = 0; i < n; i++)
    {
        int now_pattern = s[0][i] == s[1][i];
        pattern_sum = pattern_sum * reaction[pre_pattern][now_pattern] % mod;
        if (!now_pattern) i++;
        pre_pattern = now_pattern;
    }

    printf("%lld\n", pattern_sum);
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define MAXN 2010
int gcd(int a,int b)
{
	while(b)
	{
		int t=a;a=b;b=t%b;
	}
	return a;
}
int a[MAXN],g[MAXN][MAXN],du[MAXN],vis[MAXN],n;
vector<int>G[MAXN];
void dfs(int u)
{
	vis[u]=1;
	for(int i=1;i<=n;i++)
		if(!vis[i]&&g[u][i])
		{
			G[u].push_back(i);
			du[i]++;
			dfs(i);
		}
}
priority_queue<int>Q;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
			if(gcd(a[i],a[j])!=1)
				g[i][j]=g[j][i]=1;
	for(int i=1;i<=n;i++)
		if(!vis[i])
			dfs(i);
	for(int i=1;i<=n;i++)
		if(!du[i])
			Q.push(i);
	while(!Q.empty())
	{
		int u=Q.top();Q.pop();
		printf("%d ",a[u]);
		for(int i=0;i<G[u].size();i++)
			Q.push(G[u][i]);
	}
}

Measured memory_bytes: 16128