akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF INT_MAX/2
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int, int>P;
typedef long long ll;

bool kanousei[100000];
int kosuu[100000];

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	fill(kosuu, kosuu + n, 1);
	kanousei[0] = true;
	rep(i, m){
		int x, y;
		scanf("%d%d", &x, &y);
		x--; y--;
		if (kanousei[x] == true){
			if (kosuu[x] == 1){
				kanousei[x] = false;
				kanousei[y] = true;
			}
			else{
				kanousei[y] = true;
			}
		}
		kosuu[y]++;
		kosuu[x]--;
	}
	int cnt = 0;
	rep(i, n){
		if (kanousei[i] == true)cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 768
// ABC 007 C

#include<bits/stdc++.h>
using namespace std;
#define ll long long
using Graph = vector<vector<int>>;

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

int ret = 0;
void dfs(const Graph &G, int v, vector<bool> visited) {
    bool all_visited = true;
    for (auto nodes : visited) {
        if (nodes == false) {
            all_visited = false;
        }
    }
    if (all_visited) {
        ret++;
    }

    for (auto next_v : G[v]) { 
        if (visited[next_v] == false) {
            visited[next_v] = true;
            dfs(G, next_v, visited);
            visited[next_v] = false;
        }
    }
}

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

    Graph G(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<bool> visited;
    visited.assign(n, false);
    visited[0] = true;
    dfs(G, 0, visited);

    cout << ret << endl;
    return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    bool can = false;
    int n; cin >> n;
    for(int i = 1; i <10; i++) {
        for(int j = 1; j < 10; j++) {
            if(i * j == n) {
                can = true;
            }
        }
    }
    cout << (can ? "Yes" : "No") << '\n';
}

Measured memory_bytes: 256
import math

a, b, n = map(int, input().split())

x = b - 1
if n < x:
    x = n

ans = 0

while x > 0:
    l = (a * x) // b
    r = a * (x // b)
    ans = max(ans, l - r)
    x -= b

print(ans)


Measured memory_bytes: 61908
#include <stdio.h>
#define N 100

int main(){
  int i = 0, j = 0, k = 0, n = 0;
  int A[N];
  int miji = 0, key = 0;

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

  for(i = 0; i < n; i++){
    miji = i;
    for(j = i; j < n; j++){
      if(A[j] < A[miji]){
	miji = j;
      }
    }
    if(A[i] != A[miji]){
      key = A[i];
      A[i] = A[miji];
      A[miji] = key;
      k++;
    }
  }

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



Measured memory_bytes: 2100
#include <iostream>
using namespace std;
using ll = long long;
constexpr int MOD = 1e9 + 7;

ll x[101010], y[101010];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    for(int i=0; i < n; ++i) cin >> x[i];
    for(int i=0; i < m; ++i) cin >> y[i];

    ll X = 0, Y = 0;
    for(int i=0; i < n/2; ++i) 
        (X += (n-1 - i*2) * (x[n-1-i] - x[i])) %= MOD;

    for(int i=0; i < m/2; ++i)
        (Y += (m-1 - i*2) * (y[m-1-i] - y[i])) %= MOD;

    cout << X * Y % MOD << '\n';
    return 0;
}

Measured memory_bytes: 1792
yobi = {
    "SUN" : 7
   ,"MON" : 6
   ,"TUE" : 5
   ,"WED" : 4
   ,"THU" : 3
   ,"FRI" : 2
   ,"SAT" : 1
}

S=input()

print(yobi[S])

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAX=5e5+5;
bool a[MAX];


int main()
{
        LL n,m;
        cin>>n>>m;
        multiset<LL> s;
        for(int i=0;i<n;i++)
        {
                LL x;
                cin>>x;
                s.insert(x);
        }
        vector<pair<LL,LL> > v;
        for(int i=0;i<m;i++)
        {
                LL x,y;
                cin>>x>>y;
                v.push_back(make_pair(y,x));
        }
        sort(v.begin(),v.end());
        reverse(v.begin(),v.end());
        for(int i=0;i<m;i++)
        {
                LL b=v[i].second;
                LL c=v[i].first;
                while(b--)
                {
                        
                        LL x=*(s.begin());
                        if(x>=c) break;
                       // cout<<x<<" ";
                        s.erase(s.begin());
                        x=c;
                        s.insert(x);
                }
        }
        LL sum=0;
        for(auto x:s)
        {
                //cout<<x<<" ";
                sum+=x;
        }
        cout<<sum<<endl;
}

Measured memory_bytes: 7156
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
using namespace std;

int main(void)
{
	int x,y;
	scanf("%d%d",&x,&y);
	int ans=1;
	rep(i,0,x)
	{
		if(ans>y) ans+=y;
		else ans*=2;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N, K, D[10];

bool check(ll x){
    while(x > 0){
        ll d = x % 10;
        REP(i, K){
            if(d == D[i]) return false;
        }
        x /= 10;
    }
    return true;
}

signed main(){
    cin >> N >> K;
    REP(i, K) cin >> D[i];
    ll ans = N;
    while(true){
        if(check(ans)) break;
        ans++;
    }
    PRINT(ans);
    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[1000005][2][2];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  
  dp[0][0][0]=1;
  
  rep(i,n){
    rep(j,2){
      rep(k,2){
        rep(l,10){
          ll nj=j, nk=k;
          if(l==0) nj=1;
          if(l==9) nk=1;
          (dp[i+1][nj][nk]+=dp[i][j][k])%=MOD;
        }
      }
    }
  }
  
  ll ans=dp[n][1][1];
  cout<<ans<<endl;
  
}

Measured memory_bytes: 34844
import sys

def main():
    input = sys.stdin.readline
    n, x, y = map(int, input().strip().split())
    dist = [[0] * (n+1) for _ in range(n+1)]

    def calc_dist(i, j):
        return min(j-i, abs(i-x)+1+abs(j-y))

    for i in range(1, n+1):
        for j in range(i+1, n+1):
            dist[i][calc_dist(i, j)] += 1

    for k in range(1, n):
        ans = 0
        for node in range(1, n+1):
            ans += dist[node][k]
        print(ans)


if __name__ == '__main__':
    main()

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

int main(void){
	int score[1001] = {0};
	int n,i;
	double m;
	double sum1 = 0;
	double sum2 = 0;

	while(1){
		scanf("%d", &n);
		if(n == 0){
			break;
		}

		sum1 = 0;
		sum2 = 0;

		for(i = 0;i < n;i++){
			scanf("%d",&score[i]);
			sum1 += score[i];
		}

		m = sum1 / (double)n;

		for(i = 0;i < n;i++){
			//sum2 += pow((double)(score[i] - m), 2.0);
			sum2 += (score[i]-m)*(score[i]-m);
		}

		printf("%lf\n", sqrt(sum2 / n));
	}

	return 0;
}

Measured memory_bytes: 636
n=int(input())
a=list(map(int,input().split()))
seta=set(a)
d=dict([[x,0] for x in seta])
for i in range(len(a)):
  d[a[i]]+=1
seta=set(a)
ans=0
for ai in seta:
  if d[ai]==ai:
    pass
  elif d[ai]<ai:
    ans+=d[ai]
  else:
    ans+=d[ai]-ai
print(ans)


Measured memory_bytes: 33140
#include <iostream>
#include <cstdio>
using namespace std;
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};
struct Card L[MAX/2+2],R[MAX/2+2];

void merge(struct Card A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for ( i = 0; i < n1; ++i) {L[i]=A[left+i];   }
  for ( i = 0; i < n2; ++i) {R[i]=A[mid+i];    }
  L[n1].value=R[n2].value=SENTINEL;
  i=j=0;
  for ( k = left; k < right; ++k) {
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
    }
  }
}
void mergeSort(struct Card A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[],int n,int p,int r){
  int i,j;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for ( j = p; j < r; ++j) {
    if(A[j].value<=x.value){
      i++;
      t=A[i];A[i]=A[j];A[j]=t;
    }
  }
  t=A[i+1];A[i+1]=A[r];A[r]=t;
  return i+1;
}
void quickSort(struct Card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main(){
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char S[10];
  int stable=1;
  scanf("%d",&n);
  for ( i = 0; i < n; ++i) {
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }
  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);
  
  for (i = 0; i < n; ++i) {
    if(A[i].suit!=B[i].suit)stable=0;
  }
  if (stable==1) {printf("Stable\n");
  } else {printf("Not stable\n"); }
  for (i = 0; i < n; ++i) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}



Measured memory_bytes: 5484
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [N] = r.nn()
    const A = r.nn()
    const [Q] = r.nn()
    const bc = r.nnls()

    const counts = {}
    let sum = 0

    const res: string[] = []

    A.forEach((a) => {
      if (!counts[a]) counts[a] = 0
      sum += a
      counts[a]++
    })

    //

    bc.forEach(([b, c]) => {
      if (!counts[b]) {
        res.push(String(sum))
        return
      }
      const d = c - b

      sum += counts[b] * d

      res.push(String(sum))

      if (!counts[c]) counts[c] = 0
      counts[c] += counts[b]
      counts[b] = 0
    })

    return res.join('\n')
  }

  const _io = (i = 0) => {
    const str = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map((v) => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map((line) => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}


Measured memory_bytes: 80696
#include <cmath>
#include <iostream>
#include <string>
#include <time.h>
#include <stdio.h>
#include <iomanip>
using namespace std;

int main()
{
    int a, b;
    int d, r;
    double f;

    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = (double)a / (double)b;
    printf("%d %d %.5f\n", d, r, f);
    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include<string>
using namespace std;
int main(void){
    // Here your code !
    string str;
    cin>>str;
    int cnt=0;
    for(int i=0;i<str.size();i++){
        if(str[i]=='1')cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


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

int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	long long sum = 0;
	if (a % 2 == 1 && b % 2 == 1 && c % 2 == 1) {
		if (a >= b && a >= c) {
			sum = b * c;
			cout << sum << endl;
		}
		else if (b >= a && b >= c) {
			sum = a * c;
			cout << sum << endl;
		}
		else if (c >= b && c >= a) {
			sum = a * b;
			cout << sum << endl;
		}
	}
	else {
		cout << 0 << endl;
	}
	//return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()
 
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;
 
signed main() {
  int N;  
  while ( cin >> N, N ) {
    int M, K;
    int l[101];
    bool used[101][101] = {{0}};
 
    Rep(i, N) {
      cin >> M;
      Rep(j, M) {
    int p;
    cin >> p;
    p--;
    used[i][p] = true;
      }
    }
 
    cin >> K;
    Rep(i, K) {
      cin >> l[i];
      l[i]--;
    }
 
    int ans = -2;
    bool flag = false;
    Rep(i, N) {
      int cnt = 0;
      Rep(j, K) {
    if ( used[i][l[j]] ) cnt++;
      }
      if ( cnt == K ) {
    if ( flag ) {
      ans = -2;
    } else {
      ans = i;
      flag = true;
    }
      }
    }
 
    cout << ans+1 << endl;
  }
}

Measured memory_bytes: 3084
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
const int maxn=1000000+10;
char a[maxn],b[maxn],sta[maxn];
int dl[maxn*3][2];
int i,j,k,l,t,n,m,tot,head,tail,ans,mi,cnt,num;
bool czy;
int main(){
    scanf("%d",&n);
    scanf("%s",a+1);
    scanf("%s",b+1);
    fo(i,1,n+1)
        if (i>n||a[i]!=b[i]) break;
    if (i>n){
        printf("0\n");
        return 0;
    }
    czy=1;
    mi=n+1;
    i=n;k=n+1;
    head=n+1;tail=n;
    while (i){
        j=i;
        while (j>1&&b[j-1]==b[i]) j--;
        k=min(k,j);
        while (k&&a[k]!=b[i]) k--;
        if (!k){
            czy=0;
            break;
        }
        while (head<=tail){
            if (dl[tail][0]-num>i) tail--;
            else break;
        }
        cnt++;
        num++;
        head--;
        dl[head][0]=k+num;
        dl[head][1]=1-cnt;
        ans=max(ans,dl[tail][1]+cnt);
        i=j-1;
    }
    if (!czy) printf("-1\n");
    else printf("%d\n",ans);
}

Measured memory_bytes: 12160
#include <stdio.h>
#include <string.h>
#define MAX 1000
#define max(a,b) (a < b ? b : a)
 
int main() {
	int Q, i, j, l1, l2, dp[MAX+1][MAX+1];
	char X[MAX+1], Y[MAX+1];
	scanf ( "%d", &Q );
	while (Q--) {
		scanf ( "%s %s", X, Y );
		l1 = strlen (X);
		l2 = strlen (Y);
		memset ( dp, 0, sizeof(dp) );
		for ( i = 0 ; i < l1 ; i++ ) {
			for ( j = 0 ; j < l2 ; j++ ) {
				if ( X[i] == Y[j] ) {
					dp[i+1][j+1] = dp[i][j] + 1;
				} else {
					dp[i+1][j+1] = max( dp[i+1][j], dp[i][j+1] );
				}
			}
		}
		printf( "%d\n", dp[l1][l2] );
	}
	return 0;
}


Measured memory_bytes: 5660
S = input()
Q = int(input())
flip = 0
head = []
tail = []
for i in range(Q):
  Query = input().split()
  if len(Query) == 3:
    T,F,C = Query
    F = int(F)-1
    if F^flip == 1:
      tail.append(C)
    else:
      head.append(C)
  else:
    flip ^= 1
if flip:
  head, tail = tail, head
  S = S[::-1]
head = ''.join(head[::-1])
tail = ''.join(tail)
print(head+S+tail)


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

class Program
{

    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var T = double.Parse(inputs[0]);
        var X = double.Parse(inputs[1]);

        Console.WriteLine(T / X);
    }
}



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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i = 0; i<N; i++)
    cin >> h.at(i);
  
  vector<int> dp(N,10000000000000);
  dp.at(0) = 0;
  dp.at(1) = abs(h.at(1) - h.at(0));
  for(int i=2; i<N; i++){
      for(int j=max(0, i-K); j<i; j++)
        dp.at(i) = min(dp.at(j)+abs(h.at(i)-h.at(j)), dp.at(i));
  }
  cout << dp.at(N-1) << endl;
}

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

template<typename ... Ts> void read(Ts& ...vs){(std::cin >> ... >> vs);}
template<typename T> void write(const T& v){std::cout << v << std::endl;}

int main()
{
    std::size_t N , M;
    read(N, M);

    std::size_t total = 0;
    std::vector<std::size_t> A(N);
    for(auto& a : A)
    {
        read(a);
        total += a;
    }

    std::size_t threshold = total / (4 * M);
    if(total % (4 * M) != 0)
    {
        threshold += 1;
    }


    std::size_t count = 0;

    for(const auto& a : A)
    {
        if(threshold <= a)
        {
            count += 1;
        }
    }
    if(M <= count)
    {
        write("Yes");
    }
    else
    {
        write("No");
    }
    return 0;
}


Measured memory_bytes: 3640
# coding: utf-8
# Your code here!
def sum_digits(n,m):
    r = 0
    while n:
        r, n = r + n % m, n // m
    return r

def sunuke(n):
    return sum_digits(n,10)/n

#n,k = [int(i) for i in input().split()]
#a = [int(i)-1 for i in input().split()]
k=int(input())

#a=[]
#for i in range(999,8022,100):
#    a.append([i,sum_digits(i,10)/i])
#print(a)

c=0
sentou = 0
N=0
keta = 0 #
while(c<k):
    c+=1

    N+=10**keta
    if sentou < 9:
        sentou+=1
    else:
        while(sunuke(N) < 1/(10**keta)):
            N+=9*(10**keta)
            keta+=1
        sentou = (N//(10**keta))%10
#    print(N,keta,sentou)
    print(N)
    
    
    
    
        




    


Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

bool isPrime(int num)
{
    for (int i = 2; i * i <= num; i++)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return num != 1;
}
int main()
{
    bool state = true;
    ll x;
    cin >> x;
    while (state)
    {
        state = !isPrime(x);
        x++;
    }
    cout << x - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int N,I,H,W,R,i;
float B,t;
int main()
{
	for(;scanf("%d",&N),N;)
	{
		R=1000000000;B=99999;
		for(i=0;i<N;i++)
		{
			scanf("%d%d%d",&I,&H,&W);
			t=(float)W*100/(H*H);
			//printf("%f\n",t);
			if(abs(0.22-B)==abs(0.22-t))R=min(R,I);
			if(abs(0.22-B)>abs(0.22-t))
			{
				R=I;
				B=t;
			}
		}
		printf("%d\n",R);
	}
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int a,b,count =0;
    cin >> a >> b;
    if(a>=b)
    {
       count+=a;
       a--;
       if(a>=b)
       {
          count +=a;
       }
       else
       {
           count +=b;
       }
    }
    else
    {
      count+=b;
      b--;
      if(b>=a)
      {
          count+=b;
      }
      else
       {
           count +=a;
       }
    }
    cout << count << endl;
    return 0;
}




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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int count = 1;
	vector<int> a(n);
	for (auto&& ai : a) cin >> ai;
	
	vector<bool> check(n, false);
	for (int i = 0; a[i] != 2; i = a[i]-1)
	{
		if (check[i])
		{
			count = -1;
			break;
		}
		count++;
		check[i] = true;
	}

	cout << count << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define N 2002
using namespace std;
typedef long long ll;
const int mod=924844033;
int n,k,a[N],tot;
bool vis[N];
ll dp[N][N][2][2],jie[N];
inline void MOD(ll &x){x=x>=mod?x-mod:x;}
inline ll rd(){
    ll x=0;char c=getchar();bool f=0;
    while(!isdigit(c)){if(c=='-')f=1;c=getchar();}
    while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    return f?-x:x;
}
int main(){
    n=rd();k=rd();
    jie[0]=1;
    for(int i=1;i<=n;++i)jie[i]=jie[i-1]*i%mod; 
    for(int i=1;i<=n;++i)if(!vis[i]){
        int x=i;
        while(x<=n)vis[x]=1,a[++tot]=x,x+=k;
    }
    dp[0][0][0][0]=1;
    a[0]=-1e9;
    for(int i=1;i<=n;++i){
        for(int j=0;j<=i;++j){
            MOD(dp[i][j][0][0]=dp[i-1][j][0][0]+dp[i-1][j][1][0]);
            if(a[i]-a[i-1]==k)if(j)MOD(dp[i][j][0][0]+=dp[i-1][j-1][0][0]);
            MOD(dp[i][j][1][0]=dp[i-1][j][0][1]+dp[i-1][j][1][1]);
            if(a[i]-a[i-1]==k)if(j)MOD(dp[i][j][1][0]+=dp[i-1][j-1][0][1]);
            if(a[i+1]-a[i]==k)if(j)MOD(dp[i][j][0][1]=dp[i-1][j-1][0][0]+dp[i-1][j-1][1][0]);
            if(a[i+1]-a[i]==k)if(j)MOD(dp[i][j][1][1]=dp[i-1][j-1][0][1]+dp[i-1][j-1][1][1]);
        }
    }
    ll ans=0; 
    for(int i=0;i<=n;++i){
        ll now=(dp[n][i][0][0]+dp[n][i][1][0])%mod;
        if(i&1)MOD(ans=ans-now*jie[n-i]%mod+mod);
        else MOD(ans=ans+now*jie[n-i]%mod); 
    }
    cout<<ans;
    return 0;
} 

Measured memory_bytes: 123520
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i = 0; i , (n); ++i)
using ll = long long;
using namespace std;
int sum(int n) {
    if (n == 0) {
        return 0;
    }

    int s = sum(n - 1);
    return s + n;
}
int main() {
    int X;
    cin >> X;
    if (X >= 30) {
        cout << "Yes";
    }
    else cout << "No";
}


Measured memory_bytes: 3636
def main():
    N = int(input())
    ls = [[0 for _ in range(10)] for _ in range(10)]
    ans = 0
    for i in range(1,N+1):
        b,a = int(str(i)[0]),int(str(i)[-1])

        if a==b:
            ans += 2*ls[a][b]+1
            
        else:
            ans += 2*ls[a][b]

        ls[b][a] += 1

    print(ans)

        
if __name__ == '__main__':
    main()

Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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(){
    string s, t;
    cin >> s >> t;
    vector<char> a(26, -1), b(26, -1);
    bool flag = true;
    for (ll i = 0; i < s.size(); i++) {
        if(a[s[i]-'a']<0)a[s[i]-'a']=t[i];
        else{
            if (a[s[i]-'a'] != t[i]) flag = false;
        }
        if(b[t[i]-'a']<0)b[t[i]-'a']=s[i];
        else{
            if (b[t[i]-'a'] != s[i]) flag = false;
        }
    }
    cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
    int x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
    return x*f;
}
inline ll readll(){
    ll x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
    return x*f;
}
inline int check(int x){
	for(int i=1;i*(i-1)<=x;++i) if(i*(i-1)==x) return i;
	return 0;
}
const int maxn=3e2+10;
char s[maxn][maxn];
int sum[2][maxn][maxn<<1],n,m;
int calc(int ty,int x,int L,int R){
	if(x<0 || x>n+m) return 0;
//	cerr<<ty<<' '<<x<<' '<<L<<' '<<R<<' '<<sum[ty][min(R,n)][x]-sum[ty][max(L-1,0)][x]<<endl;
	return sum[ty][min(R,n)][x]-sum[ty][max(L-1,0)][x];
}
int main(){
	n=read(),m=read();
	REP(i,1,n) scanf("%s",s[i]+1);
	REP(i,1,n) REP(j,1,n+m){
		sum[0][i][j]=sum[0][i-1][j];
		if(j-i<=m && j-i>0) sum[0][i][j]+=(s[i][j-i]=='#');
		sum[1][i][j]=sum[1][i-1][j];
		if(i+m-j>=1 && i<=j) sum[1][i][j]+=(s[i][i+m-j]=='#');
	}
	ll ans=0;
	REP(i,1,n) REP(j,1,m) REP(k,1,min(n,m)){
		if(i>k && j>k && s[i-k][j]=='#' && s[i][j-k]=='#') ans+=calc(0,i+j+k,i,i+k);
		if(i>k && j+k<=m && s[i-k][j]=='#' && s[i][j+k]=='#') ans+=calc(1,i-j+k+m,i,i+k);
		if(i+k<=n && j>k && s[i+k][j]=='#' && s[i][j-k]=='#') ans+=calc(1,i-j-k+m,i-k,i);
		if(i+k<=n && j+k<=m && s[i+k][j]=='#' && s[i][j+k]=='#') ans+=calc(0,i+j-k,i-k,i);
		int num=(i>k && s[i-k][j]=='#')+(j>k && s[i][j-k]=='#')+(i+k<=n && s[i+k][j]=='#')+(j+k<=m && s[i][j+k]=='#');
//		if(ans) cerr<<i<<' '<<j<<' '<<ans<<endl;
		if(num==3) ans--;
		if(num==4) ans-=4;
	}
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <tuple>
#include <utility>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <map>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int main(){

   int a,b,c;
   cin>>a>>b>>c;
   cout <<max(0,c+b-a)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

#define N 105

int h, w;

char g[N][N];

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

void dfs(int x, int y, char c){
        g[x][y] = '.';
        for (int i = 0; i < 4; i++){
                int nx = x + dx[i];
                int ny = y + dy[i];
                if (nx >= 0 && nx < h && ny >= 0 && ny < w && g[nx][ny] == c)
                        dfs(nx, ny, c);
        }
}

int main(){
        while(true){
                scanf("%d %d", &h, &w);
                if (h == 0 && w == 0) break;
                for (int i = 0; i < h; i++){
                        getchar();
                        for (int j = 0; j < w; j++){
                                scanf("%c", &g[i][j]);
                        }
                }
                int sum = 0;
                for (int i = 0; i < h; i++){
                        for (int j = 0; j < w; j++){
                                if (g[i][j] != '.'){
                                        dfs(i, j, g[i][j]);
                                        sum++;
                                }
                        }
                }
                printf("%d\n", sum);
        }
        return 0;
}

Measured memory_bytes: 3192
/**
 * Martin Leshko (leshko.martin@gmail.com)
 */

#include <bits/stdc++.h>

using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define psb push_back
template<class T> T read() { T x; cin >> x; return x; }
typedef long long ll;
#define wyzi() read<int>()

const int maxN = 1000001;

int a[maxN], b[maxN], c[maxN];

int main() {
  int a = wyzi(), b = wyzi();
  if (a < 10 && b < 10) cout << a * b << endl;
  else
    cout << 1-2<<endl;
}


Measured memory_bytes: 256
from collections import*
input=open(0).readline
h,w,n=map(int,input().split())
d=defaultdict(int)
for _ in range(n):
    a,b=map(int,input().split())
    for i in(0,-1,-2):
        for j in(0,-1,-2):
            d[(a+i,b+j)]+=1
a=[0]*10
for i in d.keys():
    if 0<i[0]<h-1and 0<i[1]<w-1:
        a[d[i]]+=1
a[0]=(h-2)*(w-2)-sum(a)
print(*a,sep='\n')

Measured memory_bytes: 166864
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int A,B,N;
signed main(){
    scanf("%lld %lld %lld",&A,&B,&N);
    int ans=0;
    int x=min(N,B-1);
    ans=(A*x)/B-A*(x/B);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1680
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    string s, t; cin >> s >> t;
    int count = 0;
    rep(i,3){
        if(s[i] == t[i]) count++;
    }
    cout << count;
    }



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
           int a , b;
           cin >> a;
           int x[a];
           for(int i = 0;i < a;i ++){
                                    cin >> b;
		x[b-1] = i+1;
	}
	for(int i = 0 ;i < a;i ++){
		cout <<x[i]<<" ";
	}
}

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


void solve(long long A, long long B){
    cout <<  2 * B - A << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

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;}
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const int INF=1e9;
const double eps=0.0000000001;



int main(){
  ll n,ans=0;
  cin >> n;
  ll a[1000000];
  FOR(i,n){
    cin >> a[i];
  }
  ans+=a[0]/2;
  a[0]%=2;
  FOR(i,n-1){
    if(a[i]==1 && a[i+1]>0){
      ans++;
      a[i]--;
      a[i+1]--;
    }
    ans+=a[i+1]/2;
    a[i+1]%=2;
  }

  cout << ans << endl;
  
}





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

int X[2019];

int main() {
	long long int L,R; cin >> L >> R;

	long long int ans;

	if ((R-L)>=2019) ans = 0;
	else
	{
		ans = 2017 * 2018;
		for (long long int i=L; i<=R; i++) {
			if ((i%2019)==0) {
              ans = 0;
              break;
            }
          
			for (long long int j=i+1; j<=R; j++) {
				if (ans > ((i*j) % 2019)) ans = ((i*j) % 2019);
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define MN 1000
#define mod 1000000007
using namespace std;
inline int read()
{
    int x=0;char ch=getchar();
    while (ch<'0'||ch>'9')ch=getchar();
    while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x;
}
int n,A,B,C,D,f[MN+5],g[MN+5],p[MN+5],inv[MN+5];
int main()
{
    n=read();A=read();B=read();C=read();D=read();
    p[0]=inv[0]=p[1]=inv[1]=f[0]=1;
    for(int i=2;i<=n;++i) p[i]=1LL*p[i-1]*i%mod,inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
    for(int i=2;i<=n;++i) inv[i]=1LL*inv[i-1]*inv[i]%mod;
    for(int i=A;i<=B;++i)
    {
        for(int j=0,w=1;j<=D&&j*i<=n;++j,w=1LL*w*inv[i]%mod) if(j>=C)
            for(int k=0;k+i*j<=n;++k) if(f[k])
                g[k+i*j]=(g[k+i*j]+1LL*f[k]*w%mod*inv[j])%mod;
        for(int j=0;j<=n;++j) f[j]=(f[j]+g[j])%mod,g[j]=0;
    }
    cout<<1LL*p[n]*f[n]%mod;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <string>
#include <set>
#include <map>

using namespace std;

int n, T;
int c[1000], t[1000];

int main() {
	cin >> n >> T;

	int ans = 1<<29;
	for (int i = 0; i < n; i++) {
		cin >> c[i] >> t[i];
		if (t[i] <= T) ans = min(ans, c[i]);
	}

	if (ans == (1<<29)) {
		cout << "TLE" << endl;
		return 0;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
int main(){
	LL n,t;
	cin>>n>>t;
	LL sum = 0, Max = 0;
	for(int i = 1; i <= n; i++){
		LL x;
		cin>>x;
		sum += x;
		Max = max(Max,x);
		LL ans = 1;
		if(t >= sum) ans = floor((t-sum)/Max)+2;
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 1e6+1;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
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;
    }
}

// 二項係数計算
long long 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;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

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

//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
// ここから開始
int main(){
  int a,b;
  cin>>a>>b;
  if(a*b==2) cout<<3<<endl;
  else if(a*b==6) cout<<1<<endl;
  else cout<<2<<endl;
  return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {

    	try(BufferedReader i = new BufferedReader(new InputStreamReader(System.in))){

    		String S = i.readLine();
    		int a = S.length();
    		Long r = S.chars().parallel().filter(c -> c=='0').count();
    		Long b = a - r;
	    	System.out.println(Math.min(r, b) * 2);
    	}
    }
}

Measured memory_bytes: 30804
using System;
using System.Collections.Generic;

namespace Project
{
	class MainClass
	{
		public static int count = 0;
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string[] s = Console.ReadLine().Split(' ');
			int[] S = new int[n];
			for (int i = 0; i < n; i++)
			{
				S[i] = int.Parse(s[i]);
			}
			mergeSort(S, 0, n);
			for (int i = 0; i < n; i++)
			{
				Console.Write(S[i] + (i != n - 1 ? " " : "\n"));
			}
			Console.WriteLine(count);

		}

		public static void mergeSort(int[] A, int left, int right)
		{
			if (left + 1 < right)
			{
				int mid = (left + right) / 2;
				mergeSort(A, left, mid);
				mergeSort(A, mid, right);
				merge(A, left, mid, right);

			}
		}
		public static void merge(int[] A, int left, int mid, int right)
		{
			int n1 = mid - left;
			int n2 = right - mid;
			int[] L = new int[n1 + 1];
			int[] R = new int[n2 + 1];
			for (int p = 0; p < n1; p++)
			{
				L[p] = A[left + p];
			}
			for (int p = 0; p < n2; p++)
			{
				R[p] = A[mid + p];
			}
			L[n1] = int.MaxValue;
			R[n2] = int.MaxValue;
			int i = 0;
			int j = 0;
			for (int k = left; k < right; k++)
			{
				if (L[i] <= R[j])
				{
					A[k] = L[i];
					i++;
				}
				else
				{
					A[k] = R[j];
					j++;
				}
				count++;
			}
		}
	}
}

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

int main() {
	int n; cin >> n;
	string s; cin >> s;
	for (int i = 0; i < s.size(); i++) {
		int tmp = s[i] - 'A';
		tmp += n;
		if (tmp >= 26)tmp -= 26;
		cout << char('A' + tmp);
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int k = int.Parse(Console.ReadLine());
        int x = int.Parse(Console.ReadLine());
        int y = int.Parse(Console.ReadLine());
        Console.WriteLine(x * Math.Min(k, n) + y * Math.Max(0, n - k));
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   string s;
   cin>>s;
   int w;
   cin>>w;
   int n=((int)s.size()+w-1)/w;
   rep(i,n)cout<<s[w*i];
   cout<<endl;
   return 0;
}

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

int main() {
	int ans;
    string s;
	cin >> s;
  	if(s[0] == '1') ans++;
   	if(s[1] == '1') ans++;
   	if(s[2] == '1') ans++;
   	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int num = scanner.nextInt();	//要素数
		
		gcd_profits(num, scanner);
		
		scanner.close();
	}
	
	public static void gcd_profits(int num , Scanner scanner) {
		int sub;
		int min;
		int count = 0;
		int profits = 0;
		int cur;

		min = (int)Math.pow(10, 9);
		profits = (int)Math.pow(10, 9) * -1;
		
		  while (count < num) {
		  	cur = scanner.nextInt();	//価格
		  	
		  	if(count != 0){
			  	
			  	//差分を出していく
			  	sub = cur - min;
			  	
			  	if( cur <= min ) {
			  		min = cur;
			  	}
			  	
			  	//最小か最大か調べる
			  	if( sub > profits ){
			  		profits = sub;
			  	}
		  	}else{
		  		min = cur;
		  	}
		  	
		  	count ++;
		  }
		  System.out.println(profits);
		}
}




Measured memory_bytes: 68016
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, a[200000];

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	map<int, long long> cnt;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		cnt[a[i]]++;
	}
	long long ans = 0;
	for(auto &i : cnt) ans += (i.second * (i.second - 1)) / 2;
	for(int i = 0; i < n; i++){
		long long rem = cnt[a[i]] * (cnt[a[i]] - 1) / 2;
		long long add = (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2;
		cout << ans - rem + add << "\n";
	}
	return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    rep(i,N) cin >> P[i];

    sort(P.begin(), P.end());
    int total = 0;
    rep(i,K) total+=P[i];
    cout << total << endl;
}

Measured memory_bytes: 3656
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func reverse(s string) string {
    runes := []rune(s)
    for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
        runes[i], runes[j] = runes[j], runes[i]
    }
    return string(runes)
}

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	S := sc.Text()
	S = reverse(S)
	N := 2019
	var m = make([]int, N)
	// 10と2019は「互いに素」なので、累積和同士の剰余が等しいとき定数倍した累積和同士の剰余も等しい
	// x===y (mod 2019) <=> 10x===10y (mod 2019)
	m[0]++ // s0=0 (何も累積していない)
	total := 0
	ten := 1
	for x := 0; x<len(S); x++ {
		tmp, _ := strconv.Atoi(S[x:x+1])
		total += (tmp * ten) % N
		// 10^x (xが十分大きい) を剰余するとオーバーフローするのでNで剰余取りながら累積和をとる
		ten = (ten * 10) % N
		m[total % N]++
	}
	cnt := 0
	for _, v := range m {
		// 剰余の計算結果から2組ずつ選ぶパターン数を足す
		// ex) 2C2=1, 3C2=3
		cnt += v * (v - 1) / 2
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int a,b;cin >> a >> b;
	if(a<=5) cout << 0;
	else if(a <= 12) cout << b/2;
	else cout << b;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3624
n = int(input())
a=[]
for i in range(n-1):
    a.append(list(map(int,input().split())))
t=0
if n > 1:
    for i in range(n-1):
        t = a[i][1]
        for j in range(i,n-2):
            t+=a[j][0]
            
            if t < a[j+1][1]:t = a[j+1][1]
            else:t+= (-t%a[j+1][2])%a[j+1][2]
        t+=a[-1][0]
        print(t)
print(0)

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

#define EHAB_FAWZY_FCI_AaRnoB ios::sync_with_stdio(NULL); cin.tie(NULL);
#define popcnt(x) __builtin_popcount(x)
#define compination(x) ((x*(x-1))/2)
#define all(x) x.begin() , x.end()
#define ll long long
#define ld long double
#define vii vector  <ll>
#define sii set     <ll>
#define vch vector  <char>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define PI 3.141592654

using namespace std;

const int mod = 998244353;
const int MAX = 100009;

ll n , y , arr[MAX] , cnt;

int main()
{
    cin >> n;
    for ( int i = 0; i < n; i++ )
        cin >> arr[i];

    for ( int i = 0; i < n-1; i++ )
    {
        if ( arr[i]%2 == 1 && arr[i+1] > 0 )
            cnt += arr[i]/2 + 1 , arr[i+1]--;
        else
            cnt += arr[i]/2;
    }
    cout << cnt+arr[n-1]/2;
    return 0;
}

Measured memory_bytes: 1024
import math
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = IL()
a = IL()

dp = [-1]*200010
for i in a:
  dp[i] = True

for i in range(1,K+1):
  if dp[i] == -1 or dp[i] == False:
    dp[i] = False
    for j in a:
      dp[i+j] = True

if dp[K] == True:
  print("First")
else:
  print("Second")

Measured memory_bytes: 4724
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int  maxn = 2e5 + 5;
int n;
int arr[405];
ll dp[405][405];
ll cost[405][405];
ll rek(int i, int j){
    if(i == j){
        return 0;
    }
    if(dp[i][j] != -1){
        return dp[i][j];
    }
    ll ret = inf;
    for(int it = i; it < j; it ++){
        ret = min(ret, rek(i, it) + rek(it + 1, j) + cost[i][j]);
    }
    return dp[i][j] = ret;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i  =0;i  < n ;i ++){
        cin >> arr[i];
    }
    memset(dp, -1, sizeof dp);
    for(int i =0 ; i < n; i ++){
        cost[i][i] = arr[i];
        for(int j = i + 1; j < n; j ++){
            cost[i][j] = arr[j] + cost[i][j - 1];
        }
    }
    cout << rek(0, n - 1) << endl;
        return 0;
}


Measured memory_bytes: 2816