akhauriyash/Code-Regression huggingface dataset:
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <atcoder/dsu>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
using namespace atcoder;
#define int long long

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

    int n, q;
    cin >> n >> q;

    dsu d(n);

    for (int i = 0; i < q; i++) {
        int t, u, v;
        cin >> t >> u >> v;

        if (!t) {
            d.merge(u, v);
        } else {
            cout << d.same(u, v) << "\n";
        }
    }
}


Measured memory_bytes: 3956
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(i=a;i<b;i++)
int A, B;
bool check(int n) {
	return n % 10 == n / 10000 && n % 100 / 10 == n / 1000 % 10;
}
int main() {
	int i, c = 0;
	scanf("%d %d", &A, &B);
	rep(i, A, B + 1) {
		if (check(i))c++;
	}
		printf("%d", c);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int a = scn.nextInt();
        int b = scn.nextInt();
        int c = scn.nextInt();

        for (int i = 0; i < 2; i++) {
            if (a > b) {
                int t = a;
                a = b;
                b = t;
            }
            if (b > c) {
                int t = b;
                b = c;
                c = t;
            }
        }

        System.out.println(a + " " + b + " " + c);

        scn.close();
    }
}



Measured memory_bytes: 26196
a, b, c = sorted(list(map(int, input().split())))
mod = (a+b+c) % 2
if a%2 == b%2 == c%2:
  print((c-a)//2+(c-b)//2)
else:
  if a%2 == b%2:
    a += 1
    b += 1
  elif a%2 == c%2:
    a += 1
    c += 1
  else:
    b += 1
    c += 1
  print((c-a)//2+(c-b)//2+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
int gcd(int x,int y){return x?gcd(y%x,x):y;}
int main(){
    int N,K;cin>>N>>K;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    int m=0;
    REP(i,N) m=gcd(m,A[i]);
    bool ok=false;
    REP(i,N) if(A[i]>=K&&(A[i]-K)%m==0) ok=true;
    if(ok) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 640
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
for i in range(n):
    t[i+1],x[i+1],y[i+1] = map(int,input().split()) 
flag=0
for i in range(n):
    l=abs(x[i]-x[i+1])+abs(y[i]-y[i+1])
    s=t[i+1]-t[i]
    if(l>s or (l-s)%2==1):
        flag=1
if flag==0:
    print("Yes")
else:
    print("No")

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

int main() {
    int x;
    std::cin >> x;
    unsigned long long y[x];
    for (int i=0; i < x;i++){
        cin >> y[i];
    }
    
    bool flag = false;
    unsigned long int j=0;
    while (flag==false) {
        for (int i=0; i < x; i++){
            if(y[i]%2==1){
                flag=true;
                break;
            }
            else{
                y[i] = y[i]/2;    
            }
            
        }
        if (flag == false){
            j++;
        }
        
    }
	std::cout << j << std::endl;
}

Measured memory_bytes: 256
#coding:UTF-8
def BS(N,A):
    for i in range(N):
        for j in reversed(range(i+1,N)):
            if int(A[j][1:])<int(A[j-1][1:]):
                swap=A[j]
                A[j]=A[j-1]
                A[j-1]=swap
    return A

def SS(N,A):
    for i in range(N):
        minj=i
        for j in range(i,N):
            if int(A[j][1:]) < int(A[minj][1:]):
                minj=j
        
        swap=A[i]
        A[i]=A[minj]
        A[minj]=swap
    return A

def Stable(A1,A2):
    ans="Stable"
    for i in range(len(A1)):
        if A1[i][1:]==A2[i][1:] and A1[i][:1]!=A2[i][:1]:
            ans="Not stable"
    return ans

def SS2(N,A,B):
    A1=BS(N,A)
    print(" ".join(A1))
    print("Stable")
    A2=SS(N,B)
    print(" ".join(A2))
    print(Stable(A1,A2))

if __name__=="__main__":
    N=int(input())
    a=input()
    A=a.split(" ")
    B=a.split(" ")
    SS2(N,A,B)

Measured memory_bytes: 7796
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var a=new int[s[0]][];
		int m=0;
		var d=new long[s[0]][];
		for(int i = 0;i<s[0];i++) {
			a[i]=sc.Ia;
			d[i]=new long[2];
			m=Max(m,a[i][0]);
		}
		Array.Sort(a,(u,v)=>u[0]-v[0]);
		long ans=0;
		long p=0;
		for(int i = 0,j=0,k=0;i<s[0];i++) {
			while(j<k&&d[j][0]<a[i][0]){
				p-=d[j][1]*s[2];
				j++;
			}
			if(a[i][1]-p>0){
				long u=((a[i][1]-p)/s[2])+((a[i][1]-p)%s[2]==0?0:1);
				d[k][0]=a[i][0]+s[1]*2;
				d[k][1]=u;
				p+=s[2]*u;
				ans+=u;
				k++;
			}
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 37660
a, b, c, x, y = map(int, input().split())
if c < (a + b) / 2:
    if (c < a and c < b) and (c * 2 <= a or c * 2 <= b):
        ans = c * 2 * max(x, y)
    else:
        ans = c * 2 * min(x, y)
        if x > y:
            ans += a * abs(y - x)
        elif x < y:
            ans += b * abs(y - x)
else:
    ans = a * x + b * y
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef double db;
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define SZ(x) (int)(x.size())
#define sci(x) scanf("%d",&(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define syn ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll modpow(ll x,ll n,ll mod){ll res=1;for(;n;n>>=1,x=x*x%mod)if(n&1)res=res*x%mod;return res;}
const db eps=1e-8,PI=acos(-1.0);
const int N=4e3+10,M=1e6+10,INF=0x3f3f3f3f,mod=1e9+7;//998244353
int x;
ll ans;
int main(){
	sci(x);
	rep(i,1,x){
		rep(j,1,x){
			rep(k,1,x){
				ans+=__gcd(__gcd(i,j),k);
			}
		}
	}
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

string solve(int N) {
    int dig = N % 10;
    switch (dig)
    {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            return "hon";
        case 0:
        case 1:
        case 6:
        case 8:
            return "pon";
        case 3:
            return "bon";
    }
    return "";
}

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

    int N;
    cin >> N;
    cout << solve(N) << endl;

    return 0;
}

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

using namespace std;

typedef long long int64;

const int mod = 1e9 + 7;

int N;
string A[2];
int dp[54][4][4];

int rec(int idx, int a, int b)
{
  if(idx == N) return (1);
  if(~dp[idx][a][b]) return (dp[idx][a][b]);
  int64 ret = 0;
  if(A[0][idx] == A[1][idx]) {
    for(int i = 1; i <= 3; i++) {
      if(a != i && b != i) ret += rec(idx + 1, i, i);
    }
  } else {
    for(int i = 1; i <= 3; i++) {
      for(int j = 1; j <= 3; j++) {
        if(i != j && a != i && b != j) {
          ret += rec(idx + 2, i, j);
        }
      }
    }
  }
  return (dp[idx][a][b] = ret % mod);
}

int main()
{
  cin >> N;
  cin >> A[0];
  cin >> A[1];
  memset(dp, -1, sizeof(dp));
  cout << rec(0, 0, 0) << endl;
}

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

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

  int dp[110][10010];
  int s[110];
  for (int i=0; i<n; i++){
    cin >> s[i];
  }

  dp[0][0] = 1;
  for (int i=0; i<n; i++){
    for (int j=0; j<=10000; j++){
      if (dp[i][j]==1){
        dp[i+1][j]=1;
        dp[i+1][j+s[i]]=1;
      }
    }
  }

  for (int i=10000; i>=0; i--){
    if (dp[n][i]==1 && i%10!=0){
      cout << i << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3456
// https://atcoder.jp/contests/abc141/tasks/abc141_d

#include "algorithm"
#include "iostream"
#include "queue"
#include "vector"
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
using namespace std;
typedef long long ll;

template <class T>
inline bool chmax(T& a, T b);
template <class T>
inline bool chmin(T& a, T b);

void solve() {
  ll N, M;
  cin >> N >> M;

  priority_queue<ll> pq;

  rep(i, 0, N) {
    ll a;
    cin >> a;
    pq.push(a);
  }

  rep(i, 0, M) {
    ll popped = pq.top();
    pq.pop();
    pq.push(popped / 2);
  }

  ll res = 0;

  while (!pq.empty()) {
    res += pq.top();
    pq.pop();
  }

  cout << res << endl;
}

#ifndef TEST
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
#endif

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


Measured memory_bytes: 1400
#include <iostream>

using namespace std;

int main() {
  int x,a;
  cin >> x;
  cin >> a;
  
  int result;
  if (x < a) {
    result = 0;
  } else {
    result = 10;
  }
  
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#define inf 10000000
#define W 0
#define G 1
#define B 2
using namespace std;
int n,color[100];
int g[100][100],d[100],p[100];

void dikstr(int st){
int u,i,j;
	for(i=0;i<n;i++){
	color[i]=W;d[i]=inf;
	}
	d[st]=0;
	p[st]=-1;
	while(true){
	int mincost=inf;
		for(i=0;i<n;i++){
			if(color[i]!=B && d[i]<mincost){
			mincost=d[i];
				u=i;
			}
			
		}
		if(mincost==inf)
		break;
		color[u]=B;
		for(int v=0;v<n;v++){
			if(color[v]!=B && g[u][v]!=inf){
				if(d[u]+g[u][v]<d[v]){
				d[v]=d[u]+g[u][v];
					p[v]=u;
					color[v]=G;
				}
			}
		}
	}
}
main(){
	int i,j,u,k,c,v;
	cin>>n;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++)
		g[i][j]=inf;
	}
	for(i=0;i<n;i++){
	cin>>u>>k;
		for(j=0;j<k;j++){
		cin>>v>>c;
			g[u][v]=c;
		}
	}
	dikstr(0);
	
	for(i=0;i<n;i++)
	cout<<i<<" "<<d[i]<<endl;
	return 0;
}



Measured memory_bytes: 3112
//created by Whiplash99
import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,N;

        N=Integer.parseInt(br.readLine().trim());
        N%=1000;
        if(N!=0) N=1000-N;
        System.out.println(N);
    }
}

Measured memory_bytes: 32532
#include <iostream>
using namespace std;
using ll = long long;
const int MOD = 1000000007;
const int MAX = 2*100000;

long long mod(long long a) {
	a %= MOD;
	return a >= 0 ? a : a+MOD;
}

long long inverse[MAX+1];
long long factorial[MAX+1];
long long factorial_inverse[MAX+1];

void calc(int n) {
	inverse[1] = 1;
	factorial[0] = factorial[1] = 1;
	factorial_inverse[0] = factorial_inverse[1] = 1;
	for (int i = 2; i <= n; i++) {
		inverse[i] = MOD - inverse[MOD%i] * (MOD/i) % MOD;
		factorial[i] = i * factorial[i-1] % MOD;
		factorial_inverse[i] = inverse[i] * factorial_inverse[i-1] % MOD;
	}
}

long long comb(long long n, long long k) {
	long long fact_n = n;
	for (long long i = n-1; i >= n-k+1; i--) fact_n = mod(fact_n*i);
	return mod(fact_n * factorial_inverse[k]);
}

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

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	calc(max(a, b));
	ll ans = mod(pow_mod(2, n) - 1 - comb(n, a) - comb(n, b));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	int ans=700;char ch;
	while((ch=getchar())!='\n')ans+=(ch=='o')*100;
	cout<<ans<<endl;
	return 0;
}



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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  int A,B,C;cin>>A>>B>>C;
  if(A==B && B!=C)cout<<"Yes"<<endl;
  else if(B==C &&C!=A)cout<<"Yes"<<endl;
  else if(C==A&& A!=B)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}





Measured memory_bytes: 256
MOD = 10 ** 9 + 7
CEIL = 2010

FACT = Array.new(CEIL, 1)
INV  = Array.new(CEIL, 1)
FINV = Array.new(CEIL, 1)

(2 ... CEIL).each do |i|
  FACT[i] = (FACT[i - 1] * i) % MOD
  INV[i] = MOD - (INV[MOD % i] * (MOD / i)) % MOD
  FINV[i] = (FINV[i - 1] * INV[i]) % MOD
end

def combination_mod(n,k)
    return 0 if n < k
    return 0 if (n < 0 || k < 0)
    
    FACT[n] * (FINV[k] * FINV[n - k] % MOD) % MOD;
end


N, K = gets.split.map(&:to_i)
K_ = N - K

ans = (1 .. K).map do |i|
  b = combination_mod(K -  1, i - 1)
  r = combination_mod(K_ + 1, i)
  (b * r) % MOD
end

puts ans


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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 200005


int main() {
sp;
    int n,m;
    string a,b;
    cin>>a>>b;
    n=a.size();
    m=b.size();
    a=" "+a;
    b=" "+b;
    int l[n+1][m+1];
    for(int i=0; i<=n; ++i)
        for(int j=0; j<=m; ++j){
            if((!i)||(!j))
                l[i][j]=0;
            else if(a[i]==b[j])
                l[i][j]=l[i-1][j-1]+1;
            else
                l[i][j]=max(l[i-1][j],l[i][j-1]);
        }
    int i=n,j=m;
    vector<char> v;
    while(i>0&&j>0){
        if(a[i]==b[j]){
            v.push_back(a[i]);
            --i,--j;
        }
        else if(l[i][j-1]>l[i-1][j])
            --j;
        else
            --i;
    }
    while(!v.empty()){
        cout<<v.back();
        v.pop_back();
    }
    return 0;
}


Measured memory_bytes: 35456
#include <iostream>
using namespace std;
 
int main(){
    int n, x;
    int cnt;
    while(true){
        cnt = 0;
        cin >> n >> x;
        if(n==0 && x==0) break;
        for(int i=1;i<n-1;i++){
            for(int j=i+1; j<n;j++){
                for(int k=j+1; k<n+1; k++){
                    if(i+j+k==x){
                        cnt++;
                    }
                }
            }
        }
        cout << cnt << endl;
    }
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define vc vector
#define sz(v) (int)(v).size()
#define pb push_back
#define FF first
#define SS second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define pll pair<ll,ll>
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
typedef long double f80;
#define endl '\n'

const int mod = 1e9 + 7;
const int N = 2005;
int a[N];

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, k;
	cin >> n >> k;
	int ans = 0;
	fr(i, 1, n) {
		cin >> a[i];
		for(int j = 1; j < i; j++) {
			if(a[j] > a[i]) 
				ans++;
		}
	}
	ans = (ans * 1LL * k) % mod;
	int ans1 = ((k * 1LL * (k - 1)) / 2) % mod;
	int ans2 = 0;
	fr(i, 1, n) {
		fr(j, 1, n) {
			if(a[j] > a[i]) ans2++;
		}
	}
	ans1 = (ans1 * 1LL * ans2) % mod;
	cout << (ans + ans1) % mod;
	return 0;
}

Measured memory_bytes: 256
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

d,g = inm()
p = []
c = []
for i in range(d):
    pp,cc = inm()
    c.append(cc)
    p.append(pp)

mn = BIG
for i in range(2**d):
    s = [0]*d
    for j in range(d):
        s[j] = (i>>j)%2  ## set bit info
    ddprint("i {} s {}".format(i,s))
    np = 0
    sc = 0
    for j in range(d):
        if s[j]==1:
            sc += 100*(j+1)*p[j] + c[j]
            np += p[j]
    ddprint("full sc {} np {}".format(sc,np))
    if sc<g:
      for j in range(d-1,-1,-1): # only 1st non-full j enuf
        if s[j]==1:
            continue
        for k in range(p[j]-1):
            np += 1
            sc += 100*(j+1)
            if sc >= g:
                break
        break
    ddprint("all sc {} np {}".format(sc,np))
    if sc>=g and np<mn:
        mn = np
print(mn)


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 200000 + 7;
int n, v[N], sum[N];
string s;

int get(int x, int l, int r) {
  if (x == 0) {
    return r - l + 1 - get(1, l, r);
  } else {
    return sum[r] - sum[l - 1];
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> s;
  for (int i = 1; i <= n; i++) {
    if (s[i - 1] == 'W') {
      v[i] = 1;
    } else {
      v[i] = 0;
    }
    sum[i] = sum[i - 1] + v[i];
  }
  int ops = min(get(0, 1, n), get(1, 1, n));
  for (int i = 1; i <= n; i++) {
    /// [1...i] => 0
    /// [i+1...n] => 1
    int x = get(1, 1, i);
    int y = get(0, i + 1, n);
    ops = min(ops, max(x, y));
  }
  cout << ops << "\n";
  return 0;
}


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

using namespace std;


int main()
{
    long N;
    long count1 = 0;
    long sum=0, min = LONG_MAX;
    string str;
 

    cin >> N >> str;

   for (int i = 0; i < N; i++) {
        if (str[i] == '.') {
            count1++;
        }
    }
    min = sum = count1;
    for (int i = 0; i < N; i++) {
        if (str[i] == '#') {
            sum++;
        } else {
            sum--;
        }
        if (sum < min) {
            min = sum;
        }
    }

    cout << min;    
    return 0;   
};




Measured memory_bytes: 640
import java.util.*;

// ABC 62-D
// http://abc062.contest.atcoder.jp/tasks/arc074_b

public class Main {
	
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt() + in.nextInt();
		System.out.println(n >= 10 ? "error" : n);
	}
}

Measured memory_bytes: 22608
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(ll i=1;i<=(n);++i)
#define ifr(i,n) for(ll i=(n)-1;i>=0;--i)
#define iFr(i,n) for(ll i=(n);i>0;--i)
//グローバルな場所に配列を置くとすべて0に初期化される。

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a,b,c;
  cin>>a>>b>>c;
  fr(i,10){
    c=c*a-b;
    cout<<c<<"\n";
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int sx ,sy ,tx ,ty;
  scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
  int X = tx - sx , Y = ty - sy;
  
  for(int i = 0;i < X;i ++){
    putchar('R');
  }
  for(int i = 0;i < Y;i ++){
    putchar('U');
  }
  for(int i = 0;i < X;i ++){
    putchar('L');
  }
  for(int i = 0;i < Y;i ++){
    putchar('D');
  }
  putchar('D');
  for(int i = 0;i < X + 1;i ++){
    putchar('R');
  }
  for(int i = 0;i < Y + 1;i ++){
    putchar('U');
  }
  putchar('L');
  putchar('U');
  for(int i = 0;i < X + 1;i ++){
    putchar('L');
  }
  for(int i = 0;i < Y + 1;i ++){
    putchar('D');
  }
  putchar('R');
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int ans=0;
  cin >> N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  p.at(N-1)=p.at(N-1)/2;
  for(int i=0;i<N;i++){
    ans+=p.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = 0
s = sum(a)
al = []

sum1 = 0

for i in range(0,n):
        # if i == 1:
        #         sum1 = sum(a[0:i])
        # else:
        #         sum1 += a[i]
        sum1 += a[i]
        sum2 = s - sum1
        # print("sum1:"+str(sum1))
        # print("sum2:"+str(sum2))
        al.append(abs(sum1 - sum2))
        if sum1 == sum2:
                print(0)
                exit()

minDiffIdx = al.index(min(al))

# print("---")
# print(minDiffIdx)
# print("---")

tmp1 = sum(a[0:minDiffIdx])
tmp2 = sum(a[minDiffIdx:])
# print(tmp1)
# print(tmp2)
diff1 = abs(tmp1 - tmp2)

tmp3 = sum(a[0:minDiffIdx + 1])
tmp4 = sum(a[minDiffIdx + 1:])
# print(tmp3)
# print(tmp4)
diff2 = abs(tmp3 - tmp4)
print(min(diff1, diff2))

# d1 = diff1
# d2 = diff2

# if d1 < d2:
#         for i in range(n//2):
#                 if a[i] > 1:
#                         d1 -= a[i]
#                 if d1 < 0:
#                         ans += diff1 + d1
#                         break
#                 elif d1 == 0:
#                         ans += diff1
#                         break
#         if 
# else:

Measured memory_bytes: 99276
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int MOD = 1e9+7;
const int INF = 1e9;
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif


int main() {
  int N, K; cin >> N >> K;

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

  ll sum = 0;
  rep(i, K) sum += P[i];
  ll ans = sum;
  rep(i, N-K) {
    sum += P[i+K];
    sum -= P[i];
    ans = max(ans, sum);
  }
  cout << fixed << setprecision(16) << (K + ans) / 2.0 << endl;

  return 0;
}


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

int main(void)
{
  long long int n,i,a[2000000],sum=0;
  
  scanf("%lld",&n);
  
  for(i=0;i<n;i++) {
    scanf("%lld",&a[i]);
    if(i>0 && a[i] < a[i-1]){
      sum += (a[i-1] - a[i]);
      a[i]+= (a[i-1] - a[i]);
    }
  }
  
  printf("%lld", sum);

  return 0;
}

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

int main()
{
  string x;
  int sum = 0;
  cin >> x;
  while (x != "0")
  {
    for (int i = 0; i < x.size(); i++)
    {
      sum += x.at(i) - 48;
    }
    cout << sum << endl;
    sum = 0;
    cin >> x;
  }
}


Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n;
    cin, n;
    string ans = "";

    do {
        n--;
        ans += char('a' + n % 26);
        n /= 26;
    } while (n);
    reverse(ans.begin(), ans.end());
    print(ans);
    return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char x = sc.next().toCharArray()[0];
    char y = sc.next().toCharArray()[0];
    if(x>y){
      System.out.println(">");
    }else if(x==y){
      System.out.println("=");
    }else{
      System.out.println("<");
    }
  }
}

Measured memory_bytes: 22996
require 'pp'

n = gets.to_i
a_n = gets.chomp!.split(" ").map(&:to_i).sort
x = a_n.group_by {|x| x >= 0 }

if (x[false] || []).length % 2 == 0
    puts a_n.inject(0) {|sum, n| sum += n.abs }
else
    s = a_n.inject(0) {|sum, n| sum += n.abs }
    min = 10 ** 10
    a_n.each do |a|
        if a.abs < min
            min = a.abs
        end
    end
    s -= (2 * min)
    puts s
end


Measured memory_bytes: 13044
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define T int t = 0; cin >> t; while(t--)
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef  long double lld;
const ll mod = 1e9 + 7;
const ll mx = 2e6 + 5;
int dp[101][4][3];
vector<int>num;
int sz, k;
int digit_dp(int i, int cnt, int f){
    if(cnt > k)return 0;
    if(i == sz){
        return cnt == k ? 1 : 0;
    }
    if(dp[i][cnt][f] != -1)return dp[i][cnt][f];
    int res = 0;
    int LMT = (f == 1) ? 9 : num[i];
    for(int digit = 0; digit <= LMT; ++digit){
        res += digit_dp(i + 1, ((digit != 0) ? cnt + 1 : cnt), (f == 0 && digit == LMT) ? 0 : 1);
    }
    return dp[i][cnt][f] = res;
}
int solve(string n){
    f(i, n.size())num.pb(n[i] - '0');
    sz = num.size();
    return digit_dp(0, 0, 0);
}

void input(){
    memset(dp, -1, sizeof(dp));
   string n;
   cin >> n >> k;
   cout << solve(n) << endl;
    
}
int main(){
    input();
    return 0;
}

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

using namespace std;
const int Sz = 1e6 + 5;
int a[Sz],b[Sz];
string s, t;
int q, l, r, l2, r2;
int32_t main(){
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> s >> t;
    s = " " + s;
    t = " " + t;
    a[0] = 0;
    b[0] = 0;
    for(int i = 1; i < s.size(); i++){
        if(s[i] == 'A') a[i] = a[i - 1] + 1;
        else a[i] = a[i - 1] + 2;
    }
    for(int i = 1; i < t.size(); i++){
        if(t[i] == 'A') b[i] = b[i - 1] + 1;
        else b[i] = b[i - 1] + 2;
    }
    cin >> q;
    while(q--){
        cin >> l >> r >> l2 >> r2;
        int x = (a[r] - a[l - 1]) % 3;
        int y = (b[r2] - b[l2 - 1]) % 3;
        if(abs(x) == abs(y)) cout << "YES\n";
        else cout << "NO\n";
        //cerr << x << " " << y << "\n";
    }
    return 0;
}


Measured memory_bytes: 4684
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

struct SegmentTree {
private:
    int n;
    vector<ll> node;

public:
    SegmentTree(vector<ll> v) {
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, -INF);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = max(node[2*i+1], node[2*i+2]);
    }

  void update(int x, ll val) {
    // 最下段のノードにアクセスする
    x += (n - 1);

    // 最下段のノードを更新したら、あとは親に上って更新していく
    node[x] = val;
    while(x > 0) {
        x = (x - 1) / 2;
        node[x] = max(node[2*x+1], node[2*x+2]);
    }
  }
  ll getmax(int a, int b, int k=0, int l=0, int r=-1) {
    
    if(r < 0) r = n;

    if(r <= a || b <= l) return -INF;
    if(a <= l && r <= b) return node[k];

    ll vl = getmax(a, b, 2*k+1, l, (l+r)/2);
    ll vr = getmax(a, b, 2*k+2, (l+r)/2, r);
    return max(vl, vr);
  }

  ll getnode(int x){
    return node[n-1+x];
  }
  void shownode(int num){
    rep(i,num){
      cout << getnode(i+1) << endl;
    }
  }
};



int main(void){

  ll n;
  cin>>n;

  vector<ll> h(n);
  vector<ll> a(n);
  

  rep(i,n) cin>>h[i];

  rep(i,n) cin>>a[i];

  vector<ll> dp(200001,0LL);

  SegmentTree st(dp);

  rep(i,n){
    if(h[i] == 1) st.update(h[i],a[i]);
    else st.update(h[i],a[i]+st.getmax(1,h[i]));
    //st.update(h[i],a[i]);
    //cout << st.getnode(h[i]) << endl;

  }

  //st.shownode(n);

  cout << st.getmax(1,n+1) << endl;

  return 0;

}


Measured memory_bytes: 10624
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n - 1):
        for m in range(s + 1, n):
            for e in range(m + 1, n + 1):
                if x == s + m + e:
                    count += 1

    print(count)

Measured memory_bytes: 7676
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    rep(i,n-1){
        int d;
        std::cin >> d;
        a[d-1]++;
    }
    rep(i,n){
        std::cout << a[i] << std::endl;
    }
}

Measured memory_bytes: 4060
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//次回のABC
		int N = sc.nextInt();
		//桁数ゾロ目にするため
		int x = N/111;
		//割り切れないとき(670など)は
		//次回ゾロ目の時(777)に参加する
        //670/111=6, 6+1=7, 7*111=777
		if(N%111!=0) {
			x+=1;
		}
		System.out.println(111*x);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <math.h>
#define lli long long int
#include <limits.h>
#include <fstream>

using namespace std;

/*lli gcd(lli a,lli b)
{
	if(a==0)return b;
	return gcd(b%a,a);
}*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli i,j,tt=1;
    //cin>>tt;
    while(tt--)
    {
        lli n;
        cin>>n;
        int ac=0,re=0,tle=0,wa=0;
        while(n--)
        {
            string s;
            cin>>s;
            if(s=="AC")
                ac++;
            else if(s=="TLE")
                tle++;
            else if(s=="WA")
                wa++;
            else
                re++;
        }
        cout<<"AC x "<<ac<<"\n";
        cout<<"WA x "<<wa<<"\n";
        cout<<"TLE x "<<tle<<"\n";
        cout<<"RE x "<<re<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++) cin >> d[i];

    sort(d.begin(), d.end());

    int mid = N / 2;

    cout << d[mid] - d[mid - 1] << endl;

    return 0;
}

Measured memory_bytes: 640
a,b,c,x,y = map(int,input().split())
maxi = max(x,y)
if maxi == x:
  p_1 = 2*x*c
  p_2 = 2*y*c + (x - y)*a
  p_3 = x*a + y*b
  print(min(p_1,p_2,p_3))
else:
  p_1 = 2*y*c
  p_2 = 2*x*c + (y - x)*b
  p_3 = x*a + y*b
  print(min(p_1,p_2,p_3))

Measured memory_bytes: 3064
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int q = sc.nextInt();

    int s = 0;
    int g = n-1;

    int tt = 0;

    String[] name = new String[n];
    int[] time = new int[n];

    for(int i=0; i<n; i++){
      name[i] = sc.next();
      time[i] = sc.nextInt();
    }

    while(true){
      if(time[s] > q){
        time[(g+1)%n] = time[s]-q;
        name[(g+1)%n] = name[s];
        tt = tt+q;
        g = (g+1)%n;
        s = (s+1)%n;
      }
      else{
        tt = tt+time[s];
        if(s == g){
          System.out.println(name[s]+" "+tt);
          break;
        }
        else{
          System.out.println(name[s]+" "+tt);
          s = (s+1)%n;
        }
      }
    }

  }
}



Measured memory_bytes: 69348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  ll h, n;
  cin >> h >> n;
  vector<ll> a(n), b(n);
  rep(i, n) {
    cin >> a[i] >> b[i];
  }

  // dp[i] ::= 敵のHPがiのときの最小のMP
  vector<ll> dp(h+10010, inf);
  dp[0] = 0;
  rep(i, h+1) {
    rep(j, n) {
      dp[i + a[j]] = min(dp[i] + b[j], dp[i+a[j]]);
    }
  }

  ll ans = inf;
  for (int i = h; i < dp.size(); ++i) {
    chmin(ans, dp[i]);
  }

  cout << ans << endl;
}

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

int main(){
  int N;
  long long int sum=0; 
  cin>>N;
  for(int i=0;i<N+1;i++){
    if(i%3!=0&&i%5!=0)
      sum+=i;
  }
  cout<<sum;
  return 0;
}

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

int main() {
  string N;
  cin >> N;
  int count = 0;
  
  for(int i=0;i<N.size();i++){
    char c = N[i];
    count += c - '0';
  }
  
  if (stoi(N)%count==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
from itertools import product

n, m = [int(i) for i in input().rstrip().split()]
AA = [[0 if i == '.' else 1 for i in input().rstrip()] for _ in range(n)]
BB = [[0 if i == '.' else 1 for i in input().rstrip()] for _ in range(m)]

for i_r, i_c in product(range(n - m + 1), range(n - m + 1)):
    i_r -= 1
    i_c -= 1
    for k_r, k_c in product(range(m), range(m)):
        if AA[i_r + k_r][i_c + k_c] == BB[k_r][k_c]:
            continue
        else:
            break
    else:
        print('Yes')
        break
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <vector>
#include <set>
#include <string.h>
using namespace std;

int main()
{
  int n = 0;
  int k = 0;
  int max_value = 0;
  scanf("%d %d", &n, &k);
  vector<int> a(n, 0);
  for(int i=0; i<n; i++){
    scanf("%d", &a[i]);
  }
  int winner = 0;
  vector<int> arr(k+1, 0);
  arr[0] = 1;
  for(int i=1; i<k+1; i++){
    arr[i] = 1;
    for(int j=0; j<n; j++){
      if(i - a[j]<0){
        winner = 1;
      }else{
        winner = 1 - arr[i - a[j]];
      }
      arr[i] = std::min(winner, arr[i]);
    }
  }

  if(arr[k] == 0){
    printf("First\n");
  } else {
    printf("Second\n");
  }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
struct edge{int to,cap,rev;};
vector<edge> G[4000010];
bool used[4000010];
void add_edge(int from,int to,int cap){
    G[from].push_back((edge){to,cap,(int)G[to].size()});
    G[to].push_back((edge){from,0,(int)G[from].size()-1});
}
int dfs(int v,int t,int f){
    if(v==t)return f;
    used[v]=true;
    rep(i,0,G[v].size()){
        edge &e=G[v][i];
        if(used[e.to]==false&&e.cap>0){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s,int t){
    int f=0;
    for(;;){
        memset(used,0,sizeof used);
        int g=dfs(s,t,1000000000);
        if(g==0)return f;
        f+=g;
    }
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int h,w;cin>>h>>w;
    string s[h];
    rep(i,0,h)cin>>s[i];
    rep(i,0,h){
        rep(j,0,s[i].size()){
            if(s[i][j]=='.')continue;
            add_edge(i,j+100,1);
            if(s[i][j]=='S')add_edge(200,i,1000000000);
            if(s[i][j]=='T')add_edge(i,201,1000000000);
        }
    }
    rep(i,0,w){
        rep(j,0,h){
            if(s[j][i]=='.')continue;
            add_edge(i+100,j,1);
            if(s[j][i]=='S')add_edge(200,i+100,1000000000);
            if(s[j][i]=='T')add_edge(i+100,201,1000000000);
        }
    }
    int ans=max_flow(200,201);
    if(ans>=100000000)cout<<-1<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 98560
// #include "../utils.cpp"
/*
Problem

Category
全探索：ビット全探索
(参考: https://qiita.com/drken/items/7c6ff2aa4d8fce1c9361)

URL:
https://atcoder.jp/contests/abc128/tasks/abc128_c

考察:
NとMが10以下ととても小さいので愚直に全探索で解ける

Date: 2020/04/06
*/

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

/* ==== declarations ====== */
// functions
void solve();
void getInput();

// global variables
int N, M;
vector<vector<int>> lights;
vector<int> P;


/* ======================== */

signed main(){
    getInput();
    solve();
    return 0;
}

void getInput() {
    cin>>N>>M;
    for(int i=0; i<M; ++i) {
        int k;
        cin>>k;
        vector<int> LtoS = vector<int>(k, 0);
        for (int j=0; j<k; ++j) {
            int in;
            cin>>in;
            LtoS[j] = in-1;
        }
        lights.push_back(LtoS);
    }
    P = vector<int>(M, 0);
    for(int i=0; i<M; ++i) {
        cin>>P[i];
    }
}


void solve() {
    int ans = 0;
    for(int i=0; i< (1<<N); ++i) {
        vector<bool> res(M, false);
        for(int j=0; j<M; ++j) {
            auto& light = lights[j];
            for(auto s: light) {
                if (i & 1<<s) {
                    res[j] = !res[j];
                    // cout<<"switched: "<<myToStr(res)<<endl;
                }
            }
        }
        // cout<<myToStr(res)<<endl;
        bool a = true;
        for(int j=0; j<M; ++j) {
            a *= P.at(j) == res[j];
        }
        // cout<<bitset<10>(i)<<": "<<a<<endl;
        if (a) ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
n, y = map(int, input().split())

for a in range(n + 1):
    for b in range(n + 1):
        c = n - a - b
        if c >= 0 and  a * 10000 + b * 5000 + c * 1000 == y:
            print(a, b, c)
            exit()
print('-1', '-1', '-1')


Measured memory_bytes: 40812