akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define vi vector<int>
#define lvi vector<long long>
#define pi pair<int,int>
#define lpi pair<long long ,long long>
#define mp make_pair
#define pb push_back
#define ll long long 
#define N 100005
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define mod1 1000000000000000007
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>multiordered_set;
ll int pw(ll int a, ll int b,ll md) {
    if (b == 0) return 1;
    ll int t = pw(a, b / 2,md);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
vector<int> pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.push_back(p);
}
bool cmp(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    if(a.first==b.first)return a.second<b.second;
    return a.first<b.first;
}
ll int gcd(ll int a,ll int b)
{
    if(!a)return b;
    return gcd(b%a,a);
}
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
    return true; 
} 
map<int,int>pa;
int find(int i){
    if(pa[i]==i)return i;
    return pa[i]=find(pa[i]);
}     
void join(int i,int j){
    int a=find(i);
    int b=find(j);
    if(b>=a)pa[b]=a;
    else pa[a]=b;
}               
int ddx[]={-1,-1,-1,0,1,1,1,0};
int ddy[]={-1,0,1,1,1,0,-1,-1};
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int main()
{
    faltu;
    int t=1;
    //cin>>t;
    while(t--)
    {
        int A, B, ans;
 cin >> A >> B;
 ans = max(0, A - 2 * B);
 cout << ans << endl;
    }
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>

int main() {
    int nums = 0;
    std::vector<int> h;
    std::cin >> nums;
    int tmp = 0;
    while( std::cin >> tmp) {
        h.push_back(tmp);
    }

    std::vector<int> memery_(nums, 0);
    memery_[1] = std::abs(h[1] - h[0]);
    for (int i=2;i<nums;i++) {
        memery_[i] = std::min(memery_[i-1] + std::abs(h[i] - h[i-1]),
                              memery_[i-2] + std::abs(h[i] - h[i-2]));
    }
    std::cout << memery_[nums-1] << std::endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

typedef long long ll;

int main() {
    ll t1,t2,a1,a2,b1,b2;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    ll as=t1*a1+t2*a2,bs=t1*b1+t2*b2;
    if(as==bs){
        cout<<"infinity"<<endl;
        return 0;
    }
    if(as<bs){
        swap(a1,b1);
        swap(a2,b2);
        swap(as,bs);
    }
    ll len=(b1-a1)*t1;
    if(a1>=b1){
        cout<<0<<endl;
        return 0;
    }
    ll tm=len/(as-bs);
    ll ans=1+tm*2;
    if(len%(as-bs)==0) ans--;
    //cout<<tm<<" "<<len<<" "<<as-bs<<endl;
    cout<<ans<<endl;


    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
def dfs(s=''):
    ans = 0
    if s!='' and int(s)>N:
        return 0
    elif '7' in s and '5' in s and '3' in s:
        ans += 1
    for c in ['3','5','7']:
        ans += dfs(s+c)
    return ans

ans = dfs()
print(ans)


Measured memory_bytes: 49756
import java.util.Scanner;

public class Main {
    static int w; // <= 50
    static int h; // <= 50
    static int[][] map;
    static int islands;
    static Scanner sc = new Scanner(System.in);
    static int[][] directions = {{0,1}, {1,1}, {1,0}, {1,-1}, {0,-1}, {-1,-1}, {-1,0}, {-1,1}};

    public static void paintIsland(int x, int y) {
        map[y][x] = 0;
        for (int k = 0; k < directions.length; k++) {
            int nx = x + directions[k][0];
            int ny = y + directions[k][1];

            if (nx >= 0 && nx < w && ny >= 0 && ny < h && map[ny][nx] == 1)
                paintIsland(nx, ny);
        }

    }


    public static void main(String[] args) {
        while (true) {
            // Initialize variables
            islands = 0;
            w = sc.nextInt();
            h = sc.nextInt();
            map = new int[h][w];
            if (w == 0 && h == 0)
                break;

            // initialize map
            String[] rowStr;
            int[] row;
            for (int i = 0; i < h; i++) {
                row = new int[w];
                for (int j = 0; j < w; j++) {
                    row[j] = sc.nextInt();
                }
                map[i] = row;
            }

            for (int y = 0; y < h; y++) {
                for (int x = 0; x < w; x++) {
                    if (map[y][x] == 1) {
                        paintIsland(x, y);
                        islands++;
                    }
                }
            }

            // out: number of islands
            System.out.println(islands);
        }
    }
}

Measured memory_bytes: 45208
#include "bits/stdc++.h"

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;


using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	int sum;
	int mx = -1;

	int k, n;
	cin >> k >> n;
	int in1, in2 = -1,in0;
	rep(i, n) {
		cin >> in1;
		if (in2 >= 0) {
			mx = max(mx, in1 - in2);
		}
		else in0 = in1;
		in2 = in1;
	}
	sum = k - max(mx, k - in1 + in0);
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3540
c1 = list(map(int,input().split(" ")))
c2 = list(map(int,input().split(" ")))
c3 = list(map(int,input().split(" ")))

for i in range(2):
	if c1[i+1] - c1[i] == c2[i+1] - c2[i] == c3[i+1] - c3[i]:
		flg = True
	else:
		flg = False

if flg == False:
	print("No")
	exit(0)

if c2[0] - c1[0] == c2[1] - c1[1] == c2[2] - c1[2] and c3[0] - c2[0] == c3[1] - c2[1] == c3[2] - c2[2]:
	print("Yes")
else:
	print("No")



Measured memory_bytes: 3064
#include <iostream>                                          
#include <string>                                            

using namespace std;                                         
                                                             
//L[i][j] X[0]..X[i]??¨X[0]..Y[j]???LCS                        
int L[1001][1001]={};                                        
int main(){
  int testnum;
  cin>>testnum;                                              
  for(int t=0;t<testnum;++t){                                
    string X,Y;                                              
    cin>>X>>Y;
    
    for(int i=1;i<=X.length();++i){                          
      for(int j=1;j<=Y.length();++j){                        
        if(X[i-1]==Y[j-1])
          L[i][j] = 1 + L[i-1][j-1];                         
        else
          L[i][j] = max(L[i][j-1],L[i-1][j]);
      }
    }

    cout << L[X.length()][Y.length()] << endl;
  }
 
  return 0;
}

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

using namespace std;
using ll = long long;

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

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

  vector<int> res(n, 0), wa(n, 0);
  int cnt = 0;
  rep(i, m) {
    int p;
    string s;
    cin >> p >> s;
    --p;

    if (s == "AC") {
      if (res[p]) continue;
      res[p] = 1;
      cnt += wa[p];
    } else {
      if (res[p] == 1) continue;
      ++wa[p];
    }
  }

  int ac = 0;
  rep(i, n) ac += res[i];

  cout << ac << " " << cnt << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, M; long long int P; 
	cin >> N >> M >> P;
	int A[5010] = {}, B[5010] = {};
	long long int C[5010] = {}; 
	long long int D[2510] = {}; 
	long long int INF = 1e15; 
	for(int i = 0; i < M; i++){
		cin >> A[i] >> B[i] >> C[i]; 
		C[i] -= P; C[i] *= -1; 
	}
	for(int i = 2; i <= N; i++){
		D[i] = INF; 
	}
	long long int x, y; 
	for(int i = 0; i <= N * 2; i++){
		for(int j = 0; j < M; j++){
			if(D[A[j]] != INF && D[B[j]] > D[A[j]] + C[j]){
				D[B[j]] = D[A[j]] + C[j];
			}
		}
		if(i == N - 1) x = D[N]; 
		if(i == N * 2) y = D[N]; 
	}
	if(x != y) cout << -1 << endl; 
	else cout << max(- y, 0LL) << endl; 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
#include <cstdint>
#include <iterator>
#include <algorithm>
#include <fstream>
#include <unordered_map>

using namespace std;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Int int_fast64_t

int main()
{
    FAST_IO;

    Int n,d,x,y,count=0;
    cin >> n >> d;
    for(Int i=0;i<n;++i)
    {
        cin >> x >> y;
        if(x*x+y*y<=d*d)
            count++;
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
//  ??¨?????????????????????
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException {
      int S = in.nextInt();
      int h = S / 3600;
      int m = (S - 3600*h) / 60;
      int s = S % 60;
      out.println(h+":"+m+":"+s);
    }
  }

  public static void main(String[] args) throws IOException {
//    ??????
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
//    ??\???
    public BufferedReader br;
    public StringTokenizer st;
    
    public InputReader(InputStream stream) {
//      ?????????????????????
      br = new BufferedReader(new InputStreamReader(stream));
    }
   
//    ????????????????????????
    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }
    
    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken()); 
    }
    
    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }
    
    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }
    
  }
  
}

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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    int ans = 0;
    rep(i, h) cin >> s[i];
    rep(is, 1<<h)rep(js, 1<<w) {
        int cnt = 0;
        rep(i, h) rep(j, w) {
            if (is>>i&1) continue;
            if (js>>j&1) continue;
            if (s[i][j] == '#') cnt++;
        }
        if (cnt == k) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
import copy

h,w = map(int,input().split())

a = [list(map(int,input().split())) for i in range(h)]
b = copy.deepcopy(a)

n=0
for i in range(h):
  for j in range(w-1):
    if b[i][j]%2 ==1 :
      n+=1
      b[i][j] -= 1
      b[i][j+1] += 1

for i in range(h-1):
  if b[i][w-1]%2 == 1:
    n+=1
    b[i][w-1] -= 1
    b[i+1][w-1] += 1

print(n)

for i in range(h):
  for j in range(w-1):
    if a[i][j]%2 ==1 :
      print(i+1,j+1,i+1,j+2)
      a[i][j] -= 1
      a[i][j+1] += 1

for i in range(h-1):
  if a[i][w-1]%2 == 1:
    print(i+1,w,i+2,w)
    a[i][w-1] -= 1
    a[i+1][w-1] += 1

Measured memory_bytes: 10576
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int a[10000];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	int tem=0;
	for(int i=0;i<n;i++)
	{
		tem+=a[i];
	}
	tem=m-tem;
	cout<<n+(tem/a[0])<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
using namespace std;
#define INF 2001001001
#define MOD 1000000007
typedef long long ll;

int N,M;
char S[2000001];
multiset<int>adj[200001];
int As[200001],Bs[200001];
set<pair<int,int>>st; //num, index
bool del[200001];
int deleted=0;

int main()
{
  scanf("%d%d",&N,&M);
  scanf("%s",S);
  for (int i=0;i<M;i++){
    int X,Y;
    scanf("%d%d",&X,&Y);
    adj[X].insert(Y);
    adj[Y].insert(X);
    if (S[X-1]=='A')
      As[Y]++;
    else
      Bs[Y]++;
    if (S[Y-1]=='A')
      As[X]++;
    else
      Bs[X]++;
  }
  for (int i=1;i<=N;i++){
    st.insert({As[i],i});
    st.insert({Bs[i],i});
  }
  while (!st.empty() && st.begin()->first<=0){
    int X=st.begin()->second;
    //cout<<X<<endl;
    st.erase(*st.begin());
    if (!del[X]){
      del[X]=true;
      deleted++;
      for (set<int>::iterator it=adj[X].begin();it!=adj[X].end();it++){
        if (X==*it){
	  if (st.count({As[X],X})>0)
	    st.erase({As[X],X});
	  if (st.count({Bs[X],X})>0)
	    st.erase({Bs[X],X});
	  continue;
	}
	if (adj[*it].count(X)>0)
	  adj[*it].erase(adj[*it].find(X));
	if (S[X-1]=='A'){
	  if (st.count({As[*it],*it})>0)
	    st.erase({As[*it],*it});
	  As[*it]--;
	  st.insert({As[*it],*it});
	}
	else{
	  if (st.count({Bs[*it],*it})>0)
	    st.erase({Bs[*it],*it});
	  Bs[*it]--;
	  st.insert({Bs[*it],*it});
	}
      }
      //cout<<"DONE"<<endl;
      adj[X].clear();
    }
  }
  if (deleted<N)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 45312
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	string a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	rep(i, n){
		if(a[i] == b[i] && b[i] == c[i]) continue;
		if(a[i] != b[i] && b[i] != c[i] && a[i] != c[i]) ans += 2;
		else ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math
from operator import itemgetter


n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

for i in range(n):
    tmp = math.atan2(info[i][1], info[i][0])
    info[i].append(tmp)

info = sorted(info, key = itemgetter(2))
info = info + info
ans = 0

for i in range(n):
    tmp = [0, 0]
    for j in range(n):
        tmp[0] += info[i+j][0]
        tmp[1] += info[i+j][1]
        tmp_ans = tmp[0]**2 + tmp[1]**2
        ans = max(tmp_ans, ans)

print(ans**0.5)

Measured memory_bytes: 38896
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;


const LL INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

LL kaijo(LL n){
    LL ans=1;
    for(LL i=1;i<=n;++i){
        (ans*=i)%=MOD;
    }
    return ans;
}


int main(){
    LL n,m;
    cin>>n>>m;
    bool to1[200200]={0},ton[200200]={0};
    for(int i=0;i<m;i++){
        LL a,b;
        cin>>a>>b;
        if(a==1)to1[b]=1;
        if(b==n)ton[a]=1;
    }
    bool han=0;
    for(int i=2;i<n;++i){
        if(to1[i]==1&&ton[i]==1){
            han=1;
        }
    }
    if(han)cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, M, k, p[10], cnt;
vector<int>v[10];

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		cin >> k;
		v[i] = vector<int>(k);
		for (int j = 0; j < k; ++j) {
			cin >> v[i][j];
			--v[i][j];
		}
	}
	for (int i = 0; i < M; ++i) {
		cin >> p[i];
	}
	for (int i = 0; i < (1 << N); ++i) {
		bool f = true;
		for (int j = 0; j < M; ++j) {
			bool b = !p[j];
			for (int k : v[j]) {
				if ((1 << k)&i) {
					b ^= true;
				}
			}
			f &= b;
		}
		cnt += f;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
typedef pair<int,int> product;

int main() {
    int n,w;
    cin >> n >> w;
    vector<product> products(n);    // <value,weight>
    for(int i=0;i<n;i++){
        cin >> products.at(i).first >> products.at(i).second;
    }

    //　個数制限なし
    vector<int> dp(w+1,0);
    for(int weight=0;weight<=w;weight++){
        vector<int> tmp(n,0);
        for(int i=0;i<n;i++){
            if (weight - products[i].second >= 0){
                tmp[i] = dp[weight - products[i].second] + products[i].first;
            }
        }
        dp[weight] = *max_element(tmp.begin(),tmp.end());
    }
    cout << dp[w] << endl;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
ll n  ,mx , m , a , cnt , ans , d;
string s;
int main(){
    cin >> n;
    ll arr[n];
    for( int i = 0;i < n;i ++ )
        cin >> arr[i];
        sort( arr , arr + n );
    for( int i = 0;i < n;i ++ ){
        for( int j = i + 1;j < n;j ++ ){
            for( int k = j + 1;k < n;k ++ ){
                if( arr[i] != arr[j] and arr[i] != arr[k] and arr[j] != arr[k] and arr[i] + arr[j] > arr[k] )
                    cnt ++;
            }
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3628
#include <iostream>
#include <cmath>

int main() {
	int A, B, res1, res2;
	std::cin >> A >> B;

	res1 = A * 100;
	if (res1 % 8 != 0) {
		res1 /= 8;
		++res1;
	}
	else res1 /= 8;
	res2 = B * 10;
	if (res1 == res2) std::cout << res1 << '\n';
	else if (res1 > res2) {
		if (std::floor(res1 / 10) == B) std::cout << res1 << '\n';
		else std::cout << "-1\n";
	}
	else {
		if (std::floor(res2 * 0.08) == A) std::cout << res2 << '\n';
		else std::cout << "-1\n";
	}
	
	return 0;
}

Measured memory_bytes: 256
while True:
    n,x=map(int, input().split())
    if n==0 and x==0:
        break
    else:
        count=0
        for i in range(1,n-1):
            for j in range(i+1,n):
                for k in range(j+1,n+1):
                    if i+j+k==x:
                        count=count+1
        print(count)


Measured memory_bytes: 5596
/*
  Reference:-
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
#define all(vec) vec.begin(),vec.end()
//ll mod=1000000007;
ll mod=998244353;
const int N=2e5 + 5;
ll power(ll n,ll k){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%mod;
        k/=2;
        n=(n*n)%mod;
    }
    //ans=(ans-1+mod)%mod;
    return ans;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,s;
    cin>>n>>s;
    int ar[n];
    forn(i,n)cin>>ar[i];
    ll dp[n+1][s+1];
    memset(dp,0,sizeof(dp));
    dp[0][0]=power(2,n);
    ll inv=power(2,mod-2);
    forn(j,s+1){
        forn1(i,n+1){
            dp[i][j]=dp[i-1][j];
            if(j-ar[i-1]>=0){
                ll temp=(dp[i-1][j-ar[i-1]]*inv)%mod;
                dp[i][j]=(dp[i][j]+temp)%mod;
            }
            //dp[i][j]+=dp[i-1][j];
        }
    }
    //forn(i,n+1){forn(j,s+1)cout<<dp[i][j]<<" ";cout<<endl;}
    cout<<dp[n][s];

    return 0;
}


Measured memory_bytes: 73924
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x==0)
		{
			System.out.println(1);
			
		}
		else
		{
			System.out.println(0);
		}

	}

}

Measured memory_bytes: 27068
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
signed main(){

    ll A, B;
    cin>>A>>B;
    if(A==1 || B==1){
        cout<<1<<endl;
    }
    else
        cout<<(A/2LL)*B+(A%2)*((B+1)/2LL)<<endl;

    // ll ans=0;
    // for(int i=1;i<=A;i++)
    //     for(int j=1;j<=B;j++)
    //         if((i+j)%2==0)
    //             ans++;

    // cout<<ans<<endl;

    return 0;
}

// signed main(){

//     ll a, b, c;
//     cin>>a>>b>>c;

//     ll temp=a*a+b*b+c*c-2*(a*b+b*c+a*c);
//     if(temp<0)
//         cout<<"Yes"<<endl;
//     else
//         cout<<"No"<<endl;

//     return 0;
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstring>
#include <cstdio>
#include <sstream>

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
const double EPS=1e-6;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) a.rbegin(),a.rend()
#define FLL(a,b) memset((a),b,sizeof(a))
#define CLR(a) FLL(a,0)
#define declare(a,it) __typeof(a) it=(a)
#define FOR(it,a) for(declare(a.begin(),it);it!=a.end();++it)
#define FORR(it,a) for(declare(a.rbegin(),it);it!=a.rend();++it)
template<class T,class U> ostream& operator<< (ostream& o, const pair<T,U>& v){return o << "(" << v.F << ", " << v.S << ")";}
template<class T> ostream& operator<< (ostream& o, const vector<T>& v){o << "{";rep(i,SZ(v)) o << (i?", ":"") << v[i];return o << "}";}
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};
int s2i(string& a){stringstream ss(a);int r;ss>>r;return r;}
int geti(){int n;scanf("%d", &n);return n;}

/*
  factor = {(expr) | var | num} (^ num)
  term = factor (term)
  expr = term (+- expr)
 */

string in;
int pos;

typedef map<string, long long> El;
void go(){
  while(pos < SZ(in) && in[pos]==' ') ++pos;
}
El expr();
El factor(){
  go();
  El ret;
  if(isdigit(in[pos])){
    ll a = 0;
    while(pos<SZ(in) && isdigit(in[pos]))
      a = a*10 + in[pos++] - '0';
    ret[""] = a;
  }else if(isalpha(in[pos])){
    string a;
    a += in[pos++];
    go();
    if(pos<SZ(in) && in[pos]=='^'){
      ++pos;
      go();
      a = string(in[pos++]-'0',a[0]);
      //cout << a << endl;
    }
    ret[a] = 1;
  }else if(in[pos]=='('){
    ++pos;
    ret = expr();
    go();
    ++pos;
  }
  
  return ret;
}

El term(){
  go();
  auto p = factor();
  go();

  while(pos < SZ(in) && in[pos] != ')' &&
        in[pos] != '+' && in[pos] != '-'){
    El np;
    for(auto i : factor())
      for(auto j : p){
        auto ns = i.first + j.first;
        sort(ns.begin(), ns.end());
        np[ns] += i.second*j.second;
      }
    p = np;
    go();
  }
  
  return p;
}

El expr(){
  go();
  auto p = term();
  go();
  while(pos < SZ(in) && (in[pos]=='+' || in[pos]=='-')){
    auto op = in[pos++];
    for(auto f : term())
      p[f.first] += op == '+' ? f.second : -f.second;
    go();
  }
  El ret;
  for(auto f : p) if(f.second) ret[f.first] = f.second;
  return ret;
}

int main(int argc, char *argv[])
{
  while(getline(cin, in) && in != "."){
    pos = 0;
    auto p = expr();
    //for(auto pp : p) cout << pp.first << " " << pp.second << endl;
    
    while(getline(cin, in) && in != "."){
      pos = 0;
      auto q = expr();
      //for(auto pp : q) cout << pp.first << " " << pp.second << endl;        
      cout << (q == p ? "yes": "no") << endl;
    }
    cout << '.' << endl;
  }
  return 0;
}

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

#define IOS cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long double ld;
const int mod = 1e9+7;

void add_self(int& a, int b) {
    a += b;
    if(a >= mod)
        a-=mod;
}

int main(){
    IOS

    int n;
    cin>>n;

    vector<vector<int>>can(n,vector<int>(n,0));

    for(int i = 0; i< n; i++){
        for(int j = 0; j < n; j++){
            cin>>can[i][j];
        }
    }

    vector<int> dp(1 << n);

    dp[0] = 1;

    for(int mask = 0; mask < (1<<n)-1; ++mask) {
        int a = __builtin_popcount(mask);
        for (int b = 0; b < n; ++b) {
            if (can[a][b] && !(mask & (1 << b))) {
                int m2 = mask ^(1 << b);
                add_self(dp[m2], dp[mask]);
            }
        }
    }

    cout<<dp[(1<<n)-1];



}



Measured memory_bytes: 8448
n=int(input())
taro=0
hanako=0
for i in range(n):
    w1,w2=input().split()
    o1,o2=0,0
    m=max(len(w1),len(w2))
    for i in range(len(w1)):
        o1+=ord(w1[i])*123**(m-i)
    for i in range(len(w2)):
        o2+=ord(w2[i])*123**(m-i)
    if o1>o2:
        taro+=3
    elif o1<o2:
        hanako+=3
    else:
        taro+=1
        hanako+=1
print(str(taro)+' '+str(hanako))


Measured memory_bytes: 5600
#include<iostream>
#include<string>
#include<set>
#include<algorithm>

using namespace std;

int main(){
  int i, n, m;
  string id;
  bool is_open;
  set<string> data;

  cin >> n;
  for(i=0; i<n; ++i){
    cin >> id;
    data.insert(id);
  }

  cin >> m;
  for(i=0, is_open=false; i<m; ++i){
    cin >> id;
    if(data.find(id) != data.end()){
      if(is_open == false){
	cout << "Opened by " << id << endl;
	is_open = true;
      }else{
	cout << "Closed by " << id << endl;
	is_open = false;
      }
    }else{
      cout << "Unknown " << id << endl;
    }
  }

  return 0;
}

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


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



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, T;
  cin >> N >> T;
  vector<int> times(N);
  for (int i = 0; i < N; i++)
    cin >> times[i];
  int res = 0;
  for (int i = 1; i < N; i++) {
    int time_diff = times[i] - times[i - 1];
    if (time_diff <= T)
      res += time_diff;
    else
      res += T;
  }
  cout << res + T << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
   long long n;
   cin>>n;
   vector<long long> v(n);
   map<int,int> g;
   for(int i=1;i<=n;i++)
   {
   	 g[i]=0;

   }
   for(int i=0;i<n-1;i++)
   {
      cin>>v[i];
      g[v[i]]++;
   }

   for(auto x:g)
   {
   	  cout<<x.second<<"\n";
   }


}
main()
{
int t;
t=1;
while(t--)
{
solve();

}
}

Measured memory_bytes: 17248
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int a[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  FOR(i, 1, n + 1) {
    cin >> a[i];
  }

  int ans = 0;
  FOR(i, 1, n) {
    if(a[i] == i) {
      swap(a[i], a[i + 1]);
      ans++;
    }
  }

  if(a[n] == n) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1)


struct Edge{
  int to, id;
};

using Edges = vector<Edge>;

void solve(){
  int n;
  cin >> n;
  vector<Edges> e(n); 
  vector<int> ecol(n-1,0);
  FOR(i,0,n-1){
    int a, b;
    cin >> a >> b;
    --a; --b;
    e[a].push_back({b,i});
    e[b].push_back({a,i});
  }
  /*FOR(i,0,n){
    for(auto x:e[i]){
      cout << "(" <<x.to <<","<<x.id<<")"<<"  ";
    }
    cout << endl;
  }*/
  int smax=0;
  FOR(i,0,n){
    smax = max(smax,(int)e[i].size());
  }
  vector<int> checked(n,0);
  queue<int> Q;
  Q.push(0);
  while(!Q.empty()){
    int v = Q.front();
    int nowcol = 1;
    vector<int> chk(smax+1,0);
    chk[0] = 1; checked[v] = 1;
    for(auto x: e[v]) if(ecol[x.id] > 0) {chk[ecol[x.id]]=1;}
    for(auto x: e[v]){
      if(checked[x.to]==0) Q.push(x.to);
      if(ecol[x.id] > 0) {chk[ecol[x.id]]=1; continue;}
      //if(checked[x.to]==1) {continue;chk[ecol[x.id]]=1;continue;}
      while(chk[nowcol]==1){
        nowcol++;
        if(nowcol>smax) nowcol = 1;
      }
      if(ecol[x.id]==0) {ecol[x.id] = nowcol; chk[nowcol]=1;}
    }
    Q.pop();
    checked[v] = 1;
  }
  cout << smax << endl;
  FOR(i,0,n-1){
    cout << ecol[i] << endl;
  }
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 7296
s = list(input())
t = list(input())
n = len(s)
m = len(t)

i = 0
check = False
start = 0
while i+m <= n:
    temp = True
    k = 0
    while k < m and temp:
        if s[i+k] == t[k] or s[i+k] == "?":
            k += 1
        else:
            temp = False
    if temp:
        check = True
        start = i
        i += 1
    else:
        i += 1
if check:
    for k in range(start,start+m):
        s[k] = t[k-start]

if check:
    for i in range(n):
        if s[i] == "?":
            s[i] = "a"
    for i in range(n):
        if i != n-1:
            print(s[i],end = "")
        else:
            print(s[i])
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    ll n,k;
    cin >> n >> k;

    vector<pll> a(n);
    vector<bool> used(ARRAY_MAX,false);

    for(int i = 0;i < n;i++){
        cin >> a[i].second >> a[i].first;
    }

    sort(a.begin(),a.end(),greater<pll>());

    priority_queue<ll,vector<ll>,greater<ll> > que;

    ll sum = 0,ans = 0,kind = 0;

    for(int i = 0;i < k;i++){

        sum += a[i].first;
        if(used[a[i].second] == false){//まだ使われていない種類
            kind++;
            used[a[i].second] = true;
        }else{
            que.push(a[i].first);
        }
    }

    ans = sum + kind*kind;

    for(int i = k;i < n;i++){

        if(que.empty()){
            break;
        }
        if(used[a[i].second] == false){

            sum -= que.top();
            que.pop();
            kind++;
            sum += a[i].first;
            used[a[i].second] = true;
            ans = max(ans,sum + kind*kind);
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 2432
N,K = map(int,input().split())
h = list(map(int,input().split()))
DP = [float('inf')]*N
DP[0] = 0
for i in range(0,N):
    for j in range(i+1,min(N,i+K+1)):
        DP[j] = min(DP[j],DP[i]+abs(h[i]-h[j]))
print(DP[-1])

Measured memory_bytes: 55008
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long

const int N=1005;
const int MOD=1e9+7;
 

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val

 
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/
 int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 int k;
 cin>>k;
 k--;
 cout<<a[k];

  
  
}



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

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


int i = 0;
int seni = 1000 * i;
while (a > seni ) {
	i += 1;
	seni = 1000*i;
}

cout << (seni-a) << endl;
return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

    cout << a / gcd(a, b) * b << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
v=list(map(int, input().split()))
ans=0
for k in range(1,n):
	p,s=k,0
	while p<n:
		r=n-p-1
		if r<=k:
			break
		s+=v[p]+v[n-1-p]
		if r%k!=0 or p<r:
			ans=max(ans,s)
		p+=k
print(ans)

Measured memory_bytes: 14332
#![allow(unused_imports)]
#![allow(unused_variables)]

use proconio::input;
use std::cmp::{max, min};

fn main() {
  input! {
    n: i32,
  }
  for x in 1.. {
    if x > n {
      break;
    }
    let rest = x * 8 / 100;
    if x + rest == n {
      println!("{}", x);
      return;
    }
  }
  println!(":(");
}


Measured memory_bytes: 2156
code = r"""
# distutils: language=c++
# distutils: include_dirs=/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include
# cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "/opt/atcoder-stl/atcoder/dsu.hpp" namespace "atcoder":
    cdef cppclass dsu:
        dsu(int n)
        int merge(int a, int b)
        bool same(int a, int b)
        int leader(int a)
        int size(int a)
        vector[vector[int]] groups()

from libc.stdio cimport scanf, printf
cdef int i
cdef int N, Q
cdef int t, u, v
scanf("%d%d", &N, &Q)
cdef dsu *d = new dsu(N)
for i in range(Q):
    scanf("%d%d%d", &t, &u, &v)
    if t == 0:
        d.merge(u, v)
    else:
        printf("%d\n", d.same(u, v))
"""
import os
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('solve.pyx', 'w').write(code)
    os.system('cythonize -i -3 -b solve.pyx')
import solve


Measured memory_bytes: 10680
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;


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

	cin >> N >> K;
	if (K == 1 || K == N * 2 - 1) {
		cout << "No\n";
		return 0;
	}
	vector<int>ans(N * 2 - 1);
	vector<int>used(N * 2, 0);
	ans[N] = K + 1;
	ans[N - 1] = K;
	ans[N - 2] = K - 1;
	used[K]++;
	used[K - 1]++;
	used[K + 1]++;
	if (K - 2) {
		ans[N + 1] = K - 2;
		used[K - 2]++;
	}
	if (K + 2 <= N * 2 - 1) {
		ans[N - 3] = K + 2;
		used[K + 2]++;
	}
	int index = 1;
	for (auto &i : ans) {
		if (i)continue;
		while (used[index])index++;
		i = index;
		used[index]++;
	}
	cout << "Yes\n";
	for (auto i : ans)cout << i << endl;
	return 0;
}

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

using namespace std;


namespace fastIO {
    #define BUF_SIZE 100000
    //fread -> read
    bool IOerror = 0;
    inline char nc() {
        static char buf[BUF_SIZE], *p1 = buf + BUF_SIZE, *pend = buf + BUF_SIZE;
        if(p1 == pend) {
            p1 = buf;
            pend = buf + fread(buf, 1, BUF_SIZE, stdin);
            if(pend == p1) {
                IOerror = 1;
                return -1;
            }
        }
        return *p1++;
    }
    inline bool blank(char ch) {
        return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
    }
    inline void read(int &x) {
        char ch;
        while(blank(ch = nc()));
        if(IOerror)
            return;
        for(x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0');
    }
    inline void readll(long long int &x) {
        char ch;
        while(blank(ch = nc()));
        if(IOerror)
            return;
        for(x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0');
    }
    #undef BUF_SIZE
};

using namespace fastIO;

const int maxn = 1e5 + 5;

int arr[maxn];

bool cmp(int a, int b) { return a > b; }

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

    for(int i = 1; i <= n; i++)
        //read(arr[i]);
        cin >> arr[i];

    sort(arr + 1, arr + 1 + n, cmp);

     for (int i = 1; i <= n; i++)
        if (i + 1 > arr[i + 1])
        {
            int k = 0;
            while(arr[k + i + 1] == i) k++;
            if (((arr[i] - i) & 1) || (k & 1)) puts("First");
            else puts("Second");
            break;
        }

    return 0;
}


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

long	GCM(long N, long M) {
	while (0!=M) {
		N%=M;
		swap(N, M);
	}
	return N;
}

int	main() {
	long N, M;
	string S, T;
	cin >>N >>M >>S >>T;
	long G=GCM(N, M);
	long GG=N*M/G;
	long GS=GG/N;
	long GT=GG/M;
	for (long i=0; i<G; i++)
		if (S.at(i*N/G) == T.at(i*M/G))
			continue;
		else {
			cout <<-1 <<endl;
			return 0;
		}
	cout <<GG <<endl;
	return 0;
}


Measured memory_bytes: 512
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


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)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

int main() {
	ll x;
	cin >> x;

	ll n = x * 2;

	// エラトステネスのふるい
	bitset<1000000> is_prime(0); // 十分大きなサイズを確保します
	for (int i = 2; i <= n; ++i) is_prime.set(i); // とりあえず全部ふるいに入れます
	for (int i = 2; i <= n; ++i) {
		if (is_prime[i]) { // 素数 i を発見したら
			for (int j = i * 2; j <= n; j += i) {
				is_prime.reset(j); // i の倍数をふるい落とす
			}
		}
	}


	for (int i = 2; i <= n; ++i) {
		if (is_prime[i] == 1 && i >= x) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 384
r, l = 0, 0
while 1:
    try:
        a, b, c = map(int, raw_input().split(','))
        if a == b: l += 1
        elif (a ** 2) + (b ** 2) == c **2: r += 1
    except:
        break
print "%d\n%d" % (r, l)

Measured memory_bytes: 6440
#include<stdio.h>
int main(void) {
	int b[1000];
	int f[1000];
	int r[1000];
	int v[1000];
	int p;
	int room[150] = {0};
	int n;
	int i;
	int t;

	scanf("%d",&n);
	for ( i = 1; i <= n; i++) {
		scanf("%d %d %d %d",&b[i],&f[i],&r[i],&v[i]);
		p = (b[i] - 1) * 30 + (f[i] - 1) * 10 + r[i];
		room[p] = room[p] + v[i];

	}

	for ( t = 1; t <= 120; t++) {
		switch (t) {
			case 31:
			case 61:
			case 91:
				printf("\n");
				printf("####################");
				printf("\n");
				printf(" %d", room[t]);
				break;
			case 11:
			case 21:
			case 41:
			case 51:
			case 71:
			case 81:
			case 101:
			case 111:
				printf("\n");
				printf(" %d", room[t]);
				break;
			case 120:
				printf(" %d\n", room[t]);
				break;
			default:
				printf(" %d",room[t]);
				break;
			
		}
		
	}


	return 0;
}

Measured memory_bytes: 616
while (True):
    H,W = map(int,input().split())
    if H == W and H==0:
        break
    frame_T = "#"*W
    frame_M = "#"+"."*(W-2)+"#"
    print(frame_T)
    for i in range(H-2):
        print(frame_M)
    print(frame_T+"\n")


Measured memory_bytes: 5620
package main

import "fmt"

func main() {
	for i := 1; ; i++ {
		var x, y int
		fmt.Scan(&x)
		fmt.Scan(&y)
		if x == 0 && y == 0 {
			break
		}
		if x < y {
			fmt.Println(x, y)
		} else {
			fmt.Println(y, x)
		}
	}
}



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

def countDiv2(n:int):
    sum = 0
    while n % 2 == 0:
        sum += 1
        n //=2
    return sum

def solve(N: int, a: "List[int]"):
    sum = 0
    for ia in a:
        sum += countDiv2(ia)
    print(sum)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 4340
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/05 08:55:10 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long 			ll;
typedef vector<int>			VI;
typedef vector<vector<int>>	VVI;
typedef pair<int, int>		PII;

// TOP
int	h, w;

VVI	field;

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

void	dfs(int y, int x)
{
	field[y][x] = 0;
	int	ny, nx;
	rep(dir, 8)
	{
		ny = y + dy[dir];
		nx = x + dx[dir];
		if (ny < 0 || ny >= h || nx < 0 || nx >= w)
			continue;
		if (field[ny][nx] == 0)
			continue;
		dfs(ny, nx);
	}
}

void	Main()
{
	while (cin >> w >> h)
	{
		if (w == 0 && h == 0)
			break;
		field.assign(h, VI(w));
		rep(y, h)
		{
			rep(x, w)
					cin >> field[y][x];
		}
		int count;
		count = 0;
		rep(y, h)
		{
			rep(x, w)
			{
				if (field[y][x] == 0)
					continue;
				dfs(y, x);
				count++;
			}
		}
		cout << count << endl;
	}
}
// END

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



Measured memory_bytes: 3252
#include<iostream>
using namespace std;
long a,b,c,s,r;
main(){
  cin>>a>>b>>c;
  while(a%2==0&&b%2==0&&c%2==0&&r<30){
    r++;
    s=a+b+c;
    a=(s-a)/2;
    b=(s-b)/2;
    c=(s-c)/2;
  }
  cout<<(r==30?-1:r);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if(s*t >= d) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
//AtCoDeerくんとボール色塗り

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int n,k;cin>>n>>k;
    ll ans = k;
    rep(i,1,n){
        ans *= (k-1);
    }
    cout<<ans<<nnn;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << min(a, b) + min(c, d) << '\n';
    return 0;
}


Measured memory_bytes: 3632