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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

template<typename T>
class WeightedUnionFind {
    int N;
    vector<int> par;
    vector<int> rank;
    vector<int> size;
    vector<T> weight;

public:
    explicit WeightedUnionFind(int n) : N(n + 1) {
        par.resize(n + 1);
        rank.resize(n + 1, 0);
        weight.resize(n + 1, 0);
        size.resize(n + 1, 1);
        for (int i = 0; i < n + 1; ++i) {
            par[i] = i;
        }
    }

    int find(int x) {
        if (par[x] == x) return x;
        int y = find(par[x]);
        weight[x] += weight[par[x]];
        par[x] = y;
        return y;
    }

    bool is_same(int x, int y) {
        return find(x) == find(y);
    }

    T get_weight(int x) {
        find(x);
        return weight[x];
    }

    /**
     * x -> y の重みの差分
     */
    T diff(int x, int y) {
        return get_weight(y) - get_weight(x);
    }

    /**
     * get_weight(y) - get_weight(x) = w となるように結合
     * @return true:　結合成功, false: すでに結合済み
     */
    bool unit(int x, int y, T w) {
        w += get_weight(x);
        w -= get_weight(y);
        x = find(x);
        y = find(y);
        if (x == y) return false;
        // 木の高さの低い方から高い方へ繋げる
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        weight[y] = w;
        size[x] += size[y];
        return true;
    }
};

void Main() {
    ll N, Q;
    cin >> N >> Q;
    WeightedUnionFind<ll> weightedUnionFind(N);
    rep(q, Q) {
        int query;
        cin >> query;
        if (query) {
            int x, y;
            cin >> x >> y;
            if (weightedUnionFind.is_same(x, y)) {
                cout << weightedUnionFind.diff(x, y) << '\n';
            } else {
                cout << "?" << '\n';
            }
        } else {
            ll x, y, z;
            cin >> x >> y >> z;
            weightedUnionFind.unit(x, y, z);
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 5024
#include <stdio.h>

int main(void)
{
	int n, res1, res2;

	scanf("%d", &n);
	res1 = n / 10;
	res2 = n % 1000;
	if (res1 % 111 == 0 || res2 % 111 == 0)
		printf("Yes\n");
	else 
		printf("No\n");

	return 0;
}

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

int main(){
  int i;
  int A, B, K, count;
  cin >> A >> B >> K;
  for(i=min(A,B);i>0;i--){
    if(A%i==0 && B%i==0) count++;
    if(count==K){
      cout << i << endl;
      return 0;
    }
  }
}

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

int main() {
  string y;
  string k;
  cin >> y;
  cin >> k;
  
  int x;
  for (int i = 0; i < 3; i++) {
    if (y.at(i) == k.at(i))
      x++;
  }
  cout << x <<endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
num=0
array=[99999 for i in range(n)]
for _ in range(m):
  s,c = map(int,input().split())
  if array[s-1]==99999 or array[s-1]==c:
    array[s-1]=c
  else:
    array=[-1 for i in range(n)]
    break

if not n==1:
  for i in range(n):
    if not i==0:
      if array[i]==99999:
        array[i]=0
    else:
      if array[i]==99999:
        array[i]=1
  if array[0]==-1 or array[0]==0:
    num=-1
  else:
    num=int(''.join(list(map(str,array))))
else:
  if array[0]==99999:
    num=0
  else:
    num=array[0]
print(num)
    
    


Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

#define mod 1000000007
int n,m;
char s[1005][1005],tmp[1005][1005];
long long k;
struct Matrix{
    long long mat[5][5];
    Matrix(){memset(mat,0,sizeof(mat));}
    Matrix operator*(const Matrix &b)const{
        Matrix c;
        for(int i=1;i<=2;i++)
        for(int j=1;j<=2;j++){
            for(int k=1;k<=2;k++)
                c.mat[i][j]+=mat[i][k]*b.mat[k][j];
            c.mat[i][j]%=mod;
        }
        return c;
    }
    Matrix operator^(long long x)const{
        Matrix a(*this),ans;
        for(int i=1;i<=2;i++)ans.mat[i][i]=1;
        while(x){
            if(x&1)ans=ans*a;
            x>>=1,a=a*a;
        }
        return ans;
    }
}mat;

int qpow(int x,long long y){
    int ans=1;
    while(y){
        if(y&1)ans=1LL*ans*x%mod;
        y>>=1,x=1LL*x*x%mod;
    }
    return ans;
}

bool check(){
    for(int i=1;i<=n;i++)
        if(s[i][1]=='#'&&s[i][m]=='#')return true;
    return false;
}

void turn(){
    for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
        tmp[m-j+1][i]=s[i][j];
    swap(n,m);
    memcpy(s,tmp,sizeof(s));
}

int main(){
    scanf("%d%d%lld",&n,&m,&k);
    int x=0,y=0,z=0;
    for(int i=1;i<=n;i++){
        scanf("%s",s[i]+1);
        for(int j=1;j<=m;j++)x+=s[i][j]=='#';
    }   
    bool a=check(),b=(turn(),check());turn();
    if(a&&b)return printf("1"),0;
    else if(!a&&!b)return printf("%d",qpow(x,k-1)),0;
    else if(b)turn();
    for(int i=1;i<=n;i++)
        z+=s[i][1]=='#'&&s[i][m]=='#';
    for(int i=1;i<=n;i++)
    for(int j=1;j<m;j++)y+=s[i][j]=='#'&&s[i][j+1]=='#';
    mat.mat[1][1]=x,mat.mat[1][2]=y,mat.mat[2][2]=z;
    mat=mat^(k-1);
    printf("%lld",(mat.mat[1][1]-mat.mat[1][2]+mod)%mod);
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int x[110];
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	for(int i = a;i<b;i++) x[i] ++;
	for(int i = c;i<d;i++) x[i] ++;
	int ans = 0;
	for(int i = 0;i<=100;i++)
		if(x[i] == 2) ans++;
	cout<<ans<<endl;
}


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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int a[n + 1];
  memset(a, 0, sizeof a);
  int u, v;
  while (m--) {
    cin >> u >> v;
    a[u]++;
    a[v]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int val = 0;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < k && a + i <= b; i++) {
			sb.append(a + i).append("\n");
			val = a + i;
		}
		for (int i = k - 1; i >= 0; i--) {
			int x = b - i;
			if (x <= val) {
				continue;
			}
			sb.append(x).append("\n");;
		}
		System.out.print(sb);
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
#define int long long
signed main(void){
    int n;
    cin>>n;
    vector <int> a(n), b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    sort(b.begin(),b.end());
    int ans = 0;
    
    for(int i = 29; i>=0;i--){
        int tmp = 1<<(i+1);
        int bottom = 1<<i;
         
        rep(j,n) {a[j]%=tmp;  b[j]%=tmp;}
        sort(b.begin(),b.end());
        int add = 0;
        rep(j,n){
            add += lower_bound(b.begin(), b.end(), 2*bottom - a[j]) - lower_bound(b.begin(), b.end(), bottom - a[j]);
            add += lower_bound(b.begin(), b.end(), 4*bottom - a[j]) - lower_bound(b.begin(), b.end(), 3*bottom - a[j]);
        }
        //cout<<add<<endl;
        if(add&1) ans += bottom;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include<iostream> 
#include<algorithm>
#include<vector>
#include<cstring>
#define pii pair<int,int>
using namespace  std;
int n,m,l,r,d;
bool ok=0,used[100005];
int distan[100005];
vector<pii> v[100005];
void dfs(int x,int dist)
{
	if(used[x])
	{
		if(distan[x]!=dist)ok=1;
		return;
	}
	used[x]=1;
	distan[x]=dist;
	for(int i=0;i<v[x].size();i++)
	{
		int nx=v[x][i].first,nd=v[x][i].second;
		dfs(nx,dist+nd);
		if(ok)return;
	}
}
int main()
{
	cin>>n>>m;
    for(int k=0;k<m;k++)
    {
    	cin>>l>>r>>d;
    	v[l].push_back(pii(r,d));
    	v[r].push_back(pii(l,-d)); 
	}
	for(int i=1;i<=n;i++)
	if(!used[i])
	{
		dfs(i,0);
		if(ok){cout<<"No\n";return 0;}
	}
	cout<<"Yes\n";return 0;
}

Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,mod=1e9+7;
int n,k,tot,head[N],nex[N<<1],to[N<<1],d[N],dep[N],son[N];
bool flag;
ll ans,f[N],invf[N];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
ll c(ll n,ll m)
{
    return f[n]*invf[n-m]%mod*invf[m]%mod;
}
void add(int u,int v)
{
    to[++tot]=v;nex[tot]=head[u];head[u]=tot;
}
void dfs1(int u,int fa,int dis)
{
    d[u]=dis;
    dep[dis]++;
    for(int i=head[u];i;i=nex[i])
        if(to[i]!=fa)
        dfs1(to[i],u,dis+1),son[u]++;
}
void dfs2(int u,int fa)
{
    if(son[u]==0||flag) return;
    int sum=k-2;
    if(u==1) sum++;
    if(sum<son[u]) {flag=true;return;}
    ans=ans*f[son[u]]%mod*c(sum,son[u])%mod;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];
        if(v==fa) continue;
        dfs2(v,u);
    }
}
int main()
{
    f[0]=invf[0]=1;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=max(n,k);i++)
        f[i]=f[i-1]*i%mod,invf[i]=qpow(f[i],mod-2);
    for(int i=1;i<n;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v);
        add(v,u);
    }
    dfs1(1,0,1);
    ans=k;
    dfs2(1,0);
    if(flag) printf("0\n");
    else printf("%lld\n",ans);
}


Measured memory_bytes: 8448
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
#define sp cout<<"---------------------------------------------------"<<endl
const long long inf=2e15+7;
long long pre[200010]; 
int main(){
      long long n,i,x,p1,p2,p3,minn,P;
      cin>>n;
      for(i=1;i<=n;i++){
      	scanf("%lld",&x);
      	pre[i]=pre[i-1]+x;
      }
      p1=1,p2=2,p3=3;
      long long ans=inf;
      for(p2;p2<n;p2++){
        minn=inf;
        for(i=p1;i<p2;i++)
          if(abs(pre[i]-(pre[p2]-pre[i]))<minn){
            minn=abs(pre[i]-(pre[p2]-pre[i]));
            p1=i;
          }else break;
        minn=inf;
        if(p3<=p2)p3=p2+1;
        for(i=p3;i<=n;i++)
          if(abs((pre[i]-pre[p2])-(pre[n]-pre[i]))<minn){
            minn=abs((pre[i]-pre[p2])-(pre[n]-pre[i]));
            p3=i;
          }else break;
        minn=inf;long long maxn=0;
        minn=min(pre[p1],min(pre[p2]-pre[p1],min(pre[p3]-pre[p2],pre[n]-pre[p3])));
        maxn=max(pre[p1],max(pre[p2]-pre[p1],max(pre[p3]-pre[p2],pre[n]-pre[p3])));
        ans=min(ans,maxn-minn);
      }
      cout<<ans<<endl;
	  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(){
  int fib[45] = {1,1};
  int i; 
  for (i=2;i<45;i++){
    fib[i]=fib[i-1]+fib[i-2];
  }
  scanf("%d", &i);
  printf("%d\n",fib[i]);

  return 0;
}



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


def solve(a: int, b: int):
    return str(a) * b if a < b else str(b) * a


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    print(solve(a, b))

if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    vector<long long int> sum(N,0);
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        sum[a]++;
        sum[b]++;
    }

    for(int i=0;i<N;i++){
        if(sum[i]%2==1){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n;
  cin>>n;
  vector<string> l={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
  string ans="";
  while(n){
    int a=n%26;
    if(a==0){
      ans+=l[25];
      n=n/26-1;
    }
    else{
      ans+=l[a-1];
      n=n/26;
    }
  }
  for(int i=0;i<ans.size();i++){
    cout<<ans[ans.size()-i-1];
  }
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define    For(i,n) for(int i=0;i<n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    nl     "\n"
#define    test   int t;cin>>t;for(int l=0;l<t;l++)
#define    End    return 0
#define    gt     greater<int>()
#define    ll     long long int

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

    //test
    {
        int n,c=0;
        cin>>n;
        int a[n];
        For(i,n)cin>>a[i];
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                for(int k=j+1;k<n;k++){
                    if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k] and 
                    a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i])c++;
                }
            }
        }
        cout<<c;
    }
}


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

using namespace std;
using ll = long long;

// Union-Find木
// 宣言は UnionFind uf(N); のようにする
// find(x) : xの根を求める
// same(x, y) : xとyが同じ集合に属するかどうか
// size(x) : xの属する集合の要素数
// size() : 集合がいくつあるか
// unite(x, y) : xとyの属する集合を併合する
struct UnionFind {
private:
	vector<int> uf;
	size_t sz;

public:
	UnionFind(size_t Size) {
		uf.assign(Size, -1);
		sz = Size;
	}

	int find(int x) { return (uf[x] < 0) ? x : uf[x] = find(uf[x]); }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -uf[find(x)]; }
	int size() { return sz; }

	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) { return; }
		--sz;

		if (uf[y] < uf[x]) { swap(x, y); }
		uf[x] += uf[y];
		uf[y] = x;
	}
};

int main() {
	ll N, M;
	cin >> N >> M;
	vector<int> a(M);
	vector<int> b(M);
	for (int i = 0; i < M; ++i) {
		cin >> a[i] >> b[i];
	}

	UnionFind uf(N + 1);
	vector<ll> res(M, 0);
	res[M - 1] = (N - 1) * N / 2;
	for (int i = M - 1; i > 0; --i) {
		if (uf.same(a[i], b[i])) {
			res[i - 1] = res[i];
			continue;
		}
		ll s = uf.size(a[i]);
		ll t = uf.size(b[i]);
		res[i - 1] = res[i] - (s * t);
		uf.unite(a[i], b[i]);
	}

	for (int i = 0; i < M; ++i) {
		cout << res[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

using namespace std;

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

//void sort_erase(vector<int> &num);



int main() {
	
	unsigned long long int s, c,sum;

	cin >> s >> c;

	sum = 0;

	if (s < c) {
		sum += s;
		c -= 2*s;
		sum += (c / 4);
		
	}
	else {
		sum += c / 2;
	}

	

	cout << sum << endl;
	


	return 0;
}


//
//void sort_erase(vector<int> &num) {
//	std::sort(num.begin(), num.end());
//	num.erase(std::unique(num.begin(), num.end()), num.end());
//}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
int n;
vector<int> vx[4][200010], vy[4][200010], va[4][400010], vb[4][400010];

string s = "URDL";

int main() {
    cin >> n;
    int ans = mod;
    for (int i = 0; i < n; i++) {
        int xx,yy;
        char u;
        cin >> xx >> yy >> u;
        for (int j = 0; j < 4; j++) {
            if (u == s[j]) {
                vx[j][xx].push_back(yy);
                vy[j][yy].push_back(xx);
                va[j][xx-yy+200000].push_back(xx);
                vb[j][xx+yy].push_back(xx);
            }
        }
    }

    for (int i = 0; i <= 200000; i++) {
        for (int j = 0; j < 4; j++) {
            sort(vx[j][i].begin(), vx[j][i].end());
            sort(vy[j][i].begin(), vy[j][i].end());
        }
        //Down Up
        for (int j = 0; j < vx[0][i].size(); j++) {
            auto pos = lower_bound(vx[2][i].begin(), vx[2][i].end(), vx[0][i][j]);
            if (pos != vx[2][i].end()) {
                ans = min(ans, *pos - vx[0][i][j]);
            }
        }
        //Left Right
        for (int j = 0; j < vy[1][i].size(); j++) {
            auto pos = lower_bound(vy[3][i].begin(), vy[3][i].end(), vy[1][i][j]);
            if (pos != vy[3][i].end()) {
                ans = min(ans, *pos - vy[1][i][j]);
            }
        }
    }

    for (int i = 0; i <= 400000; i++) {
        for (int j = 0; j < 4; j++) {
            sort(va[j][i].begin(), va[j][i].end());
            sort(vb[j][i].begin(), vb[j][i].end());
        }
        //Right Down -a
        for (int j = 0; j < va[1][i].size(); j++) {
            auto pos = lower_bound(va[2][i].begin(), va[2][i].end(), va[1][i][j]);
            if (pos != va[2][i].end()) {
                ans = min(ans, (*pos - va[1][i][j]) * 2);
            }
        }
        //Up Left -a
        for (int j = 0; j < va[0][i].size(); j++) {
            auto pos = lower_bound(va[3][i].begin(), va[3][i].end(), va[0][i][j]);
            if (pos != va[3][i].end()) {
                ans = min(ans, (*pos - va[0][i][j]) * 2);
            }
        }
        //Down Left -b
        for (int j = 0; j < vb[2][i].size(); j++) {
            auto pos = lower_bound(vb[3][i].begin(), vb[3][i].end(), vb[2][i][j]);
            if (pos != vb[3][i].end()) {
                ans = min(ans, (*pos - vb[2][i][j]) * 2);
            }
        }
        //Up Right -b
        for (int j = 0; j < vb[1][i].size(); j++) {
            auto pos = lower_bound(vb[0][i].begin(), vb[0][i].end(), vb[1][i][j]);
            if (pos != vb[0][i].end()) {
                ans = min(ans, (*pos - vb[1][i][j]) * 2);
            }
        }
    }
    if (ans == mod) {
        cout << "SAFE" << endl;
    } else {
        cout << ans*5 << endl;
    }
    return 0;
}

Measured memory_bytes: 138636
//=====================COMPILER OPTIMIZATION STARTS=======================
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
//======================COMPILER OPTIMIZATION ENDS=======================

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

#define ll long long int
#define pi pair<ll,ll>

ll power(ll x, ll y, ll mod = 1e9+7){
    ll res = 1;
    while(y > 0){
        if(y & 1)
            res = (res * x) % mod;
        y = y >> 1;
        x = (x*x)% mod;
    }
    return res % mod;
}

void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << ' ' << b << ' ' << c << '\n';

}

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

    int test = 1;
    // cin >> test;
    while(test--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
ll MOD = 1000000007;
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main()
{   
    int n; cin >> n;
    vector<pair<int,int> > a(n);
    rep(i,n){
        int j; cin >> j;
        a[i]=make_pair(j,i+1);
    }
    sort(all(a));
    rep(i,n){
        if(i!=0) cout <<" ";
        cout << a[i].second;
    }
    cout << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int M = nextInt();
  cout << 24 + (24 - M) << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main() {
    int N; cin>>N;
    for(int i=1;i<=N;i++){
        if(i*(i+1)/2>=N){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <queue>
#include <map>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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 ll = long long;

ll X, Y, Z, K;
ll A[1010], B[1010], C[1010];

using P = std::pair<int, int>;
using PP = std::pair<int, P>;

std::map<PP, ll> mp;

struct Dat {
  ll sum;
  ll ai, bi, ci;

  Dat( ll sum, ll ai, ll bi, ll ci )
  : sum(sum), ai(ai), bi(bi), ci(ci)
  {}

  bool operator< ( const Dat & d ) const
  {
    return sum < d.sum;
  }
};

int main()
{
  scanf( "%lld%lld%lld%lld", &X, &Y, &Z, &K );
  rep( i, X )
    scanf( "%lld", A+i );
  rep( i, Y )
    scanf( "%lld", B+i );
  rep( i, Z )
    scanf( "%lld", C+i );
  
  std::sort( A, A+X );
  std::sort( B, B+Y );
  std::sort( C, C+Z );

  std::priority_queue<Dat> pque;
  pque.push( Dat( A[X-1]+B[Y-1]+C[Z-1], X-1, Y-1, Z-1 ) );

  ll cnt = 0;

  while( !pque.empty() )
  {
    Dat dat = pque.top(); pque.pop();

    ++cnt;

    if( cnt > K )
      break;

    printf( "%lld\n", dat.sum );

    if( dat.ai > 0 ) if( !mp[PP(dat.ai-1, P(dat.bi, dat.ci))] )
      pque.push( Dat( dat.sum-A[dat.ai]+A[dat.ai-1], dat.ai-1, dat.bi, dat.ci ) ), ++mp[PP(dat.ai-1, P(dat.bi, dat.ci))];
    if( dat.bi > 0 ) if( !mp[PP(dat.ai, P(dat.bi-1, dat.ci))] )
      pque.push( Dat( dat.sum-B[dat.bi]+B[dat.bi-1], dat.ai, dat.bi-1, dat.ci ) ), ++mp[PP(dat.ai, P(dat.bi-1, dat.ci))];
    if( dat.ci > 0 ) if( !mp[PP(dat.ai, P(dat.bi, dat.ci-1))] )
      pque.push( Dat( dat.sum-C[dat.ci]+C[dat.ci-1], dat.ai, dat.bi, dat.ci-1 ) ), ++mp[PP(dat.ai, P(dat.bi, dat.ci-1))];
  }

  return 0;
}

Measured memory_bytes: 896
// Problem : C - Sum of gcd of Tuples (Easy)
// Contest : AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define int long long
#define vi vector<int>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.resize(n,x)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()
using namespace std;
using namespace __gnu_pbds;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1e9+7;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};
template<class T>
T abst(T a)
{return a<0?-a:a;}
template<class T> using ordered_set=tree<
T,
null_type,
less_equal<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}
int ncr(int n,int r){
return (((fact[n]*inv[r])%md)*inv[n-r])%md;
}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int k;cin>>k;
int sum=0;
for(int i=1;i<=k;i++)
for(int j=1;j<=k;j++)
for(int l=1;l<=k;l++)
sum+=(__gcd(i,__gcd(j,l)));
cout<<sum;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap
 
ll mini(ll a,ll b){	return a<b?a:b;}
ll maxi(ll a,ll b){	return a>b?a:b;}
ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int n,k;
    cin>>n>>k;
 
    vector<int> A(n+4,0), cost(n+4,0);
 
    for(int i=1;i<=n;++i)   cin>>A[i];
 
    cost[0] = 1200000000;
    cost[1] = 0;
    cost[2] = abs(A[2]-A[1]);
 
    int curmin;
 
    for(int i=2;i<=n;++i){
        curmin = cost[i-1] + abs(A[i] - A[i-1]);
        for(int j=1;j<=k && i-j>=1; ++j) curmin = min(cost[i-j] + abs(A[i] - A[i-j]), curmin);
        cost[i] = curmin;
    }
 
    cout<<cost[n]<<"\n";
 
    return 0;
}

Measured memory_bytes: 3968
#include <stdio.h>

int h, w;
char map[101][101];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int ans[20];
void dfs(int i, int j, char tree){
  map[i][j] = '.';
  int x, y;
  for(int l = 0; l < 4; l++){
    x = j + dx[l];
    y = i + dy[l];
    if(y < h && y >= 0 && x < w &&  x >= 0 && map[y][x] == tree){
      dfs(y,x,tree);
    }
  }
  return;
}

int solve(){
  int sum = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(map[i][j] != '.'){
        dfs(i, j, map[i][j]);
        sum++;
      }
    }
  }
  return sum;
}

int main(){
  int n = 0;
  while(true){
    scanf("%d %d", &h, &w);
    if(h == 0 && w == 0)
      break;
    for(int i = 0; i< h; i++){
      scanf("%s",map[i]);
    }
    ans[n++] = solve();
  }
  for(int i = 0; i < n; i++){
    printf("%d\n",ans[i]);
  }
  return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;


int main(){

    long long money = 100;
    long long year = 0;

    long long x;

    cin >> x;

    while(money < x){
        year++;
        money = money * 1.01;
    }

    printf("%lld\n", year);

    return 0;
    
}

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

using namespace std;

const long long mod = 1e9+7;
const long long upperBound = 101010;

long long solve(long long n){
    
    long long ans = 1;
    
    for (int i = 1; i <= n; i++){
        ans *= 2;
        ans %= mod;
    }
    return ans;
}

int main(void){
    long long n;
    cin >> n;
    
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    vector<long long> cnt(upperBound);
    
    for (int i = 0; i < n; i++){
        cnt[a[i]]++;
    }
    
    bool check = true;
    
    if (n % 2 == 0){
        for (int i = 1; i < n; i += 2){
            if (cnt[i] != 2) check = false;
        }
        
        if (check){
            cout << solve(n/2) << endl;
            return 0;
        }
        else{
            cout << 0 << endl;
            return 0;
        }
    }
    else{
        
        if (cnt[0] != 1) check = false;
        
        for (int i = 2; i < n; i+=2){
            if (cnt[i] != 2) check = false;
        }
        
        if (check){
            cout << solve((n-1)/2) << endl;
            return 0;
        }
        else{
            cout << 0 << endl;
            return 0;
        }
    }
    
}


Measured memory_bytes: 1792
A = int(input()) #500円の枚数
B = int(input()) #100円の枚数
C = int(input()) # 50円の枚数
X = int(input()) #合計金額

D = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if 500*a + 100*b + 50*c == X:
        D += 1

print(D)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
int main(){
  int n;cin>>n;
  int a,sum=0;
  map<int,int>mp;
  rep(i,n-1){
    cin>>a;
    mp[a]++;
  }
  rep(i,n+1){
    if(i==0)continue;
    cout<<mp[i]<<endl;
  }
}

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

const long long INF = 1e18;
const int MAX = 2000005;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

ll modinv(ll a,ll m=MOD) {
    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;
}

void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i] =MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll COM(int n, int k){
    if (n<k)
        return 0;
    if (n<0 || k<0)
        return 0;
    return fac[n]*(finv[k]*finv[n - k]%MOD)%MOD;
}
int main(){
    ll r1,c1,r2,c2;cin>>r1>>c1>>r2>>c2;
    COMinit();
    ll res=0;
    for(ll i=r1;i<=r2;++i){
        res+=COM(i+c2+1,i+1)-COM(i+c1,i+1);res+=MOD;res%=MOD;
    }
    cout<<res<<endl;
    return 0;
}


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

using namespace std;

int N, M;
bool G[10][10];

bool CanVisitAllVertex(const vector<int> &vertexOrders) {
  for (int i = 0; i < N - 1; i++) {
    int current = vertexOrders[i];
    int next = vertexOrders[i + 1];
    if (!G[current][next]) {
      return false;
    }
  }
  return true;
}

int main() {
  memset(G, false, sizeof(G));

  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a][b] = true;
    G[b][a] = true;
  }

  vector<int> vertexOrders;
  for (int i = 0; i < N; i++) {
    vertexOrders.push_back(i);
  }

  int count = 0;
  do {
    if (CanVisitAllVertex(vertexOrders)) {
      count++;
    }
  } while (next_permutation(vertexOrders.begin() + 1, vertexOrders.end()));

  printf("%d\n", count);

  return 0;
}


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

using namespace std;

const int INF = 1e6;

int main(){
    int n, ma, mb;  cin >> n >> ma >> mb;
    vector<int> a(n), b(n), c(n);
    for (int i=0; i<n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    vector< vector< vector<int> > > dp(n+5, vector< vector<int> >(410, vector<int>(410, INF)));
    dp[0][0][0] = 0;

    for (int i=0; i<n; i++){
        for (int j=0; j<10*(i+2); j++){
            for (int k=0; k<10*(i+2); k++){
                if (dp[i][j][k] != INF){
                    dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
                    dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);
                }
            }
        }
    }

    int _a=ma, _b=mb;
    int ans=INF;
    while(_a < 410 && _b < 410){
        ans = min(ans, dp[n][_a][_b]);
        _a += ma;
        _b += mb;
    }

    cout << (ans == INF ? -1 : ans) << endl;

}

Measured memory_bytes: 31104
#include <iostream>
#include <queue>
#include <algorithm>
#include <set>

using namespace std; using ll=long long; const int INF=1e2; using P=pair<int,int>;

int main() {
  ll h,w,n; cin>>h>>w>>n;
  set<P> s1, s2;
  for(int i=0;i<n;i++) {
    int x,y; cin>>x>>y;
    s1.insert({x,y});
    for(int j=-1;j<=1;j++) {
      for(int k=-1;k<=1;k++) {
        if (2 <= x+j && x+j <= h-1 && 2 <= y+k && y+k <= w-1)
        s2.insert({x+j, y+k});
      }
    }
  }

  ll an[10]={(h-2)*(w-2)-s2.size()};

  for(P x:s2) {
    int sm=0;
    for(int i=x.first-1;i<=x.first+1;i++) {
      for(int j=x.second-1;j<=x.second+1;j++) {
        auto it = s1.find({i,j});
        if (it == s1.end() || *(it) != make_pair(i,j)) continue;
        sm++;
      }
    }
    an[sm]++;
  }
  for(int i=0;i<10;i++) {
    cout<<an[i]<<endl;
  }
}


Measured memory_bytes: 47104
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int a,b; cin >>a>>b;

    int soc = 1;
    int count = 0;
    while (soc < b) {
        soc -= 1;
        soc += a;
        count++;
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
using namespace std;
int main(){
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    bool ans=false;
    for(int i=a;i<=b;i++){
        if(i%k==0) ans=true;
    }
    if(ans)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    int xx[n];
    int yy[m];
    REP(i,n) cin >> xx[i];
    REP(i,m) cin >> yy[i];
    sort(xx,xx+n);
    sort(yy,yy+m);
    int xm = xx[n-1];
    int ym = yy[0];
 
    if(xm<ym && !(ym<=x||xm>=y)){
        cout << "No War\n";
    }else{
        cout << "War\n";
    }
    return 0;
}

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



void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

int main(void){
  int k,n;
  scanf("%d%d",&k,&n);
  int a[n];
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int ans=a[n-1]-a[0];
  for(int i=1;i<n;i++){
    int len=k-(a[i]-a[i-1]);
    chmin(&ans,len);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 2476
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e9
typedef long long ll;
using namespace std;
//�I�[�o�[�t���[�ɋC������您����������
//�m�F�Y���Ȃ您����������

struct P{
    int num;
    int count;
};
int main() {
    int n, k; cin >> n >> k;
    map<int, int> m;
    rep(i,n){
        int num; cin >> num;
        m[num]++;
    }
    vector<P> v;
    for(auto ma: m){
        v.push_back({ma.first,ma.second});
    }
    sort(v.begin(), v.end(), [](P a, P b){return a.count > b.count;});
    int ans = 0;
    if(v.size()<=k) cout << 0 << endl;
    else{
        for(int i = k; i < v.size(); i++){
            ans += v[i].count;
        }
        cout << ans << endl;
    }
    


    return 0;
}

Measured memory_bytes: 11768
#include <iostream>
#include <cstdio>
#include <cctype>
#include <stack>
#include <sstream>
#include <cstdlib>
#include <algorithm>
#include <cstring>
using namespace std;

int main(void){
  string str;
  while(getline(cin, str)){
    stringstream ss(str);
    stack<double> num;
    while(ss >> str){
      if(isdigit(*str.rbegin())){
        num.push(atof(str.c_str()));
      }else{
        double b = num.top(); num.pop();
        double a = num.top(); num.pop();
        double res = 0;
        switch(str[0]){
          case '+': res = a + b; break;
          case '-': res = a - b; break;
          case '*': res = a * b; break;
          case '/': res = a / b; break;
        }
        num.push(res);
      }
    }
    printf("%.6lf\n", num.top());
    num.pop();
  }
  return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
int main(){
  int D,i,j,sum;scanf("%d",&D);
  pair<int,vector<int>> ans;
  pair<int,int> k;
  int c[26],l[26] = {},up[26],down[26];
  for(i=0;i<26;i++) scanf("%d",&c[i]);
  for(i=0;i<D;i++){
    for(j=0;j<26;j++){
      scanf("%d",&up[j]);
      down[j] = (i-l[j]+1)*c[j];
    }
    sum = accumulate(down,down+26,0);
    ans = make_pair(-1000000000,vector<int>());
    for(j=0;j<26;j++){
      if(up[j]-sum+down[j] > ans.first){
        ans.first = up[j]-sum+down[j];
        ans.second = vector<int>({j});
      }
      else if(up[j]-sum+down[j] == ans.first){
        ans.second.push_back(j);
      }
    }
    k = make_pair(-1,-1);
    for(j=0;j<ans.second.size();j++){
      if(c[ans.second[j]] > k.first){
        k.first = c[ans.second[j]];
        k.second = ans.second[j];
      }
    }
    l[k.second] = i;
    printf("%d\n",k.second+1);
  }
}

Measured memory_bytes: 3788
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

#define FOR(i, l, r) for (int i = (l); i <= (r); ++i)

int main() {
#ifdef __APPLE__
    freopen("main.in", "r", stdin);
#endif
    int n, r; cin >> n >> r;
    if (n >= 10) cout << r << endl;
    else cout << r + 100 * (10 - n) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;

	scanf("%d", &n);

	if (400 <= n && n < 600)
		puts("8");
	else if (600 <= n && n < 800)
		puts("7");
	else if (800 <= n && n < 1000)
		puts("6");
	else if (1000 <= n && n < 1200)
		puts("5");
	else if (1200 <= n && n < 1400)
		puts("4");
	else if (1400 <= n && n < 1600)
		puts("3");
	else if (1600 <= n && n < 1800)
		puts("2");
	else
		puts("1");
	return 0;
}

Measured memory_bytes: 1656
#include <iostream>
using namespace std;
using ll = long long;

// xを絶対値で考え, k回の移動で0より先(マイナス)に行くかどうかで場合分けする.
// x/d > kということはk回移動しても0を越えないので, x-(d*k)が最終位置となる.
// x/d <= kなら途中で0を越える. 越えた後は元の位置に戻ってまた越えての繰り返し.
// 繰り返す回数はk-(x/d)で, その値が偶数なら0以右にいて, 奇数なら0以左にいる.

int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  
  x = abs(x);
  ll ans;	
  if (x / d > k) ans = x - (d * k);
  else {
    ll e = x / d;
    k -= e;
    x -= d * e;
    if (k % 2 == 1) x = abs(x - d);
    ans = x;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int n;
  cin >> n;
  cin.ignore();
  for(int i=0;i<n;i++){
    getline(cin,s);
    while(s.find("Hoshino")!=string::npos){
      s.replace(s.find("Hoshino"),7,"Hoshina");
    }
    cout<<s<<endl;
  }
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int &pi : p) cin >> pi;
    
    
    
    int cnt = 1;
    int ans = 0;
    rep3(i, 1, n) {
        if (p[i] > p[i - 1]) cnt++;
        else {
            if (cnt >= k) ans++;
            cnt = 1;
        }
    }
    if (cnt >= k) ans++;
    if (ans) ans--;
    
    set<int> s;
    int mmin = inf, mmax = -inf;
    rep(i, k) {
        s.insert(p[i]);
        chmin(mmin, p[i]);
        chmax(mmax, p[i]);
    }
    
    rep3(i, k, n) {
        int pop_ = p[i - k];
        s.erase(pop_);
        s.insert(p[i]);
        
        mmax = *(--s.end());
        // mminは前の最小値, mmaxは新しい最大値
        if (mmin == pop_ && mmax == p[i]) ans++;
        mmin = *s.begin();
    }
    
    ans = (n - k + 1) - ans;
    cout << ans << endl;
    
}


Measured memory_bytes: 10368
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
	string s;
	cin >> s;

	int len = 0, maxlen = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		if (s[i] == 'R')
		{
			++len;
			maxlen = max(maxlen, len);
		}
		else
		{
			len = 0;
		}
	}

	printf("%d\n", maxlen);


	return 0;
}

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

int main()
{
    int n,c=0;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        int x=i,k=0;
        while(x>0)
        {
            x/=10;
            k++;
        }
        if(k%2==1) c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fastcin {\
    cin.tie(0);\
    ios::sync_with_stdio(false);\
}
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i >= b; i--)
#define print(x) cout << x << "\n"
#define VSORT(v) sort(v.begin(), v.end());
typedef long long ll;

struct xyz {
    ll x, y, z;
};
int main() {
    fastcin;
    int n, m;
    xyz in;
    vector<xyz> e;
    ll ans = 0;
    cin >> n >> m;
    rep(i, 0, n) {
        cin >> in.x >> in.y >> in.z;
        e.push_back(in);
    }
    rep(i, 0, 8) {
        ll t, x = 0, y = 0, z = 0;
        int a, b, c;
        a = i&1 ? -1:1;
        b = i>>1 &1 ? -1:1;
        c = i>>2 &1 ? -1:1;
        vector<pair<ll, int> > l;
        rep(j, 0, n) {
            t = e[j].x * a + e[j].y * b + e[j].z * c;
            l.push_back(make_pair(t, j));
        }
        VSORT(l);
        rrep(j, n-1, n-m) {
            int num = l[j].second;
            x += e[num].x;
            y += e[num].y;
            z += e[num].z;
        }
        ans = max(ans, abs(x)+abs(y)+abs(z));
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 384
/**
 * Created by kaki on 2017/04/17.
 */

import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int c = Integer.parseInt(scan.next());
        if (a <= b && a <= c && b <= c) {
            System.out.println(a + " " + b + " " + c);
        } else if (a <= b && a <= c && c <= b) {
            System.out.println(a + " " + c + " " + b);
        } else if (b <= a && b <= c && a <= c) {
            System.out.println(b + " " + a + " " + c);
        } else if (b <= a && b <= c && c <= a) {
            System.out.println(b + " " + c + " " + a);
        } else if (c <= a && c <= b && a <= b) {
            System.out.println(c + " " + a + " " + b);
        } else if (c <= a && c <= b && b <= a) {
            System.out.println(c + " " + b + " " + a);
        }

    }
}

Measured memory_bytes: 26140
#include <bits/stdc++.h>
using namespace std;
int h,w;
vector<vector<int> >dp;
vector<vector<char> >a;
int main(){
	
	cin>>h>>w;
	dp=vector<vector<int> >(h+1,vector<int>(w+1,1e9));
	a=vector<vector<char> >(h+1,vector<char>(w+1,'.'));
	
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++)cin>>a[i][j];
	}	
	
	dp[1][0]=dp[0][1]=0;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(a[i][j]=='.')dp[i][j]=min(dp[i][j-1],dp[i-1][j]);
			else{
				dp[i][j]=min(dp[i][j],dp[i][j-1]+(a[i][j-1]=='.'));
				dp[i][j]=min(dp[i][j],dp[i-1][j]+(a[i-1][j]=='.'));
			}
		}
	}
	cout<<dp[h][w];
	return 0;
}


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




//----------------------------MACROS-------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 2e5 + 1;//                                                             |
//----------------------------------------------------------------------------------





//main func
void solve()
{
    
    ll n;cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        ll p=n/i;
        ll q=(p*(p+1))/2;
        ans+=q*i;
    }
    cout<<ans<<"\n";
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
	return 0;
}


Measured memory_bytes: 3620