akhauriyash/Code-Regression huggingface dataset:
n = int(input().rstrip())
nums = [int(input().rstrip()) for _ in range(n)]

num_hash={}
for n in nums:
    if num_hash.get(n):
        num_hash[n] += 1
    else:
        num_hash[n] = 1

num_counter = 0
for k in num_hash.keys():
    if num_hash[k] %2 == 1:
        num_counter += 1
print(num_counter)

Measured memory_bytes: 16272
#include <stdio.h>
#include <stdlib.h>



int main(){
	long long N,sho,amr;
	char ans[200];
	scanf("%lld",&N);
	
	long i=0,j;
	
	long tmp=N;
	if(tmp<=26) {
		if(tmp%26==0)amr=26;
		else amr=tmp%26;
		ans[i++]= amr;
	}
	else {
		while(tmp>26){
			amr=tmp%26;
			tmp=tmp/26;
			if(amr==0){
				amr=26;tmp--;
			}
			ans[i++]=amr;
		}
		ans[i++]=tmp;
	
	}
	for(j=i-1;j>=0;j--){
		printf("%c",ans[j]+'a'-1);
		//printf("%d,",ans[j]);
	}

	return 0;
}


//702 =  1 1 +0

Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 4000000000000000000
int dx8[8]={-1,0,1,1,1,0,-1,-1};
int dy8[8]={1,1,1,0,-1,-1,-1,0};
int dx4[4]={-1,0,1,0};
int dy4[4]={0,-1,0,1};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int uni[100010];
int root(int a){
    if(uni[a]<0)return a;
    return uni[a]=root(uni[a]); 
}
bool connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(uni[a]>uni[b]){
        swap(a,b);
    }
    uni[a]=uni[a]+uni[b];
    uni[b]=a;
    return true;
}
signed main(void){
    int A[3][3];
    rep(i,3)rep(j,3)cin>>A[i][j];
    int n;cin>>n;
    bool B[3][3];rep(i,3)rep(j,3)B[i][j]=false;
    rep(i,n){
        int b;cin>>b;
        rep(j,3)rep(k,3){
            if(A[j][k]==b)B[j][k]=true;
        }
    }
    bool ans=false;
    rep(i,3){
        if(B[i][0]&&B[i][1]&&B[i][2])ans=true;
    }
    rep(j,3){
        if(B[0][j]&&B[1][j]&&B[2][j])ans=true;
    }
    if(B[0][0]&&B[1][1]&&B[2][2])ans=true;
    if(B[0][2]&&B[1][1]&&B[2][0])ans=true;
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
        


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    a,b = map(int, input().split())
    S = input()

    for i in range(a+b+1):
        if i == a:
            if S[a]!='-':
                print('No')
                return
        else:
            if S[i]=='-':
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s, t;
    cin >> s >> t;
    string na = "UNRESTORABLE";
    if(s.length() < t.length()) {
        cout << na << endl;
        return 0;
    }

    for(int i = s.size() - t.size(); i >= 0; --i) {
        bool f = true;
        for(int j = i; j < i + t.size(); ++j) {
            if(s[j] != t[j - i] && s[j] != '?') {
                f = false;
                break;
            }
        }

        if(f) {
            for(int j = i; j < i + t.size(); ++j) {
                s[j] = t[j - i];
            }
            for(int j = 0; j < s.size(); ++j) {
                if(s[j] == '?') s[j] = 'a';
            }
            cout << s << endl;
            return 0;
        }
    }
    cout << na << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextInt();
        long N = sc.nextInt();
        long sum = 0;
        for(int i=0;i<N;i++) sum+=sc.nextInt();
        if(H-sum<=0) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 48468
#include <stdio.h>
int main(void)
{
    int i,N,m,p[50];

    scanf("%d",&N);
    for(i=0;i<N;i++)
       scanf("%d",&p[i]);
    m=0;
    for(i=0;i<N;i++)
       if (p[i] != i+1) m++;
    if(m==2 || m==0) printf("YES");
    else if(m>2)     printf("NO");
 
    return 0;
}

Measured memory_bytes: 128
/*
Path compression happens 
when no node on the path is marked before query happens
*/
#include <cstdio>
#include <iostream>
using namespace std;

const int INF = 0x7f7f7f7f;
const int MAXN = 1e5 + 16;

int p[MAXN], mark[MAXN], qt[MAXN], qv[MAXN];
// mark[i] is the time node i is marked
// qt[q] is the time query q happens
// qv[q] is the node of query q
int t;

int find(int i) {
    return mark[i] < t ? i : p[i] = find(p[i]);
}

int main() {
    //freopen("2170-input.txt", "r", stdin);
    int N, Q;
    while (~scanf("%d%d", &N, &Q) && (N | Q)) {
        for (int i = 2; i <= N; i++) {
            scanf("%d", p + i);
            mark[i] = INF;
        }
        int cnt = 0, x;
        char op[2];
        for (int i = 1; i <= Q; i++) {
            scanf("%s%d", op, &x);
            if (op[0] == 'M') {
                mark[x] = min(i, mark[x]);
            } else {
                qt[cnt] = i;
                qv[cnt++] = x;
            }
        }
        unsigned long long result = 0;
        while (cnt--) {
            t = qt[cnt];
            result += find(qv[cnt]);
        }
        printf("%lld\n", result);
    }
}

Measured memory_bytes: 4476
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

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

    int X[N+1], Y[N+1], T[N+1];

    for(int i=1;i<=N;i++){
        cin >> T[i] >> X[i] >> Y[i];
    }
    T[0] = 0;
    X[0] = 0;
    Y[0] = 0;

    for(int i=0;i<N;i++){
        if(abs(X[i+1] - X[i]) + abs(Y[i+1] - Y[i]) > abs(T[i+1] - T[i])){
            cout << "No" << endl;
            return 0;
        }
        else{
            if((abs(X[i+1] - X[i]) + abs(Y[i+1] - Y[i])) % 2 != abs(T[i+1] - T[i]) % 2){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;

}

Measured memory_bytes: 1408
n = int(input())
t, a = map(int, input().split())
H = list(map(int, input().split()))

best_t = 10**3
ans = 0

for i in range(n):
    if abs(a - (t-H[i]*0.006)) < best_t:
        best_t = abs(a - (t-H[i]*0.006))
        ans = i+1

print(ans)


Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello
{
    public static void Main()
    {
        long N = long.Parse(Console.ReadLine());
        long i = 0;
        List<string> sList = new List<string>();
        while (i < N)
        {
            string S = Console.ReadLine();
            sList.Add(S);
            i++;
        }
        
        Console.WriteLine($"AC x {sList.Count( v => v == "AC")}");
        Console.WriteLine($"WA x {sList.Count( v => v == "WA")}");
        Console.WriteLine($"TLE x {sList.Count( v => v == "TLE")}");
        Console.WriteLine($"RE x {sList.Count( v => v == "RE")}");
    }
}


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

int main(){
	int m,n[4]={0,0,0,0};
	char c,b[][3]={"A","B","AB","O"};
	string s;

	while (cin>>m>>c>>s)
		for (int i=0; i<4; i++)
			if (s==b[i]){
				n[i]++;
				break;
			}
	for (int i=0; i<4; i++) cout<<n[i]<<endl;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;

auto digit_sum = [&](int c) {
    int d,res = 0;
    while(c) {
        d = c % 10;
        res += d;
        c /= 10;
    }
    return res;
};

int S = digit_sum(N);
if(N % S == 0) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

ll f(ll X) {
	ll res = 0;
	for (int i = 50; i > 0; --i) {
		if (X >> i & 1) {
			ll c = X % (1ll << i) + 1;
			if (c & 1) res |= 1ll << i;
		}
	}
	if (X % 4 == 1 || X % 4 == 2) res |= 1;
	return res;
}

int main() {
	ll A, B;
	cin >> A >> B;
	ll ans = f(B);
	if (A > 0) ans ^= f(A - 1);
	cout << ans << endl;
	return 0;
}


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

int main() {

    int X, Y;
    cin >> X >> Y;
    
    int ans = X + Y /2 ;
//    string ans;
//    if(N <= A){
//        ans = "Yes";
//    }else{
//        ans = "No";
//    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.StringTokenizer
import kotlin.math.abs
import kotlin.math.min

fun main() {
    val reader = System.`in`.bufferedReader()
    val writer = PrintWriter(System.out, false)

    var tokenizer: StringTokenizer = StringTokenizer("")

    fun next(): String {
        while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())
        return tokenizer.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextLine() = reader.readLine()

    fun PrintWriter.solve() {
        var (n,k) = List(2){nextLong()}
        n%=k

        print(min(n, abs(n-k)))


    }

    writer.solve()
    writer.flush()


}




Measured memory_bytes: 34664
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin - 1; end <= i; i--)		// repeat reverse

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << endl << msec << " msec " << endl;
}

#endif

struct A
{
	ll index;
	ll value;
	bool operator < (const A& a) const
	{
		return value < a.value;
	};
	bool operator > (const A& a) const
	{
		return value > a.value;
	};
};

class AGC005B
{
public:
	AGC005B()
	{
		cin >> n;
		n = n + 1;

		a.resize(n);
		a[0].value = 0;
		a[0].index = 0;
		rep(i, 1, n)
		{
			cin >> a[i].value;
			a[i].index = i;
		}
	}
	void Run(void)
	{
		ll l;
		ll r;
		ll ans = 0;
		sort(all(a));
		set<ll> a_set;

		a_set.insert(0);
		rep(i, 1, n)
		{
			auto it = a_set.lower_bound(a[i].index);

			if (it == a_set.end())
			{
				r = n - a[i].index;
				it--;
				l = (a[i].index - *it);
			}
			else
			{
				r = (*it - a[i].index);
				it--;
				l = (a[i].index - *it);
			}
			ans += a[i].value * l * r;
			a_set.insert(a[i].index);
		}

		cout << ans;
	}
private:
	ll n;
	vector <A> a;
};

int main()
{
	AGC005B agc005b;
	agc005b.Run();

	return 0;
}



Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a*n, b) << endl;
    return 0;
}



Measured memory_bytes: 256
import math

def KC(n,p1,p2):
    if n==0:
        return
    s=[(2*p1[0]+p2[0])/3,(2*p1[1]+p2[1])/3]
    t=[(p1[0]+2*p2[0])/3,(p1[1]+2*p2[1])/3]
    u=[(t[0]-s[0])*math.cos(math.pi/3)-(t[1]-s[1])*math.sin(math.pi/3)+s[0],(t[0]-s[0])*math.sin(math.pi/3)+(t[1]-s[1])*math.cos(math.pi/3)+s[1]]
    KC(n-1,p1,s)
    print(str(format(s[0],'.8f'))+" "+str(format(s[1],'.8f')))
    KC(n-1,s,u)
    print(str(format(u[0],'.8f'))+" "+str(format(u[1],'.8f')))
    KC(n-1,u,t)
    print(str(format(t[0],'.8f'))+" "+str(format(t[1],'.8f')))
    KC(n-1,t,p2)
    
  
if __name__=="__main__":
    n=int(input())
    p1=[0,0]
    p2=[100,0]
    print(str(format(p1[0],'.8f'))+" "+str(format(p1[1],'.8f')))
    KC(n,p1,p2)
    print(str(format(p2[0],'.8f'))+" "+str(format(p2[1],'.7f')))


Measured memory_bytes: 5768
N=int(input())
A=list(map(int,input().split()))
ans=100
for i in range(N):
  a=A[i]
  an=0
  while True:
    if a%2==1:
      ans=min(ans,an)
      break
    else:
      an+=1
      a=a//2
print(ans)

Measured memory_bytes: 3060
n = int(input())
s = input()
# #与えられた文字列 text を k回先にずらす関数。
def caesar(text, k):
    result = ""
    for i in range(len(text)):
        c1 = text[i]
        n1 = ord(c1)
        if 65 <= n1 <= 90:
            n2 = n1 + k
            if n2 < 65 or 90 < n2:
                n2 = 65 + (n2 - 65) % 26
            result = result + chr(n2)
        else:
            result = result + chr(n1)
    return result

ss = caesar(s, n)
print(ss)

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

int n,ans;
map<ll,int> cnt;

ll read(){
	ll x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	int n=read();
	for (int i=1;i<=n;i++){
		ll t=read(),x=1,y=1;
		for (ll i=2;i*i*i<=t;i++){
			int k=0;while (t%i==0) t/=i,k++;
			if (k%3==1) x*=i,y*=i*i;
			if (k%3==2) x*=i*i,y*=i;
		}
		x*=t;
		if ((ll)sqrt(t)*(ll)sqrt(t)==t)
		y*=(ll)sqrt(t); else y*=t*t;
		if (x==1) ans+=(++cnt[1]==1);
		else ans+=(++cnt[x]>cnt[y]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
	IOS;
	int n,m;
	cin >> n >> m;
	int l,r;
	int under=1,upper=n;
	for(int i=0;i<m;i++){
		cin >> l >> r;
		under = max(under,l);
		upper = min(upper,r);
	}
	if(under > upper){
		cout << '0' << endl;
	}else{
		cout << upper - under + 1 << endl;
	}
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#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 REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll K, Q;
ll t;
ll ret = 0;
ll player[ARRAY];

void input() {
  IN(N);
  IN(K);
  IN(Q);
  FOR(i, 1, N+1) {
    player[i] = K - Q;
  }
  REP(i, Q) {
    IN(t);
    player[t] += 1;
  }
}

void solve() {
  FOR(i, 1, N+1) {
    if (player[i] > 0) {
      PRINT("Yes");
    } else {
      PRINT("No");
    }
  }
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.size() <= k) cout << s << endl;
    else {
        cout << s.substr(0, k) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
//#define DEBUG

using namespace std;
struct node {
    int id, point;
} node[1<<18];
const int N=100010;
int n, a[N];

void add(int id, int x)
{
    id=n-1+id;
    node[id].point+=x;

    while (id>0) {
        id=(id-1)/2;
        int c1=2*id+1, c2=2*id+2;
        if (node[c1].point>=node[c2].point)
            node[id]=node[c1];
        else
            node[id]=node[c2];
    }
}

void print()
{
#ifdef DEBUG
    int k=1;
    int x=0;
    while (true) {
        for(int i=0;i<k;++i) printf("(%d %d)", node[x+i].id, node[x+i].point);
        puts("");
        x+=k;
        k<<=1;
        if (x>=n) break;
    }
    puts("");
#endif
}

int main()
{
    int m, r, l;
    scanf("%d%d%d", &m, &r, &l);
    n=1;
    while (n<m) n<<=1;
    for(int i=0;i<m;++i) node[n-1+i].id=i;

    int pt=0;
    for(int i=0;i<r;++i) {
        int d, t, x;
        scanf("%d%d%d", &d, &t, &x);

        if (pt<t) {
            int id=node[0].id;
            a[id]+=t-pt;
        }
        add(d-1, x);
        print();
        pt=t;
    }
    print();
    a[node[0].id]+=l-pt;
#ifdef DEBUG
    for(int i=0;i<n;++i) printf("%d ", a[i]); puts("");
#endif
    printf("%d\n", 1+(max_element(a, a+m)-a));
}

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

using namespace std;

int main(void){
  int N,i,j,ans=0;
  cin >> N;
  string S[N];
  int L[N];
  for(i=0;i<N;i++){
    cin >> S[i];
    L[i]=S[i].length();
  }
  for(i=0;i<N;i++){
    for(j=0;j<L[i]-1;j++){
      if(S[i][j]=='A' && S[i][j+1]=='B'){
        ans++;
      }
    }
  }
  int Acount=0,Bcount=0;
  for(i=0;i<N;i++){
    if(S[i][0]=='B'){
      Bcount++;
    }
    if(S[i][L[i]-1]=='A'){
      Acount++;
    }
  }
  int check=1;
  for(i=0;i<N;i++){
    if((S[i][0]=='B' && S[i][L[i]-1]!='A') ||(S[i][0]!='B' && S[i][L[i]-1]=='A')){
      check=0;
      break;
    }
  }
  ans=ans+min(Acount,Bcount)-check;
  if(Acount==0 && Bcount==0){
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    int h,w ; cin >> h >> w;
    vector<vector<ll>> a(h,vector<ll>(w));
    rep(i,h) rep(j,w){
        cin >> a.at(i).at(j);
    }

    vector<vector<int>> output(0,vector<int>(4));

    rep(i,h){
        if(!(i%2)){
            //iが偶数の時はjの昇順に見ていく
            for(int j=0;j<=w-2;j++){
                if(a.at(i).at(j)%2){
                    a.at(i).at(j+1)++;
                    output.push_back({i,j,i,j+1});
                }
            }
            if(i==h-1) break;
            if(a.at(i).at(w-1)%2){
                a.at(i+1).at(w-1)++;
                output.push_back({i,w-1,i+1,w-1});
            }
        }else{
            //iが奇数の時はjの降順に見ていく
            for(int j=w-1;j>=1;j--){
                if(a.at(i).at(j)%2){
                    a.at(i).at(j-1)++;
                    output.push_back({i,j,i,j-1});
                }
            }
            if(i==h-1) break;
            if(a.at(i).at(0)%2){
                a.at(i+1).at(0)++;
                output.push_back({i,0,i+1,0});
            }
        }
    }
    
    ll n = output.size();
    cout << n << endl;

    rep(i,n){
        rep(j,4){
            cout << output.at(i).at(j) + 1;
            if(j!=3) cout << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 10928
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("YES")
    elif q == 0:print("NO")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
"""
#decomment when needed
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""
n = ip()
a = iprow()
s = 0
for i in range(n):
    if a[i] != i+1:s+=1
if s==0 or s==2:j(1)
else:j(0)

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

#define int long long

int N, A;
vector<int> x;
int dp[55][2555]; // dp[インデックス][合計] = 総数

int rec(int idx, int sum) {
  // 全部調べ終わる
  if (idx >= N) {
    return sum == 0;
  }

  // 計算済み
  if (dp[idx][sum] != -1) {
    return dp[idx][sum];
  }

  int ret = 0;

  // index枚目のカードを選ぶ
  int yes = rec(idx + 1, sum + x[idx]);
  // index枚目のカードを選ばない
  int no = rec(idx + 1, sum);

  ret += yes + no;

  return dp[idx][sum] = ret;
}

signed main() {
  cin >> N >> A;
  x.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
    x[i] -= A;
  }

  memset(dp, -1, sizeof(dp));
  int ans = rec(0, 0) - 1;

  cout << max(0LL, ans) << endl;

  return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>

int main(){
    char s[512]={0};
    int i;
    int count1=0,count2=0,count3=0;
    
    gets(s);
    for(i=0;i<500;i++){ 
        if(s[i]!=0){
            count1++;
        }
        else {
            break;
        }
    }
    for(i=0;i<count1;i++){
            if(s[i]=='K'){
                count2++;
            }
        
    }
    count3=count2;
    
    count2=0;
    for(i=0;i<count1;i++){
            if(s[i]=='U'){
                count2++;
            }
        
    }
    if(count2<count3){
        count3=count2;
    }
    count2=0;
    for(i=0;i<count1;i++){
            if(s[i]=='P'){
                count2++;
            }
        
    }
    if(count2<count3){
        count3=count2;
    }
    count2=0;
    for(i=0;i<count1;i++){
            if(s[i]=='C'){
                count2++;
            }
        
    }
    if(count2<count3){
        count3=count2;
    }
    printf("%d\n",count3);
}

Measured memory_bytes: 944
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm> 
using namespace std;
int main()
{	
	int n,k,sum=0,m[1000],i,sum2=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>m[i];
		sum+=m[i];
	}
	//cout<<sum*10<<endl;
	k=sum%n;
	//cout<<k<<endl;
	if((k*10)>=(n*10)/2)
		sum=sum/n+1;
	else
		sum=sum/n;
	for(i=0;i<n;i++)
	{
		sum2+=(m[i]-sum)*(m[i]-sum);
	}
	cout<<sum2;
 } 

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int n;cin>>n;
  V<int> v(n);
  bool ex1=false;
  rep(i,0,n){
    char c;cin>>c;
    v[i]=c-'0';
    v[i]--;
    if(v[i]==1)ex1=true;
  }

  if(!ex1){
    rep(i,0,n)v[i]>>=1;
  }

  ll ans=0;
  rep(i,0,n){
    if(v[i]==1)ans^=(((n-1)|i)== n-1);
  }

  if(!ex1)ans<<=1;

  cout<<ans<<ENDL;
  
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 4224
from sys import stdin, stdout
from collections import deque, defaultdict
from math import cos, sin, sqrt, pi

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	a, b, h, m = rli()
	mins = 60*h + m
	hcoor = lambda t: (a*cos(2*pi*t/720), a*sin(2*pi*t/720))
	mcoor = lambda t:(b*cos(2*pi*t/60), b*sin(2*pi*t/60))
	dist = lambda x1, y1, x2, y2: sqrt((x1-x2)**2 + (y1-y2)**2)
	x1, y1 = hcoor(mins)
	x2, y2 = mcoor(m)
	print(dist(x1, y1, x2, y2))
	stdout.close()

if __name__ == "__main__":
	main()

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

typedef long long ll;

ll A, B, C;
set<ll> S;
int main() {
  cin >> A >> B >> C;
  S.insert(A);
  S.insert(B);
  S.insert(C);
  cout << (S.size() == 2 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	long long n,p=1;
	cin >> n;
	for (int i = 1; i <= n; i++)p = (p * i % 1000000007);
	cout << p << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define int long long


class ADiscountFare {
public:
    void solve(std::istream &in, std::ostream &out) {
      int x, y;
      in >> x >> y;
      out << x + y / 2 << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  ADiscountFare solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d,e,f,g,h,i,r[10000];
    vector<int>v;
    string s,t;
    while(cin>>a>>b>>c)
    {
       v.push_back(c);
       v.push_back(a);
       v.push_back(b);
       sort(v.begin(),v.end());
       e=v[0];
       d=v[1];
       f=e*d;
       f=f/2.;
       cout<<f<<endl;
       v.clear();

    }






    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    
    int a[4];
    rep(i,4)cin>>a[i];
    int ans=-INF;
    rep(i,2){
        for(int j=2;j<4;j++){
            ans=max(ans,a[i]*a[j]);
        }
    }
    cout<<ans<<endl;


    

}


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

int main(){
	unordered_set<int> s;
	int x,n;
	cin>>x>>n;
	for(int i=0;i<n;i++){
		int v;
		cin>>v;
		s.insert(v);
	}
	for(int i=0;i<=100;i++){
		if(s.find(x-i)==s.end()){
			cout<<x-i<<endl;
			break;
		}else if(s.find(x+i)==s.end()){
			cout<<x+i<<endl;
			break;
		}
	}
	
	
	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define bgn begin()
#define sz size()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define all(a)  (a).begin(),(a).end()
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second


signed main(){
  string s;
  cin >> s;
  V<int> a;
  fo(i,4){
    a.pb(s[i]-'0');
  }
  for(int bit = 0; bit < (1 << 3); bit++){
    int b = 0;
    b += a[0];
    fo(i,3){
      if(bit&(1<<i))
        b += a[i+1];
      else
        b -= a[i+1];
    }
    if(b == 7){
      cout << a[0];
      fo(i,3){
        if(bit&(1<<i))
          cout << '+';
        else
          cout << '-';
        cout << a[i+1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      ans += (d[i]*d[j]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> v(n + 1);
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    v[a]++;
  }

  int left = 0, right = 0;
  for (int i = 0; i < n; i++) {
    if (i < x && v[i]) left++;
    if (i > x && v[i]) right++;
  }
  cout << min(left, right) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
    int x,y;
    cin >> x >> y;
    cout << x+y/2 << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N, K;
	string S;
	cin >> S;
	bool ok = true;
	ll path = 0;
	ll now;
	ll L = S.size();
	VLL ans(L);
	for (int i = 0;i < L;i++) {
		path = 0;
		if (S[i] == 'R') {
			while (1) {
				path++;
				i++;
				if (S[i] == 'L') {
					ans[i] += path / 2;
				    ans[i - 1] += (path-path / 2);
					break;
				}
			}
		}
	}
	for (int i = L;i >= 0;i--) {
		path = 0;
		if (S[i] == 'L') {
			while (1) {
				path++;
				i--;
				if (S[i] == 'R') {
					ans[i]+=path/2;
					ans[i+1]+=(path-path/2);
					break;
				}
			}
		}
	}
	for (int i = 0;i < L;i++) cout << ans[i] << " ";
}

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

int main(){
    int N;
    cin >> N;
    vector<long long> vec(N);
    for(int i=0;i<N;i++){
        cin >> vec[i];
    }
    sort(vec.begin(),vec.end());
    cout << vec[N-1]-vec[0] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		scan.close();
		System.out.println((k%2==0)? (k/2)*(k/2):(k/2+1)*(k/2));
	}
}

Measured memory_bytes: 23636
# セグ木のパフォーマンステスト

class SegmentTree(object):
    __slots__ = ["elem_size", "tree", "default", "op", "real_size"]

    def __init__(self, a, default, op):
        self.default = default
        self.op = op
        if hasattr(a, "__iter__"):
            self.real_size = len(a)
            self.elem_size = elem_size = 1 << (self.real_size-1).bit_length()
            self.tree = tree = [default] * (elem_size * 2)
            tree[elem_size:elem_size + self.real_size] = a
            for i in range(elem_size - 1, 0, -1):
                tree[i] = op(tree[i << 1], tree[(i << 1) + 1])
        elif isinstance(a, int):
            self.real_size = a
            self.elem_size = elem_size = 1 << (self.real_size-1).bit_length()
            self.tree = [default] * (elem_size * 2)

    def get_value(self, x: int, y: int) -> int:  # 半開区間
        l, r = x + self.elem_size, y + self.elem_size
        tree, result, op = self.tree, self.default, self.op
        while l < r:
            if l & 1:
                result = op(tree[l], result)
                l += 1
            if r & 1:
                r -= 1
                result = op(tree[r], result)
            l, r = l >> 1, r >> 1
        return result

    def set_value(self, i: int, value: int) -> None:
        k = self.elem_size + i
        op, tree = self.op, self.tree
        tree[k] = value
        while k > 1:
            k >>= 1
            tree[k] = op(tree[k << 1], tree[(k << 1) + 1])

    def get_one_value(self, i):
        return self.tree[i+self.elem_size]

    def debug(self):
        print(self.tree[self.elem_size:self.elem_size+self.real_size])


from operator import itemgetter

N, M = map(int, input().split())
LRC = [list(map(int, input().split())) for _ in range(M)]
LRC.sort(key=itemgetter(0))

idx_LRC = 0
q = []

seg = SegmentTree(N+1, float("inf"), min)

seg.set_value(1, 0)
for v in range(1, N + 1):
    d = seg.get_value(v, N + 1)
    while idx_LRC < M:
        l, r, c = LRC[idx_LRC]
        if l <= v:
            seg.set_value(r, min(seg.tree[r + seg.elem_size], d + c))
            idx_LRC += 1
        else:
            break
ans = seg.tree[N + seg.elem_size]
print(ans if ans != float("inf") else -1)


Measured memory_bytes: 103380
import math

mod = 10**9+7

def comb(n, r):
	x = 1
	y = 1
	if n-r<r:
		r = n-r
	for i in range(r):
		x *= n-i
		y *= (i+1)
		x %= mod
		y %= mod
	return x * pow(y, mod-2, mod) % mod

X, Y = map(int, input().split())

o = -1

if X%2 == 0:
	if (Y-X//2)%3 != 0:
		o = 0
else:
	if (Y-(X-3)//2)%3 != 0:
		o = 0

if o == -1:
	n = (2*Y-X)//3
	m = Y-2*n
	if n >= 0 and m >= 0:
		o = comb(n+m, min(n,m))
	else:
		o = 0
		
print(o)

Measured memory_bytes: 3064
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	vector<ll>arr(n+10);
	ll fl=0;
	for(ll i=1;i<=n;i++)
	{
		cin>>arr[i];
		if(arr[i]==1)
		{
			fl=1;
		}
	}
	if(fl==0)
	{
		cout<<-1;
	}
	else
	{
		ll reqd=1;
		ll pos=0;
		ll ccount=0;
		for(ll i=1;i<=n;i++)
		{
			if(arr[i]==reqd)
			{
				pos=i;
				ccount++;
				reqd++;
			}
		}
		cout<<(pos-ccount+(n-pos));
	}
    return 0;
}


//252908XL

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	vector<int> p(3);
	cin >> p[0] >> p[1] >> p[2];
	sort(p.begin(),p.end());
	cout << p[0]+p[1] << endl;
	return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    int ans=0;
    for(int i=a;i<=b;i++){
        int c[5];
        int j=0;
        int x=i;
        while(true){
            if(x==0) break;
            c[j]=x%10;
            j++;
            x/=10;
        }
        if(c[0]==c[4]&&c[1]==c[3]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
using namespace std;
int a, b, c;
int main() {
	cin >> a >> b >> c;
	cout << min(b / a, c) << "\n";
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n = 0, x = 0, t = 0;
	cin>>n>>x>>t;
	
    int times = n/x;
    
    if(n%x)
    {
        times++;
    }
    
    cout<<times*t<<"\n";
    
	
	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
#define int long long
const int inf = 999999999999999999;
typedef long long ll;
typedef long double ld;
int n, a[100], gcm;
int solve(int i, int j) {
	if (i == 0) return j;
	return solve(j%i, i);
}
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	gcm = a[0];
	int ans = a[0];
	for (int i = 1; i < n; i++) {
		int g = solve(min(ans, a[i]), max(ans, a[i]));
		ans = (ans / g*a[i]);
	}
	cout << ans << endl;
	getchar(); getchar();
}

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

int main() {
    int n;
    cin >> n;
    map<ll,ll> mp1,mp2;
    rep(i,n){
        ll a;
        cin >> a;
        mp1[a+i+1]++;
        if(i+1-a>0) mp2[i+1-a]++;
    }
    ll ans=0;
    for(auto i : mp1){
            ans += i.second*mp2[i.first];
    }
    cout << ans << endl;
}

Measured memory_bytes: 29024
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

ll p = 1000000007;

int main()
{
    ll H, W, A, B;
    cin >> H >> W >> A >> B;
    vector<ll> fac, ifac;
    // sigma_x=B+1^W (x+H-A-2) C (H-A-1) * (W-x+A-2) C (A-1)

    // calculate factorial
    fac.push_back(1);
    for (ll i = 1; i <= H + W; i++) {
        ll t = fac[i - 1];
        t *= i;
        fac.push_back(t % p);
    }

    // calculate inverse factorial
    // a^(p-2) == a^(-1) (mod p)
    // a^(p-2) = a^1 * c_0 * .. * a^2^i * c_i * ..
    // c_i = (p-2) >> i & 1
    ll fac_t = fac[H + W];
    ll ifac_max = 1;
    for (int i = 0; ((p - 2) >> i) > 0 ; i++) {
        if (((p - 2) >> i) & 1) {
            ifac_max *= fac_t;
            ifac_max %= p;
        }
        fac_t *= fac_t;
        fac_t %= p;
    }
    ifac.push_back(ifac_max);

    for (int i = 1; i <= H + W; i++) {
        ll t = ifac[i - 1];
        t *= H + W - i + 1;
        ifac.push_back(t % p);
    }
    reverse(ifac.begin(), ifac.end());

    ll ans = 0;
    for (ll x = B + 1; x <= W; x++) {
        ll t = fac[x - 1 + H - A - 1];
        t *= ifac[x - 1];
        t %= p;
        t *= ifac[H - A - 1];
        t %= p;
        t *= fac[W - x + A - 1];
        t %= p;
        t *= ifac[W - x];
        t %= p;
        t *= ifac[A - 1];
        t %= p;
        ans += t;
        ans %= p;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4848
K, N = map(int, input().split())
A = list(map(int, input().split()))
n = K + min(A)
A.append(n)
A = sorted(A)
l = len(A)
B = []
for i in range(l-1):
  b = abs(A[i+1] - A[i])
  B.append(b)
x = sum(B) - max(B)
print(x)

Measured memory_bytes: 25840
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
#include<complex>
#include<array>
#include<numeric>
#include<functional>

using namespace std;
#define ll long long
#define ull unsigned long long
#define rrep(i,m,n) for(ll (i)=(ll)(m);(i)>=(ll)(n);(i)--)
#define rep(i,m,n) for(ll (i)=(ll)(m);i<(ll)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
constexpr long double m_pi = 3.1415926535897932L;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 61;
constexpr long double EPS = 1e-10;
template<typename T> using vector2 = vector<vector<T>>;
template<typename T> using vector3 = vector<vector2<T>>;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
string operator*(const string& s, int k) {
	if (k == 0) return "";
	string p = (s + s) * (k / 2);
	if (k % 2 == 1) p += s;
	return p;
}

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


	ll h, w, d;
	cin >> h >> w >> d;
	vector2<char> ans(h, vector<char>(w));
	REP(i, h) REP(j, w) {
		ll x = i + j, y = i - j + 500;
		if ((x / d) % 2 == 0) {
			if ((y / d) % 2 == 0)ans[i][j] = 'R';
			else ans[i][j] = 'G';
		}
		else {
			if ((y / d) % 2 == 0)ans[i][j] = 'B';
			else ans[i][j] = 'Y';
		}
	}
	REP(i, h)REP(j, w)cout << ans[i][j] << (j == w - 1 ? "\n" : "");

	
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;



int main(){

    ll n;
    cin >> n;

    vector<ll> a(n+1);
    vector<ll> b(n);


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

    for(int i = 0; i< n; i++){
        cin >> b.at(i);
    }

    ll count = 0;
    for(int i = 0; i< n; i++){
        if(b.at(i) >= a.at(i)){
            b.at(i) -= a.at(i);
            count += a.at(i);
        }else{
            count += b.at(i);
            b.at(i) =0;
        }

        if(a.at(i+1) >= b.at(i)){
            a.at(i+1) -= b.at(i);
            count += b.at(i);
        }else{
            count += a.at(i+1);
            a.at(i+1) = 0;
        }
    }
   
    cout << count << endl;

}       



Measured memory_bytes: 1792
#include<iostream>
#include<complex>
#include<vector>
using namespace std;
typedef complex<double> P;
int n;
vector<P> p;
int ret(){
	int cnt=1;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(abs(p[i]-p[j])>2.0)
				continue;
			P c=(p[i]+p[j])*0.5;
			double d=sqrt(1.0-abs(p[i]-c)*abs(p[i]-c));
			P l1=(p[i]-p[j])*P(0,1);
			P l2=(p[i]-p[j])*P(0,-1);
			l1=l1*d/abs(l1)+c;l2=l2*d/abs(l2)+c;
			int x=2,y=2;
			for(int k=0;k<n;k++){
				if(k==i||k==j)
					continue;
				if(abs(l1-p[k])<=1.0){
					x++;
				}
				if(abs(l2-p[k])<=1.0){
					y++;
				}
				
			}
			cnt=max(cnt,max(x,y));
		}
	}
	return cnt;
	
}
int main(){
	while(cin>>n,n){
		p.resize(n);
		for(int i=0;i<n;i++){
			double x,y;
			cin>>x>>y;
			p[i]=P(x,y);
		}
		cout<<ret()<<endl;
	}
	return 0;
}

Measured memory_bytes: 988
#include <iostream>
#include <vector>
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

bool solve(vector<int> A) {
    long long sum = 0;
    int odd = 0;
    bool ichi = false;
    for (int i = 0; i < A.size(); ++i) {
        sum += A[i] - 1;
        if (A[i] & 1) ++odd;
        if (A[i] == 1) ichi = true;
    }
    if (ichi) {
        if (sum % 2 == 0) return false;
        else return true;
    }
    else if (odd > 1) {
        if (sum % 2 == 0) return false;
        else return true;
    }
    else {
        if (sum % 2 == 1) return true;
        for (int i = 0; i < A.size(); ++i) if (A[i] & 1) --A[i];
        long long g = A[0];
        for (int i = 0; i < A.size(); ++i) g = GCD(g, A[i]);
        for (int i = 0; i < A.size(); ++i) A[i] /= g;
        if (!solve(A)) return true;
        else return false;
    }
}

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    if (solve(A)) puts("First");
    else puts("Second");
}

Measured memory_bytes: 9984