akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int main(void)
{
  int a, b;
  cin >> a >> b;
  int idx = b - a;
  int sum = 0;
  for (int i = 1; i <= idx; i++) sum += i;
  cout << sum - b << endl;
  return 0;
}


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

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

using ll = long long;
using P = pair<ll,ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int gcd(int x, int y) {
    if (x % y == 0) {
        return y;
    }

    else {
        return gcd(y, x % y);
    }
}

int main(){
    int N;
    cin>>N;
    vector<bool> ok(30005);
    rep(i,30005){
        if(i%2==0||i%3==0) ok[i] = true;
    }
    vector<int> ans;
    int t = 1;
    vector<bool> used(30005);
    while(ans.size()<N-1){
        if(ok[t]) {
            ans.push_back(t);
            used[t] = true;
        }
        t++;
    }
    int S = 0;
    for(auto x:ans) S+=x;
    rep(i,30001){
        if(i==0||i==1) continue;
        if(gcd(S,i)==1) continue;
        if((S+i)%6!=0) continue;
        if(used[i]) continue;
        ans.push_back(i);
        break;
    }
    for(auto x:ans) cout<<x<<" ";
    cout<<endl;
}

Measured memory_bytes: 3716
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    bool flag = true;
    for(int i = 0;i < n;i++){
        int a;
        cin >> a;
        if(a % 2 == 0 && a % 3 != 0 && a % 5 != 0)flag = false;
    }

    if(flag)cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
/* ちゃんと考えてわかって実装 */

const int MAX_V = 50;
const int MAX_S = 50 * MAX_V + 5;
const ll INF = 1e18;

struct Edge{
    int to, a, b;

    // これを書いたらerrorが取れた。どうして必要なのｫぉ
    Edge(int to, int a, int b):to(to),a(a),b(b) {}
};

struct State{
    int v, s; // state = (頂点, 所持金)
    ll x; // その状態までの経過時間

    // これを書いたらerrorが取れた。どうして必要なのｫぉ
    State(int v, int s, ll x):v(v),s(s),x(x) {}

    bool operator<(const State& a) const {
        return x > a.x; // (x < a.x だとちゃんと動かねぇ)
    }
};

vector<Edge> g[MAX_V]; // 各頂点から伸びている辺の集合として保持。
ll min_time[MAX_V][MAX_S+5]; // 状態(v, s)までの最小の時間を記録。


int main(void){
    int n, m, s;
    cin >> n >> m >> s;

    for(int i=0; i<m; i++){
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        g[u].emplace_back(v, a, b);
        g[v].emplace_back(u, a, b);
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<MAX_S+5; j++){
            min_time[i][j] = INF;
        }
    }

    vector<int> c(n), d(n);
    for(int i=0; i<n; i++){
        cin >> c[i] >> d[i];
    }

    s = min(s, MAX_S); // 十分な値で切り捨てる。
    priority_queue<State> pq;

    // pqに状態(v, s, x)を emplace するときに、
    // min_time[v][s]の値を x に更新する。(xが最小じゃないなら更新しない。)
    auto push = [&](int v, int s, ll x){
        if(s < 0) return;
        if(min_time[v][s] <= x) return;
        min_time[v][s] = x;
        pq.emplace(v, s, x);
    };
    // 初期状態は(0, s, 0)
    push(0, s, 0);
    while(!pq.empty()){
        State now = pq.top(); pq.pop();
        int v = now.v, s = now.s;
        ll x = now.x;
        if(min_time[v][s] != x) continue; // なぜ?????
        
        // 遷移その1 : 換金
        int next_s = min(s+c[v], MAX_S);
        push(v, next_s, x+d[v]);
        

        // 遷移その2 : 電車に乗る
        // そこから伸びている辺を全てみる
        for(Edge e : g[v]){
            push(e.to, s-e.a, x+e.b);
        }
    }

    for(int i=1; i<n; i++){
        ll ans = INF;
        for(int j=0; j<MAX_S+5; j++){
            ans = min(ans, min_time[i][j]);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 6264
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
 
cnt = {}
for ai in a:
    for c in ai:
        if c in cnt:
            cnt[c] += 1
        else:
            cnt[c] = 1
c1 = 0
c2 = 0
c4 = 0
for k, v in cnt.items():
    c4 += (v // 4) * 4
    c2 += ((v % 4) // 2) * 2
    c1 += v % 2
 
ans = "No"
if h % 2 == 0:
    if w % 2 == 0:
        if c4 == h * w:
            ans = "Yes"
    else:
        if c2 <= h and c1 == 0:
            ans = "Yes"
else:
    if w % 2 == 0:
        if c2 <= w and c1 == 0:
            ans = "Yes"
    else:
        if c2 <= h + w - 1 and c1 == 1:
            ans = "Yes"
print(ans)

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


int main() {
  int n;
  cin >> n;
  string s;
  cin>>s;
  vector<int>r(5000),b(5000),g(5000);
  int co=0;
  int cp=0;
  int cq=0;
  rep(i,n){
    
    if(s.at(i)=='R'){
      co++;
      r.at(i)=co;
    }
    else{
      r.at(i)=co;
    }
  }
  rep(i,n){
    
    if(s.at(i)=='B'){
      cp++;
      b.at(i)=cp;
    }
    else{
      b.at(i)=cp;
    }
  }
  rep(i,n){
    
    if(s.at(i)=='G'){
      cq++;
      g.at(i)=cq;
    }
    else{
      g.at(i)=cq;
    }
  }
  
  long ans=0;
  for (int i = n-1; i >=2; --i){
    for (int j = i-1; j >=1; --j){
      if(s.at(i)=='R'&&s.at(j)=='B'){
        ans+=g.at(j-1);
      }
      else if(s.at(i)=='B'&&s.at(j)=='R'){
        ans+=g.at(j-1);
      }
      else if(s.at(i)=='G'&&s.at(j)=='R'){
        ans+=b.at(j-1);
      }
      else if(s.at(i)=='R'&&s.at(j)=='G'){
        ans+=b.at(j-1);
      }
      else if(s.at(i)=='B'&&s.at(j)=='G'){
        ans+=r.at(j-1);
      }
      else if(s.at(i)=='G'&&s.at(j)=='B'){
        ans+=r.at(j-1);
      }
    }
  }
  
  rep(j,n){
    for (int i = 0; i*2+j<n; ++i){
      if(s.at(j)!=s.at(j+i)&&s.at(j)!=s.at(j+i*2)&&s.at(j+2*i)!=s.at(j+i)){
        ans--;
      }
    }
  }
  
    cout<<ans<<endl;
  
  
}






Measured memory_bytes: 3692
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = 0
for i in range(n):
    c += min(a[i] + a[i + 1], b[i])
    a[i + 1] += min(0, a[i] - b[i])
    a[i + 1] = max(0, a[i + 1])
print(c)

Measured memory_bytes: 19116
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
int z=0;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
//ここから始めよう
signed main(){
    int n;cin>>n;
    int maxi=0;
    int ans=0;
    rep(i,0,n){
        int a;cin>>a;
        maxi=max(maxi,a);ans+=a;
    }cout<<ans-(maxi/2)<<endl;return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;

class Main{
	public static void main(String args[]){
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt(),k = stdIn.nextInt();
		int l[] = new int[n];
		for (int count = 0; count < n; count++){
			l[count]=stdIn.nextInt();
		}
		Arrays.sort(l); 
		int sum = 0;
		for (int count2 = 1; count2 < k+1;count2++){
			sum=sum+l[n-count2];
		}
		System.out.println(sum);
		

		
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

ll mod = 1000000007;
int dp[110][4][4][4];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	vector<int> a(3 * n);
	rep(i, 3 * n) cin >> a[i];
	priority_queue<int, vector<int>, greater<int>> left;
	priority_queue<int> right;
	vector<int> l(3 * n), r(3 * n);
	int p = 0;
	rep(i, n) {
		left.push(a[i]); p += a[i];
	}
	l[n - 1] = p;
	for (int i = n; i <= 2 * n - 1; i++) {
		left.push(a[i]); p += a[i];
		int q = left.top(); left.pop();
		p -= q; l[i] = p;
	}
	p = 0;
	for (int i = 2 * n; i < 3 * n; i++) {
		right.push(a[i]); p += a[i];
	}
	r[2 * n - 1] = p;
	for (int i = 2 * n - 2; i >= n - 1; i--) {
		right.push(a[i + 1]); p += a[i + 1];
		int q = right.top(); right.pop();
		p -= q; r[i] = p;
	}
	int ans = -INF;
	for (int i = n - 1; i < 2 * n; i++) {
		chmax(ans, l[i] - r[i]);
		//cout << l[i] << ' ' << r[i] << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

ll f(ll n, ll c, ll d){
    ll sum=n, lcm;
    lcm = c/__gcd(c,d)*d;
    sum -= n/c;
    sum -= n/d;
    sum += n/lcm;
    return sum;
}

int main(void)
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout << f(b,c,d)-f(a-1,c,d) << endl;
    return 0;
}

Measured memory_bytes: 3616
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())

def prime_decomposition(n):
    i = 2
    table = defaultdict(int)
    while i*i <= n:
        while n%i == 0:
            n //= i
            table[i] += 1
        i += 1
    if n > 1:
        table[n] += 1
    return table

table = prime_decomposition(N)

cnt = 0
for key, val in table.items():
    mnum = 1
    while val-mnum >= 0:
        val -= mnum
        mnum += 1
        cnt += 1
print(cnt)

Measured memory_bytes: 9492
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var str = Console.ReadLine();
        var array = str.Split(' ').Select(s => int.Parse(s)).ToArray();
        var w = array[0];
        var h = array[1];
        var x = array[2];
        var y = array[3];
        var r = array[4];
        var message = "";
        
        if((x - r) < 0 || (x + r) > w){
            message = "No";
        }else if((y - r) < 0 || (y + r) > h){
            message = "No";
        }else{
            message = "Yes";
        }
        
        Console.WriteLine(message);
    }
}



Measured memory_bytes: 18432
#include <iostream>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    int food[10000] = {};

    for (int i = 0; i < N; i++)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            int ans;
            cin >> ans;
            food[ans - 1]++;
        }
    }

    int a = 0;
    for (int i = 0; i < M; i++)
    {
        if (food[i] == N)
        {
            a++;
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n;   cin >> n;
    vector<ll> a(n), cum(n+1, 0);
    ll res = 0;
    rep(i, n) cin >> a[i];
    rep(i, n){
        cum[i+1] += cum[i]+a[i];
        cum[i+1] %= MOD;
    }
    // rep(i, n) cout << cum[i+1] << ' ';
    // cout << endl;
    rep(i, n-1){
        res += a[i]*(((cum[n]-cum[i+1])+MOD)%MOD);
        res %= MOD;
        //cout << res << ' ';
    }
    cout << res << endl;
}


Measured memory_bytes: 6368
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		Long[] v = new Long[N];
		for(int i=0; i<N; i++)
			v[i] = sc.nextLong();
		
		Arrays.sort(v, Collections.reverseOrder());
		
		long[][] comb = new long[60][60];
		for(int i=0; i<60; i++) {
			comb[i][0] = comb[i][i] = 1;
			for(int j=1; j<i; j++) {
				comb[i][j] = comb[i-1][j] + comb[i-1][j-1];
			}
		}
		
		double sum = 0;
		for(int i=0; i<A; i++)
			sum += v[i];
		
		System.out.println(sum/A);
		
		int K = 0,L = 0;
		for(int i=0; i<N; i++)
			if(v[i].equals(v[A-1])) {
				K++;
				if(i<A)
					L++;
			}
		
		long ans = 0;
		if(v[0].equals(v[A-1])) {
			for(int i=A; i<=B; i++)
				ans += comb[K][i];
		} else {
			ans = comb[K][L];
		}
		System.out.println(ans);
		
		sc.close();
	}
}

Measured memory_bytes: 21972
#include <stdio.h>

typedef struct{
  char c;
  int number;
}card;

int main(){
  char dm;
  int n,i,j,min,flag;
  card a[36],b[36],x;
  scanf("%d\n",&n);
  for(i=0;i<n;i++){ scanf("%c%d%c",&a[i].c,&a[i].number,&dm);
    b[i]=a[i]; 
  }
  

  for(j=0;j<n;j++){
    flag=0;   
    for(i=n-1;i>j;i--){
      if(a[i].number<a[i-1].number)
	{
	  x=a[i];
	  a[i]=a[i-1];
	  a[i-1]=x;
	  flag=1;
	}
    }
    if(flag==0)break;

  }

  for(j=0;j<n;j++){
    min=j;   
    for(i=j;i<n;i++){
      if(b[i].number<b[min].number)
	min=i;
	
    }   
    if(min!=j){
      x=b[j];
      b[j]=b[min];
      b[min]=x;

    }
  }

  for(i=0;i<n-1;i++) printf("%c%d ",a[i].c,a[i].number);
  printf("%c%d\n",a[n-1].c,a[n-1].number);
    
  printf("Stable\n");
  for(i=0;i<n-1;i++) {printf("%c%d ",b[i].c,b[i].number);
    if(a[i].c!=b[i].c)flag=2;

  }
  printf("%c%d\n",b[n-1].c,b[n-1].number);
  if(flag==2)printf("Not stable\n");
  else printf("Stable\n");

  return 0;
  
}

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

int main() {
  int a, b, m, min;
  cin >> a >> b >> m;
  int A[a], B[b], x[m], y[m], c[m];
  int minA = (1 << 30);
  int minB = (1 << 30);
  int minS;
  rep(i, a) {
    cin >> A[i];
    if (A[i] < minA) minA = A[i];
  }
  rep(i, b) {
    cin >> B[i];
    if (B[i] < minB) minB = B[i];
  }
  minS = minA + minB;
  rep(i, m) {
    cin >> x[i] >> y[i] >> c[i];
    if ((A[x[i]-1] + B[y[i]-1] - c[i]) < minS) minS = (A[x[i]-1] + B[y[i]-1] - c[i]);
  }

  cout << minS << endl;

  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
#define allsortg(v)sort(v.begin(),v.end(),greater<int>());
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	string S;
	cin >> S;
	int flag[26] = {};
	rep(i, S.size()) flag[S[i] - 'a']++;
	rep(i, 26) {
		if (flag[i] == 0) {
			cout << char('a' + i) << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 512
//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
//入力マクロここまで

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        n: usize,
        a: [i64;n],
    }

    let mut x = 0;
    for i in 0..n {
        if i % 2 == 0 {
            x += a[i];
        } else {
            x -= a[i]
        }
    }

    print!("{}", x);
    for i in 0..n - 1 {
        x = (a[i] - x / 2) * 2;
        print!(" {}", x);
    }
    println!();
}


Measured memory_bytes: 5372
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<queue>
#include<cstring>
#include<utility>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<bitset>
#include<deque>
#include<cctype>
using namespace std;
int main() 
{
	int n,m;
	cin>>n>>m;
	cout<<(n-1)*(m-1);
    return 0; 
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define scan(a,n) for (ll i = 0; i < n; ++i) cin >> a[i]
int minimumChar(string S1, string S2) 
{ 
    // Get the sizes of both strings 
    int n = S1.size(), m = S2.size(); 
  
    int ans = INT_MAX; 
  
    // Traverse the string S2 
    for (int i = 0; i < m - n + 1; i++) { 
        int minRemovedChar = 0; 
  
        // From every index in S2, check the number of 
        // mis-matching characters in substring of 
        // length of S1 
        for (int j = 0; j < n; j++) { 
            if (S1[j] != S2[i + j]) { 
                minRemovedChar++; 
            } 
        } 
  
        // Take minimum of prev and current mis-match 
        ans = min(minRemovedChar, ans); 
    } 
  
    // return answer 
    return ans; 
} 
int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	string a,b;
	cin>>a;
	cin>>b;
	cout << minimumChar(b,a); 
	return 0;
}


Measured memory_bytes: 3616
#ソートなし版
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def gcdlist(l):
    a = l[0]
    for i in range(1,len(l)):
        a = gcd(a,l[i])
    return a

def fctr1(n): 
    f = []
    c = 0
    for i in range(2,int(n**0.5)+2):
        while n%i == 0:
            c += 1
            n = n//i
        if c !=0:
            f.append([i,c])
            c = 0
    if n != 1:
        f.append([n,1])
    return f

n = int(readline())
a = list(map(int,readline().split()))
check = [True]*(10**6+5)
p1 = True
for ai in a:
    if not p1:
        break
    dlist = fctr1(ai)
    for d,c in dlist:
        if check[d]:
            check[d] = False
        else:
            p1 = False
            break

if p1:
    print("pairwise coprime")
else:
    p2 = gcdlist(a)
    if p2 == 1:
        print("setwise coprime")
    else:
        print("not coprime")




Measured memory_bytes: 183272
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		List<Integer> A=new ArrayList<>();
		int q=in.nextInt();
		for(int i=0;i<q;i++) {
			int query=Integer.parseInt(in.next());
			
			switch(query) {
			case 0:
				int x=Integer.parseInt(in.next());
				A.add(x);
				break;
				
			case 1:
				int p=Integer.parseInt(in.next());
				System.out.println(A.get(p));
				break;
				
			case 2:
				A.remove(A.size()-1);
				break;
			}
		}
	}

}


Measured memory_bytes: 116468
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

using graph = vector<vector<ll>>;

// function -------------------------------------------
ll f(ll a, ll b){
    return a / b;
}

// 最大公約数を計算 GCD
// 最小公倍数を計算 LCM
ll llgcd(ll a, ll b){
    if(b == 0){
        return a;
    }
    return llgcd(b, a % b);
}
ll lllcm(ll a, ll b){
    if(a == 0 || b == 0){
        return 1;
    }
    return a / llgcd(a, b) * b;
}

// main -----------------------------------------------

int main() {
    ll n, k;
    cin >> n >> k;
    if((n-1) * (n-2) / 2 < k){
        cout << -1 << endl;
        return 0;
    }
    ll s = (n-1) * (n-2) / 2;
    ll m = (n - 1) + (s - k);
    cout << m << endl;
    PREP(i, 1, n){
        cout << i+1 << " " << 1 << endl;
        m --;
    }
    PREP(i, 1, n){
        PREP(j, i+1, n){
            if(m <= 0){
                return 0;
            }
            cout << i+1 << " " << j+1 << endl;
            m --;
        }
    }
    return 0;
}

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

int main() {
	int N, X, i;
	cin >> N >> X;
	vector<int> L(N);
	for (i = 0; i < N; i++) {
		cin >> L.at(i);
	}

	int D = 0;
	for (i = 0; i < N; i++) {
		D += L.at(i);
		if (D > X) {
			break;
		}
	}
	cout << i + 1 << endl;
	return 0;
}

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

signed main(){
	int n,t;
	cin>>n>>t;
	int a[100010];
	rep(i,n)cin>>a[i];
	int mn[100010],mx[100010];
	mn[0]=a[0];
	rep(i,1,n)mn[i]=min(mn[i-1],a[i]);
	mx[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--)mx[i]=max(mx[i+1],a[i]);
	int k=0;
	rep(i,n)chmax(k,mx[i]-mn[i]);
	set<int> s;
	int re=0;
	rep(i,n)if(mx[i]-mn[i]==k)s.insert(mx[i]);
	cout<<s.size()<<endl;
}

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

int main() {
	// your code goes here
	int n,m,k,sum = 0;
	cin>>n;
//	int*a = new int[n+1];
	for(int i = 1;i<=n;i++)
	{
		cin>>m>>k;
		sum+=k-m+1;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1
struct Node{int p,l,r;};

Node T[MAX];
int n,D[MAX];

void print(int u){
    int i,c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";
    
    if(T[u].p==NIL) cout << "root, ";
    else if(T[u].l==NIL)    cout << "leaf, ";
    else cout << "internal node, ";
    cout << "[";
    for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
        if(i)   cout<<", ";
        cout<<c;
    }
    cout << "]"<<endl;
}

int rec(int u,int p){
    D[u]=p;
    if(T[u].r != NIL)   rec(T[u].r,p);
    if(T[u].l != NIL)   rec(T[u].l,p+1);
}

int main(){
    int i,j,d,v,c,l,r;
    cin >> n;
    for(i=0;i<n;i++)    T[i].p = T[i].l = T [i].r = NIL;
    
    for(i=0;i<n;i++){
        cin >> v >> d;
        for(j=0;j<d;j++){
            cin >> c;
            if(j==0)    T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for(i=0;i<n;i++){
        if(T[i].p==NIL) r = i;
    }
    rec(r,0);
    for(i=0;i<n;i++)   print(i);
    return 0;
}

Measured memory_bytes: 7676
N = int(input())
a = 0
k = 2*(N-2)+1
for i in range(2,N):
    for j in range(i,N):
        if (i*j<N)and(i!=j):
            a+=2
        elif(i*j<N)and(i==j):
            a+=1
        else:
            break
       
print(a+k)



Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
int isprime[100001],prime[100001],sum[100001];
void Euler_seive(int n)
{
	int i,j,total=0;
	memset(isprime,0,sizeof(isprime));
	isprime[0]=isprime[1]=1;
	prime[0]=0;
	for(i=2;i<=n;i++)
	{
		if(!isprime[i])
		{
			prime[++prime[0]]=i;
			if(!isprime[(i+1)/2])
			{
				total++;
			}
		}
		sum[i]=total;
		for(j=1;j<=prime[0]&&i*prime[j]<=n;j++)
		{
			isprime[i*prime[j]]=1;
			if(i%prime[j]==0)
				break;
		}
	}
}
int main()
{
	int i,q,l,r;
	scanf("%d",&q);
	Euler_seive(100000);
	for(i=1;i<=q;i++)
	{
		scanf("%d %d",&l,&r);
		printf("%d\n",sum[r]-sum[l-1]);
	}
	return 0;
}

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

int arr[100010];

using ll = long long;
int n;

ll solve(int a){
    int total = 0;
    int before = a;
    ll result = 0;
    
    for(int i = 0; i < n; i++){
        
        total += arr[i];
        //cout << total << endl;
        
        if(before < 0 && total > 0){
            
        }else if(before > 0 && total < 0 ){
            
        }else if(before < 0){
            result += abs(1-total);
            total = 1;
        }else if(before > 0){
            result += abs(-1-total);
            total = -1;
        }
        
        
        before = total;
        
    }
    
    //cout << endl;
    
    return result;
}


int main(void){
    // Here your code !
    cin >> n;
    
    for(int i = 0; i < n; i++) cin >> arr[i];
    

    
    cout << min(solve(1),solve(-1)) << endl;
    
    
    
}


Measured memory_bytes: 640
//template---{{{
//Header file---{{{
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
//}}}
using namespace std;

//DEFINE---{{{
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b); i > (a); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
//end.DEFINE---}}}

//end.template ---}}}

int main() {
  int A, B;

  cin >> A >> B;

  cout << A * B - (A + B - 1) << endl;

  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int val;
int N;
string s;
string a;
int calc(int& it){
	if(a[it]=='_'){
		it+=2;
		int x=calc(it);
		assert(a[it]==',');
		it++;
		int y=calc(it);
		assert(a[it]==')');
		it++;
		return min(x,y);
	}else if(a[it]=='^'){
		it+=2;
		int x=calc(it);
		assert(a[it]==',');
		it++;
		int y=calc(it);
		assert(a[it]==')');
		it++;
		return max(x,y);
	}else{
		int ret=0;
		while(isdigit(a[it])){
			ret=ret*10+a[it]-'0';
			it++;
		}
		return ret;
	}
}
bool can(int m){
	int vmax,vmin;
	{
		string mx=s.substr(0,m);
		bool nowdig=isdigit(s[m-1]);
		bool fst=1;
		for(int i=m;i<N;i++){
			if(isdigit(s[i])){
				nowdig=1;
				continue;
			}else{
				if(nowdig){
					if(fst){
						int X=mx.size()-1;
						string tmp;
						while(X>0){
							if(isdigit(mx[X])){
								tmp=mx[X]+tmp;
								X--;
							}else{
								break;
							}
						}
						assert(tmp.size()<=2);
						if(tmp.size()==0){
							mx+="99";
						}
						if(tmp.size()==1){
							if(tmp[0]!='0') mx+="9";
						}
						fst=0;
					}
					else mx+="99";
					nowdig=0;
				}
				mx+=s[i];
			}
		}
//		show(m);
//		show(mx);
		a=mx;
		int it=0;
		vmax=calc(it);
//		show(vmax);
	}

	{
		string mx=s.substr(0,m);
		bool nowdig=isdigit(s[m-1]);
		bool fst=1;
		for(int i=m;i<N;i++){
			if(isdigit(s[i])){
				nowdig=1;
				continue;
			}else{
				if(nowdig){
					if(fst){
						int X=mx.size()-1;
						string tmp;
						while(X>0){
							if(isdigit(mx[X])){
								tmp=mx[X]+tmp;
								X--;
							}else{
								break;
							}
						}
						assert(tmp.size()<=2);
						if(tmp.size()==0){
							mx+="0";
						}
						fst=0;
					}
					else mx+="0";
					nowdig=0;
				}
				mx+=s[i];
			}
		}
	//	show(m);
	//	show(mx);
		a=mx;
		int it=0;
		vmin=calc(it);
	//	show(vmax);
	}
	if(vmax==vmin) val=vmax;
	return vmax==vmin;
}
void solve(){
	cin>>s;
	if(isdigit(s[0])){
		if(s[0]=='0'){
			cout<<"0 1"<<endl;
			return;
		}
		if(s.size()==2){
			cout<<s[0]<<" "<<2<<endl;
			return;
		}
		if(s.size()==3){
			cout<<s.substr(0,2)<<" "<<2<<endl;
			return;
		}
	}
	N=s.size();
	int ub=N+1,lb=0;
	while(ub-lb>1){
		int m=(ub+lb)/2;
		if(can(m)) ub=m;
		else lb=m;
	}
	cout<<val<<" "<<ub<<endl;
//	rep1(i,N) can(i);
}
int main(){
	int Q;
	cin>>Q;
	rep(i,Q) solve();
}


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

using namespace std;

int k;

string s;

int main () {
    cin >> k >> s;
    for (int i = 0;i < s.size ();i ++) {
        int num = int(s[i]);
        num += k;
        if (num > 'Z') {
            num %= 'Z';
            num += 64;
        }
        s[i] = char (num);
    }
    cout << s;
}


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

typedef long long ll;

ll N;
ll ans;

int main()
{
    cin >> N;

    if(N == 1)cout << 0 << endl;
    else
    {
        for(ll i = 1; i * i <= N; i++)if((N - i) % i == 0 && N / ((N - i) / i) == N % ((N - i) / i))ans += (N - i) / i;
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    if(abs(a-b)<=(v-w)*t){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
#define N 1000000007

int main(){
    long long int n, m;
    cin >> n;
    m = n;
    long long int bi[62];
    bi[0] = 1;
    for(long long int i = 1; i < 62; i++){
        bi[i] = bi[i-1]*2;
    }
    long long int tri[100];
    tri[0] = 1;
    for(long long int i = 1; i < 62; i++){
        tri[i] = (tri[i-1]*3)%N;
    }
    long long int a[62];
    long long int keta = 100000;
    for(long long int i = 61; i >= 0; i--){
        a[i] = n/bi[i];
        if(a[i] == 1 && keta == 100000) keta = i;
        n = n-bi[i]*a[i];
    }
    // for(int i = keta; i >= 0; i--){
        // cout << a[i] << endl;
    // }
    long long int kosan[63];
    long long int kosan1[63];
    kosan[0] = 1;
    kosan1[0] = 1;
    for(long long int j = 1; j <= 62; j++){
        if(a[j-1] == 1){
            kosan[j] = (kosan[j-1] + kosan1[j-1])%N;
            kosan1[j] = (kosan1[j-1] + 2*tri[j-1])%N;
        }
        else{
            kosan[j] = kosan[j-1];
            kosan1[j] = (tri[j-1] + kosan[j-1] + kosan1[j-1])%N;
        }
    }
    long long int sum = 0;
    sum = (1 + m/2)%N;
    for(long long int i = 0; i <= keta; i++){
        if(a[i] == 0 && a[i+1] == 0){
            sum = (sum + tri[i]*((m/bi[i+2])%N))%N;
        }
        if(a[i] == 0 && a[i+1] == 1){
            sum = (sum + (kosan1[i]*((m/bi[i+2]+1)%N))%N + (((tri[i]-kosan1[i])%N) * ((m/bi[i+2])%N))%N)%N;
        }
        if(a[i] == 1 && a[i+1] == 0){
            sum = (sum + (kosan[i]*((m/bi[i+2]+1)%N))%N + (((tri[i]-kosan[i])%N)*((m/bi[i+2])%N))%N)%N;
        }
        if(a[i] == 1 && a[i+1] == 1){
            sum = (sum + (tri[i]*((m/bi[i+2]+1)%N))%N)%N;
        }
    }
    cout << sum << endl;
    return 0;
}

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

int main(void) {
  long double a, b;
  scanf("%Lf %Lf", &a, &b);
  printf("%lld\n", (long long int) (a * b));

  return 0;
}


Measured memory_bytes: 1760
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long n, m;
    scan(n, m);
    writeln((n - 1) * (m - 1));

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    string S;
    cin>>S;
    ll A=S[0]-'0';
    ll B=S[1]-'0';
    ll C=S[2]-'0';
    ll D=S[3]-'0';
    if(A+B+C+D==7) cout<<A<<"+"<<B<<"+"<<C<<"+"<<D<<"=7"<<endl;
    else if(A-B-C-D==7) cout<<A<<"-"<<B<<"-"<<C<<"-"<<D<<"=7"<<endl;
    else if(A+B+C-D==7) cout<<A<<"+"<<B<<"+"<<C<<"-"<<D<<"=7"<<endl;
    else if(A+B-C+D==7) cout<<A<<"+"<<B<<"-"<<C<<"+"<<D<<"=7"<<endl;
    else if(A-B+C+D==7) cout<<A<<"-"<<B<<"+"<<C<<"+"<<D<<"=7"<<endl;
    else if(A-B+C-D==7) cout<<A<<"-"<<B<<"+"<<C<<"-"<<D<<"=7"<<endl;
    else if(A+B-C-D==7) cout<<A<<"+"<<B<<"-"<<C<<"-"<<D<<"=7"<<endl;
    else if(A-B-C+D==7) cout<<A<<"-"<<B<<"-"<<C<<"+"<<D<<"=7"<<endl;
    return 0;
}


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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

void intSwap(int *a, int *b){int tmp=*a;*a=*b;*b=tmp;}

int main(){
  int i,j,k,n;
  int cup[3];
  char c,c1;

  rep(i,3) cup[i] = 0;
  cup[0] = 1;
  while(scanf("%c,%c\n",&c,&c1) != EOF){
    c -= 'A'; c1 -= 'A';
    intSwap(&cup[c],&cup[c1]);
  }
  rep(i,3) if(cup[i] == 1) printf("%c\n", i+'A');

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    set<int> st;
    int q,a,b;
    cin >> q;
    for (int i=0;i<q;i++) {
        cin >> a >> b;
        if ( a==0 ) {
            st.insert(b);
            cout << st.size() << endl;
        } else if ( a==1 ) {
            auto itr = st.find(b);
            if (itr!=st.end()) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }
}



Measured memory_bytes: 12448
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long,long>
#define INF 1000000000000000000
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; }
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
class Union_Find {
private:
	vector<int> par;
	vector<int> rank;
public:
	Union_Find(int n) {
		rep(i, n) {
			par.push_back(i);
			rank.push_back(0);
		}
	}
	int find(int x) {
		if (par.at(x) == x) return x;
		else return par.at(x) = find(par.at(x));
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank.at(x) < rank.at(y)) {
			par.at(x) = y;
		}
		else {
			par.at(y) = x;
			if (rank.at(x) == rank.at(y)) rank.at(x)++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if (b + c <= a)cout << 0 << endl;
	else cout << b + c - a<< endl;

	return 0;
}

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

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

	for(int i=1;i<=n;i++)
	{
		x = i;
		if(x%3 == 0)
			cout << " " << i;
		else
		{
			while(x)
			{
				if(x%10 == 3)
				{
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int D;	cin>>D;
	vi c(26);
	vector<pair<int,int>>cs(26);
	rep(i,0,26){
		cin>>c[i];
		cs[i].first=c[i];
		cs[i].second=i;
	}
	int s[D][26];
	rep(i,0,D){
		rep(j,0,26){
			cin>>s[i][j];
		}
	}

	sort(all(cs));
	reverse(all(cs));
	vi top(10);
	rep(i,0,10){
		top[i]=cs[i].second+1;
	}
	vi notop(D,1);
	rep(i,0,16){
		notop[i]=cs[i+10].second+1;
	}

	int cnt=1;
	int nt_idx=0;
	while(1){
		rep(i,0,10){
			cout<<top[i]<<endl;
			cnt++;
			if(cnt>D) return 0;
		}
		rep(i,0,5){
			cout<<notop[nt_idx]<<endl;
			nt_idx++;
			if(nt_idx>15) nt_idx=0;
			cnt++;
			if(cnt>D) return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;

public class SegmentTree
{
    public int N { get; private set; }
    public int[] Node;
    public int InvalidVal { get; private set; }

    public SegmentTree(int[] a, int invVal)
    {
        InvalidVal = invVal;
        for (N = 1; N < a.Length; N *= 2) ;
        Node = new int[2 * N - 1];
        for (int i = 0; i < Node.Length; i++)
        {
            Node[i] = InvalidVal;
        }
        for (int i = 0; i < a.Length; i++)
        {
            Node[N + i - 1] = a[i];
        }
        for (int i = N - 2; i >= 0; i--)
        {
            Node[i] = Sum(Node[2 * i + 1], Node[2 * i + 2]);
        }
    }

    public SegmentTree(int invVal, int len)
    {
        InvalidVal = invVal;
        for (N = 1; N < len; N *= 2) ;
        Node = new int[2 * N - 1];
        for (int i = 0; i < Node.Length; i++)
        {
            Node[i] = InvalidVal;
        }
    }

    public void Update(int x, int v)
    {
        x += (N - 1);
        Node[x] = v;

        while (x > 0)
        {
            x = (x - 1) / 2;
            Node[x] = Sum(Node[2 * x + 1], Node[2 * x + 2]);
        }
    }

    public int Get(int a, int b)
    {
        return Get(a, b, 0, 0, N);
    }

    private int Get(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l)
        {
            return InvalidVal;
        }
        if (a <= l && r <= b)
        {
            return Node[k];
        }

        var vl = Get(a, b, 2 * k + 1, l, (l + r) / 2);
        var vr = Get(a, b, 2 * k + 2, (l + r) / 2, r);
        return Sum(vl, vr);
    }

    private static int Sum(int a, int b)
    {
        return a + b;
    }
}

public class Query
{
    // 1オリジン [L,R)
    public int L;
    public int R;
    public int Answer;

    public Query(string s)
    {
        var vals = s.Split(' ').Select(int.Parse).ToArray();
        L = vals[0];
        R = vals[1] + 1;
    }
}

public static class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var Q = vals[1];
        // 1オリジン c[0]はダミー
        var c = new int[1].Concat(Console.ReadLine().Split(' ').Select(int.Parse)).ToArray();
        var queries = new List<Query>();
        for (int q = 0; q < Q; q++)
        {
            queries.Add(new Query(Console.ReadLine()));
        }

        var segtree = new SegmentTree(0, N + 1);
        var cur = 1;
        var lastIndex = new int[N + 1];
        foreach (var q in queries.OrderBy(q => q.R))
        {
            for (; cur < q.R; cur++)
            {
                var v = c[cur];
                segtree.Update(lastIndex[v], 0);
                segtree.Update(cur, 1);
                lastIndex[v] = cur;
            }
            q.Answer = segtree.Get(q.L, q.R);
        }

        Console.WriteLine(string.Join(Environment.NewLine, queries.Select(q => q.Answer)));
    }
}

Measured memory_bytes: 103056
import collections
n = int(input())
v = list(map(int, input().split()))
v_odd = v[::2]
v_even = v[1::2]
v_odd = collections.Counter(v_odd)
v_even = collections.Counter(v_even)
v_odd = v_odd.most_common()
v_even = v_even.most_common()
if v_odd[0][0] == v_even[0][0]:
  if len(v_odd) == len(v_even) == 1:
    print(int(n/2))
  else:
    print(min(n - v_odd[1][1] -v_even[0][1],n - v_odd[0][1] -v_even[1][1]))
else:
  print(n - v_odd[0][1] -v_even[0][1])

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

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));

    for(int i = 0; i < n; i++){
        cin >> c.at(i);
        for(int j = 0; j < m; j++){
            cin >> a.at(i).at(j);
        }
    }
    const int sugoi = 1000000000;
    int ans = sugoi;

    for(int tmp = 0; tmp < (1 << n); tmp++){
        int cost = 0;
        vector<int> skill(m);
        for(int i = 0; i < n; i++){
            if(tmp >> i & 1){
                cost += c.at(i);
                for(int j = 0; j < m; j++) skill.at(j) += a.at(i).at(j);
            }
        }        
        bool ok = true;
        for(int l = 0; l < m; l++){
            if(skill.at(l) < x){
                ok = false;
            }
        }
        if(ok) ans = min(ans,cost);
    }
    if(ans == sugoi) cout << -1 << endl;
    else cout << ans << endl;
    
}

Measured memory_bytes: 3636
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()

	ans := 2
	if n == 2 {
		ans--
	}
	for i := 2; i*i <= n; i++ {
		num := n
		for num%i == 0 {
			num /= i
		}
		if num == 1 || (num-1)%i == 0 {
			ans++
			// debug(i, num)
		}
		num = n
		t := n / i
		if t == i {
			continue
		}
		for num%t == 0 {
			num /= t
		}
		if num == 1 || (num-1)%t == 0 {
			ans++
			// debug(t, num)
		}
	}

	fmt.Fprintln(wr, ans)

}


Measured memory_bytes: 1784