akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;
ll INF=100000000000001;
vector<ll> value; // ノードの値を持つ配列
ll N;             // 葉の数
 
void update(ll i, ll x) {
    // i 番目の葉の値を x に変える
    i += N - 1; // i 番目の葉のノード番号
    value[i] = x;
    while (i > 0) {
        i = (i - 1) / 2; // ノード i の親ノードの番号に変える
        value[i] = min(value[i * 2 + 1],
                       value[i * 2 + 2]); // 左右の子の min を計算しなおす
    }
}
 
ll query(ll a, ll b, ll k, ll l, ll r) {
    // [a, b) の区間に対するクエリについて
    // ノード k （区間 [l, r) 担当）が答える
    if (r <= a || b <= l) return INF; // 区間が被らない場合は INF を返す
    if (a <= l && r <= b)
        return value[k]; // ノード k の担当範囲がクエリ区間 [a, b)
                         // に完全に含まれる
    else {
        ll c1 = query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子に値を聞く
        ll c2 = query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子に値を聞く
        return min(c1, c2); // 左右の子の値の min を取る
    }
}

signed main(){
    llin(n);
    llin(x);
    llin(y);
    vll a(n,0);
    ll t;
    FOR(i,1,n){
        FOR(j,i+1,n){
            t=min(j-i,abs(x-i)+1+abs(y-j));
            a[t]++;
        }
    }
    FOR(i,1,n-1){
        sal(a[i])
    }
}

Measured memory_bytes: 256
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-02-15 14:28:12
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define pdd std::pair<double,double>
const int N=3010;
const double pi=acos(-1.);
int n,a[N];
double l;
pdd ans;
pdd operator*(pdd a,double b){ return pdd(a.first*b,a.second*b); }
pdd operator+(pdd a,pdd b){ return pdd(a.first+b.first,a.second+b.second); }
pdd calc(double x){ return pdd(cos(x*l),sin(x*l)); }
int main()
{
	n=read(); l=pi/read();
	fr(i,1,n) a[i]=read();
	fr(i,1,n) fr(j,i+1,n) ans=ans+calc(a[j]+a[i])*((-(j-i-1)+n-(j-i+1))*(a[j]-a[i]>int(pi/l+0.5)?-1:1));
	ans=ans*(6./n/(n-1)/(n-2));
	printf("%.10lf %.10lf\n",ans.first,ans.second);
//	printf("%lf %lf\n",calc(4).first,calc(4).second);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#define rep(i,beg,end) for(int i=(beg);i<(end);i++)
typedef long long LL;
using namespace std;

struct edge{
	int u,v,nex;
}e[100005];
int head[100005];
int n,m;
int ru[100005];
int tb_li[100005],tb_cnt;
int dp[100005];
void tobo(){
	queue<int> q;
	rep(i,1,n+1){
		if(ru[i]==0)
			q.push(i);
		//dp[i]=1;
	}
	while(!q.empty()){
		int curr=q.front();
		q.pop();
		tb_li[tb_cnt++]=curr;
		for(int i=head[curr];i;i=e[i].nex){
			ru[e[i].v]--;
			if(ru[e[i].v]==0){
				q.push(e[i].v);
			}
		}
	}
	//cout<<"list:\n";
	rep(i,0,tb_cnt){
		//cout<<tb_li[i]<<" ";
		for(int j=head[tb_li[i]];j;j=e[j].nex){
			dp[e[j].v]=max(dp[tb_li[i]]+1,dp[e[j].v]);
		}
	}
	//cout<<"\n";
	int ans=0;
	rep(i,1,n+1){
		ans=max(ans,dp[i]);
		//cout<<dp[i]<<" ";
	}
	//cout<<endl;
	cout<<ans<<endl;
	return;
}
int main(){
	cin>>n>>m;
	rep(i,1,m+1){
		int u,v;
		cin>>u>>v;
		e[i].u=u,e[i].v=v,e[i].nex=head[u];
		head[u]=i;
		ru[v]++;
		//cout<<"v="<<v<<" ++\n";
	}
	tobo();
	return 0;
}


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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  string temp;
  cin>>temp;
  
  if( (temp[2] == temp[3]) and (temp[4]==temp[5]) ){
  	cout<<"Yes";
  }else{
  cout<<"No";
  }
  

  return 0;
}

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

int main(void)
{
    int n,a[100],ans=0,i,j;

    scanf("%d",&n);
    for ( i = 0; i < n; i++)
    {
        scanf("%d",a+i);
    }

    for ( i = 0; i < n; i++)
    {
        for ( j = 0; j < n; j++)
        {
            if(ans<=abs(a[i]-a[j])) ans=abs(a[i]-a[j]);
        }
        
    }
    
    printf("%d",ans);
    
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys

def solve(N: int, S: str):
    answer = 0
    for i in range(0,1000):
        i = str(i).zfill(3)
        x = S.find(i[0])
        if x == -1:
            continue

        y = S.find(i[1],x+1)
        if y == -1:
            continue

        z = S.find(i[2],y+1)
        if z == -1:
            continue
        
        answer +=1
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#![allow(unused_macros, unused_imports, dead_code)]

use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
            assert!(_it.next().is_none());
        }
    };
}

fn main() {
    from_line!(N : i64);
    println!("{}",N/3);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <ctime>
#include <deque>
#include <ctime>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cassert>
#include <cstring>
#include <queue>
#include <random>

#define fi first
#define se second
#define ll long long
#define pii pair<int, int>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pll pair<long long, long long>
#define mp(x, y) make_pair((x), (y))

using namespace std;

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

    ll a, b;
    cin >> a >> b;

    a = __gcd(a, b);
    vector<int> vec;
    vec.push_back(1);
    for (ll i = 2; i * i <= a; ++i) {
        while (a % i == 0) {
            vec.push_back(i);
            a /= i;
        }
    }


    vec.push_back(a);
    //vec.push_back(b);
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    cout << vec.size() << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

class Main{
	static Scanner s=new Scanner(System.in);
	static int gInt(){return Integer.parseInt(s.next());}
	public static void main(String[]$){
		System.out.println(IntStream.range(0,gInt()).map(i->gInt()+gInt()).min().getAsInt());
	}
}

Measured memory_bytes: 53492
#include <iostream>
#include <algorithm>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>

#define INF 1e9
#define MOD 1000000007
#define ll long long
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
typedef unsigned long long ull;
typedef pair<int, ll> pr;
//ll t[100004],d[100004];
vector<int>t[100004];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x[3];
    cin>>x[0]>>x[1]>>x[2];
    sort(x,x+3);
    cout<<x[0]*x[1]/2<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    int K;
    string S;
    cin >> K >> S;
    if(S.length() > K){
        REP(i, K) cout << S[i];
        cout << "..." << endl;
    }else{
        PRINT(S);
    }
    return 0;
}

Measured memory_bytes: 3628
l =[]
s = []
for i in range(4):
  l.append(int(input()))
if l[0] <= l[1]:
  s.append(l[0])
else:
  s.append(l[1])
if l[2] <= l[3]:
  s.append(l[2])
else:
  s.append(l[3])
print(sum(s))

Measured memory_bytes: 3060
//code by lynmisakura.wish to be accepted
/****************************/
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;
 
const long long Mod = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;
 
#define itn int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(void){
	int n,m;cin >> n >> m;
	vpi a(m);
	rep(i,m){
		int aa,b;scanf("%d%d",&aa,&b);
		a[i] = mp(b,aa);
	}
	sort(all(a));
	
	int last = 0;
	int ans = 0;
	rep(i,m){
		if(a[i].ss <= last && a[i].ff > last) continue;
		else{
			last = a[i].ff - 1;
			ans++;
		}
	}
	cout << ans << endl;
}

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

long long dp[100002];

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

  int a;
  for(int i=0; i<m; ++i){
    cin >> a;
    dp[a] = -1;
  }

  dp[0] = 1;
  for(int i=0; i<n; ++i){
    if(dp[i] == -1) continue;
    if(dp[i+2] != -1) dp[i+2] += dp[i] % 1000000007;
    if(dp[i+1] != -1) dp[i+1] +=  dp[i] % 1000000007;
  }

  cout << dp[n] % 1000000007 << endl;
}


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

typedef long long ll;

const int N = 1e5 + 5;
int a[N];
int n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);
    int cnt = 1;
    int ans = 0;
    int s = 0;
    for (int i = 1; i < n; ++i) {
        if (a[i] == a[i - 1])
            ++cnt;
        else {
            if (cnt != 1 && (cnt & 1) == 0)
                ++s;
            ++ans;
            cnt = 1;
        }
    }
    if (cnt != 1 && (cnt & 1) == 0)
        ++s;
    ++ans;
    if (s & 1)
        --ans;

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3928
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Solve
{
    public class Solve
    {
        static void Main(string[] args)
        {
            var price = int.Parse(Console.ReadLine());
            var CoinFiveHundred = price / 500;
            var remain = price - CoinFiveHundred * 500;
            var CoinFive = remain / 5;
            Console.WriteLine(CoinFiveHundred * 1000 + CoinFive * 5);
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	int N;
	cin >> N;
	int i = 0;
	while(1){
		if((i + 1) * (i + 1) > N) break;
		i++;
	}
	cout << i * i << endl;
	return 0;
}


Measured memory_bytes: 256
using System;

namespace AOJ {
    public class Probrem {
        public static void Main() {
            var input = int.Parse(Console.ReadLine());
            var se = input % 60;
            input -= se;
            input /= 60;
            var mi = input % 60;
            input -= mi;
            var hr = input / 60;
            Console.WriteLine(hr + ":" + mi + ":" + se);
        }
    }
}


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main() {
  int n;
  cin >> n;
  vector<P> v(n);
  REP(i, n) {
    int val;
    cin >> val;

    auto p = make_pair(val, i);
    v[i] = p;
  }

  SORT(v);

  REP(i, n) {
    cout << v[i].second + 1;
    if (i != n - 1) {
      cout << " ";
    }
  }
  cout << endl;
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<math.h>

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	int i;
	double dw;
	double wr = 0.;
	for (i = 1; i <= n; i++) {
        if(i<k){
   			dw = log((double)k / (double)i) / log(2.);
			dw = ceil(dw);
			wr += pow(.5, dw)/(double)n;
        }else{
			wr += 1/(double)n;
        }
	}
	printf("%0.12f\n", wr);
	return 0;
}

Measured memory_bytes: 384
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define all(x) x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
#define    debg(x)  cout<<"#x = "<<x<<"\n";
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}



int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{




int x,a;
cin>>x>>a;
if(x<a)
cout<<0;
else
cout<<10;












}return 0;}

Measured memory_bytes: 256
import java.util.*
import kotlin.math.*

private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = { readLine()!!.toInt() }
private val readLong: ()->Long = { readLine()!!.toLong() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }
private val errPrint: (String)->Unit = { msg -> System.err.println(msg) }


fun main(args: Array<String>) {
    val (N, M,Q) = readListInt()

    data class Row(val a:Int, val b:Int, val c:Int, val d:Int)

    var rows = ArrayList<Row>()
    repeat(Q) {
        val (a, b, c, d) = readListInt()
        rows.add(Row(a-1,b-1,c,d))
    }

    var A = Array<Int>(N){1}

    fun sum(A: Array<Int>): Int {
        var res = 0
        for (row in rows) {
            if (A[row.b] - A[row.a] == row.c) {
                res += row.d
            }
        }
        return res
    }

    var ans = 0
    fun dfs(i:Int, x:Int) {
        if (i<0) {
            ans = max(ans, sum(A))
            return
        }

        A[i] = x

        for (nx in x downTo 1) {
            dfs(i-1, nx)
        }
    }

    dfs(N-1, M)

    println(ans)
}


Measured memory_bytes: 41288
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 7;

ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main(void){
  ll n, k, i, j, ans = 0;
  vector<ll> g;

  cin >> n >> k;

  g.resize(k+1,0);

  for(i=k;i>0;i--){
    g[i] = modpow(k/i,n) % MOD;
    j = 2;
    while(j*i<=k){
      g[i] -= g[j*i];
      g[i] %= MOD;
      if(g[i]<0) g[i] += MOD;

      j++;
    }
    ans += g[i] * i;
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3964
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <bitset>
using namespace std;


const double EPS = 1e-9;
const double PI = 3.14159265359;

int main(){
	int n;

	while(cin >> n, n != -1){
		pair<double, double> p(0, 0);
		double dir = PI/2;
		for(int i = 0; i < n; i++){
			dir -= PI/2;
			p.first += cos(dir);
			p.second += sin(dir);
			dir = atan2(-p.second, -p.first);
		}

		cout << p.first << endl;
		cout << p.second << endl;
	}

	return 0;
}

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

int main(){
	cin>>a;
	int x=a.find("C");
	for (int i=x;i<a.size();i++)
	{
		if (a[i]=='F') 
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	Main m = new Main();
	m.answer();
    }

    private Scanner scan = new Scanner(System.in);
    private final long K;

    public Main() {
	K = Long.parseLong(scan.next());

	scan.close();
    }

    public final void answer() {
	int N = (int)(K < 2 ? 2 : (K < 50 ? K : 50));
	long[] a = new long[N];
	long q = K / N;
	long r = K % N;

	StringBuilder str = new StringBuilder();
	
	for (int i = 0; i < N; i++) {
	    if(i > 0) str.append(' ');
	    
	    a[i] = N-1 + q;
	    if(i < r) a[i] += (N-r+1);
	    else a[i] -= r;

	    str.append(a[i]);
	}
	
	System.out.println(N);
	System.out.println(str.toString());
    }
}


Measured memory_bytes: 23764
import java.util.Scanner

object Main extends App{
  val sc = new Scanner(System.in)

  val s = sc.next
  val cs = strSplit(s)

  val judge =
    cs(0) == cs(1) ||
    cs(1) == cs(2) ||
    cs(2) == cs(3)

  val res = if(judge) "Bad" else "Good"

  println(res)

  def strSplit(str: String): Array[String] ={
    str.split("(?<=.)")
  }

}


Measured memory_bytes: 27344
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	string s;
	cin >> s;
	if(s.length() < 4 || s.substr(0,4) != "YAKI") No();
	else Yes();
	return 0;
}

Measured memory_bytes: 764
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int a = inp.nextInt();
        inp.nextInt();inp.nextInt();inp.nextInt();
        int e = inp.nextInt();
        int k = inp.nextInt();
        if (e - a <= k) System.out.println("Yay!");
        else System.out.println(":(");
        inp.close();
    }
}


Measured memory_bytes: 21844
# -*- coding:utf-8 -*-
import sys
input = sys.stdin.readline
from collections import deque
sa = deque(list(str(input()).replace('\n', '')))
sb = deque(list(str(input()).replace('\n', '')))
sc = deque(list(str(input()).replace('\n', '')))
di = {'a':sa, 'b':sb, 'c':sc}
turn = 'a'
while True:
  turn = di[turn].popleft()
  # print(turn)
  if len(di[turn])==0:
    print(turn.upper())
    break

Measured memory_bytes: 9336
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define INF 10000
using namespace std;

typedef long long ll;
int l[8] = {};
int n, a, b, c;

int min_mp(int cnt, int x, int y, int z)
{
    if (cnt == n)
        return min({x,y,z}) >0 ? abs(a - x) + abs(b - y) + abs(c - z) -30 : INF;
    int res1 = min_mp(cnt + 1, x + l[cnt], y, z) + 10;
    int res2 = min_mp(cnt + 1, x, y + l[cnt], z) + 10;
    int res3 = min_mp(cnt + 1, x, y, z + l[cnt]) + 10;
    int res4 = min_mp(cnt + 1, x, y, z);

    return min({res1, res2, res3, res4});
}

int main()
{
    cin >> n >> a >> b >> c;
    FOR(i, 0, n)
    cin >> l[i];
    cout << min_mp(0, 0, 0, 0) << "\n";
    return 0;
}

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

string solve(string s){
	for(int i=0;i<s.size();i++){
		if(s[i]>='a' && s[i]<='z'){
			s[i]=(s[i]-'a'+'A');
		}
	}
	return s;
}

int main(){
	string str;
	
	while(getline(cin,str)){
		cout<<solve(str)<<endl;
	}
}

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

using namespace std;

int xt[42], yt[42];

double dist(int a, int b, int c, int d) {
  return sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

int main() {
  for (int i = 0; i < 3; i++) {
    scanf("%d %d", xt + i, yt + i);
  }
  double a = dist(xt[0], yt[0], xt[1], yt[1]);
  double b = dist(xt[0], yt[0], xt[2], yt[2]);
  double c = dist(xt[2], yt[2], xt[1], yt[1]);
  if (a < b) swap(a, b);
  if (a < c) swap(a, c);
  if (b < c) swap(b, c);
  double x = ((c * c - b * b) / a + a) / 2;
  double y = sqrt(c * c - x * x);
  double low = 0.0, high = 1e6;
  for (int it = 0; it < 200; it++) {
    double mid = (low + high) * 0.5;
    double aa = y / c;
    double bb = -x / c;
    double cc = -mid;
    double from = (-bb * mid - cc) / aa;
    aa = y / b;
    bb = (a - x) / b;
    cc = -a * aa + mid;
    double to = (-bb * mid - cc) / aa;
    if (from + mid <= to - mid) {
      low = mid;
    } else {
      high = mid;
    }
  }
  printf("%.15f\n", 0.5 * (low + high));
  return 0;
}


Measured memory_bytes: 384
flag = false
l = gets.to_i.times.map{ gets.chomp }
gets.to_i.times do
  if l.include?( name = gets.chomp )
    if flag then puts "Closed by #{name}"
    else puts "Opened by #{name}"
    end
    flag = !flag
  else puts "Unknown #{name}"
  end
end

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

int main() {
    using namespace std;
    constexpr unsigned long maxN = 200010;
    unsigned long N;
    scanf("%lu", &N);
    array<unsigned long, maxN> perm;
    {
        array<pair<long, long>, maxN> p;
        for(unsigned long i = 0; i < N; ++i)scanf("%lu%lu", &p[i].first, &p[i].second);
        sort(p.begin(), p.begin() + N);
        for(unsigned long i = 0; i < N; ++i)p[i] = {p[i].second, i + 1};
        sort(p.begin(), p.begin() + N);
        transform(p.cbegin(), p.cbegin() + N, perm.begin(), [](auto i){return i.second;});
    }

    constexpr unsigned long MOD = 998244353;
    array<unsigned long, maxN> binary;
    unsigned long n = binary[0] = 1;
    generate(binary.begin() + 1, binary.end(), [&n](){if(n >= MOD)n -= MOD;return n <<= 1;});

    array<unsigned long, maxN> fenwick_tree{};
    auto que = [&fenwick_tree, &N](unsigned long i){
        unsigned long s{0}, j{i};
        while (i) { s += fenwick_tree[i]; i -= i & -i; }
        while (j <= N) { ++fenwick_tree[j]; j += j & -j; }
        return s;
    };

    array<unsigned long, maxN> coef{};
    coef[N] = N + MOD - 4;
    for(unsigned long i = 0; i != N; ++i){
        auto p = perm[i], q = que(p);
        ++coef[q];
        ++coef[i - q];
        ++coef[p - q - 1];
        ++coef[N - i - p + q];
    }

    cout << inner_product(binary.begin(), binary.begin() + N + 1, coef.begin(), 4 + MOD - N) % MOD << endl;
    return 0;
}

Measured memory_bytes: 8064
import math
def f(a,b):
  return max(len(str(a)),len(str(b)))

N = int(input())
n = N
ans = N

for _ in range(1,int(math.sqrt(n))+1):
  if n % _ == 0:
#    print("{}: {} {}".format(f(_,N/_),_,int(N/_)))
    if ans >= f(_,int(N/_)):
      ans = f(_,int(N/_))
    else:
      break
print(ans)


Measured memory_bytes: 3060
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    ll n;
    cin>>n;
    ll pos = 0;
    for(ll i=0; i<n; i++){
        pos+=(i+1)*(n-i);
    }
    ll neg = 0;
    for(ll i=0; i<n-1; i++){
        ll u, v;
        cin>>u>>v;
        neg+=((min(u, v))*(n-max(u, v)+1));
    }
    cout<<pos-neg<<endl;
}









Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{
    class People
    {
        public int point
        {
            get;set;
        }

        public  void Win()
        {
            point += 3;
        }
        public void Draw()
        {
            point += 1;
        }

        public int FinishScore()
        {
            return point;
        }
    }

    class Program
    {

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            People tarou = new People();
            People hanako = new People();
            for(int i = 0; i < n; i++)
            {
                string[] str = Console.ReadLine().Split(' ').ToArray();
                if (str[0].CompareTo(str[1]) > 0)
                {
                    tarou.Win();
                }else if (str[1].CompareTo(str[0]) > 0)
                {
                    hanako.Win();
                }else
                {
                    tarou.Draw();
                    hanako.Draw();
                }
            }
            Console.WriteLine("{0} {1}",tarou.FinishScore(),hanako.FinishScore());
        }
    }
}

Measured memory_bytes: 10068
#include<stdio.h>
/*ALDS1_1_A:Insertion Sort*/
int main(void)
{
	int array_length;
	int array[100]={0};
	int temp;
	int i,j,k;
	
	scanf("%d",&array_length);
	for(i=0;i<array_length;i++){
		scanf("%d",&array[i]);
	}
	
	for(i=0;i<array_length-1;i++){
		printf("%d ",array[i]);
	}
	printf("%d\n",array[array_length-1]);
	
	for(i=1;i<array_length;i++){
		temp=array[i];
		j=i-1;
		while((j>=0)&&(array[j]>temp)){
			array[j+1]=array[j];
			j--;
			array[j+1]=temp;
		}
		for(k=0;k<array_length-1;k++){
			printf("%d ",array[k]);
		}
		printf("%d\n",array[array_length-1]);
	}
}


Measured memory_bytes: 2148
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N,T,S,E;
vector<int> A,B,W;

vector<pair<int,int>> g[100010];

void fail(){
  cout<<"No"<<endl;
  exit(0);
}

pair<int,int> dfs(int now,int par,int c){
  vector<int> v;
  int e=-1;
  for(int i=0;i<g[now].size();i++){
    int nex=g[now][i].first;
    if(nex==par) continue;

    auto f=dfs(nex,now,g[now][i].second);
    if(f.second==1){
      e=f.first;
    }else{
      v.push_back(f.first);
    }
  }

  sort(v.begin(),v.end());
  int minus=0;
  if(now!=S) minus=T;
  for(auto p:v){
    if(p-minus<=0) fail();
    minus+=T;
  }

  if(e==-1){
    if(now==E) return mkp(c,1);

    if(c-minus<=0) fail();
    return mkp(c-minus,0);
  }else{
    if(e-minus<=0) fail();
    return mkp(c,1);
  }
}

int main(){
  cin>>N>>T>>S>>E;
  A.resize(N);
  B.resize(N);
  W.resize(N);
  rep(i,N-1) cin>>A[i]>>B[i]>>W[i];

  for(int i=0;i<N-1;i++){
    g[A[i]].push_back(mkp(B[i],W[i]));
    g[B[i]].push_back(mkp(A[i],W[i]));
  }

  dfs(S,-1,0);
  cout<<"Yes"<<endl;

  return 0;
}



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

int main(){
    int n; cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    int ans = 1;
    for(int i = 1; i < n; i++){
        if(a[i-1]!=a[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

ll mod = 1e9+7;
inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return (dividend / divisor);
}

// 因数分解
inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

//階乗
inline ll factorialMethod(ll k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

inline ll vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) { // 発見できたとき
        return 1;
        
        
    }
    else { // 発見できなかったとき
        return 0;
    }
}

void recursive_comb(ll *indexes, ll s, ll rest, std::function<void(ll *)> f) {
    if (rest == 0) {
        f(indexes);
    } else {
        if (s < 0) return;
        recursive_comb(indexes, s - 1, rest, f);
        indexes[rest - 1] = s;
        recursive_comb(indexes, s - 1, rest - 1, f);
    }
}

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

int main(){
    ll ans = 0;
    ll n, m;
    cin >> n >> m;
    
    ans = nCr(n, 2) + nCr(m, 2);
    if(n <= 1){
        ans --;
    }
    if(m <= 1){
        ans --;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-9
using namespace std;
typedef complex<double> point;

pair<point, point> norm(point p){
  return pair<point, point>(p*point(0, 1)/abs(p),
                            p*point(0, -1)/abs(p));
}

vector<point> calcC(point a, point b){
  point p = (b - a)/2.0;
  pair<point, point> n = norm(p);
  double unit = sqrt(1 - abs(p)*abs(p));
  n.first  =  n.first*unit;
  n.second = n.second*unit;
  vector<point> res(2);
  res[0] = a + p + n.first;
  res[1] = a + p + n.second;
  return res;
}
int main(int argc, char *argv[]){
  int n;
  while(cin >> n, n){;
    point p[n];
    for (int i = 0; i < n; i++) {
      double real, imag;
      cin >> real >> imag;
      p[i] = complex<double>(real, imag);
    }
    int ans = 1, cnt = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        point a = p[i], b = p[j];
        if(abs(b - a) > 2 - eps)continue;
        vector<point> center = calcC(a, b);
        for (int c = 0; c < 2; c++) {
          cnt = 0;
          for (int k = 0; k < n; k++) {
            if(abs(center[c] - p[k]) <= 1 + eps)cnt++;
          }
          ans = max(ans, cnt);
        }
      }
    }
    std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1260
"""    Arnab Chanda    """

from collections import defaultdict, deque
from itertools import permutations
from sys import stdin,stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq

int_input=lambda : int(stdin.readline())
string_input=lambda : stdin.readline().split()
multi_int_input =lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input=lambda : list(map(int,stdin.readline().split()))
string_list_input=lambda: list(string_input())
MOD = pow(10,9)+7


n, k = multi_int_input()

a = list_input()


prev = 1

if k < n:
    
    for i in range(k):
        nextTown = a[prev-1]
        prev = nextTown

    print(prev)

else:

    seti = {}
    seti[1] = 0
    count = 0
    cycle = 0
    x = 0
    order = [1]
    while(True):
        count+=1
        nextTown = a[prev-1]
        order.append(nextTown)
        prev = nextTown
        if nextTown in seti:
            cycle = count - seti[nextTown]
            x = seti[nextTown]
            break
        else:
            seti[nextTown] = count

    # print(k, cycle, x, seti)
    k = k - (x - seti[1])
    # print(k, order)
    print(order[x+(k%cycle)])


Measured memory_bytes: 32144
#include <iostream> 
#include <vector> 
using namespace std; 
  
int main() 
{
  float d,t,s;
  cin>>d>>t>>s;
  float speed=d/t;
  if(speed<=s)
  {
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

using namespace std;

// void print2DArray(vector<vector<int>> &mat) {
//   for (auto row : mat) {
//     for (auto elm : row)
//       cout << elm << " ";
//     cout << endl;
//   }
// }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string in;
  cin >> in;

  if (in == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long n,dp[111][10][10][10];
int main()
{
	cin>>n;
	dp[0][4][4][4]=1;
	for(int i=0;i<n;i++)
	{
		for(int x=0;x<5;x++)
		{
			for(int y=0;y<5;y++)
			{
				for(int z=0;z<5;z++)
				{
					for(int j=0;j<4;j++)
					{
						if(y==0 && z==1 && j==2)
						{
							continue;
						}
						if(y==0 && z==2 && j==1)
						{
							continue;
						}
						if(y==1 && z==0 && j==2)
						{
							continue;
						}
						if(x==0 && y==1 && j==2)
						{
							continue;
						}
						if(x==0 && z==1 && j==2)
						{
							continue;
						}
						dp[i+1][y][z][j]+=dp[i][x][y][z];
						dp[i+1][y][z][j]%=md;
					}
				}
			}
		}
	}
	long long ans=0;
	for(int x=0;x<5;x++)
	{
		for(int y=0;y<5;y++)
		{
			for(int z=0;z<5;z++)
			{
				ans+=dp[n][x][y][z];
			}
		}
	}
	cout<<ans%md<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans,cnt;

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

	ll n,k;
	cin >> n >> k;
	
	for (ll i = k; i <= n + 1; i++) {
		ll l = (i * (i - 1)) / 2;
		ll r = (2 * n - i + 1) * i / 2;
		ans += r - l + 1;
	}
	
	cout << ans % MOD << endl;

	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll a,b;cin>>a>>b;
    ll res=max(a*b,max(a+b,a-b));
    cout<<res<<endl;
}

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

int main() {
    int maxA = 100000;
    int n;
    cin >> n;

    int a[maxA] = {};
    int b;
    for (int i = 0; i < n; i++) {
        cin >> b;

        a[b]++;
        if (b - 1 >= 0) a[b - 1]++;
        if (b + 1 < maxA) a[b + 1]++;
    }

    sort(a, a + maxA, greater<int>());

    cout << a[0] << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int K;
    string S;
    cin >> K >> S;
    if (S.length() <= K) {
        cout << S << endl;
    }
    else {
        REP(i, K) {
            cout << S[i];
        }
        cout << "..." << endl;
    }
    return 0;
}


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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int main()
{
    ll l, r;
    cin >> l >> r;
    const int m = 2019;

    ll ans = INF;
    REPS(l,i,min(r,l+m+1)){
        REPS(l+1,j,min(r+1,l+m+1)){
            ans = min((i*j)%m,ans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>		
using namespace std;
typedef long long ll;
#define ff first
#define ss second
#define forl(n) for(int i=0;i<n;i++)
#define forp(i,n) for(int i=0;i<n;i++)
#define fort(i,m,n) for(int i=m;i<n;i++)
#define fora(arr,n) for(int i=0;i<n;i++) cin>>arr[i];
#define begud(k) cout<<"\t-->"<<#k<<" = "<<k<<"\n";
#define endl "\n";
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll res = power(a,b/2);
	if(b%2==0)
		return res*res;
	return a*res*res;
}
#define inf 10000000000

// vector<ll> cache()

// int find(int idx, int w)
// {
// 	if (w < 0)
// 		return -inf;
// 	if (idx == -1)
// 	{
// 		// if (w)
// 		// 	return -inf;
// 		// else
// 			return 0;
// 	}

// 	int &ans = cache[idx][w];
// 	if (ans != -1)
// 		return ans;

// 	ans = 0;
// 	for (int i = 0; i <= idx; ++i)
// 	{
// 		ans = max(ans, find(i - 1, w - v[i].ff) + v[i].ss);
// 	}

// 	return ans;
// }

// find(i, j) // Max value choosing some objects in range [0, i] with weight <= j

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 	int n,w;
 	cin>>n>>w;
 	vector<pair<ll,ll>>v(n);
 	fort(i,0,n)
 	{
 		ll wt,val;
 		cin>>wt>>val;
 		v[i] = {wt,val};
 	}
 	sort(v.begin(),v.end());
 	vector<ll>dp(w+1,-inf);
 	//dp[i] = value when total weight is i
 	dp[0] = 0;
 	for (int i = 0; i < n; ++i)
 	{
 		for (int j = w - v[i].ff; j >= 0; --j)
 		{
 			if (dp[j] == -inf)
 				continue;
 			dp[j + v[i].ff] = max(dp[j + v[i].ff], dp[j] + v[i].ss);
 		}
 	}
 	ll p = 0;
 	fort(i,0,w+1)
 	{
 		p = max(p,dp[i]);
 	}
 	cout<<p<<endl;
	return 0;
}

Measured memory_bytes: 1024
const int N = 400005;
const int LG = 21;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, m;
    cin >> n >> m;
    int x = m / 2, y = (m + 1) / 2;
    int l = 2 * x + 1;
    for (int i = 1; i <= l / 2; i++)
    {
        cout << i << " " << l + 1 - i << "\n";
    }
    int r = 2 * y;
    for (int i = 1; i <= r / 2; i++)
    {
        cout << l + i << " " << l + r + 1 - i << "\n";
    }
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 3664
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;



/* Name of the class has to be "Main" only if the class is public. */
public class Main
 
 
{
    static Scanner in = new Scanner(System.in);
    
    public static void solve()
    {
        int n=in.nextInt(),m=in.nextInt();
        int[] a = new int[m];
        for(int i=0;i<m;i++)
        {
            a[i]=in.nextInt();
        }
        
        int sum=0;
        
        for(int i=0;i<m;i++)
        {
            sum+=a[i];
            
            if(sum>n)
            {
                break;
            }
            
        }
        
        if(sum>n)
        {
            System.out.println(-1);
        }
        else
        {
            System.out.println(n-sum);
        }
        
    }
    

    
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		
		int t=1;
		//in.nextLine();
		
		while(t>0)
		{
		    
		    solve();
		    t--;
		}
		
		
	
	//	System.out.println(x);
	}
}


Measured memory_bytes: 46296
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  int B;
  cin >> A >> B;
  int K = (A + B) / 2;
  
  if ((A + B) % 2 == 0) {
    cout << K << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
def ABC146D_ColoringEdge():
    N = int(input())

    graph = [[] for i in range(0, N)]
    edge = [0] * (N - 1)
    for i in range(0, N - 1):
        frm, to = list(map(int, input().split()))
        frm -= 1
        to -= 1
        graph[frm].append(i)
        graph[to].append(i)
    
    maxColor = 0
    for node in graph:
        usedColor = []
        maxColor = max(maxColor, len(node))
        for eNo in node:
            if edge[eNo] is not 0:
                usedColor.append(edge[eNo])
        
        nowColor = 1
        for eNo in node:
            if edge[eNo] is 0:
                while nowColor in usedColor:
                    nowColor += 1

                edge[eNo] = nowColor
                usedColor.append(nowColor)

    print(maxColor)
    
    for color in edge:
        print(color)


def main():
    ABC146D_ColoringEdge()

if __name__ == "__main__":
    main()


Measured memory_bytes: 68000