akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX 500000
#define INFTY 1000000000
int n,A[MAX];
int count=0;
void merge(int [],int,int,int);
int mergeSort(int [],int,int);

int main(){
  int i;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,0,n);
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
  
}

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

Measured memory_bytes: 4504
N, M = list(map(int, input().split()))
sc = [list(map(int, input().split())) for _ in range(M)]

t = 10 ** (N - 1)
e = t * 10
if N == 1:
  t = 0

for i in range(t, e):
  k = list(str(i))
  for s, c in sc:
    if int(k[s - 1]) != c:
      break
  else:
    print(i)
    exit()
print(-1)


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

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

  ll ans = 0;
  for (ll i=1; i <= N; i+=2) {
    ll count = 0;
    for (ll j=1; j <= N; ++j) {
      if (i%j==0) count++;
    }
    if (count == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx, dy = ty - sy;
    
    string res = "";
    
    for(int i = 0; i < dx; i++)res +="R";
    for(int i = 0; i < dy; i++)res +="U";
    for(int i = 0; i < dx; i++)res +="L";
    for(int i = 0; i < dy; i++)res +="D";
    
    res += "D";
    for(int i = 0; i <= dx; i++)res +="R";
    for(int i = 0; i <= dy; i++)res +="U";
    res += "L";
    res += "U";
    for(int i = 0; i <= dx; i++)res +="L";
    for(int i = 0; i <= dy; i++)res +="D";
    res += "R";
    cout << res << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, c;
int x[100000];
int v[100000];
int rv[200010];

int solve1() {
	int r;
	int fl = 0, fr, ret = 0;
	for (r = 1; r < n; r++) {
		fl = max(fl, rv[n + r] - x[r - 1]);
		fr = -rv[r] - 2 * (c - x[r]);
		ret = max(ret, fl + fr);
	}
	return ret;
}

int solve2() {
	int r;
	int fl = 0, fr, ret = 0;
	for (r = 1; r < n; r++) {
		fl = max(fl, rv[n + r] - 2 * x[r - 1]);
		fr = -rv[r] - (c - x[r]);
		//cout << "res2 : " << "r = " << r << ", fl = " << fl << ", fr = " << fr << endl;
		ret = max(ret, fl + fr);
	}
	return ret;
}

int solve3() {
	int l, ret = 0;
	for (l = 0; l < n; l++) {
		ret = max(ret, rv[l + 1] - x[l]);
	}
	return ret;
}

int solve4() {
	int r, ret = 0;
	for (r = 0; r < n; r++) {
		ret = max(ret, rv[n] - rv[r] - (c - x[r]));
	}
	return ret;
}

signed main() {
	int i;
	
	cin >> n >> c;
	rep(i, n) cin >> x[i] >> v[i];
	rep(i, n) rv[i + 1] = rv[i] + v[i];
	rep(i, n) rv[i + n + 1] = rv[i + n] + v[i];
	//rep(i, 2 * n + 1) cout << rv[i] << " "; cout << endl;
	int res1 = solve1(); //cout << "res1 = " << res1 << endl;
	int res2 = solve2(); //cout << "res2 = " << res2 << endl;
	int res3 = solve3(); //cout << "res3 = " << res3 << endl;
	int res4 = solve4(); //cout << "res4 = " << res4 << endl;
	
	cout << max(res1, max(res2, max(res3, res4))) << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
using ll = long long;
const int INF=1001001001;
const int MAX_N = 200005;

int main(){
  int s, w;
  cin >> s >> w;
  if(w >= s) cout << "unsafe" << endl;
  else cout << "safe" << endl;
  
  return 0;
}
    
  
   

Measured memory_bytes: 3644
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N, M = mi()
PYs = []
for i in range(M):
  p, y = mi()
  p -= 1 #0スタートに
  PYs.append((y, p, i)) #PY[2]は市の番号
PYs = sorted(PYs) #誕生した年で昇順ソート

PREFs = [0] * N #PREFs[0~N-1]で各県の市数にアクセス
#各PYsの要素を[属する県番号, 県に所属したときに振られた通し番号, ID]に書き換える
for i, (eachy, eachp, eachi) in enumerate(PYs):
  PREFs[eachp] += 1
  PYs[i] = [eachp+1, PREFs[eachp], eachi] #県番号を1スタートに戻す



#市の番号昇順でソートし直し
from operator import itemgetter
PYs = sorted(PYs, key=itemgetter(2)) #添字が変わっている
for p, num, i in PYs:
  print('{:06}{:06}'.format(p, num))




Measured memory_bytes: 78172
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

const int SIZE = 100000 + 10;
const ll MOD = 1000000000 + 7;
ll dp[SIZE][4];
// DP                                                                           
int main() {
  string S; cin>>S;
  int len = S.length();
  dp[0][0] = 1;
  for(int i = 0; i < len; i++) {
    for(int j = 0; j < 4; j++) {
      dp[i+1][j] = dp[i][j] * (S[i] == '?' ? 3 : 1);
    }
    if(S[i] == 'A' || S[i] == '?') {
      dp[i+1][1] += dp[i][0];
    }
    if(S[i] == 'B' || S[i] == '?') {
      dp[i+1][2] += dp[i][1];
    }
    if(S[i] == 'C' || S[i] == '?') {
      dp[i+1][3] += dp[i][2];
    }
#ifdef DEBUG
    cout << i+1;
#endif
    REP(j,4) {
      dp[i+1][j] %= MOD;
#ifdef DEBUG
      cout << "," << dp[i+1][j];
#endif
    }
#ifdef DEBUG
    cout << endl;
#endif
  }
  ll ans = dp[len][3];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3584
def li():
    return list(map(int, input().split()))


[H, W, N] = li()
s = li()
S = input()
T = input()

if __name__ == '__main__':
    # 左上戦略
    is_no = False
    takahashi = [s[0], s[1]]
    for index, (S_i, T_i) in enumerate(zip(S, T)):
        if S_i == 'L':
            takahashi[1] = takahashi[1] - 1
        if S_i == 'U':
            takahashi[0] = takahashi[0] - 1
        if min(takahashi) <= 0:
            is_no = True
            break
        if T_i == 'R':
            takahashi[1] = min(takahashi[1] + 1, W)
        if T_i == 'D':
            takahashi[0] = min(takahashi[0] + 1, H)

    if not is_no:
        # 右下戦略
        takahashi = [s[0], s[1]]
        for index, (S_i, T_i) in enumerate(zip(S, T)):
            if S_i == 'R':
                takahashi[1] = takahashi[1] + 1
            if S_i == 'D':
                takahashi[0] = takahashi[0] + 1
            if takahashi[0] > H or takahashi[1] > W:
                is_no = True
                break
            if T_i == 'L':
                takahashi[1] = max(takahashi[1] - 1, 1)
            if T_i == 'U':
                takahashi[0] = max(takahashi[0] - 1, 1)

    if is_no:
        print("NO")
    else:
        print("YES")


Measured memory_bytes: 3888
# coding: utf-8
# Your code here!
N=int(input())
l=[[0]*3 for i in range(N)]
A,B,C=map(int,input().split())
l[0][0]=A
l[0][1]=B
l[0][2]=C


for i in range(1,N):
    A,B,C=map(int,input().split())
    l[i][0]=A+(max(l[i-1][1],l[i-1][2]))
    l[i][1]=B+(max(l[i-1][0],l[i-1][2]))
    l[i][2]=C+(max(l[i-1][1],l[i-1][0]))

print(max(l[-1]))


Measured memory_bytes: 22772
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(str(type(var)) + name +":" + " = " + repr(var), file=stderr)
    return
NUM = 100
MOD = 10 ** 16 + 61
base = 12345
base_inv = pow(base,MOD-2,MOD)
power = [1] * NUM
power_inv = [1] * NUM
for n in range(1,NUM):
    power[n] = power[n-1] * base % MOD
    power_inv[n] = power_inv[n-1] * base_inv % MOD
def rollhash(s):
    res = [0]*(len(s)+1)
    for i in range(len(s)):
        res[i+1] = (res[i] + power[i] * ord(s[i])) % MOD
    return res

def main():
    while(1):
        N = int(input())
        if (N == 0):
            break
        S = []
        mL = 0
        for _ in range(N):
            s = (input().rstrip())
            n = ''
            for i in range(len(s)-1):
                if s[i] in {'a', 'i', 'u', 'e', 'o'}:
                    n += s[i+1]
            n = s[0] + n
            S.append(n)
        S = sorted(S, key=lambda x: -len(x))
        # print(S)
        if len(set(S)) < N:
            print(-1)
            continue
        for k in range(1,51):
            kind = set()
            for s in S:
                kind.add(s[:k])
            if len(kind) == N:
                break
        if len(kind) == N:
            print(k)


if __name__ == "__main__":
    main()



Measured memory_bytes: 5628
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=10007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	multiset<llint>A;
	int n,i,x,ans=0;cin>>n;
	for(i=0;i<n;i++){cin>>x;A.ins(x);}
	while(A.size()>=2){
		x=*prev(A.end());
		A.erase(prev(A.end()));
		int aaa=1;
		while(aaa<=x){aaa*=2;}
		int ter=aaa-x;
		if(A.find(ter)!=A.end()){ans++;A.erase(A.find(ter));}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){

    int a[100][3], i, j;

    for(i=0; i<100; i++){
        for(j=0; j<3; j++){
            cin >> a[i][j];
        }
        if(a[i][0]==-1 && a[i][1]==-1 && a[i][2]==-1){
            break;
        }
    }

    int n=i;

    for(i=0; i<n; i++){
        if(a[i][0]==-1 || a[i][1]==-1){
            cout << 'F' << endl;
        }
        else if(a[i][0] + a[i][1] >= 80){
            cout << 'A' << endl;
        }
        else if(a[i][0] + a[i][1] >= 65){
            cout << 'B' << endl;
        }
        else if(a[i][0] + a[i][1] >= 50){
            cout << 'C' << endl;
        }
        else if(a[i][0] + a[i][1] >=30 && a[i][2] >= 50){
            cout << 'C' << endl;
        }
        else if(a[i][0] + a[i][1] >= 30){
            cout << 'D' << endl;
        }
        else{
            cout << 'F' << endl;
        }

    }

    return 0;
}


Measured memory_bytes: 3096
A, B, K = map(int, input().split())
cnt = 0
ans = 1
cntlist = []

for i in range(min(A, B)):
    if A % (i + 1) == 0 and B % (i + 1) == 0:
        cntlist.append(i + 1)
print(cntlist[-K])

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <map> 
#include <set>
#include <vector>
#include <list>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define ll long long
#define debug cout << __FILE__ << ":" << __LINE__ << endl;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    if (v.empty()) {
        ostr << "{ }";
        return ostr;
    }
    ostr << "{" << v.front();
    for (auto itr = ++v.begin(); itr != v.end(); itr++) {
        ostr << ", " << *itr;
    }
    ostr << "}";
    return ostr;
}

int gcd(int a, int b) {
    if (a < b) a, b = b, a;
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

void solve() {
    string S;
    cin >> S;

    rep(i, S.size()-1) {
        if(S[i] == 'A' && S[i+1] == 'C') {
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout << "No" << endl;
}

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    cout.precision(20);
    cout << fixed;

    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    if(c >= a && c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl

ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 


int main() {
    string s,t;
    cin>>s>>t;
	ll l1=s.length();
	ll l2=t.length();
	ll dp[l1+1][l2+1];
  memset(dp,0,sizeof(dp));
	for(ll i=1;i<=l1;i++)
	{
	    for(ll j=1;j<=l2;j++)
	    {
	        if(s[i-1]==t[j-1])
	        dp[i][j]=dp[i-1][j-1]+1;
	        else
	        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
       //   cout<<dp[i][j]<<" ";
	    }
     // cout<<endl;
	}
//	cout<<dp[l1][l2];
	string s1="";
	ll i=l1,j=l2;
	while(true)
	{
	    if(i==0||j==0)
	    break;
	    if(s[i-1]==t[j-1])
	    {
	        s1+=t[j-1];
	        i--;
	        j--;
	    }
	    else if(dp[i-1][j]>dp[i][j-1])
	    {
	        i--;
	    }
	    else// if(dp[i-1][j]<dp[i][j-1])
	    j--;
     // cout<<i<<" "<<j<<endl;
	}
	reverse(s1.begin(),s1.end());
	cout<<s1;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,x[100010] = {},ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> x[i + 1];
		ans += abs(x[i + 1] - x[i]);
	}
	ans += abs(x[n + 1] - x[n]);
	for(int i = 1;i <= n;i++) cout << ans - abs(x[i + 1] - x[i]) - abs(x[i] - x[i - 1]) + abs(x[i + 1] - x[i - 1]) << endl;
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a, v, b ,w, t, ap, am, bp, bm;
    cin >> a >> v >> b >> w >> t;
    if(w>=v){
        cout << "NO" <<endl;
        return 0;
    }
    ap=a+v*t;
    am=a-v*t;
    bp=b+w*t;
    bm=b-w*t;
    if(am<=bm && bp<=ap){
        cout << "YES" <<endl;
    }
    else cout << "NO" <<endl;
    
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(){


  int r,c,b,f=0,d=0,e=0;

  cin >>r>>c;

  int a[r][c];

  for(int i=0 ; i < r ; i++){
    for(int j=0 ; j < c ; j++){
      
      cin >>b;
      a[i][j]=b;

    }
  }

  for(int k=0 ; k < r ; k++){
    d=0;    
    for(int l=0 ; l < c ; l++){
    
   
      d=d+a[k][l];      
   
      cout <<a[k][l]<<" ";
    }
    cout <<d;
    cout <<"\n";
  }
  
  for(int p=0 ; p < c ; p++){
    e=0;
    for(int o=0 ; o < r ; o++){
      
      e=e+a[o][p];
      f=f+a[o][p];
}
    cout <<e<<" ";
  }
  cout <<f;
cout <<"\n";

return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
int main() {
    int M, D;
    cin >> M >> D;
    int counter = 0;

    for(int i = 4; i <= M; i++) {
        for(int j = 22; j <= D; j++) {
            int d1 = j / 10;
            int d2 = j % 10;
            if(d1 >= 2 && d2 >= 2) {
                if(d1 * d2 == i) counter++;
            }
        }
    }

    cout << counter << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    int val(char ch){ return ch-'0';}

    int sub(String maxs, String mins){
        for ( int i = 0; i < maxs.length(); i++ ){
            if ( maxs.charAt(i) != mins.charAt(i) ) {
                if ( i == maxs.length()-1 )
                    return val(maxs.charAt(i)) - val(mins.charAt(i));
                if ( i == maxs.length()-2 )
                    return (10*val(maxs.charAt(i))+val(maxs.charAt(i+1))) - (10*val(mins.charAt(i))+val(mins.charAt(i+1)));
                return 10;
            }
        }
        return 0;
    }

  int checkEqual(String S){
        String mins, maxs;
        int ans = 8;
        for ( int k = 1; k < S.length(); k++ ){
            if ( S.length()%k != 0 ) continue;
            mins = maxs = S.substring(0, k);
            for ( int s = 0; s < S.length(); s += k ){
                String tmp = S.substring(s, s + k);
                if ( tmp.compareTo(maxs) > 0 ) maxs = tmp;
                if ( tmp.compareTo(mins) < 0 ) mins = tmp;
            }
            ans = Math.min(ans, sub(maxs, mins));
        }
        return ans;
    }

    int check12(String S){
        int maxv = 0;
        int minv = 10;
        for( int p = 0; p < S.length(); p++){
            int v = val(S.charAt(p));
            if ( S.charAt(p) == '1' && p+1 < S.length()) {
                v = 10 + val(S.charAt(p+1));
                p++;
            }
            maxv = Math.max(maxv, v);
            minv = Math.min(minv, v);
        }
        return maxv - minv;
    }

    void solve(){
        String S;
        Scanner sc = new Scanner(System.in);
        S = sc.next();
        System.out.println(Math.min(checkEqual(S), check12(S)));
    }

    public static void main(String[] args){
        new Main().solve();
    }
}




Measured memory_bytes: 59880
#include <iostream>
#include <algorithm>
using namespace std;
long long a[100005],ans,n,cnt;
int main()
{
 cin>>n;
 for(int i=1;i<=n;i++)
 {
  cin>>a[i];
  if(a[i]<=0)cnt++;
  a[i]=abs(a[i]);
 }
 sort(a+1,a+n+1);
 for(int i=2;i<=n;i++)
  ans+=a[i];
 if(cnt%2)ans-=a[1];
 else ans+=a[1];
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max

int main ()  {

    int n,m;cin>>n>>m;

    vector<int> s[11];
    rep(i,m) {
        int k;cin>>k;
        rep(j,k) {
            int a;cin>>a;
            a--;
            s[i].push_back(a);
        }
    }

    int p[11];
    rep(i,m) {
        cin>>p[i];
    }
    
    int ans=0;
    for (int bit=0;bit<(1<<n);bit++) {
        bool ok=true;
        rep(j,m) {
            int cnt=0;
            rep(k,s[j].size()) {
                if (bit & (1<<s[j][k])) cnt++;
            }
            if (cnt%2!=p[j]) {
                ok=false;
                break;
            }
        }
        if (ok) ans++;
    }

    cout<<ans<<endl;

}

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

int main() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	vector<long long> vec{ a * c, a * d, b * c, b * d};
	sort(vec.begin(), vec.end());
	cout << vec.at(3) << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI acos(-1)
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
const int N = 0;
 
typedef long long int ll;
 
using namespace std;


 
int main(){
    FIN;
    //freopen("../input.txt", "r", stdin);
    int n,k;cin>>n>>k;
    ll ans = 0;
    ll firstS = 0;
    ll lastS = 0;
    ll state = 0;
    fore(i,0,k){
        firstS += state;
        lastS += (n-state);
        state++;
    }

    ans += (lastS - firstS+1)%MOD;

    fore(i,k,n+1){
        firstS += state;
        lastS += (n-state);
        ans += (lastS - firstS+1)%MOD;
        state++;
    }

    cout<<((ans)%MOD)<<"\n";

    return 0;
}

// ============== Notes =============== //
// common bugs
// - remove reader 
// - fastio
// - int overflow (especially intermediate expressionns)
// - array bounds (indices bigger than MAXN?, is MAXN correct?)
// - special cases (n=1, graph not connected?)
// - re-initialize efficiently between test cases

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

using ll = long long;

int main()
{
    ll N, M;
    cin >> N >> M;
    ll ans = 0;
    ll now = 0;
    vector<pair<ll, ll>> p(N);
    for (ll i = 0; i < N; i++)
    {
        ll A, B;
        cin >> A >> B;
        p[i] = make_pair(A, B);
    }
    sort(p.begin(), p.end());
    for (int i = 0; i < N; i++)
    {
        now += p[i].second;
        ans += p[i].first * p[i].second;
        if (M < now)
        {
            ans -= (now - M) * p[i].first;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B = map(int, readline().split())
color_flipped = False
if A < B:
    A, B = B, A
    color_flipped = True


def solve():
    hb = min(B, 12)
    h = (hb * 2 + 1) * 3
    w = 100
    # If not flipped, False -> White (A), True -> Black (B)
    grid = [[True] * w for _ in range(h)]
    black = 1
    white = 0
    for i in range(hb):
        if black == B:
            break
        black += 1
        white += 1
        for c in range(w):
            for j in range(3):
                grid[6 * i + j + 3][c] = False

    def paint_white(i):
        nonlocal white
        for c in range(0, w, 2):
            if white == A:
                return
            grid[6 * i + 1][c] = False
            white += 1

    def paint_black(i):
        nonlocal black
        for c in range(0, w, 2):
            if black == B:
                return
            grid[6 * i + 4][c] = True
            black += 1

    for i in range(hb):
        paint_white(i)
        paint_black(i)
    assert black == B
    while white < A:
        grid.append([True] * w)
        grid.append([True] * w)
        for c in range(0, w, 2):
            if white == A:
                break
            white += 1
            grid[-1][c] = False

    return grid


def print_grid(grid):
    h, w = len(grid), len(grid[0])
    print(h, w)
    for r in range(h):
        for c in range(w):
            if grid[r][c] ^ color_flipped:
                print("#", end="")
            else:
                print(".", end="")
        print()


if __name__ == "__main__":
    print_grid(solve())


Measured memory_bytes: 4468
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
//    val a = (0 until n).map { sc.next().toInt() }
    println(problem2020a(s))
}

fun problem2020a(s: String): String {
    return s[0].toString() + s[1] + s[2]
}

Measured memory_bytes: 36296
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<string>
using namespace std;
#define MAX 200001
int n,k;
long long int h[MAX];
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h,h+n);
    long long int sum=0;
    for(int i=0;i<n-k;i++){
        sum+=h[i];
    }
    printf("%lld\n",sum);
}

Measured memory_bytes: 1792
fn main() {
    let v = read_vec::<u32>();
    let n = v[0];
    let m = v[1];

    let gaku = read_vec2::<i32>(n);
    let check = read_vec2::<i32>(m);

    for g in gaku {
        let mut min = 1000000000;
        let mut minpoint = 0;
        for (i, c) in check.iter().enumerate() {
            let manhattan = (g[0] - c[0]).abs() + (g[1] - c[1]).abs();
            if min > manhattan {
                min = manhattan;
                minpoint = i + 1;
            }
        }
        println!("{}", minpoint);
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		String leftS = S.substring(0, (S.length()-1)/2);
		String rightS = S.substring(((S.length() + 3)/2) - 1);

		StringBuffer sb = new StringBuffer(leftS);
		String reverseLeftS = sb.reverse().toString();
		sb = new StringBuffer(rightS);
		String reverseRightS = sb.reverse().toString();
		sb = new StringBuffer(S);
		String reverseS = sb.reverse().toString();
		if (leftS.equals(reverseLeftS) && rightS.equals(reverseRightS) && S.equals(reverseS)){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 22356
import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
S = list(input())

LR = ['L', 'R']
if S[0] != "B" or S[-1] != "B":
	print(0)
	exit()
x = [0]
for i in range(1, 2*N):
	if S[i] == S[i - 1]:
		x.append(x[-1]^1)
	else:
		x.append(x[-1])

if x[-1] != 1:
	print(0)
	exit()
if sum(x) != N:
	print(0)
	exit()

L_sum = 0
total = 1
for i in range(0, 2*N):
	if x[i] == 0:
		L_sum += 1
	else:
		total *= L_sum
		L_sum -=1
		total = total % 1000000007

for i in range(N):
	total *= i + 1
	total = total % 1000000007

print(total)

Measured memory_bytes: 61552
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

	int n, m, x, ans=1e9;
	cin >> n >> m >> x;
	vector<vector<int> > v(n, vector<int>(m+1));
	for(int i=0; i<n; i++)
        for(int j=0; j<=m; j++)
            cin >> v[i][j];
	for(int i=0; i<(1<<n); i++){
        vector<int> tmp(m+1, 0);
        int cost=0;
        for(int j=0; j<n; j++){
            if(i&(1<<j)){
                cost+=v[j][0];
                for(int k=1; k<=m; k++)
                    tmp[k]+=v[j][k];
            }
        }
        int k;
        for(k=1; k<=m; k++)
            if(tmp[k]<x)
                break;
        if(k>m)
            ans=min(ans, cost);
	}
	if(ans==1e9)
        cout << -1 << endl;
    else
        cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3660
import itertools

def main(N, M, Q, input):
    '''
    配列Aを求める→得点をreturn
    A: 長さN, 最大値Mの配列
    '''

    max_score = 0
    for i in [sorted(i) for i in list(itertools.combinations_with_replacement([i + 1 for i in range(M)], N))]:
        score = 0
        for j in range(Q):
            if i[input[j][1] - 1] - i[input[j][0] - 1] == input[j][2]: #pythonでは一つindexがずれるため．
                score += input[j][3]
        max_score = max(max_score, score)
    print(max_score)



if __name__ == '__main__':
    N, M, Q = list(map(int, input().split()))
    input = [list(map(int, input().split())) for i in range(Q)]
    main(N, M, Q, input)



Measured memory_bytes: 96000
import bisect
A, B, Q = map(int, input().split())

a=[-float("inf")]
b=[-float("inf")]
for i in range(A):
    a.append(int(input()))
for i in range(B):
    b.append(int(input()))   
a+=[float("inf")]
b+=[float("inf")]

for i in range(Q):
    q = int(input())
    x = bisect.bisect_left(a, q)
    y = bisect.bisect_left(b, q)
    ans = float("inf")
    for j in [a[x-1], a[x]]:
        for k in [b[y-1], b[y]]:
            ans1 = abs(j-q)+abs(j-k)
            ans2 = abs(k-q)+abs(j-k)
            ans = min(ans, ans1, ans2)
    print(ans)

Measured memory_bytes: 13496
using System;
using System.Linq;
    class Program
    {
        static void Main(string[] args)
        {
            var AopB = Console.ReadLine().Split(' ').ToList();
            Console.WriteLine(AopB[1] == "+" ? int.Parse(AopB[0]) + int.Parse(AopB[2]) : int.Parse(AopB[0]) - int.Parse(AopB[2]));

        }
    }

Measured memory_bytes: 11220
//@@@@@@@@@@ JAI BAJRANG BALI @@@@@@@@@

// COMPILE BY:) NAMAN


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define maxn 10000001
#define endl "\n"
#define inf INT_MAX
#define vec vector <ll>
#define mps map <ll,ll>
#define ppl vector<pair<ll,ll>> 
#define fi first
#define si second
#define pr pair<ll,ll> 
#define mvec map<ll,vector <ll>>
#define all(v) v.begin(),v.end()
#define infi LLONG_MAX
#define pi 3.141592653
#define ninf INT_MIN
#define ninfi LLONG_MIN
#define lbn lower_bound
#define ubn upper_bound
#define memset(a,b) memset(a,(b),sizeof(a))
ll modexpo(ll a, ll b, ll c)  
{  
    if (a == 0)  
        return 0;  
    if (b == 0)  
        return 1;  
    ll y;  
    if (b % 2 == 0) {  
        y = modexpo(a, b / 2, c);  
        y = (y * y) % c;  
    }  
    else {  
        y = a % c;  
        y = (y * modexpo(a, b - 1, c) % c) % c;  
    }  
  
    return y;
}  
  
  

  
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    vec dp(k+1);
    for(ll i=k;i>=1;i--)
    {
    	ll q=modexpo(k/i,n,mod);
    	// cout<<q<<endl;
    	q%=mod;
    	dp[i]=q;

    }

    // for(ll i=1;i<=k;i++)
    // 	cout<<dp[i]<<" ";

    for(ll i=k;i>=1;i--)
    {
    	for(ll j=2*i;j<=k;j+=i)
    		dp[i]-=dp[j];
    }
    ll sum=0;

    for(ll i=1;i<=k;i++)
    {
    	dp[i]=i*dp[i];
    	dp[i]%=mod;
    	sum+=dp[i];
    	sum%=mod;
    }

    cout<<sum<<endl;


return 0;
}


Measured memory_bytes: 3960
import math
inf = math.inf
negative_cycle_flag = False

def INITSS (G, s): # s means start
    # for u in G.V:
    #      u.d = inf
    #      u.pi = None
    G.V_d[s] = 0


def RELAX(u, v, w, V_d, V_pi):
    if V_d[v] > V_d[u] + w[u][v]:
        V_d[v] = V_d[u] + w[u][v]
        V_pi[v] = u


def BELLMANFORD (G, s, w):# w is weight matrix
    global negative_cycle_flag
    INITSS(G, s)
    for i in range(1,len(G.V_d)):
        for u, v in G.E:
            RELAX(u, v, w, G.V_d, G.V_pi)

    for u, v in G.E:
        if G.V_d[u] + w[u][v] < G.V_d[v]:
            negative_cycle_flag = True
            break

class Graph:
    def __init__(self, v_num, e_num, E):
        self.V_d = [inf for _ in range(v_num)]
        self.V_pi = [None for _ in range(v_num)]
        self.E = E

v_num, e_num, s = map(int, input().split())
E =[]
w = [[inf for _ in range(v_num)] for _ in range(v_num)]
for _ in range(e_num):
    u, v, weight = map(int, input().split())
    w[u][v] = weight
    E.append((u, v))

G = Graph(v_num, e_num, E)

BELLMANFORD(G, s, w)
if negative_cycle_flag == True:
    print("NEGATIVE CYCLE")
else:
    for k in range(v_num):
        if(G.V_d[k]==inf):
            print("INF")
        else:
            print(G.V_d[k])




Measured memory_bytes: 15016
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
input = sys.stdin.readline
a,b,x= map(float,input().split())
if x == a*a*b:
    print(0)
else:
    if x > a*a*b/2:
        left = (x-a*a*b/2)/a
        tei = left*2/a
        left1 = b-tei
        ans = math.atan(a/left1)
        print(90-math.degrees(ans))
    else:
        left = x/a
        tei = left*2/b
        ans = math.atan(b/tei)
        print(math.degrees(ans))


Measured memory_bytes: 6936
#include<iostream>
#include<map>
#include<vector>
#include<queue>
#include<set>
using namespace std;

int main(){
    int n, r, k, t;
    cin >> n;

    map<int, vector<int>> path;
    for(int i = 0; i < n; i++){
        cin >> r >> k;
        for(int j = 0; j < k; j++){
            cin >> t;
            path[r].push_back(t);
        }
    }

    int p, s, d, v;
    cin >> p;
    for(int i = 0; i < p; i++){
        cin >> s >> d >> v;
        queue<pair<int, int>> q;
        set<int> appear;

        q.push({s,1});

        int ans = -1;
        while(!q.empty()){
            pair<int,int> p = q.front();    q.pop();
            if(appear.find(p.first) != appear.end())   continue;
            
            if(p.first == d){
                ans = p.second;
                break;
            }

            appear.insert(p.first);

            for(int j = 0; j < path[p.first].size(); j++){
                if(appear.find(path[p.first][j]) == appear.end()){
                    q.push({path[p.first][j], p.second+1});
                }
            }
        }

        if(ans == -1 || ans > v){
            cout << "NA" << endl;
        }else{
            cout << ans << endl;
        }
    }

    return 0;
}


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

int main(){
    int a;
    int b;
    int ensyu;
    int menseki;
    cin >> a >> b;
    ensyu = a*2 + b*2;
    menseki = a * b;
    cout << menseki << " " << ensyu << endl;
    return 0;

}
 


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
using namespace std;
int  n;
int a[9] = {111, 222, 333, 444, 555, 666, 777, 888, 999};
int main()
{
  
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    if (n <=a[i]){
      ans = a[i];
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator> 
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);


#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)1e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

struct node{
	int x, y, z;
	mutable int w;
	node() {
		x = -1, y = -1, z = -1;
	}
	bool operator<(const node& nod) const{
		if (this->x == nod.x) {
			if (this->y == nod.y){
				return this->z < nod.z;
			}
			return this->y < nod.y;
		}
		return this->x < nod.x;
	}
};


int main() {
	string s, t; cin>> s>> t;
	bool ok = true;
	for (int i = 0; i < (int)s.size(); i++) {
		if (s[i] != t[i]) {
			ok = false;
		}
	}
	if (ok)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>

#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



int main(){
    int n;
    cin >> n;
    if(n%1000==0) cout << 0 << endl;
    else  cout << (n/1000 + 1)*1000 - n<< endl;
}

Measured memory_bytes: 3604
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), k = next();
  var a = [];
  for(var i = 0; i < n; i++){
    var t = next();
    if(t < k)a.push(t);
  }
  n = a.length;
  a.sort((a,b)=>b-a);
  var dp = xArray(0,k);
  dp[0] = 1;
  var q = -1;
  for(var i = 0; i < n; i++){
    var t = a[i];
    for(var j = k-t; j < k; j++){
      if(dp[j]){
        q = i;
        break;
      }
    }
    for(var j = k-t; j--;){
      dp[j+t] |= dp[j];
    }
  }
  return n-q-1;
}

Measured memory_bytes: 21192
import math
N,A,B=map(int,input().split())
S=[]
for i in range(N):
  S+=[int(input())] 
S.sort(reverse=1)
count=0

def Check(T):
  count=0
  for i in range(N):
    a=math.ceil((S[i]-B*T)/(A-B))
    if a>0:
      count+=a
    else:
      break
  if count<=T:
    return 1
  else:
    return 0

L=1
while True:
  if S[0]/B >=2**L:
    L+=1
  else:
    break

T=2**L#checkしたいナンバー。
for l in range(L,0,-1):
  if Check(T)==1:
    T-=2**(l-1)
  elif Check(T)==0:
    T+=2**(l-1)
if Check(T)==0:
  print(T+1)
else:
  print(T)

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

using namespace std;

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

	vector<int> argA(sizeA);
	for (uint i = 0; i < sizeA; ++i) {
		cin >> argA.at(i);
	}

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

	int maxA = *max_element(argA.begin(), argA.end());
	int minA = *min_element(argA.begin(), argA.end());

	cout << maxA - minA << endl;
}


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

int main() {
    char b;
    cin >> b;
    
    if (b == 'A') {
        cout << 'T' << endl;
    } else if (b == 'T') {
        cout << 'A' << endl;
    } else if (b == 'C') {
        cout << 'G' << endl;
    } else {
        cout << 'C' << endl;
    }
}

Measured memory_bytes: 256
<?php
function eratosthenes3($max) {
	
	// maxの平方根
	$sqrt = floor(sqrt($max));
	
	for ($i=2; $i<=$max; $i++) {
		$lists[$i] = $i;
	}
	
	// もっと単純に倍数を取り除くだけ
	for ($i=2; $i<=$sqrt; $i++) {
		if (isset($lists[$i])) {
			for ($j=$i*2; $j<=$max; $j+=$i) {
				unset($lists[$j]);
			}
		}
	}
	
	return $lists;
}
$prime_lists = eratosthenes3(100003);

$tmp = fgets(STDIN);
foreach ($prime_lists as $key => $value) {
    if($value >= $tmp){
    	$a = $value;
        break;
    }
}
echo $a;

Measured memory_bytes: 10744
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

//using namespace __gnu_pbds;

using namespace std;

#define ll  long long

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef unordered_map<int,int> um;
typedef unordered_set<int> us;
typedef priority_queue<int> pq;
typedef deque<int> dq;
typedef queue<int> q;
typedef stack<int> st;

#define f first
#define s second
#define pb push_back
#define mp make_pair

#define rep(i,a,b) for (int i = a; i <= b; i++)
//#define bitset<n> b<n>

/* typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set; */

void c_p_c()
{
	
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int main(){

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


	ll n;
	cin>>n;

	ll sum=0;

	rep(i,1,n){
		if((i%5!=0 && i%3!=0)&&(i%3!=0)&&(i%5!=0))
			sum+=i;
	}

	cout<<sum;

	return 0;
	}

		

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<stack>
#include<queue>
#include<map>



using namespace std;


int main()
{
    int s,w;
    cin >> s>> w;
    if (s <= w)
    {
        cout << "unsafe"<< endl;
    }else{
        cout << "safe"<< endl;
    }
    
    return 0;
}

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

using namespace std;

int main() {
    /*
        int の最大値は 4 bites 、すなわち 2^31 - 1 = 2147483647 である。
        よって、power が一時的にこれを越えてしまう場合があるから、long 型を用いる.`
     */

    int N;
    cin >> N;

    long long power = 1;
    for (int i = 1; i < N + 1; ++i)
    {
        power *= i;
        power %= int(pow(10, 9) + 7);
    }
    cout << power << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int N = sc.nextInt();
        int[][] vacation = new int[N][3];

        for(int i=0;i<N;++i) {
            vacation[i][0] = sc.nextInt();
            vacation[i][1] = sc.nextInt();
            vacation[i][2] = sc.nextInt();
        }

        int[][] solution = new int[N][3];
        solution[0][0] = vacation[0][0];
        solution[0][1] = vacation[0][1];
        solution[0][2] = vacation[0][2];

        for(int i=1;i<N;++i) {
            solution[i][0] = vacation[i][0] + Math.max(solution[i-1][1], solution[i-1][2]);
            solution[i][1] = vacation[i][1] + Math.max(solution[i-1][0], solution[i-1][2]);
            solution[i][2] = vacation[i][2] + Math.max(solution[i-1][0], solution[i-1][1]);
        }

        System.out.println(Math.max(Math.max(solution[N-1][0], solution[N-1][1]), solution[N-1][2]));
    }
}


Measured memory_bytes: 98384
N = int(input())
L = list(map(int, input().split()))
K = [ 0 for i in range(10**5)]
for i in range(N):
    K[L[i]] += 1
a = []   
res = 0
for i in range(len(K)):
    a.append(K[i])
    if len(a) > 3:
        a.pop(0)
    if sum(a) > res:
        res =sum(a)
print(res)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    double ans = 0;
    rep(i, 0, n) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") ans += x;
        else ans += 380000.0 * x;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int calc(int* array, int N) {
	for (int n = 0; n < N; n++) {
		if (array[n] & 1 == 1 || array[n] == 0) return 0;
		else array[n] >>= 1;
	}
	return 1;
}

int main()
{
	int count = 0;
	unsigned char N;
	int A[200];

	scanf("%i", &N);
	for (int n = 0; n < N; n++) {
		scanf("%i", &A[n]);
	}
	while (calc(A, N)) {
		count++;
	}
	printf("%i", count);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
using namespace std;
#pragma endregion
signed main() {
	int A, B, C;
	cin >>A >> B >>C;
	if (BETWEEN(C,A,B))
		cout << "Yes";
	else
		cout << "No";
}

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


int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>>C(H,vector<char>(W));

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>C.at(i).at(j);

    }
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout<<C.at(i).at(j);
    }
    cout<<endl;
    for(int j=0;j<W;j++){
      cout<<C.at(i).at(j);
    }
    cout<<endl;
  }


}


Measured memory_bytes: 256
H,W = map(int,input().split())
src = [input() for i in range(H)]

dxy = [(0,1),(1,0),(0,-1),(-1,0)]
def is_isolated(x,y):
    if src[y][x] == '.': return False
    for dx,dy in dxy:
        if not 0 <= x+dx < W: continue
        if not 0 <= y+dy < H: continue
        if src[y+dy][x+dx] == '#': return False
    else:
        return True

for y in range(H):
    for x in range(W):
        if is_isolated(x,y):
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064