akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,m,a,b;
int h[5010];
vector<int> g[5010];
 
int main(){
    cin >> n >> m;
    REP(i,0,m){
        cin >> a >> b; a--; b--;
        g[a].push_back(b);
        h[b]++;
    }
     
    queue<int> qu;
    REP(i,0,n) if(!h[i]) qu.push(i);
     
    vector<int> vec;
    bool f=false;
    while(!qu.empty()){
        auto p=qu.front(); qu.pop();
         
        int c=0;
        vec.push_back(p);
        for(auto v:g[p]){
            h[v]--;
            if(!h[v]) qu.push(v),c++;
        }
         
        if(c>1) f=true;
    }
     
    for(auto v:vec) cout << v+1 << endl;
    cout << f << endl;
    return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
int main() {
  int K;
  cin >> K;
  ll ans = 0;
  for(int i = 1; i <= K; ++i) for(int j = 1; j <= K; ++j) for(int k = 1; k <= K; ++k) {
    ll t = gcd(i, j);
    t = gcd(t, k);
    ans += t;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.*;

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

      int n = Integer.parseInt(sc.next());

      int[] d = new int[n];
      for(int i=0;i<n;i++){
        d[i] = Integer.parseInt(sc.next());
      }

      int ans = 0;

      for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
          ans += d[i]*d[j];
        }
      }

      System.out.println(ans);

    }
}

Measured memory_bytes: 23636
mod = 10 ** 9 + 7

H, W, A, B = map(int, input().split())

fact = [-1] * (H + W + 1)
fact[0] = 1
fact[1] = 1
for x in range(2, H + W + 1):
    fact[x] = x * fact[x - 1] % mod

invs = [-1] * (H + W + 1)
invs[H + W] = pow(fact[H + W], mod - 2, mod)
for x in range(H + W - 1, 0, -1):
    invs[x] = invs[x + 1] * (x + 1) % mod


def combination(n, r):
    if n - r < r:
        return combination(n, n - r)
    if r < 0:
        return 0
    if r == 0:
        return 1
    if r == 1:
        return n
    return fact[n] * invs[r] * invs[n - r] % mod


ret = 0
for c in range(B, W):
    ret = (ret + combination(H - 1 - A + c, c) * combination(W - 2 + A - c, A - 1)) % mod
print(ret)

# 左下にA*Bの入れない区画
# S->{aa,bb,cc,dd,ee,ff,gg}->G
# S->aはcombination(H - 1 - A + c, c):aの座標(H-1-A,c),通る列番号cを選ぶ
# a->aは1通り
# a->Gはcombination(W - 2 + A - c, A - 1):aの座標(H-A,c),Gの座標(H-1,W-1)この距離からA-1を選ぶ
# S**********
# *         *
# *         *
# *         *
# ****abcdefg
# *   abcdefg
# *   *     *
# *   *     *
# **********G

Measured memory_bytes: 20724
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static boolean solve() {
		int n = in.nextInt();
		int m = in.nextInt();
		if (n + m == 0) return false;

		int[][] p = new int[n][2];
		for (int i=0; i<n; i++) {
			for (int j=0; j<2; j++) {
				p[i][j] = in.nextInt();
			}
		}

		Arrays.sort(p, new Comparator<int[]>(){
			public int compare(int[] a, int[] b) {
				return b[1] - a[1];
			}
		});

		int ans = 0;
		for (int i=0; i<n; i++) {
			int min = Math.min(Math.max(0, m), p[i][0]);
			ans += (p[i][0] - min)*p[i][1];
			m -= min;
		}
		out.println(ans);

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 70220
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
count = 0
for i in range(n):
     h[i] = abs(t - h[i] * 0.006 - a)
for i in range(n):
     if h[i] == min(h):
          print(i+1)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n;
    n=s.length();
    char A[n];
    for (int i=0; i<n; i++){
        A[i]=s[i];
    }
    if (A[2]==A[3] && A[4]==A[5]){
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}


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

int main() {
	int64_t k, x;
	cin >> k  >> x;

	for(int64_t i = x - (k - 1); i < (x + k - 1); i++) {
		cout << i << " ";
	}
	cout << k + x - 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A * N, B) << endl;
    return 0;
}


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

#define ll long long int
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
/*typedef tuple<ll,ll,ll>tpl;

ll bigmod(ll n,ll pow)
{
    if(pow==0)
        return 1;
    if(pow==1)
        return n%MOD;

    ll ans=bigmod(n,pow/2);
    ans=(ans*ans)%MOD;

    if(pow%2==1)
    {
        ans=(ans*n)%MOD;
    }
    return ans%MOD;
}

ll fact[1000005];

ll nCr(ll n,ll r)
{

    ll ans=fact[n];
    ans=(ans*bigmod(fact[r],MOD-2))%MOD;
    ans=(ans*bigmod(fact[n-r],MOD-2))%MOD;
    return ans;
} */

ll ar[200005],sm[200005];
int main()
{
    _fastio
    ll n,a,sum=0;

    cin>>n;
    
    for1(i,n)
    {
        cin>>ar[i];
        if(i==1) sm[i]=ar[i];
        else sm[i]=ar[i]+sm[i-1];

        sum=sum+ar[i];
    }
    ll as=0;

    for1(i,n)
    {
        a=sum-sm[i];
        ll b=((a%MOD)*(ar[i]%MOD))%MOD;

        as=(as+b)%MOD;
    }
    cout<<as<<en;
}


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

int a, b, c;
int A, B, C;
int ans;

int main() {
	cin >> a >> b >> c;
	A = min(a, min(b, c));
	C = max(a, max(b, c));
	B = a + b + c - A - C;
	while (B != C) {
		B++;
		A++;
		ans++;
	}
	while (A < B) {
		A += 2;
		ans++;
	}
	if (A != B) ans++;
	cout << ans;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int m = 0;
        long ans = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            a[i] -= i + 1;
        }
        Arrays.sort(a);
        if (a.length % 2 == 1)
            m = a[n / 2];
        else
            m = (a[n / 2] + a[n / 2 - 1]) / 2;
        for (int i = 0; i < n; i++) {
            ans += Math.abs(a[i] - m);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 66576
#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[b]+=siz[a];
			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=998244353;
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);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

signed main(){
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	bool re=false;
	rep(i,n){
		if(c*i-d*(n-i-1)<=b-a&&b-a<=d*i-c*(n-i-1)){
			re=true;
		}

	}
	if(re)puts("YES");
	else puts("NO");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned lon1g long
#define double long double
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sett(c) (c).resize(unique(all(c))-(c).begin())
#define sz(a) (int)(a).size()
#define hell 1000000007
#define pi pair<int,int>
#define vi vector<int>
#define vb vector<bool>
#define vpi vector<pair<int,int>>
#define x first
#define y second
#define endl '\n'
#define forn(i,n) for(int i = 0 ; i < n ; i++ )
#define for1(i,n) for(int i = 1 ; i < n ; i++ )
#define fore(i,a,b) for(int i = a ; (a>b)?(i>=b):(i<=b) ; (a>b)?(i--):(i++) )

using namespace std;

bool comp(const pi& a , const pi& b ){
        return a.y < b.y;
}

long long binpow(long long a, long long b) {

    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a ;
        a = a * a ;
        b >>= 1;
    }
    return res;
}

void task_A(){
        int n ; cin >> n ; cout << n*n << endl;
}

void task_B(){
        int n ; cin >> n ;
        string s ; cin >> s ;
        if(n&1){
                cout << "No" << endl;
                return ;
        }
        cout << ( (s.substr(0,n/2) == s.substr(n/2,n/2))?"Yes":"No" ) << endl;
}

void task_C(){

}

void task_D(){

}

void task_E(){

}

int32_t main(){

        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
        cout << fixed;
        cout.precision(10);

        int t = 1;
        //cin >> t ;
        while(t--){
                //task_A();
                task_B();
                //task_C();
                //task_D();
                //task_E();
        }

        return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    set<int>s;
    rep(i,3){
        int a;cin>>a;s.insert(a);
    }
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

bool p(ll N){
  for(ll i = 2; i * i <= N; i++){
    if(N % i == 0) return 0;
  }
  return 1;
}

void solve(){
  ll N;
  cin >> N;
  while(true){
    if(p(N)){
      cout << N << endl;
      return;
    }else{
      N++;
    }
  }
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#define ll long long
#define INF 1e+7
#define MOD 1000000007
using namespace std;

int main(){
    ll N;
    cin >> N;
    
    if(N==1){
        cout<<"Yes"<<endl;
        cout<<2<<endl;
        cout<<"1 1"<<endl;
        cout<<"1 1"<<endl;
        return 0;
        return 0;
    }
    
    ll k=1;
    int ans=0;
    for(; k<=N; k++){
        if(k*(k+1) == N*2){
            ans=1;
            break;
        }
    }
    
    if(ans==0){
        cout<<"No"<<endl;
        return 0;
    }
    
    cout<<"Yes"<<endl;

    vector<ll> S[1000];
    ll l[1000]={};
    for(int i=1; i<=k; i++){
        S[1].push_back(i);
        l[1]++;
    }
    
    for(int i=2; i<=k+1; i++){
        S[i].push_back(i-1);
        l[i]++;
    }
    
    for(ll i=3; i<=k+1; i++){
        ll num=k+ (i-3)*(i-2)/2 +1 -2;
        for(ll t=2; t<=i-1; t++){

            S[i].push_back(num+t);
            l[i]++;

            S[t].push_back(num+t);
            l[t]++;
        }
    }


    cout<<k+1<<endl;
    for(ll i=1; i<=k+1; i++){
        cout<<l[i];
        for(ll s=0; s<l[i]; s++){
            cout<<" "<<S[i][s];
        }
        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
 
int main() {
  int x;
  int y;
  for(int i = 1; i >= 0; ++i) {
    std::cin >> x;
    std::cin >> y;
    if((x + y) == 0){
      break;
    }else{
      if(x >= y){
        std::cout << y << " " << x << std::endl;
      }else{
        std::cout << x << " " << y << std::endl;    
      }
    }
  }
}


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

int a,b,c;
int ax,ay;


void upd(int x,int y){
	if(ax+ay>x+y){
		ax=x;
		ay=y;
	}
	if(ax+ay==x+y && a*ax+b*ay>a*x+b*y){
		ax=x;
		ay=y;
	}
}

int chk(int x,int y){
	if(c+a*x==b*y)return 1;
	if(c+b*y==a*x)return 1;
	if(c==b*y+a*x)return 1;
	return 0;
}


int main(){
	while(cin>>a>>b>>c){
		if(a==0 && b==0 && c==0)break;
		ax=114514;
		ay=810893;
		
		for(int x=0;x<=100000;x++){
			int y;
			
			y=(a*x+c)/b;
			if(y>=0 && chk(x,y)){
				upd(x,y);
			}
			
			y=(a*x-c)/b;
			if(y>=0 && chk(x,y)){
				upd(x,y);
			}
			
			y=(c-a*x)/b;
			if(y>=0 && chk(x,y)){
				upd(x,y);
			}
			
		}
		
		
		cout<<ax<<" "<<ay<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if(a%2==0 and b%2==0 and c%2==0 and a==b and b==c){
        cout << -1 << endl;
        return 0;
    }
    ll answer=0;
    while(a%2==0 and b%2==0 and c%2==0){
        ll newa,newb,newc;
        newa = b/2+c/2;
        newb = a/2+c/2;
        newc = a/2+b/2;
        a = newa;
        b = newb;
        c = newc;
        answer++;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
typedef long long ll;
ll INF=(10000000000LL);
ll N,M;
ll s[MAX],t[MAX],p[MAX];

ll u[MAX],sum[MAX];
ll ans;

ll solve(ll s,ll t){
  bool flg=false,flg2=false;
  if(s>t){
    swap(s,t);
    flg=true;
  }

  ll* sit=lower_bound(p,p+M,s);
  ll* tit=upper_bound(p,p+M,t);
  tit--;

  ll si=sit-p;
  ll ti=tit-p;

  if(t<=p[si]){
    return t-s;
  }



  ll res=p[si]-s;
  ll cnt=ti-si+1;
  if(cnt%2==0){
    res+=(t-p[ti]);
  }else{
    flg2=true;
  }


  
  

  ll res2=0;
  if(si%2==1){
    res2= sum[ti-1]-sum[si-1];
  }else{
    res2= (p[ti]-p[si])-(sum[ti-1]-sum[si-1]);
  }
  /*
  cout<<s<<' '<<t<<endl;
  cout<<p[si]<<' '<<p[ti]<<endl;
  cout<<res<<' '<<res2<<endl;
  cout<<flg<<' '<<flg2<<endl;
  cout<<endl;
  */
  if(flg&&flg2){
    return t-s-res-res2;
  }
  return res+res2;
}




int main(){
  cin>>N>>M;
  for(int i=0;i<N;i++){
    cin>>s[i]>>t[i];
  }
  for(int i=1;i<=M;i++){
    cin>>p[i];
  }
  p[0]=0;
  M++;
  p[M]=INF;
  M++;
  sort(p,p+M);

  for(int i=0;i+1<M;i++){
    u[i]=p[i+1]-p[i];    
  }

  sum[0]=u[0];
  for(int i=2;i<M;i+=2){
    sum[i]=sum[i-2]+u[i];
  }
  for(int i=1;i<M;i+=2)sum[i]=sum[i-1];


  ans=0;


  for(int i=0;i<N;i++){
    // cout<<solve(s[i],t[i])<<endl;
    ans+=solve(s[i],t[i]);
    
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5080
///******* In the name of Allah *******///

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

//long int ar[10013];
//long int gcd(long int a, long int b)
//{
//    if(b==0)
//        return a;
//    return gcd(b,a%b);
//}
//void sieve()
//{
//    long long int i,j,k = 0;
//    memset(ar,0,sizeof(ar));
//    ar[1] = 1;
//    for(i=2; i<=713; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=713; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//}

void Ok()
{
    long int a[50013],b,c,d,e,f,g,h,t,i,j,k,l,m,n,Min,Max;
    long int ans_1,ans_2,ans_3,cnt_1,cnt_2,cnt_3,flag_1,flag_2,flag_3,temp,sum;
    double aa,bb,cc,dd,ee,ff,gg;
    char aaa,bbb,ccc,ddd;
    string spc,in,store;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    in = "ACL";
    cin>>k;
    while(k--)
        cout<<in;

    return;
}

int main()
{

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    Ok();

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k, x, y;
  cin >> n >> k >> x >> y;
  ll ans = 0;
  if(n > k)
    ans = k * x + (n - k) * y;
  else
    ans = n * x;
  cout << ans << endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <string>
using namespace std;
int main(){
         char str[] = "abcdefghijklmnopqrstuvwxyz";
         char input;
          cin >> input;
 
          int element;
 
         for(int i=0; i<sizeof(str); i++){
                  if(str[i]==input){
                         element = i+1;
                          break;
                  }
          }
         /*cout << "Please input character:" <<input  << endl;
          cout << "Next alphabet is :"  << str[element] << endl;*/
          cout << str[element] << endl;
          return 0;
 }

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long int64;
int MOD = 1e9 + 7;

int main() {
  int64 N, K, ans = 0;
  cin >> N >> K;
  for (int64 i = K; i <= N + 1; ++i) {
    int64 start = (i-1)*i/2;
    int64 end = (N)*(N+1)/2 - (N-i)*(N+1-i)/2;
    ans = (ans + end - start + 1) % MOD;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3640
a_list = [chr(ord('a') + i) for i in range(26)]
n = int(input())

l_list = []
ans = ''
while n > 0:
    if n % 26 == 0:
        l_list.append(26)
        n = n // 26 - 1
    else:
        l_list.append(n%26)
        n = n // 26
l_list = l_list[::-1]
for i in l_list:
    ans += a_list[i-1]
print(ans)

Measured memory_bytes: 9104
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
int tn[11],L,R,tp,sm;
char c[5];

inline int read()
{
	int n=0,f=1; char c=getchar();
	while (c<'0' || c>'9') {if(c=='-')f=-1; c=getchar();}
	while (c>='0' && c<='9') {n=n*10+c-'0'; c=getchar();}
	return n*f;
}

main()
{
	register int i;
	for (tn[0]=i=1;i<=9;++i) tn[i]=tn[i-1]*10;
	for (i=0;i<=9;++i)
	{
		printf("? %lld\n",tn[i]);
		fflush(stdout);
		scanf("%s",c);
		if (c[0]=='N') break;
	}
	if (i>9)
	{
		for (i=1;i<=9;++i)
		{
			printf("? %lld\n",tn[i]-1);
			fflush(stdout);
			scanf("%s",c);
			if (c[0]=='Y') break;
		}
		printf("! %lld\n",tn[i-1]);
		fflush(stdout); return 0;
	} else tp=i;
	for (i=tp;i;--i)
	{
		if (i==tp) L=1; else L=0; R=9;
		while (L<R)
		{
			int mid=L+R+1>>1;
			printf("? %lld\n",(sm+tn[i-1]*mid)*10);
			fflush(stdout);
			scanf("%s",c);
			if (c[0]=='N') L=mid; else R=mid-1;
		}
		if (L<9)
		{
			printf("? %lld\n",(sm+tn[i-1]*(L+1))*10-1);
			fflush(stdout);
			scanf("%s",c);
			if (c[0]=='N')
			{
				printf("! %lld",sm+tn[i-1]*(L+1));
				fflush(stdout);
				return 0;
			}
		}
		sm+=L*tn[i-1];
	}
}

Measured memory_bytes: 504
N = int(input())
A = list(map(int, input().split()))
M = 0
B = [0]*N
for i in reversed(range(N)):
    tmp = 0
    for k in range(i, N, i+1):
        tmp += B[k]
    if tmp % 2 != A[i]:
        B[i] = 1
        M += 1
print(M)
for i in range(N):
    if B[i] == 1:
        print(i+1)


Measured memory_bytes: 7148
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n;
ll G[12][12],w[11]={0,1,2,4,7,12,20,29,38,53,73},mx;
void Get_mx(int n){
	static int p[12];
	for(int i=1;i<=n;++i){
		p[i]=i;
	}
	do{
		ll tot=0;
		for(int i=2;i<=n;++i){
			tot+=G[p[i-1]][p[i]];
		}
		mx=max(mx,tot);
	}while(next_permutation(p+1,p+n+1));
}
int main(){
	n=read();
	for(int i=2;i<=n;++i){
		for(int j=1;j<i;++j){
			G[i][j]=G[j][i]=(mx+1)*w[j];
		}
		Get_mx(i);
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			printf("%lld ",G[i][j]);
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 3732
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            long ans = 0;
            for (int i = 1; i <= N; i++)
            {
                if (i % 3 == 0)
                {

                }
                else if (i % 5 == 0)
                {

                }
                else
                {
                    ans += i;
                }
            }
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27536
#include<iostream>
#include<list>
#include<map>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    bool b[100] = {};
    for(int i = 0; i < m; i++){
        int a, l;
        cin >> a >> l;
        for(int i = 1; i <= l; i++) b[(a+i)%n] = true;
    }
    list<int> l;
    int cur = 0;
    while(cur < n){
        if(b[cur]){
            int next = cur;
            while(b[next] && next < n)  next++;
            l.push_back(next-cur);
            cur = next;
        }else{
            cur++;
        }
    }

    if(l.size() == 1){
        cout << l.front() << " " << 1 << endl;
        return 0;
    }

    if(b[0] && b[n-1]){
        int x = l.front() + l.back();
        l.pop_front();  l.pop_back();
        l.push_back(x);
    }

    map<int,int> ans;
    for(auto it = l.begin(); it != l.end(); it++)   ans[*it]++;
    for(auto it = ans.rbegin(); it != ans.rend(); it++){
        cout << (*it).first << " " << (*it).second << endl;
    }

    return 0;
}


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

int main()
{
	size_t k;
	cin >> k;

	string s;
	cin >> s;

	if (s.length() <= k)
	{
		cout << s << endl;
	}
	else
	{
		cout << s.substr(0, k) << "..."s << endl;
	}

	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    ios_base::sync_with_stdio(false);
    int grid[3][3];
    while(cin>>grid[0][0]){
        for(int i =0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(i == 0 && j == 0)continue;
                cin>>grid[i][j];
            }
        }
        bool mark[3][3];
        memset(mark,0,sizeof(mark));
        int n;
        cin>>n;
        for(int i = 0; i < n; i++){
            int temp;
            cin>>temp;
            for(int j =0; j < 3; j++){
                for(int k = 0; k < 3; k++){
                    if(temp == grid[j][k]){
                        mark[j][k]=true;
                    }
                }
            }
        }
        bool success = false;
        if(mark[0][0]&&mark[1][1]&&mark[2][2])success = true;
        if(mark[2][0]&&mark[1][1]&&mark[0][2])success = true;
        for(int i = 0; i < 3; i++){
            if(mark[i][0]&&mark[i][1]&&mark[i][2])success = true;
            if(mark[0][i]&&mark[1][i]&&mark[2][i])success = true;
        }
        if(success){
            cout<<"Yes\n";
        }
        else{
            cout<<"No\n";
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    ll num = N - (N / K) * K;
    ll ans = min(num, K - num);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
#include <complex>
int sign(double x){
  if(x > EPS) return 1;
  if(x < -EPS) return -1;
  return 0;
}
typedef complex<double> Point;
struct Line : public vector<Point> {
  Line(const Point& a, const Point& b){
    push_back(a); push_back(b);
  }
  Point vector() const {
    return back() - front();
  }
};
struct Circle{
  Point c;
  double r;
  Circle() {}
  Circle(Point c, double r) : c(c), r(r) {}
};

double dot(Point a, Point b){
  return real(conj(a) * b);
}
double cross(Point a, Point b){
  return imag(conj(a) * b);
}

int ccw(Point a, Point b, Point c){
  b -= a; c -= a;
  if(cross(b, c) > EPS) return +1;
  if(cross(b, c) < -EPS) return -1;
  if(dot(b, c) < 0) return +2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}


bool intersectSP(const Line& s, const Point& p){
  return ccw(s[0], s[1], p) == 0;
}

Point projection(const Line& l, const Point& p){
  double t = dot(p - l[0], l.vector()) / norm(l.vector());
  return l[0] + t * l.vector();
}

double distanceSP(const Line& s, const Point& p){
  const Point r = projection(s, p);
  if(intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}

enum{ OUT, ON, IN };
int contains(const Circle& C, const Point& p){
  double d = abs(C.c - p);
  if(sign(d - C.r) > 0) return OUT;
  if(sign(d - C.r) == 0) return ON;
  return IN;
}

bool intersectCS(const Circle& C, const Line& l){
  int b[2];
  REP(i, 2) b[i] = contains(C, l[i]);
  if(b[0] > b[1]) swap(b[0], b[1]);
  if(b[0] == OUT && b[1] == IN) return true;
  if(b[0] == IN && b[1] == IN) return false;
  if(b[0] == ON) return true;
  double d = distanceSP(l, C.c);
  if(sign(d - C.r) > 0) return false;
  return true;
}

int main(){
  int N;
  while(cin >> N && N){
    vector<Circle> WALL(N);
    REP(i, N) cin >> WALL[i].c.real() >> WALL[i].c.imag() >> WALL[i].r;
    int M;
    cin >> M;
    Point p[2];
    REP(i, M){
      REP(j, 2) cin >> p[j].real() >> p[j].imag();
      bool danger = true;
      REP(j, N) if(intersectCS(WALL[j], Line(p[0], p[1]))) danger = false;
      if(danger) cout << "Danger" << endl;
      else cout << "Safe" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1248
class UnionFind():
  def __init__(self, n):
    self.par = [i for i in range(n+1)]
    self.rank = [0] * (n+1)
    self.size = [1] * (n+1)
    
  def union(self, a, b):
    para = self.find(a)
    parb = self.find(b)
    if self.rank[para] > self.rank[parb]:
      self.par[para] = parb
    else:
      self.par[parb] = para
      if self.rank[para] == self.rank[parb]:
        self.rank[para] += 1
    
  def find(self, x):
    if self.par[x] == x:
      return x
    else: 
      self.par[x] = self.find(self.par[x])
      return self.par[x]

  def is_same(self, a, b):
    return self.find(a) == self.find(b)

n, m = [int(item) for item in input().split()]
p = [int(item) for item in input().split()]
xy = [[int(item) for item in input().split()] for _ in range(m)]
UF = UnionFind(n)

for x, y in xy:
  UF.union(x,y)
  
ans = 0
for i,item in enumerate(p):
  if UF.is_same(item, i+1):
    ans += 1
    
print(ans)


Measured memory_bytes: 30636
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [s] = r.ss()

    return 'a' <= s && s <= 'z' ? 'a' : 'A'
  }

  const _io = (i = 0) => {
    const str = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map((v) => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map((line) => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}


Measured memory_bytes: 29680
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n, t, a;
  cin >> n >> t >> a;
  a *= 1000;
  vector<int> vec(n);
  int c = 0;
  int d = INF;
  rep(i, n) {
    cin >> vec[i];
    vec[i] = t * 1000 - vec[i] * 6;
    if (abs(vec[i] - a) < d) {
      d = abs(vec[i] - a);
      c = i;
    }
  }
  cout << c+1 << endl;

  return 0;
}

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

int main() {
	int c[]{ 2,3,4,5,6,7,8,9,10,11,12,13,1 };
	int a, b; cin >> a >> b;
	if (a == b) {
		puts("Draw"); return 0;
	}
	if (find(c, c + 13, a) > find(c, c + 13, b)) {
		puts("Alice");
	}
	else puts("Bob");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)
typedef long long ll;

int main(){
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};

int main() {
    int N;
    cin >> N;
    map<int, ll> cnt;
    cnt[0] = 0;
    cnt[1] = 0;
    cnt[2] = 0;
    cnt[3] = 0;
    cnt[4] = 0;

    ll array[5] = {0, 1, 2, 3, 4};

    rep(i, N) {
        string s;
        cin >> s;
        if (s[0] == 'M')
            cnt[0] += 1;
        if (s[0] == 'A')
            cnt[1] += 1;
        if (s[0] == 'R')
            cnt[2] += 1;
        if (s[0] == 'C')
            cnt[3] += 1;
        if (s[0] == 'H')
            cnt[4] += 1;
    }

    ll res = 0;
    for (int i = 0; i < 10; i++) {
        res += cnt[P[i]] * cnt[Q[i]] * cnt[R[i]];
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var M = one[1];
	var map = {};
	for(var i = 0; i < N; i++){
		map[i + 1] = {
			isAC : false,
			wa : 0
		};
	}
	var ac = 0;
	var wa = 0;
	for(var i = 0; i < M; i++){
		var tmp = nextStrArray();
		var pi = myconv(tmp[0],1);
		var S = tmp[1];
		if(S == "AC"){
			if(!map[pi].isAC){
				map[pi].isAC = true;
				ac++;
				wa += map[pi].wa;
			}
		}else{
			map[pi].wa++;
		}
	}
	myout(ac + " " + wa);
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

int main() {
  int N;
  cin >> N;
  vector<int> d(N, 0);
  rep(i, 0, N) {
    cin >> d[i];
  }

  ll ans = 0;
  rep(i, 0, N) {
    int first = d[i];
    rep(j, i + 1, N) {
      int second = d[j];
      ans += (first * second);
    }
  }

  cout << ans << endl;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

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

int mod_inverse(int a, int m){
    int x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}


signed main(){

    int M = 998244353;
    int N, A, B, K, x, y;
    cin >> N >> A >> B >> K;

    int g = extgcd(A, B, x, y);
    if(K % g != 0){
        cout << 0;
        return 0;
    }

    x *= K / g;
    y *= K / g;
    //これでAx+By=K

    int a = A / g;
    int b = B / g;
    //X=x+kb,Y=y-ka

    int k_min = -1 * (x / b);
    int k_max = y / a;

    vector<int> fact(N + 1, 1);
    FOR(i, 1, N + 1){
        fact[i] = (fact[i - 1] * i) % M;
    }

    int ans = 0;
    FOR(k, k_min, k_max + 1){
        int X = x + k * b;
        int Y = y - k * a;
        if(X < 0 || Y < 0 || X > N || Y > N) continue;
        int tmp1 = (((fact[N] * mod_inverse(fact[X], M)) % M) * mod_inverse(fact[N - X], M)) % M;
        int tmp2 = (((fact[N] * mod_inverse(fact[Y], M)) % M) * mod_inverse(fact[N - Y], M)) % M;
        ans = (ans + tmp1 * tmp2) % M;
    }

    cout << ans;

    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 2560
qSort::[Char] -> [Char]
qSort [] = []
qSort (x:xs)
    | xs == [] = [x]
    | otherwise = qSort [y|y<-xs, y < x] ++ [x] ++ qSort [z|z<-xs, z >= x]
main = do
    a <- getLine
    let b = qSort a
    if b == "abc" then putStrLn "Yes" else putStrLn "No"

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

struct Node {
  int parent;
  int left;
  int right;
};
Node T[25];
int D[25];
int H[25];
const int NIL = -1;

void setDepth(int id, int depth) {
  D[id] = depth;
  if (T[id].left != -1) setDepth(T[id].left, depth + 1);
  if (T[id].right != -1) setDepth(T[id].right, depth + 1);
}

int setHeight(int id, int height) {
  if (id == NIL) return height - 1;
  int h_left = setHeight(T[id].left, height + 1);
  int h_right = setHeight(T[id].right, height + 1);
  int m = max(h_left, h_right);
  H[id] = m - height;
  return m;
}

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

  int n;
  cin >> n;

  int id, right, left;

  for (int i = 0; i < n; i++) {
    T[i].parent = T[i].left = T[i].right = NIL;
  }

  for (int i = 0; i < n; i++) {
    cin >> id;
    cin >> left >> right;
    T[id].left = left;
    T[id].right = right;
    if (left != NIL) T[left].parent = id;
    if (right != NIL) T[right].parent = id;
  }

  for (int i = 0; i < n; i++) {
    if (T[i].parent == NIL) {
      setDepth(i, 0);
      setHeight(i, 0);
      break;
    }
  }

  for (int i = 0; i < n; i++) {
    if (T[i].parent == NIL) {
      setDepth(i, 0);
      break;
    }
  }

  for (int i = 0; i < n; i++) {
    cout << "node " << i << ": ";
    cout << "parent = " << T[i].parent << ", ";

    int sibling = -1;
    if (T[i].parent != NIL) {
      if (T[T[i].parent].left == i) {
        sibling = T[T[i].parent].right;
      } else {
        sibling = T[T[i].parent].left;
      }
    }
    cout << "sibling = " << sibling << ", ";

    int degree = 0;
    if (T[i].left != NIL) degree++;
    if (T[i].right != NIL) degree++;
    cout << "degree = " << degree << ", ";

    cout << "depth = " << D[i] << ", ";
    cout << "height = " << H[i] << ", ";

    if (T[i].parent == NIL) {
      cout << "root";
    } else if (T[i].left != NIL || T[i].right != NIL) {
      cout << "internal node";
    } else {
      cout << "leaf";
    }

    cout << endl;
  }

  return 0;
}

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

void print( const vector<int>& a, char sep = ' ' ) {
	size_t n = a.size();

	for( size_t i = 0; i < n; ++i ) {
		cout << a.at( i );

		if( i < n-1 ) { cout << sep; }
	}

	cout << endl;
}

int merge( vector<int>& a, int left, int mid, int right ) {
	int n1 = mid - left;
	int n2 = right - mid;

	vector<int> L( a.begin()+left, a.begin()+left + n1 );
	vector<int> R( a.begin()+mid,  a.begin()+mid  + n2 );
	L.push_back( INT_MAX ); // inf
	R.push_back( INT_MAX );

	int count = 0;
	int i = 0;
	int j = 0;

	for( int k = left; k < right; ++k ) {
		a[k] = L[i] <= R[j] ? L[i++] : R[j++];

		count += 1;
	}

	return count;
}

int mergeSort( vector<int>& a, int left, int right ) {
	int r = 0;

	if( left+1 < right ) {
		int mid = (left + right) / 2;

		r += mergeSort( a, left, mid );
		r += mergeSort( a, mid, right );
		r += merge( a, left, mid, right );
	}

	return r;
}

int main() {
	ios_base::sync_with_stdio( false );

	int n;
	cin >> n;

	vector<int> S( n );
	for( auto& v: S ) { cin >> v; }

	int count = mergeSort( S, 0, n );

	print( S );
	cout << count << endl;
}



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

using namespace std;

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

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

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

	int n, i;
	cin >> n >> i;
	cout << n - i + 1 << endl;
	return 0;
}


Measured memory_bytes: 256