akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

void SCC(vector<vector<int>> &graph,vector<int> &group) {
    int n=SZ(graph);
    vector<vector<int>> rg(n);
    REP(i,n) FORE(x,graph[i]) rg[x].push_back(i);
    priority_queue<pii> pq;
    vector<bool> vis(n,false);
    int cnt=0;
    function<void(int,int)> dfs1=[&](int v,int p) {
        vis[v]=1;
        FORE(x,graph[v]) if(x!=p && !vis[x]) dfs1(x,v);
        pq.push({cnt++,v});
    };
    REP(i,n) if(!vis[i]) dfs1(i,-1);

    cnt=0;
    group=vector<int>(n,-1);
    function<void(int,int)> dfs2=[&](int v,int p) {
        group[v]=cnt;
        FORE(x,rg[v]) if(x!=p && group[x]==-1) dfs2(x,v);
    };
    while(!pq.empty()) {
        int v=pq.top().second;
        pq.pop();
        if(group[v]!=-1) continue;
        dfs2(v,-1);
        cnt++;
    }
}
signed main() {
    int n,m;
    cin>>n>>m;
    vector<vector<int>> g(n);
    REP(i,m) {
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
    }
    vector<int> scc;
    SCC(g,scc);
    
    int Q;
    cin>>Q;
    while(Q--) {
        int a,b;
        cin>>a>>b;
        cout<<(scc[a]==scc[b])<<endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

string s;
unordered_map<char, int> um;

signed main() {
    cin >> s;
    for (auto &c:s) um[c]++;
    for (auto &c:s) {
        if (um[c] != 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

// 配列

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

using namespace std;

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

    string s1[52], s2[52];

    int n, m;
    cin >> n >> m;

    for(int i = 0; i < n; ++i)
        cin >> s1[i];

    for(int i = 0; i < m; ++i)
        cin >> s2[i];

    int li = n - m + 1;
    for(int i = 0; i < li; ++i) {
        for(int j = 0; j < li; ++j) {
            if (s1[i][j] == s2[0][0]) {
                bool q = 1;
                for(int x = i, o = 0; x < i + m && o < m && q; ++x, ++o)
                    for(int y = j, p = 0; y < j + m && p < m && q; ++y, ++p) {
                        if (s1[x][y] != s2[o][p])
                            q = 0;
                }
                if (q) {
                    cout << "Yes";
                    return 0;
                }
            }
        }
    }

    cout << "No";

    return 0;
}


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

using namespace std;

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



Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#include <vector>
#include <limits.h>
#include <stack>
#include <queue>
#include <cstdlib>
#define maxn 10000000
#define pi acos(-1)
#define ll long long
using namespace std;
struct node{
	double x;
	double y;
};
void solve(int n,node a,node b)
{
	if(n==0)return;
	node t,s,u;
	double th=M_PI*60.0/180.0;  //将单位从度变为弧度；
	
	s.x=(2.0*a.x+1.0*b.x)/3.0;
	s.y=(2.0*a.y+1.0*b.y)/3.0;
	t.x=(1.0*a.x+2.0*b.x)/3.0;
	t.y=(1.0*a.y+2.0*b.y)/3.0;
	u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;///旋转矩阵；
	u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
	
	solve(n-1, a, s);
	printf("%.8lf %.8lf\n",s.x,s.y);
	solve(n-1, s, u);
	printf("%.8lf %.8lf\n",u.x,u.y);
	solve(n-1, u, t);
	printf("%.8lf %.8lf\n",t.x,t.y);
	solve(n-1, t, b);
	
}
int main()
{
	node a,b;
	int n;
	cin>>n;
	a.x=0;
	a.y=0;
	b.x=100;
	b.y=0;
	printf("%.8lf %.8lf\n",a.x,a.y);
//	cout<<a.x<<" "<<a.y<<endl;
	solve(n, a, b);
	printf("%.8lf %.8lf\n",b.x,b.y);
//	cout<<b.x<<" "<<b.y<<endl;
	return 0;
}


Measured memory_bytes: 3136
#include <stdio.h>

int main(void)
{
    int a,b;

    scanf("%d %d",&a,&b);

    if (a>b){
        printf("a > b\n");

    }
    if (a==b){
        printf("a == b\n");

    }
    if (a<b){
        printf("a < b\n");

    }

    return 0;
}


Measured memory_bytes: 2028
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,a=0,b=0,ba=0,res=0; 
    cin>>n; 
    string s;
    for (int i=0,c;i<n;i++){
        cin>>s;
        for (int j=0;j<sz(s)-1;j++){
            if (s[j]=='A' and s[j+1]=='B') res++;
        }
        if (s[0]=='B' and s[sz(s)-1]=='A') ba++;
        else if (s[0]=='B') b++;
        else if (s[sz(s)-1]=='A') a++;
    }
    if (ba) {
        res += ba-1; 
        if (a) res++,a--;
        if (b) res++,b--;
    }
    cout << (res+min(a,b)) << endl; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}
/* 
3
B
A
BABA

*/

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        String n = sc.next();
        long sum = 0;
        for(char c: n.toCharArray()){
            sum += Character.getNumericValue(c);
        }
        if (sum%9 == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }    
}

Measured memory_bytes: 40688
#include <iostream>
using namespace std;
//include
//------------------------------------------
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int n,as[(int)1e6];
int main() {
	scanf("%d", &n);
	int m=1e9,M=0;
	REP(i,n){
		scanf("%d",as+i);
		m=min(as[i],m);
		M=max(as[i],M);
	}
	if(M-m>1){
		printf("No\n");
	}else if(M==m){
		bool can = m+1==n || m*2<=n;
		printf(can ? "Yes\n" : "No\n");
	}else{
		int w = 0;
		REP(i, n){
			if(as[i]==m)w++;
		}
		bool can = m+1>w && (m-w+1)*2 <= n-w;
		printf(can ? "Yes\n" : "No\n");
	}

	return 0;
}


Measured memory_bytes: 640
void main()
{
    long[] tmp = rdRow;
    long h = tmp[0], w = tmp[1];

    long choco = h * w;
    long result = 1L << 60;
    foreach (i; 1 .. h)
    {
        long s1 = i * w;
        long s2 = (h - i) * (w / 2);
        long s3 = choco - s1 - s2;
        long diff = max(s1, s2, s3) - min(s1, s2, s3);
        result = min(result, diff);

        s2 = ((h - i) / 2) * w;
        s3 = choco - s1 - s2;
        diff = max(s1, s2, s3) - min(s1, s2, s3);
        result = min(result, diff);
    }

    foreach (j; 1 .. w)
    {
        long s1 = h * j;
        long s2 = (h / 2) * (w - j);
        long s3 = choco - s1 - s2;
        long diff = max(s1, s2, s3) - min(s1, s2, s3);
        result = min(result, diff);

        s2 = h * ((w - j) / 2);
        s3 = choco - s1 - s2;
        diff = max(s1, s2, s3) - min(s1, s2, s3);
        result = min(result, diff);
    }

    result.writeln;
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main()
{
	int N, f = 0, temp;
	cin >> N;
	temp = N;

	while (temp > 0) {
		f += temp % 10;
		temp /= 10;
	}

	if (N % f) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    a95(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}


fun a95(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    println(700 + (100 * args[0].count { it == 'o' }))
}


Measured memory_bytes: 33724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N, k;

ll f(int n, ll x){
    if(!n) return x;
    if(!(x%k)) return f(n, x+1);
    return f(n-1, x - x/k - 1);
}

int main(){
    cin >> N >> k;
    ll l = 0, r = 2e18;
    while(l + 1 < r){
        ll x = (l + r) / 2;
        (f(N-1, x) ? r : l) = x;
    }
    cout << l << endl;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < n - 1; ++i) {
    if(s[i] == s[i + 1]) ++cnt;
  }
  cnt = min(n - 1, cnt + 2 * k);
  cout << cnt << endl;
}

Measured memory_bytes: 512
#include <iostream>

#define ABS(n) ((n >= 0) ? (n) : -1 * (n))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;

int main(void)
{
    long long int N, K;
    long long int remain;

    cin >> N >> K;

    if (N >= K)
        cout << MIN((remain = (N % K)), ABS(remain - K));
    else
        cout << MIN(N, ABS(N - K));

    return 0;
}

Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int h, w; cin >> h >> w;
	vector<string> s(h); rep(i, h)cin >> s[i];
	vector<vector<int>> l(h, vector<int>(w)), r(h, vector<int>(w)), u(h, vector<int>(w)), d(h, vector<int>(w));
	rep(i, h)rep(j, w)
	{
		int cnt = 0;
		while (j < w&&s[i][j] == '.')
		{
			++cnt;
			l[i][j] = cnt;
			++j;
		}
		if (j == w)continue;
		if (s[i][j] == '#')l[i][j] = 0;
	}
	rep(i, h)rep(j, w)
	{
		int cnt = 0;
		while (j < w&&s[i][w - j - 1] == '.')
		{
			++cnt;
			r[i][w - j - 1] = cnt;
			++j;
		}
		if (j == w)continue;
		if (s[i][w - j - 1] == '#')r[i][w - j - 1] = 0;
	}
	rep(i, w)rep(j, h)
	{
		int cnt = 0;
		while (j < h&&s[j][i] == '.')
		{
			++cnt;
			u[j][i] = cnt;
			++j;
		}
		if (j == h)continue;
		if (s[j][i] == '#')u[j][i] = 0;
	}
	rep(i, w)rep(j, h)
	{
		int cnt = 0;
		while (j < h&&s[h - j - 1][i] == '.')
		{
			++cnt;
			d[h - j - 1][i] = cnt;
			++j;
		}
		if (j == h)continue;
		if (s[h - j - 1][i] == '#')d[h - j - 1][i] = 0;
	}
	int res = 0;
	rep(i, h)rep(j, w)
	{
		chmax(res, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
	}
	cout << res << endl;
}

Measured memory_bytes: 73652
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define maxn 200005

ll fastpower (ll b , ll p){
    ll k= p%2 ? b : 1 ;
    return p==0 ? 1 : k*(fastpower(b*b,p/2));
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	cout<<(((n+999)/1000)*1000)-n;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int n;
const int maxn = 505;

pi x[maxn];
bool vis[maxn * maxn];
int a[maxn * maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> x[i].fi;
        x[i].se = i;
    } 
    sort(x + 1,x + 1 + n);
    int sum = 0;
    int sum1 = 0;
    bool flag = true;
    for(int i = 1;i <= n;i++){
        if(sum + x[i].se > x[i].fi)
            flag = false;  
        if(n * (n - 1) / 2 + sum1 + i < x[i].fi)
            flag = false;
        sum += x[i].se;
        sum1 += (n - x[i].se);
    }
    if(!flag){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        int j = 1;
        for(int i = 1;i <= n;i++){
            for(int k = 1;k < x[i].se;k++){
                while(vis[j]){
                    j++;
                }
                a[j] = x[i].se;
                vis[j++] = true;
            } 
            a[x[i].fi] = x[i].se; 
            vis[x[i].fi] = true;
        }
        for(int i = 1;i <= n;i++){
            for(int k = x[i].se + 1;k <= n;k++){
                while(vis[j]){
                    j++;
                }
                a[j] = x[i].se;
                vis[j++] = true;
            }
        }
        for(int i = 1;i <= n * n;i++){
            cout << a[i] << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 2432
#include <stdio.h>
#include <ctype.h>
#include <string.h>
  
int main(void) {
    int i;
    char string[1200];
    fgets(string,sizeof(string),stdin);
    for (i=0; i<strlen(string); i++) {
        if (isalpha(string[i])) {
            if (islower(string[i])) {
                printf("%c",toupper(string[i]));
            } else {
                printf("%c",tolower(string[i]));
            }
        } else {
            printf("%c",string[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 2016
#include <iostream>

using namespace std;

typedef long long ll;

const int MOD = 1e9+7;
const int MAXN = 1e6+10;
ll x, y;

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

ll mod_inv(ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}

ll multiple(ll n, ll a) {
  ll res = 1;
  for (ll i=0;i<a;i++) {
    res = res * (n - i) % MOD;
  }
  return res;
}


ll nCr(ll n, ll r) {
  return multiple(n, r) * mod_inv(multiple(r, r)) % MOD;
}

void solve() {
  // k + 2 * l, 2 * k + l
  ll diff = abs(x - y);
  x -= diff;
  y -= diff;

  if (x > y) {
    x -= diff;
  } else {
    y -= diff;
  }
  if (x < 0 || y < 0 || (x + y) % 3 != 0) {
    cout << 0 << endl;
    return;
  }

  ll sum = (x + y) / 3;
  cout << nCr(sum + diff, diff + sum / 2) << endl;
}

int main() {
  cin >> x >> y;
  solve();
}



Measured memory_bytes: 256
#include <stdio.h>
/*#include <string.h>*/
#define LEN 100005
#define MAX 100000

typedef struct pp {
  char name[100];
  int t;
} P;

P Q[LEN]; 
int head, tail, n;

void enqueue(P x){

  Q[tail] = x;
  tail = (tail + 1) % LEN;
}


P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b){ return a < b ? a : b; }

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for(i = 1; i <= n; i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1;
  tail = n + 1;

  while( head != tail ){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else{
      printf("%s %d\n",u.name, elaps);
    }
  }


  return 0;
}

Measured memory_bytes: 10752
#include <stdio.h>
#include <stdbool.h>

int main(void)
{
  bool card[4][13];
  int n, card_num;
  char sign;

  for (int i = 0; i < 4; i++){
    for (int j = 0; j < 13; j++){
      card[i][j] = false;
    }
  }

  scanf (" %d", &n);

  for (int i = 0; i < n; i++){
    scanf (" %c %d", &sign, &card_num);

    switch(sign){
    case 'S':
      card[0][card_num-1] = true;
      break;
    case 'H':
      card[1][card_num-1] = true;
      break;
    case 'C':
      card[2][card_num-1] = true;
      break;
    case 'D':
      card[3][card_num-1] = true;
      break;
    }
  }

  for (int i = 0; i < 4; i++){
    for (int j = 0; j < 13; j++){
      if (card[i][j] == false){
	if(i == 0){
	  printf("S %d\n", j+1);
	}
	else if (i == 1){
	  printf("H %d\n", j+1);
	}
	else if (i == 2){
	  printf("C %d\n", j+1);
	}
	else if (i == 3){
	  printf("D %d\n", j+1);
	}
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

void run(void){
  int n;
  scanf("%d",&n);
  double ans=0;
  while(n--){
    double x;
    char u[100];
    scanf("%lf%s",&x,u);
    if(u[0]=='J'){
      ans+=x;
    } else {
      ans+=380000*x;
    }
  }
  printf("%.5f\n",ans);
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int a[101010];

int main() {
	cin >> n;
	LL ans = 0;
	REP(i, n) {
		cin >> a[i];
		ans += a[i] - 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007


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

	vector<vector<int> > tree(n);
	for(int i = 0; i < n - 1; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}

	vector<bool> ischecked(n, false);
	ischecked[0] = true;
	queue<int> qu;

	long long int ans = k;

	// 根の子ノードのみ特別処理
	int childnodenum = tree[0].size();
	int colornum = k - 1;
	if(childnodenum > colornum){
		cout << 0 << endl;
		return 0;
	}
	for(int i = 0; i < childnodenum; i++){
		ans = (ans * (colornum - i)) % mod;
		ischecked[tree[0][i]] = true;
		qu.push(tree[0][i]);
	}

	// (k-2)Pi を先に求めておく
	long long int perm[100001];
	perm[0] = 1;
	perm[1] = k - 2;
	for(int i = 2; i <= k - 2; i++){
		perm[i] = (perm[i - 1] * (k - 2 - i + 1)) % mod;
	}

	while(!qu.empty()){
		int now = qu.front();
		qu.pop();

		// nowの子ノードたちは互いに異なる色でないといけない
		// よって (k - 2)P(tree[now].size() - 1) 通りの塗り方がある
		int childnodenum = tree[now].size() - 1;
		if(childnodenum > k - 2){
			ans = 0;
			continue;
		}
		ans = (ans * perm[childnodenum]) % mod;

		for(int i = 0; i < tree[now].size(); i++){
			int next = tree[now][i];
			if(ischecked[next]) continue;
			ischecked[next] = true;
			qu.push(next);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 7288
//😄😄😄😄😄😄😄😄😄😄😄😄😄
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define endl "\n"
#define debug(x) cout<<"DEBUG------> "<<#x<<" -> "<<x<<endl
#define all(x) x.begin(),x.end()
#define mint map<int,int>

////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////


void solve() {
	int n, k; cin >> n >> k;
	vi v(n);
	For(i, 0, n)cin >> v[i];
	ll curr = 1;
	For(i, k, n) {
		double x = (double)v[i] / (double)v[i - k];
		if (x > 1)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}


}

////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
//	freopen("in.txt", "r", stdin);
//	freopen ("out.txt", "w", stdout);
//	int t; cin >> t;
	//while (t--)
	solve();

	return 0;
}





///////////////////////////////////////////////////////////////////////////////////////////
//What are you doing ???



Measured memory_bytes: 3984
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
char s[233333];
int n;
int main(){
	scanf("%s", s);
	n = strlen(s);
	int las = n - 1;
	ll ans = 0;
	for(int i = n - 1; i >= 0; i--)
		if(s[i] == 'B') ans += 1ll * las - i, las--;
	return !printf("%lld\n", ans);
}

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

constexpr int N = 1 << 18, P = 1000000007;

int h, l;
int p[N];
int sum[N];

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    std::cin >> h;
    l = 1 << (h - 1);
    for (int i = 0; i < l; ++i) {
        std::cin >> p[i];
        --p[i];
    }
    
    int ans = 0;
    
    for (int lca1 = 1; lca1 < l; ++lca1) {
        int dep = std::__lg(lca1);
        int in = lca1 << (h - 1 - dep);
        int out = (lca1 + 1) << (h - 1 - dep);
        int mid = (in + out) / 2;
        
        for (int i = in; i < mid; ++i) {
            int v = 1;
            for (int j = i; j != lca1; j /= 2)
                v = 1ll * v * j % P;
            for (int j = l + p[i - l]; j > 1; j /= 2) {
                v = 1ll * v * j % P;
                sum[j] = (sum[j] + v) % P;
            }
        }
        
        for (int i = mid; i < out; ++i) {
            int v = 1;
            for (int j = i; j != lca1; j /= 2)
                v = 1ll * v * j % P;
            for (int j = l + p[i - l]; j > 1; j /= 2) {
                v = 1ll * v * j % P;
                ans = (ans + 1ll * v * sum[j ^ 1] % P * (j / 2) % P * lca1) % P;
            }
        }
        
        for (int i = in; i < mid; ++i)
            for (int j = l + p[i - l]; j > 1; j /= 2)
                sum[j] = 0;
    }
    
    std::cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 5164
import heapq
from sys import stdin
input = stdin.readline

#入力
# s = input()
n = int(input())
# n,m = map(int, input().split())
# a = list(map(int,input().split()))
# a = [int(input()) for i in range()]


st=[]
for i in range(n):
    s,t = map(str, input().split())
    t = int(t)
    st.append((s,t))

x = input()[0:-1]
     
def main():
    ans = 0
    flag = False

    for i in  st:
        s,t = i
        if flag:
            ans+=t
        if s == x:
            flag = True
        
    print(ans)
    
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
	int i;
	int n;
	int max_a, max_b;

	scanf("%d", &n);

	max_a = max_b = 0;
	for (i = 0; i < n; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		if (a > max_a) {
			max_a = a;
			max_b = b;
		}
	}

	printf("%d\n", max_a + max_b);

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << endl;
#else
#define DBG(X)
#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

void solve()
{
	ll L, R;
	cin >> L >> R;

	for(ll i = L; i <= R; ++i)
	{
		if(i % 2019 == 0)
		{
			cout << 0 << endl;
			return;
		}
	}

	ll besti = L, bestj = R;

	for(ll i = L; i <= R; ++i)
	{
		for(ll j = i + 1; j <= R; ++j)
		{
			if((i * j) % 2019 < (besti * bestj) % 2019)
				besti = i, bestj = j;
		}
	}

	cout << (besti * bestj) % 2019 << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int X;
    cin >> X;
    if(X>=30){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pll pair<ll,ll>
#define vi vector < int >
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define s(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define flash ios_base::sync_with_stdio(false);cin.tie(0)
#define goog(x) cout << "Case #" << x << ": "
#define MAX5 200005
#define MAX6 2000005
#define MLOG 18
#define limit 1e18
#define mod 1000000007   
void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int power(int x, int y, int p){
    int res = 1;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int v[MAX5];

string noOf(int x){
	int r = 0;
	string t = "";
	while(x){
		r = x % 10;
		t += (r + '0');
		x /= 10;
	}
	reverse(all(t));
	return t;
}

void solve(){
    int n, m;
    cin >> n;
    if(n%1000){
        cout << (n/1000 + 1)*1000 - n << endl;
    }
    else{
        cout << 0 << endl;
    }
} 
signed main(){  
//   freopen("output.txt", "r", stdin);
//   freopen("tt.txt", "w", stdout);
    // flash;
    int t = 1;
    //  cin >> t;  
    for(int tc = 1; tc <= t; tc++){
    // goog(tc);
        solve();
		if(tc != t) cout << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int D = 1000;
  int n = s.size();
  for(int i = 0 ;i< n -2 ;i++){
    int num = (s.at(i) - '0')*100 + (s.at(i+1) - '0')*10 + (s.at(i+2) -'0');
    int d = 753 - num;
    if( d < 0){
      d = -d;
    }
    D = min(D,d);
  }
  cout << D;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main( void )
{
  string s;
  while( 1 ){
    getline( cin, s );
    if( cin.eof() ) break;
    while( 1 ){
      for( int i=0; i<s.size(); i++ ){
        if( s[i] == 'z' ) s[i] = 'a';
        else if( 'a' <= s[i] && s[i] < 'z' ) s[i]++;
      }
      if( s.find( "the",  0 ) != string::npos ){ cout << s << endl; break; }
      if( s.find( "this", 0 ) != string::npos ){ cout << s << endl; break; }
      if( s.find( "that", 0 ) != string::npos ){ cout << s << endl; break; }
    }
  }
  return 0;
}

Measured memory_bytes: 0
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
num = Counter(a)

if n == len(num)+1 or n == len(num):
    print(0)
    exit()

ans = []

for i in num:
    if num[i] >= 2:
        ans.append(i)
    if num[i] >= 4:
        ans.append(i)     
n = max(ans)
ans.pop(ans.index(max(ans)))
m = max(ans)
print(n*m)


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


int main(){
	int N;cin>>N;
	map<int,int> m;
	for(int i=0;i<N;i++){
		int x;cin>>x;
		if(m.count(x-1) == 0) m[x] = 1;
		else m[x] = m[x-1] + 1;
	}
	int ans = 0;
	for(auto p: m) ans = max(p.second,ans);
	cout<<N-ans<<endl;
	return 0;
}


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

using namespace std;

#define Vi vector<int>
#define FOR(i,s,e) for (int i=s; i<e; i++)
#define ITER(v) v.begin(), v.end()

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

    int64_t a, b;
    int64_t gcd;
    int64_t minval;
    bool iscoprime;

    while (true) {
        cin >> a >> b;
        if (cin.eof()) { break; }
        gcd = 1;
        while (true) {
            iscoprime = true;
            minval = min(a,b);
            FOR(i,2,minval+1) {
                if (a % i == 0 && b % i == 0) {
                    a /= i;
                    b /= i;
                    gcd *= i;
                    iscoprime = false;
                    break;
                }
            }
            if (iscoprime) { break; }
        }
        cout << gcd << " " << gcd * a * b << endl;
    }

    return 0;
}

Measured memory_bytes: 3072
#include<stdio.h>
#include<math.h>
int Sosu(int N){
  int i=3;
if(N==2)return 1;
if(N<2 || N%2==0)return 0;
while(i<=sqrt(N)){
  if(N%i==0)return 0;
  i=i+2;
}
return 1;
}
int main(void){
int N;
int n,i;
int S=0,c=0;
while(1){
scanf("%d",&n);
if(n>=1 && n<=10000)break;
}
for(i=0 ; i<n ; i++){
  while(1){
  scanf("%d",&N);
  if(N>=2 && N<=100000000)break;
  }
  S+=Sosu(N);
}
printf("%d\n",S);
return 0;
}


Measured memory_bytes: 2052
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 2020
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
const int n=read()*3,mod=read(),base=6000;
int dp[3*N][6*N],ans;
int main(){
	dp[0][base]=1;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=(base<<1);++j){
			dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod;
			if(i>=2)dp[i][j]=(dp[i][j]+1LL*dp[i-2][j+1]*(i-1))%mod;
			if(i>=3)dp[i][j]=(dp[i][j]+1LL*dp[i-3][j]*(i-2)%mod*(i-1))%mod;
		}
	}
	for(int i=base;i<=(base<<1);++i){
		ans=(ans+dp[n][i])%mod;
	}
	printf("%d\n",ans);
	return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int n; cin>>n;
  if (n<=999) out("ABC");
  out("ABD");
  

  return 0;
}


Measured memory_bytes: 256
let a, b, x = Scanf.scanf " %f %f %f" @@ fun a b c -> a, b, c
let f r = 180. *. r /. acos (-1.) |> Printf.printf "%.10f\n"
let _ = f @@ if x <= b *. a *. a /. 2. then let d = 2. *. x /. (a *. b) in let k = sqrt (b *. b +. d *. d) in acos @@ 2. *. x /. (a *. k) /. b
  else let s = a *. b -. x /. a in let l = 2. *. s /. a in acos @@ a /. sqrt (a *. a +. l *. l)

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long w,h,o,t,ans=0;
  cin >> w >> h;
  o=h+1;
  t=w+1;
  vector<pair<long,long>> pq(w+h,{0,0});
  for(long i=0;i<w;i++) {
    cin >> pq[i].first;
    pq[i].second=1;
  }
  for(long i=0;i<h;i++) {
    cin >> pq[w+i].first;
    pq[w+i].second=2;
  }
  sort(pq.begin(),pq.end());
  for(long i=0;i<h+w;i++) {
    if(pq[i].second==1) {
      ans+=pq[i].first*o;
      t--;
    } else {
      ans+=pq[i].first*t;
      o--;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 6344
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c, d);
    Cout((a-1)/2);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
const int mod=1e9+7;
const int N=1e3+5;
int dp[N][N];
char s[N]; 
int main()
{
	int h,w,i,j;
	scanf("%d%d",&h,&w);
	dp[1][1]=1;
	for(i=1;i<=h;i++)
	{
		scanf("%s",s+1);
		for(j=1;j<=w;j++)
		{
			if((i!=1||j!=1)&&s[j]!='#') dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
		}
	}
	printf("%d\n",dp[h][w]);
	return 0;
}

Measured memory_bytes: 4224
#include<stdio.h>
#define MAX 100

int main(){
  int A[MAX];
  int i,j,minj,N,swap,count = 0;

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

  for(i=0; i<N; i++){
    minj = i;
    for(j=i; j<N; j++){
      if(A[j] < A[minj]) minj = j;     
    }
    if(i!=minj){
    swap = A[i];
    A[i] = A[minj];
    A[minj] = swap;
    count++;
    }
  }

  for(i=0; i<N; i++){
    printf("%d",A[i]);
    if(i==N-1) break;
    printf(" ");
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2128
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#include <stack>
#include <iomanip>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 100000

using namespace std;
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
double PI = atan2(0, -1);
int main () {
    double a, b, x;
    cin >> a >> b >> x;
	x /= a;
	double alpha;
	if (2*x <= a*b) {
		alpha = atan2(b, 2*x/b);
	} else {
		alpha = atan2(2*(a*b- x)/a, a);
	}
	cout << fixed << setprecision(10) << alpha / PI * 180  << endl;
    return 0;
}

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

int main()
{
	map<int, int> calander;
	int N;
	while (cin >> N)
	{
		int left = (N / 100);
		int right = N % 100;
		bool leftm = 0, rightm = 0;
		if (left > 0 && left <= 12)
		{
			leftm = 1;
		}
		if (right >= 1 && right <= 12)
		{
			rightm = 1;
		}
		if (leftm && rightm)
		{
			cout << "AMBIGUOUS" << '\n';
		}
		else if (leftm)
		{
			cout << "MMYY" << '\n';
		}
		else if(rightm)
		{
			cout << "YYMM" << '\n';
		}
		else
		{
			cout << "NA" << '\n';
		}
	}
}



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

int main(){
    int n;
    cin >> n;
    int p[500000];
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    int count = 0;
    int min = 300000;
    for(int i=0; i<n; i++){
        if(p[i] < min){
            min = p[i];
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>
#include <list>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
//#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;

int main(void)
{
    lli A, B, N; cin >> A >> B >> N;
    lli x = less(B - 1, N);
    lli ans = A * x / B - (x / B) * A;
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3624
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())
  
n=i()
a=intl()
a.sort()
alice=0
bob=0
for i in range(1,n+1):
	if i%2==1:
		alice+=a[-i]
	else:
		bob+=a[-i]
print(alice-bob)

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int x,y;cin>>x>>y;

  int a[]={1,3,5,7,8,10,12};
  int b[]={4,6,9,11};

  int t=0;
  for(int i=0;i<7;i++){
    if(a[i]==x||a[i]==y){
      t++;
    }
  }
  if(t==2){cout<<"Yes"<<endl;return 0;}
  t=0;
  for(int i=0;i<4;i++){
    if(b[i]==x||b[i]==y){
      t++;
    }
  }
  if(t==2){cout<<"Yes"<<endl;return 0;}
  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll M = 1e9 + 7;
const int iinf = 1 << 29;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mrand(ll B) {
  return (ull)rng() % B;
}

void work() {
    int n; cin>>n;
    ll ans = 0;
    for (ll i = 1; i <= n; ++i) {
        ll f = n/i;
        ans += i * ((f*f + f)>>1);
    }
    cout << ans << endl;
    /*
    int n; cin>>n;
    vector<vector<int>> s(n+1, vector<int>(50));
    vector<int> p(n+1, 0);
    for (ll i = 2; i <= n; ++i) {
        if (p[i] == 0) {
            s[i][p[i]++] = i;
            for (int j = i + i; j <= n; j += i)
                s[j][p[j]++] = i;
        }
    }

    ll ans = 1;
    for (ll i = 2; i <= n; ++i) {
        ll cur = 1;
        ll c = i;
        for (int j = 0; j < p[i]; ++j) {
            int nd = 0;
            while (c%s[i][j] == 0) {
                ++nd;
                c /= s[i][j];
            }
            cur *= nd + 1;
        }
        ans += i * cur;
    }
    cout << ans << endl;
    */
    /*
    int n; cin>>n;
    vector<int> a(n);
    for (auto& e : a) cin>>e;
    vector<int> b(n);
    for (auto& e : b) cin>>e;
    priority_queue<pair<ll, int>> c;
    for (int i = 0; i < n; ++i) {
        c.push({a[i], i});
    }

    sort(b.begin(), b.end());
    reverse(b.begin(), b.end());
    vector<int> ans(n, -1);
    for (auto e : b) {
        pair<ll, int> t = c.top();
        int prev = t.second == 0 ? n - 1 : i - 1;
        while (ans[t.second] != -1 && ans[prev] != -1) {
            c.pop();
            t = c.top();
            prev = t.second == 0 ? n - 1 : i - 1;
        }
        c.pop();
        c.push({t.first - e, t.second})
        if (ans[t.second] == -1)
    }
    */

}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}


Measured memory_bytes: 3660