akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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

int A[3][3];
bool ok[3][3];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i,3) REP(j,3) cin >> A[i][j];
    int N;
    cin >> N;
    REP(i,N){
        int b;
        cin >> b;
        REP(j,3) REP(k,3) if(A[j][k] == b) ok[j][k] = true;
    }
    bool bingo = false;
    REP(i,3){
        int cnt = 0;
        REP(j,3) if(ok[i][j]) cnt++;
        if(cnt >= 3) bingo = true;
    }
    REP(j,3){
        int cnt = 0;
        REP(i,3) if(ok[i][j]) cnt++;
        if(cnt >= 3) bingo = true;
    }
    int cnt = 0;
    REP(i,3) if(ok[i][i]) cnt++;
    if(cnt >= 3) bingo = true;
    cnt = 0;
    if(ok[0][2] && ok[1][1] && ok[2][0]) bingo = true;

    if(bingo) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  // 奇数が偶数個であればできる
  int odd = 0;
  for (int i = 0; i < N; i++) if (a[i] & 1) {
    odd++;
  }

  // 解答
  cout << (odd & 1 ? "NO" : "YES") << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int m = n;
  int s = 0;
  while (m > 0) {
    s += m % 10;
    m /= 10;
  }
  if (n % s == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3044
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>
#include<fstream>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

const int MOD = 1000000007;

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

    ofstream w_file("abc134_f.txt", ios::out);
    // for (ll n = 2; n <= 5; n++) {
    //     w_file << "n=" << n << "\n";
    //     vector<ll> perm(n);
    //     Rep (i, n) perm[i] = i;
    //     do {
    //         ll oddness = 0;
    //         Rep (i, n) {
    //             oddness += abs(i-perm[i]);
    //         }

    //         for (ll e : perm) {
    //             w_file << e << " ";
    //         }
    //         w_file << "k=" << oddness << "\n";
    //     } while (next_permutation(perm.begin(), perm.end()));
    // }

    ll n, kgiven;
    cin >> n >> kgiven;

    vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(n+1, vector<ll>(n*n+1, 0)));
    dp[0][0][0] = 1;
    Rep (i, n) {
        Rep (j, n+1) Rep (k, n*n+1) {
            // そのままペアにする
            if (k+2*j <= n*n) {
                dp[i+1][j][k+2*j] += dp[i][j][k];
                dp[i+1][j][k+2*j] %= MOD;
            }
            // 保留する
            if (j+1 <= n && k+2*j <= n*n) {
                dp[i+1][j+1][k+2*j] += dp[i][j][k];
                dp[i+1][j+1][k+2*j] %= MOD;
            }
            // 保留してた番号を対応させる
            if (k+2*j <= n*n) {
                dp[i+1][j][k+2*j] += j * dp[i][j][k];
                dp[i+1][j][k+2*j] %= MOD;
            }
            if (j-1 >= 0 && k+2*j <= n*n) {
                dp[i+1][j-1][k+2*j] += j*j*dp[i][j][k];
                dp[i+1][j-1][k+2*j] %= MOD;
            }
            if (k+2*j <= n*n) {
                dp[i+1][j][k+2*j] += j*dp[i][j][k];
                dp[i+1][j][k+2*j] %= MOD;
            }
        }
    }

    Rep (i, n+1) {
        Rep (j, n+1) {
            w_file << "i=" << i << " j=" << j << "\n";
            Rep (k, n*n+1) {
                w_file << dp[i][j][k] << " ";
            }
            w_file << "\n";
        }
    }

    cout << dp[n][0][kgiven] << endl;

}

Measured memory_bytes: 67968
package main                                              
                                                          
import "fmt"
import "strconv"
                                                          
func find(a []int, x int) int {
        for i, n := range a {           
                if x == n {                               
                        return i                
                }        
        }        
        return len(a)
}                                                         
                             
func main() {                                             
        var S string                                      
        var nums []int  
n := 3 // + or - が入る位置

        fmt.Scanf("%s", &S)

        for i := 0; i < len(S); i++ {
                num, _ := strconv.Atoi(S[i : i+1])
                nums = append(nums, num)
        }

        for bit := 0; bit < (1 << n); bit++ {
                var p []int
                for i := 0; i < n; i++ {
                        if bit&(1<<i) >= 1 {
                                p = append(p, i)
                        }
                }

                var result []string
                total := 0
                for i, num := range nums {
                        f := find(p, i-1)
                        if i == 0 {
                                total += num
                        } else if f < len(p) && p[f] == i-1 {
                                total += num
                                result = append(result, "+")
                        } else {
                                total -= num
                                result = append(result, "-")
                        }
                        result = append(result, strconv.Itoa(num))
                }

                var sentence string

                if total == 7 {
                        for _, re := range result {
                                sentence += re
                        }
                        fmt.Print(sentence + "=7")
                        return
                }
        }
}

Measured memory_bytes: 1840
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

N, K = map(int, input().split())

ans = [0] * (10**5+1)
for i in range(N):
    a, b = map(int, input().split())
    ans[a] += b

remain = K
for i in range(10**5+1):
    if ans[i] == 0:
        continue

    remain -= ans[i]
    if remain <= 0:
        print(i)
        exit()

Measured memory_bytes: 5744
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {
	int n,k;
	cin>>n>>k;int cnt = 0;
	
	while(n--) {
		int x;
		cin>>x;
		cnt+=2*min(x,k-x);
	}
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

int main() {
    int K,A,B;
    cin >> K >> A >> B;

  	int ans = K;
    while (ans <= B) {
        if (A <= ans && ans <= B) {
            cout << "OK" << endl;
            return 0;
        }
        ans += K;
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3636
/// awoooooo

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair < int, int > pii;

const int N = (int)4e6 + 5;
const int inf = (int)1e9 + 7;


int binpow(int x, int y){
  if(!y) return 1;
  int z = binpow(x, y >> 1);
  z = z * 1ll * z % inf;
  if(y & 1) z = z * 1ll * x % inf;
  return z;
}

int x, y;
int f[N], rf[N];

int cnk(int n, int k){
  return n < k ? 0 : (f[n] * 1ll * rf[n - k] % inf) * rf[k] % inf;
}

int main(){

  f[0] = 1;
  for(int i = 1; i < N; ++i) f[i] = f[i - 1] * 1ll * i % inf;
  rf[N - 1] = binpow(f[N - 1], inf - 2);
  for(int i = N - 2; i >= 0; --i){
    rf[i] = rf[i + 1] * 1ll * (i + 1) % inf;
  }
  cin >> x >> y;
  int ans = 0;
  for(int i = 0; i * 2 <= x && i <= y; ++i){
    if((y - i) % 2 || (x - i * 2) != (y - i) / 2){
      continue;
    }
    int steps = (y - i) / 2;
    (ans += cnk(steps + i, i)) %= inf;
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 31488
#include <stdio.h>
int main(int argc, char const *argv[]) {
  char s[6];
  scanf("%s",&s );
  for (size_t i = 0; s[i]!='\0'; i++) {
    if (s[i]=='A'&&s[i+1]=='C') {
      printf("Yes");
      return 0;
    }
  }
  printf("No");
  return 0;
}


Measured memory_bytes: 128
n,k = map(int,input().split())
d = []
a = []
u = set(range(1,n+1))
okashi = set()
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int,input().split())))

for i in a:
    for j in i:
        okashi.add(j)

print(len(u-okashi))

Measured memory_bytes: 9204
n,m = map(int,input().split())
mod = 10**9+7
dp = [[[0 for i in range(j+1)] for j in range(n+1)] for k in range(m+1)]
dp[0][1][1] = 1
for i in range(m):
  for j in range(n+1):
    for k in range(j+1):
      x = dp[i][j][k]
      if j < n:
        dp[i+1][j+1][k] += x*(n-j)
        dp[i+1][j+1][k] %= mod
      dp[i+1][j][j] = (dp[i+1][j][j]+x*k)%mod
      dp[i+1][j][k] = (dp[i+1][j][k]+x*(j-k))%mod
print(dp[m][n][n])

Measured memory_bytes: 158604
#include <stdio.h>
#include <stdlib.h>
int cmp(const long *a,const long *b){
  long g=*a-*b;
  if(g){
    if(g>0)return 1;
    else return -1;
  }else return 0;
}
int main(){
  long i,n,a[200001]={0},b,c=1,r=0;
  scanf("%ld",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&b);
    a[i+1]=a[i]+b;
  }
  qsort(a,n+1,sizeof(long),cmp);
  for(i=0;i<n;i++){
    if(a[i+1]==a[i])c++;
    else {
      r+=c*(c-1)/2;
      c=1;
    }
  }
  r+=c*(c-1)/2;
  printf("%ld",r);
  return 0;
}

Measured memory_bytes: 3324
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){

  double a[11111]={0};
  int i=0;
  while(scanf("%lf",&a[i]) != EOF){
    i++;
  }
  
  sort(a,a+i);

  cout << fabs(a[0]-a[i-1]) << endl;

  return 0;
}

Measured memory_bytes: 1384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,k,j,l,m1,m2;
    long long b1,b2,b3,b4,b5,b6,b7,b8,b9;
    b1=b2=b3=b4=b5=b6=b7=b8=b9=0;
    cin>>n;
    for(long long i=0;i<n;i++)
    {
        cin>>k;
        if(k>=1&&k<=399)
        {
            b1++;
        }
        else if(k>=400&&k<=799)
        {
            b2++;
        }
        else if(k>=800&&k<=1199)
        {
            b3++;
        }
        else if(k>=1200&&k<=1599)
        {
            b4++;
        }
        else if(k>=1600&&k<=1999)
        {
            b5++;
        }
         else if(k>=2000&&k<=2399)
        {
            b6++;
        }
         else if(k>=2400&&k<=2799)
        {
            b7++;
        }
        else if(k>=2800&&k<=3199)
        {
            b8++;
        }
        else
        {
            b9++;
        }
    }
    m1=m2=0;
    if(b1>0)
    {
        m1++;
    }
    if(b2>0)
    {
        m1++;
    }
    if(b3>0)
    {
        m1++;
    }
    if(b4>0)
    {
        m1++;
    }
    if(b5>0)
    {
        m1++;
    }
    if(b6>0)
    {
        m1++;
    }
    if(b7>0)
    {
        m1++;
    }
    if(b8>0)
    {
        m1++;
    }
    if(m1==0&&b9!=0)
    {
        m2=m1+b9;
        m1=1;

    }
    else if(m1!=0)
    {
        m2=m1+b9;

    }
    cout<<m1<<" "<<m2<<endl;
    return 0;


}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Maximum Volume
            var L = double.Parse(Console.ReadLine());

            var edge1 = L / 3;
            var edge2 = L - edge1 * 2;

            Console.WriteLine(edge1 * edge1 * edge2);
        }
    }
}

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


int main() {
int N;
cin >> N;
//vector<int> luca(N);  ←0~N-1　Nこ
//vector<int> luca(N+1); //←0~N: N+1こ int→int_64t 2*10^9をこえそうなとき
vector<int64_t> luca(N+1);

luca.at(0) = 2;
luca.at(1) = 1;
for(int i=2; i < N+1; i++){  //0~Nまで
   luca.at(i) = luca.at(i-2) + luca.at(i-1);
  }
   cout << luca.at(N) << endl;
   //printf("%d, luca(N )", luca(N ));
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

static class CodeJam
{
    static long Solve(int N, int K, int[][] values)
    {
        long max = 0;
        for (int i = 0; i < 30; ++i)
        {
            int bit = 1 << i;
            if ((bit & K) != 0)
            {
                int mask = K & ~bit | (bit - 1);
                long sum = 0;
                foreach (var v in values)
                {
                    if ((v[0] | mask) == mask) { sum += v[1]; }
                }
                max = Math.Max(sum, max);
            }
        }
        {
            long sum = 0;
            foreach (var v in values)
            {
                if ((v[0] | K) == K) { sum += v[1]; }
            }
            max = Math.Max(sum, max);
        }
        return max;
    }

    static void Main(string[] args)
    {
        var V1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int N = V1[0], K = V1[1];
        var values = new int[N][];
        for (int i = 0; i < N; ++i)
        {
            values[i] = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        }
        Console.WriteLine(Solve(N, K, values));
    }
}


Measured memory_bytes: 23744
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 
#define int ll
using namespace std;

const int N = 3e5 + 5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const long double eps = 1e-9 ;

using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

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

void solve()
{
    int a,b,v,w,t;
    cin >> a >> v >> b >> w >> t ;
    if(abs(b - a) <= (v - w) * t){
        cout << "YES";
    } else cout << "NO";
}
     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

 int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x-r >= 0 && y-r >= 0 && x+r <= w && y+r <= h)
      cout << "Yes" << endl;
    else 
       cout << "No" << endl;

   
   return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
	ll n; cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	ll ans = 0;
	for(ll digit = 0; digit <= 60; digit++){
		ll c0 = 0, c1 = 0;
		for(int i = 0; i < n; i++){
			if(1LL & (a[i] >> digit)) c1++;
			else c0++;
		}
      ans += ((c0 * c1)%MOD) * ((1ll << digit)%MOD);
        ans %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 5556
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <math.h>

using namespace std;

int main()
{
    double n;
    cin >> n;
    double ans;

    double temp = n / 3;
    ans = pow(temp, 3);

    printf("%.7lf\n", ans);
    return 0;
}

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

int main(){
    int n;
    int result = 100000;

    cin >> n;

    for(int i=1; i<=n; i++){
        result *= 1.05;
        result = (result + 999) / 1000 * 1000;
    }

    cout << result << endl;

    return 0;

}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<cstdlib> 
#include<string>
#include<math.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<set>
#include<stack>
#include<queue>
using namespace std;


int main(){

	string s;
	cin>>s;

	bool flag1=0,flag2=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='C')flag1=1;
		if(s[i]=='F' && flag1)flag2=1;
	}
	if(flag2){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	

	//while(1);
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,L; cin>>N>>L;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  int sum=0,memo=1;
  rep(i,1,N){
    if(sum<A[i]+A[i-1]){
      sum=A[i]+A[i-1];
      memo=i;
    }
  }
  if(sum>=L){
    cout<<"Possible"<<endl;
    rep(i,1,memo) cout<<i<<endl;
    rep(i,1,N-memo) cout<<N-i<<endl;
    cout<<memo<<endl;
  }
  else cout<<"Impossible"<<endl;
  }


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

using namespace std;
#define MN(x,ind,x2,ind2) abs(x[ind][0]-x2[ind2][0])+abs(x[ind][1]-x2[ind2][1])
int main() {
    ios::sync_with_stdio(false);
    int dp[51][51] ={};
    int mn[51]={};
    //fill(mn,mn+51,0);
    int N,M;
    cin >> N >> M;
    int s[N][2]={},p[M][2]={};
    for(int i=0; i<N; i++){
        cin >> s[i][0] >> s[i][1];
    }
    for(int i=0; i<M; i++){
        cin >> p[i][0] >> p[i][1];
        for(int j=0; j<N; j++){
            dp[j][i] = MN(s,j,p,i);
            if(dp[j][mn[j]] > dp[j][i]){
                mn[j] = i;
            }
            if(i == 0){
                mn[j] = i;
            }
        }
    }
    for(int i=0; i<N; i++){
        cout << mn[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

#[allow(dead_code)]
const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let k: usize = sc.cin();
    let mut ans = 0.0;
    for i in 1..n+1 {
        let mut p = 1.0 / n as f64;
        let mut x = i;
        while x < k {
            p /= 2.0;
            x *= 2;
        }
        ans += p;
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


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

int asc(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}

int main()
{
    int n, v[100];
    float result;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &v[i]);
    }
    qsort(v, n, sizeof(int), asc);
    result = (float)v[0];
    for (int i = 1; i < n; i++)
    {
        result = (result+v[i])/2.0;
    }
    printf("%f\n",result);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
const int N=2005;
int stack[N],b[N];
bool a[N][N];
char s[N];
int main(){
	int h,w;
	scanf("%d%d\n",&h,&w);
	for (int i=0;i<h;i++){
		scanf("%s",s);
		for (int j=0;j<w;j++) a[i][j]=(s[j]=='#');
	}
	for (int i=h-1;i;i--){
		for (int j=0;j<w;j++) a[i][j]^=a[i-1][j];
		for (int j=w-1;j;j--) a[i][j]^=a[i][j-1];
	}
	int ans=std::max(h,w);
	for (int i=1;i<w;i++) b[i]=1;
	for (int i=1;i<h;i++){
		int top=0;
		for (int j=1;j<w;j++){
			if (a[i][j]) b[j]=1;else b[j]++;
			for (;b[stack[top]]>b[j];top--)
				ans=std::max(ans,(j-stack[top-1])*b[stack[top]]);
			stack[++top]=j;
		}
		for (;stack[top];top--)
			ans=std::max(ans,(w-stack[top-1])*b[stack[top]]);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
inline int newline() { putchar('\n'); return 0; }

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

    int min8, max8, min10, max10;

    min8 = a * 12.5;
    max8 = (a + 1) * 12.5;
    if (a % 2 != 0) min8++; max8--;

    min10 = b * 10;
    max10 = (b + 1) * 10 - 1;

    if (max(min8, min10) < min(max8, max10)) {
        print(max(min8, min10));
    } else {
        print(-1);
    }

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  ll N, X, Y;
  cin >> N >> X >> Y;

  map<ll, ll> mp;
  for (ll i = 1; i < N; i++) {
    mp[i] = 0;
  }

  for (ll i = 1; i <= N; i++) {
    for (ll j = i + 1; j <= N; j++) {

      ll dist = min({abs(i - X) + abs(j - Y) + 1, j - i});
      mp[dist]++;
    }
  }

  for (auto &&e : mp) {
    cout << e.second << " ";
  }
  cout << endl;
}

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

using namespace std;

int arr[1000005];

int main()
{
	int n;
	for(int i=1;i<=100;i++)
	{
		for(int j=1;j<=100;j++)
		{
			for(int k=1;k<=100;k++)
			{
				int res=i*i+j*j+k*k+i*j+i*k+j*k;
				arr[res]++;
			}
		}
	}
	cin >> n;
	for(int i=1;i<=n;i++)
		cout << arr[i] << endl;
}

Measured memory_bytes: 3884
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  long long A[N], B[N];
  for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
  sort(A, A + N);
  sort(B, B + N);
  if (N & 1) {
    cout << B[(N + 1) / 2 - 1] - A[(N + 1) / 2 - 1] + 1 << endl;
  } else {
    long long U = B[N / 2 - 1] + B[N / 2];
    long long L = A[N / 2 - 1] + A[N / 2];
    long long ans = U - L + 1;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 6784
import qualified Data.ByteString.Char8 as B
import           Data.Maybe            (fromJust)

readInts :: B.ByteString -> [Int]
readInts = map (fst . fromJust . B.readInt) . B.words

getInts :: IO [Int]
getInts = readInts <$> B.getLine

main :: IO ()
main = do
  n <- readLn
  xs <- getInts
  print $ solve n xs

solve :: Int -> [Int] -> Int
solve n xs = min (calcHP aveF xs) (calcHP aveC xs) where
  aveF = floor ave
  aveC = ceiling ave
  ave = fromIntegral (sum xs) / fromIntegral n :: Double

calcHP :: Int -> [Int] -> Int
calcHP p xs = sum [(x - p) ^ (2 :: Int) | x <- xs]


Measured memory_bytes: 508
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve(){
    ll a;cin>>a;
    string b;cin>>b;
    vector<ll> dig;
    for(ll i=0;i<b.length();i++)
    {
        if(b[i]=='.')continue;
        dig.pb(b[i]-'0');
    }
    ll no=0;
    for(auto it:dig)
        no=no*10+it;
//    cout<<"no= "<<no<<endl;
    ll res=(a*no)/100;
    cout<<res<<endl;
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

//    cin.tie(NULL);cout.tie(NULL);

    solve();
    return 0;
}


Measured memory_bytes: 3656
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
const int mxn=1e5+1;
int arr[101],dp[101][10001];
//int solve(int i,int prev)
//{
//    if(i==n)
//        return 0;
//    if(dp[i][prev]!=-1)
//        return dp[i][prev];
//    if(arr[i]!=prev)
//    {
//        int himj=change(i);
//        return dp[i][prev]=1+solve(i+1,himj);
//    }
//    if(i+1<n&&arr[i]!=arr[i+1])
//    {
//        int himj=change(i+1);
//        return 
//    }
//}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  ll t=1;
  //cin>>t;
    while(t--){
            int n,i;
    cin>>n;
    int ans=0;
    fr(i,0,n)
    cin>>arr[i];
    int j=0;
    i=0;
    while(i<n)
    {
        j=i+1;
        int himj=1;
        while(j<n&&arr[i]==arr[j])
        {
        	j++;
        	himj++;
        }
        ans+=himj/2;
        i=j;
    }
    cout<<ans;

    }
  return 0;
  }



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool is_prime(int x){
    if(x<=1)return false;
    for(int i=2; i*i<=x; i++){
        if(x%i==0) return false;
    }
    return true;
}
    
int main(){
    int x;
    cin >> x;
    int p;
    p=x;
    while(!is_prime(p)) p++;
    cout << p << endl;
}




Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n&&n!=0){
		int a[100];
		for(int i=0;i<n;i++) cin>>a[i];
		sort(a,a+n);
		int sum=0;
		for(int i=1;i<n-1;i++){
			sum+=a[i];
		}
		sum/=floor((n-2));
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 3132
a=list(input().split())
def reverse_porand(r):
    s=[]#stack配列の用意
    for i in range(len(r)):#stackは左から読むのが当たり前なので、for文でよい
        if r[i]=="+":
            a=s.pop(-1)
            b=s.pop(-1)
            s.append(a+b)
        elif r[i]=="-":
            a=s.pop(-1)
            b=s.pop(-1)
            s.append(b-a)
        elif r[i]=="*":
            a=s.pop(-1)
            b=s.pop(-1)
            s.append(a*b)
        else:
            s.append(int(r[i]))#数字なら流す
    print(s[-1])

reverse_porand(a)


Measured memory_bytes: 5604
program cm
   implicit none
   integer::N,M,Q,a(50),b(50),c(50),d(50),X(10)=1,i,ans=0
   read*,N,M,Q
   do i=1,Q
      read*,a(i),b(i),c(i),d(i)
   end do
   X(1)=1
   call DFS(2)
   print"(I0)",ans
contains
recursive subroutine DFS(K)
   integer::K
   integer::i
   if(K==N+1)then
      ans=max(ans,calc())
      return
   endif
   do i=X(K-1),M
      X(K)=i
      call DFS(K+1)
   end do
end subroutine
integer function calc()
   integer::i
   calc=0
   do i=1,Q
      if(X(B(i))-X(A(i))==c(i))calc=calc+d(i)
   end do
end function
end program cm

Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
const int MAXN = 101;
int n, A[MAXN];

using namespace std;

void trace(int A[], int len)
{
	for(int i = 0; i < len; i++)
	{
		printf("%d", A[i]);
		if(i < n-1)
		{
			printf(" ");
		}
	}
	printf("\n");
}

int main(int argc, char *argv[]) {
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	trace(A, n);
	for(int i = 1; i < n; i++)
	{
		int key = A[i];
		int j = i-1;
		while (i >= 0 && A[j] > key) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = key;
		trace(A, n);
	}
	
	return 0;
}


Measured memory_bytes: 3120
using System;

class Program
{
	static int[] a;
	static int count;

	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		string[] input = Console.ReadLine().Split(' ');

		a = new int[n];
		for (int i = 0; i < a.Length; i++)
		{
			a[i] = int.Parse(input[i]);
		}

		SelectionSort();
		for (int i = 0; i < a.Length; i++)
		{
			Console.Write((i > 0 ? " " : "") + a[i]);
		}
		Console.WriteLine("\n" + count);
	}

	static void SelectionSort()
	{
		for (int i = 0; i < a.Length; i++)
		{
			int min = i;
			for(int j = i + 1; j < a.Length; j++)
			{
				if(a[min] > a[j])
				{
					int buf = min;
					min = j;
					j = buf;
				}
			}

			if(min != i)
			{
				int buf = a[min];
				a[min] = a[i];
				a[i] = buf;

				count++;
			}
		}
	}
}

Measured memory_bytes: 9204
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <map>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-9

int data[100000];
int main(){
	int t,n,k;
	scanf("%d",&t);
	while(t--){
		scanf("%d%d",&n,&k);
		
		int prev;
		rep(i,n){
			int tmp; scanf("%d",&tmp);
			if( i>0 ){
				data[i-1] = tmp-prev;
				//printf("%d:%d\n",i-1,data[i-1]);
			}
			prev = tmp;
		}
		sort(data,data+n-1);
		int ans = 0;
		for(int i=n-1-k; i>=0; i--){
			ans += data[i];
			//printf("i:%d  ,  %d\n",i,data[i]);
		}
		printf("%d\n",ans);	
	}
	return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int f(int n){
  return (n*n+4)/8;
}

int main(){
  int n,l; cin >> n >> l;
  vector<string> v(n); cin >> v;
  sort(v.begin(), v.end());
  for(int i = 0; i < n; ++i)cout << v[i];
  cout << endl;
}



Measured memory_bytes: 3496
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();

		pr.println((n - h + 1) * (n - w + 1));
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int m,i;
	ll d,c,ans=-1ll,tmp=-1ll;
	cin >> m;
	for(i=0; i<m; ++i){
		cin >> d >> c;
		ans += c;
		tmp += d*c;
	}
	tmp /= 9ll;
	ans += tmp;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
mod = 10**9 + 7
if n == 1:
	print(0)
	exit()
a = pow(10,n,mod)
b = pow(9,n,mod)
c = pow(8,n,mod)
ans = (a - (2*b) + c) % mod
if ans < 0:
	ans += mod
print(ans)

Measured memory_bytes: 9196
import java.util.*;

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

        for (;;) {
            char[] digits = scanner.next().toCharArray();
            
            if(digits.length == 1 && digits[0] == '0')
                return;

            int ans = 0;
            for(int i = 0; i < digits.length; ++i) {
                ans += Character.getNumericValue(digits[i]);;
            }

            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 26352
import numpy as np

def check_mass(i,j):
  c=0
  if i>0:
    if j>0:
      if mass[i-1][j-1]=="#":
        c+=1
    if mass[i-1][j]=="#":
        c+=1
    if j<W-1:
      if mass[i-1][j+1]=="#":
        c+=1
  if True:
      if j>0:
        if mass[i][j-1]=="#":
          c+=1
      if mass[i][j]=="#":
          c+=1
      if j<W-1:
        if mass[i][j+1]=="#":
          c+=1
  if i<H-1:
      if j>0:
        if mass[i+1][j-1]=="#":
          c+=1
      if mass[i+1][j]=="#":
          c+=1
      if j<W-1:
        if mass[i+1][j+1]=="#":
          c+=1
  return c

H,W= list(map(int, input().split()))
mass= []
for i in range(H):
  s = list(input()) # stringのままだと、replaceが出来ないのでlistに変換
  mass.append(s)

# print(mass)

for i in range(H):
  for j in range(W):
    if mass[i][j] == ".":
      c=check_mass(i,j)
      mass[i][j] = str(c)

for i in range(H):
  for j in range(W):
    print(mass[i][j], end="")
  print()


Measured memory_bytes: 12892
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;

    int x;
    x = (B - 2) / (A - 1.0) + 1.0;
  
    cout << x << endl;
}

Measured memory_bytes: 256
from sys import stdin
S = stdin.readline().rstrip()
N = len(S)+1
l = [0]*N
r = [0]*N
for i in range(N-1):
    if S[i] == '<':
        l[i+1] = l[i]+1 
for i in range(N-2, -1, -1):
    if S[i] == '>':
        r[i] = r[i+1]+1
ans = []
for ll, rr in zip(l, r):
    ans.append(max(ll, rr))
print(sum(ans))

Measured memory_bytes: 31908
#include<iostream>
#include<string>
#include<set>
int main() {
	std::string cmd, str;
	std::set<std::string> mp;
	int n, i;
	std::cin >> n;
	for (i = 0; i < n; i++) {
		std::cin >> cmd >> str;
		if (cmd == "insert") mp.insert(str);
		else if (cmd == "find") {
			if (mp.count(str) > 0) std::cout << "yes\n";
			else std::cout << "no\n";
		}
	}
	return 0;
}


Measured memory_bytes: 32532
#include<bits/stdc++.h>
using namespace std;
long long int dist[2510];
vector<long long int> v[2510];
int visited[2510], inPath[2510];
void dfs(int node)
{
	visited[node] = 1;
	for(auto child : v[node])
	{
		if(!visited[child])
		{
			dfs(child);
		}
		inPath[node] |= inPath[child];
	}
}
int main()
{
	set<pair<pair<long long int, long long int>, long long int> >st;
	long long int n, m, p;
	cin >> n >> m >> p;
	for(int i=0; i<m; i++)
	{
		long long int a, b, c;
		cin >> a >> b >> c;
		v[a].push_back(b);
		st.insert({{a, b}, p-c});
	}

	inPath[n] = 1;
	dfs(1);
	for(int i=0; i<=n; i++)
		dist[i] = 1e18;
	dist[1] = 0;

	int flag = 0;
	for(int i=1; i<=2*n; i++)
	{
		for(auto it = st.begin(); it!= st.end(); it++)
		{
			pair<pair<long long int, long long int>, long long int> p = *it;
			long long int a = p.first.first;
			long long int b = p.first.second;
			long long int c = p.second;
			if(dist[a] != 1e18 && dist[a] + c < dist[b])
			{
				dist[b] = dist[a] + c;
				if(i >= n && inPath[a] && inPath[b])
					flag = 1;
			}
		}
	}

	if(flag)
		cout << -1 << endl;
	else
		cout << max(0LL, -dist[n]) << endl;

}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 100005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N;
ll A,B;
ll h[SIZE];

bool check(ll n){
	ll cnt=0;
	rep(i,0,N){
		ll now = max(0LL,h[i]-B*n);
		cnt += (now+A-1)/A;
	}
	//cout << n << " " << cnt << endl;
	return cnt <= n;
}

int main()
{
	cin >> N >> A >> B;
	A -= B;
	rep(i,0,N)cin >> h[i];
	ll l=-1,r=INF;
	while(r-l>1){
		ll m = (l+r)/2;
		if(check(m))r = m;
		else l = m;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	int N;
	cin >> N;

	int max = 0;

	int val;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> val;
		if (max <= val) {
			ans += 1;
			max = val;
		}
	}
	
	cout << ans << endl;

	return 0;
}

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

using namespace std;

long long solve(int h, int w)
{
    long long ans = (long long) h * w;
    if (w % 3 == 0)
        ans = 0;
    else
        ans = min(ans, (long long) h);
    for (int i = max(0, w / 3 - 2); i <= min(w, w / 3 + 2) ; i++)
    {
        long long a = h * i;
        long long b = (w - i) * (h / 2);
        long long c = (w - i) * (h / 2 + (h % 2 == 1 ? 1 : 0));
        long long diff = max(abs(a - b), max(abs(a - c), abs(b - c)));
        ans = min(ans, diff);
    }
    return ans;
}

int main()
{
    int h, w;
    cin >> h >> w;
    cout << min(solve(h, w), solve(w, h)) << endl;
    return 0;
}


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

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

    int n, l;
    cin >> n >> l;
    
    string s[n];
    for (int i=0; i<n; i++){
    	cin >> s[i];
    }
    
    sort(s, s+n);
    
    for (int i=0; i<n; i++){
    	cout << s[i];
    }

    return 0;
}

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

//#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, d[100];
set<int> s;

signed main() {
	cin >> n;
	rep(i,n) {
		cin >> d[i];
		s.insert(d[i]);
	}
	cout << s.size() << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int h, w;
  cin >> h >> w;
 
  map<int,int> s;
  multiset<int> vals;
 
  rep(i,w) s[i] = i;
  rep(i,w) vals.insert(0);
 
  rep(i,h) {
    int l, r;
    cin >> l >> r;
    --l;
    auto it = s.lower_bound(l);
    int mr = -1;
    while (it != s.end() && it->first <= r) {
      mr = max(mr, it->second);
      int x = it->first - it->second;
      vals.erase(vals.find(x));
      s.erase(it++);
    }
    if (mr != -1 && r < w) {
      vals.insert(r-mr);
      s[r] = mr;
    }
    int ans = -1;
    if (vals.size() > 0) {
      ans = *vals.begin() + (i+1);
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 22444
#include<stdio.h>

int c_place(char *s){
    int c_place,i=0,counter = 0;
    char c;
    while(1){
        c = s[i];
        if(i==0){
            if(c != 'A'){
                counter = 0;
                break;
            }
        }
        if(c == '\0'){
            break;
        }
        else if(c == 'C'){
            counter++;
            c_place=i;
        }
        else if(('a'>c || c>'z')&& i!=0){
            counter = 0;
            break;
        }
        i++;
    }
    if(counter == 1 && c_place < i-1){
        return c_place;
    }
    else{
        return -1;
    }
}

int main(void){
    char s[12];
    scanf("%s",s);
    if(2<=c_place(s)){
        printf("AC\n");
    }
    else{
        printf("WA\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

long gcd(long a, long b) {
  while (true) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    a %= b;
  }
}

int main(void) {
  long N, X;
  cin >> N >> X;
  cout << (N / gcd(N, X) - 1) * 3 * gcd(N, X) << endl; 
  return 0;
}


Measured memory_bytes: 256
using System;
class Program
 {
        static void Main(string[] args)
        {
    　　int N,i;
            string[] str = Console.ReadLine().Split(' ');
            N = int.Parse(str[0]); 
            i = int.Parse(str[1]);
　　　 
            Console.WriteLine(N + 1 - i);
        }
 }

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

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

    if (abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
#define MOD 998244353
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/

ll poww(long long a, long long n, long long m)
{
        long long ans = 1;
        long long mul = a;
        while (n != 0)
        {
                if (n % 2)
                {
                        ans = (ans * mul) % m;
                }
                mul = (mul * mul) % m;
                n /= 2;
        }
        return ans;
}
/* 
Fermat's little theorem: 
1) (a/b)%mod= (a*(poww(b,mod-2,mod)))%mod iff a%b==0
2) (a^b)%mod= (a^(b%(mod-1)))%mod iff mod is prime
*/
const int SZ=2e5+100;
ll factorial[SZ];
ll iv[SZ];
void precompute()
{
	factorial[0]=1;
    iv[0]=1;
	for(int i=1;i<SZ;i++)
	{
		factorial[i]=(factorial[i-1]*i)%MOD;
	   iv[i]=poww(factorial[i],MOD-2,MOD);
    }
}
ll InverseEuler(ll n, ll m)
{
    return poww(n, m - 2, m);
}
ll C(ll n, ll r, ll m)
{

    return (factorial[n] * ((iv[r] * iv[n-r]) % m)) % m;
}
const int N=1e6+10;
int w[N];
int f[N];
int32_t main()
{
	fastio();
	for(int i=1;i<N;i++)
	{
		int ivi=InverseEuler(i,MOD);
		w[i]+=ivi;
		for(int j=2*i;j<N;j+=i)
		{
			w[j]+=MOD-w[i];
			if(w[j]>MOD)w[j]-=MOD;
		}
	}
	int n;
	cin>>n;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		ans+=MOD-x;
		if(ans>MOD)ans-=MOD;
		f[x]+=x;
		if(f[x]>MOD)f[x]-=MOD;
	}
	
	for(int i=1;i<N;i++)
	{
		int x=0;
		for(int j=i;j<N;j+=i)
		{
			x+=f[j];
			x%=MOD;
		}
		int cr=(x*x)%MOD;
		cr*=w[i];
		cr%=MOD;
		ans+=cr;
		ans%=MOD;
	}
	ans*=InverseEuler(2,MOD);
	ans%=MOD;
	cout<<ans<<endl;
}


Measured memory_bytes: 16640
//
// Created by chuan on 2020-04-10.
//

#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>

using namespace std;
int main() {

    int x; cin>>x;

    long long h{};

    cout<<(x/500) * 1000 +  5 * ((x%500)/5)<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
    ll a, b, k; cin >> a >> b >> k;
    if(a > k) {
        cout << a-k << ' ' << b << endl;
    }
    else if(b > k - a) {
        cout << 0 << ' ' << b - k + a << endl;
    }
    else cout << 0 << ' ' << 0 << endl;
}

Measured memory_bytes: 256