akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<62);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


int main(){
	ll N;cin>>N;
	vector<ll>A(N);
	vector<ll>sumE(N+1,0);
	vector<ll>sumO(N+1,0);
	ll sumA=0;
	rep(i,N){
		cin>>A[i];
		sumA+=A[i];
		if(i%2==1){
			sumO[i+1]+=A[i];
		}else sumE[i+1]+=A[i];
		sumO[i+1]+=sumO[i];
		sumE[i+1]+=sumE[i];
	}
	sumA/=2;
	rep(i,N){
		if(i%2==1){
			//sumO
			cout<<2*(sumA-sumO[i]-(sumE[N]-sumE[i+1]))<<endl;
		}else{
			cout<<2*(sumA-sumE[i]-(sumO[N]-sumO[i+1]))<<endl;
		}
	}
	
}


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

int main()
{
    int N; cin >> N;
    double x;
    string u;
    double Y = 0.0; //お年玉の合計
    for (int i = 0; i < N; i++) {
        cin >> x;
        cin >> u;
        if (u == "JPY") Y += x;
        else            Y += 380000.0 * x;
    }

    cout << Y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

ll dp[100000+10];

int main(void) {
  int n, W;
  scanf("%d%d", &n, &W);
  REP(i, 100000+10) {
    dp[i] = 1e18;
  }
  dp[0] = 0;
  REP(i, n) {
    ll w, v;
    scanf("%lld%lld", &w, &v);
    for(int j = 100000-v; j >= 0; --j) {
      dp[j+v] = min(dp[j+v], dp[j] + w);
    }
  }
  ll res = 0;
  REP(i, 100000+10) {
    if(dp[i] <= W) {
      res = i;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    if(a-2*b < 0){
        cout << 0 << endl;
    } else {
        cout << a-2*b << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import math

N, M = [int(x) for x in input().split()]
MOD = 10 ** 9 + 7

divisor = []
dict = {}

m = M
d = 2
while m != 1:
    while m % d == 0:
        # divisor.append(d)
        m //= d
        dict[d] = dict.get(d, 0) + 1
    d += 1
C = dict.values()
ret = 1


# def combinations_count(n, r):
#     return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def combinations_count(n, r):
    a = max(r, n-r)
    b = min(r, n-r)
    r = 1
    for i in range(a+1, n+1):
        r *= i
    return r // math.factorial(b)


for c in C:
    ret *= combinations_count(c + N - 1, c)
    ret %= MOD

print(ret)


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

const int INF = 2e9;

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    rep(i,n){
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }
    int ans = INF;
    rep(s,1<<n){
        int cost = 0;
        vector<int> d(m);
        rep(i,n){
            if(s >> i & 1){
                cost += c[i];
                rep(j,m) d[j] += a[i][j];
            }
        }
        bool ok = true;
        rep(j,m) if(d[j] < x) ok = false;
        if(ok) ans = min(ans,cost);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

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

void dfs (string s, char mx){
    if(s.length() == n){
        cout << s << endl;
    }else{
        for(char c = 'a'; c <= mx; ++c){
            char next = mx;
            if(c == mx) ++next; 
            dfs(s + c, next);
        }
    }   
}

int main(){
    cin >> n;
    dfs("", 'a');
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, p;
    cin >> n >> p;
    vector<int> a(n);
    int odd = 0, even = 0;
    rep(i, 0, n){
        cin >> a[i];
        a[i] % 2;
    }
    int dp[110][2] = {};
    dp[0][0] = 1;
    rep(i, 0, n){
        rep(j, 0, 2){
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][(j + a[i]) % 2] += dp[i][j];
        }
    }
    cout << dp[n][p] << endl;
}

Measured memory_bytes: 256
import numpy as np

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall


def solve():
    N = int(input())
    A = np.array([input().split() for _ in range(N)], dtype=np.int64).reshape(N, N)
    
    B = floyd_warshall(csr_matrix(A), directed=False)
    
    if np.any(B < A):
        print(-1)
        exit()
    
    np.fill_diagonal(B, np.inf)
    for i in range(N - 1):
        for j in range(i + 1, N):
            if B[i][j] == np.min(B[i] + B[j]):
                A[i][j] = A[j][i] = 0
    print(np.sum(A) // 2)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 24496
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int X;
  cin >> X;
  int ans = 1;
  for(int i=2;i*i<=X;i++){
    int res = 1;
    while(res <= X){
      res *= i;
    }
    res /= i;
    ans = max(ans , res);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N,Y = map(int,input().split())

flag = 0
for i in range(N+1):
    for j in range(N-i+1):
        dama = 10000*i + 5000*j + 1000*(N-i-j)
        if dama == Y:
            print(str(i)+" "+str(j)+" "+str(N-i-j))
            flag = 1
            break
    else:
        continue
    break

if flag == 0:
    print("-1 -1 -1")


Measured memory_bytes: 3060
#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(){
	string s;
	cin >> s;
	stack<int> stc;
	int ans = 0;
	rep(i, s.size()){
		int c = s[i] - '0';
		if(!stc.empty() && stc.top() == c ^ 1){
			ans += 2;
			stc.pop();
		}else{
			stc.push(c);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
x,n = map(int,input().split())
if n>0:
    p = list(map(int,input().split()))
else:
  print(x)
  exit()


if x not in p:
  print(x)
  exit()
else:
  i = 1
  while True:
    if x-i not in p:
      print(x-i)
      exit()
    elif x+i not in p:
      print(x+i)
      exit()
    i += 1

      

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

inline int deTax(int rate, double yen){
  return yen * 100 / (100 + rate);
}
inline int enTax(int rate, double yen){
  return yen * (100 + rate) / 100;
}

int main(){
  while(1){
    int x, y, s; cin >> x >> y >> s;
    if(!x && !y && !s) break;

    int maximum = 0;
    for(double i=1.0;i < s/2+1; ++i){
      double j = s-i+0.99999999999999;
      double k = i+0.99999999999999;

      int nx = deTax(x, k), ny = deTax(x, j);
      if(enTax(x, nx) + enTax(x, ny) == s){
        maximum = max(maximum, enTax(y, nx) + enTax(y, ny));
      }
    }
    cout << maximum << endl;
  }
}

Measured memory_bytes: 1160
N, K = map(int,input().split())
H = list(map(int,input().split()))
import numpy as np
dp = np.zeros(N,dtype=np.int)
harr = np.array(H)
for i in range(1,N):
  St = max(0,i-K)
  Hi = harr[i]
  dp[i] = min(dp[max(0,i-K):i] + np.abs(Hi - harr[max(0,i-K):i]))
print(dp[-1])

Measured memory_bytes: 19644
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int w[10],k[10];
  for(int i=0;i<10;i++)
    cin >> w[i];
  for(int i=0;i<10;i++)
    cin >> k[i];
  sort(w,w+10);
  reverse(w,w+10);
  sort(k,k+10);
  reverse(k,k+10);

  cout << (w[0]+w[1]+w[2]) << " " << (k[0]+k[1]+k[2]) << endl;
  return 0;
}

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

using namespace std;

int main()
{   long long n,m;
    long long a[5];
    cin>>n>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
    long long min=a[0];
    for(int i=0;i<5;i++)
    {
        if(a[i]<min)
            {min=a[i];}
    }
    if(min>=n)
        m=5;
     else if(n%min==0) m=(n/min-1)+5;
    else m=(n/min)+5;
    cout<<m;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  int a,b,c,x,y;
  int i,j;
  int cost=0;
  
  scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
  
  while( x > 0 && y > 0){
    if( a + b > c*2 ) cost += c + c;
    else              cost += a + b;
    
    x--; y--;
  }
  
  while( x > 0 ){
    if( a > c*2 ) cost += c + c;
    else          cost += a;
      
    x--;
  }
  
  while( y > 0 ){
    if( b > c*2 ) cost += c + c;
    else          cost += b;
    
    y--;
  }
  
  printf("%d\n",cost);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main()
{
    ll MAX = 55555;
    vector<int> kouho;

    vector<bool> isp(MAX, 1);
    isp[0] = isp[1] = false;
    for (ll p = 2; p < MAX; ++p) {
        if (!isp[p]) continue;
        for (ll i = p * 2; i < MAX; i += p) isp[i] = false;
    }
    rep(i,55555){
        if(i%5 == 1 && isp[i]){
            kouho.pb(i);
        }
    }
    int n;
    cin >> n;
    rep(i,n){
        cout << kouho[i] << " ";
    }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

long long number(long long l)
{
    return l/2LL;
}

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

    string S;
    cin>>S;
    int n;
    cin>>n;

    bool same=true;
    for(int i=0; i<S.size(); i++)
        if(S[i]!=S[0])
            same=false;

    if(same)
        cout<<number(1LL*n*S.size())<<"\n";
    else
    {
        int nrbeg=0,nrend=0;
        for(int i=0; i<S.size(); i++)
        {
            if(S[i]!=S[S.size()-1])
                break;
            nrbeg++;
        }

        for(int i=S.size()-1; i>=0; i--)
        {
            if(S[i]!=S[0])
                break;
            nrend++;
        }

        int lung=0;
        long long rez=0;
        for(int i=nrbeg; i<S.size()-nrend; i++)
        {
            if(i==0 || S[i-1]!=S[i])
            {
                rez+=number(lung);
                lung=1;
            }
            else
                lung++;
        }
        rez+=number(lung);
        rez*=n;
        rez+=number(nrbeg);
        rez+=number(nrend);
        rez+=number(nrbeg+nrend)*(n-1);
        cout<<rez<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
def dfs(t):
    # 全ての辺を訪問していた場合
    if (0 not in already): return 1
    # 全ての辺を訪問する回数を格納する変数
    allReach=0
    for i in range(N):
        # 辺があり、訪問していない場合
        if connect[t][i]==1 and already[i]==0:
            already[i]=1
            allReach+=dfs(i)
            already[i]=0
    return allReach


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

connect=[[0for i in range(N)]for j in range(N)]
for i in range(M):
    a,b=map(int, input().split())
    # 辺の情報を記録する
    connect[a-1][b-1]=1
    connect[b-1][a-1]=1

# 訪問した頂点を記録する
already=[0 for i in range(N)]
# 必ず1から始まるので訪問履歴をつけておく
already[0]=1
# 記録した情報をもとに0からdfs
print(dfs(0))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

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

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> sum(n+1,0);
    rep(i,n)sum[i+1] = sum[i] + a[i];
    ll ans = INF;
    for(int i = 1; i <= n-1; i++){
        ll temp = abs(sum[i] - sum[0] - (sum[n] - sum[i]));
        chmin(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define NAME "INPUT"
using namespace std;
ifstream fi (NAME".inp");
ofstream fo (NAME".out");
int main(){
    int k;
    string s;
    cin>>k;
    cin>>s;
    if(k>=s.size())
        cout<<s;
    else{
        for(int i=0;i<k;i++)
            cout<<s[i];
        cout<<"...";
    }
}





Measured memory_bytes: 3612
#include<stdio.h>
int main(void)
{
 int a;
 int b;
 int c;
 int d;
 scanf("%d", &a);
 b = a / 3600;
 c = (a % 3600) / 60;
 d = (a % 3600) % 60;
 printf("%d:%d:%d\n", b, c, d);
 return 0;
}


Measured memory_bytes: 2128
w, h, n = map(int, input().split(" "))
list_place = [0, w, 0, h]
for _ in range(n):
  x, y, a = map(int, input().split(" "))
  if a == 1:
    if x > list_place[0]:
      list_place[0] = x
  elif a == 2:
    if x < list_place[1]:
      list_place[1] = x
  elif a == 3:
    if y > list_place[2]:
      list_place[2] = y
  else:
    if y < list_place[3]:
      list_place[3] = y
if list_place[1] - list_place[0] < 0 or list_place[3] - list_place[2] < 0:
  print(0)
else:
  s = (list_place[1] - list_place[0]) * (list_place[3] - list_place[2])
  print(s)

Measured memory_bytes: 3064
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.*;

class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()) {
			String[] strArr = in.nextLine().split(",");
			List<Integer> intArr = new ArrayList<>();
			for (int i = 0; i < strArr.length; i++) {
				intArr.add(Integer.parseInt(strArr[i]));
			}
			solve(intArr);
		}
	}
	public static void solve(List<Integer> hands) {
		Collections.sort(hands);
		int ans = 0;
		int[] cards = new int[15];
		for(int i=0;i<hands.size();i++) {
			cards[hands.get(i)]++;
		}
		int pairs = 0;
		int max = 0;
		for(int i=0;i<cards.length;i++) {
			max = Math.max(max, cards[i]);
			if(cards[i] == 2) pairs++;
		}

		// ?????????A
		boolean streight = false;
		if(hands.get(0) == 1) {
			if(hands.get(1) == 2 && hands.get(2) == 3 && hands.get(3) == 4 && hands.get(4) == 5) streight=true;
			if(hands.get(1) == 10 && hands.get(2) == 11 && hands.get(3) == 12 && hands.get(4) == 13) streight=true;
		} else {
			streight = true;
			for(int i=1;i<hands.size();i++) {
				if(hands.get(i) - hands.get(i-1) != 1) {
					streight = false;
					break;
				}
			}
		}

		if(max == 4) {
			System.out.println("four card");
		} else if(max == 3 && pairs == 1) {
			System.out.println("full house");
		} else if(streight) {
			System.out.println("straight");
		} else if(max == 3) {
			System.out.println("three card");
		} else if(pairs == 2) {
			System.out.println("two pair");
		} else if(pairs == 1) {
			System.out.println("one pair");
		} else {
			System.out.println("null");
		}
	}
}

Measured memory_bytes: 25776
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

ll fac[510000], finv[510000], inv[510000];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 510000; ++i) {
		fac[i] = fac[i - 1] * i%INF;//i!のmod INF
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
int main() {
	int n, k; cin >> n >> k;
	vector<ll>a;
	COMinit();
	REP(i, n) {
		ll s; cin >> s;
		a.push_back(s);
	}
	sort(a.begin(), a.end());
	ll ans = 0;
	ll dif = a[n - 1] - a[0];
	ans += dif * COM(n, k);
	ans %= INF;
	if (k == 1) {
		cout << 0 << endl;
		return 0;
	}
	else {
		ll S = 0;
		for (int i = 0; i < n - 1; ++i) {
			S += (a[i + 1] - a[i])*(COM(i+1, k) + COM(n - i-1, k));
			S %= INF;
		}
		if (ans - S > 0) {
			cout << ans - S << endl;
		}
		else {
			cout << ans - S + INF << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 13304
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;


int tests,current_case;
int n;
char a[128],b[128];
int ans;

void message(int current_case) {
    //cerr<<"Case "<<current_case<<" solved!"<<endl;
    fprintf(stderr, "Case %d solved!\n", current_case);
}

bool check(int l) {
    int i,j;
    for(i=n-l+1,j=1;i<=n;i++,j++) if(a[i]!=b[j]) return false;
    return true;
}

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

    tests=1;
    //scanf("%d", &tests);
    //cin>>tests;
    for(current_case=1;current_case<=tests;current_case++) {
        scanf("%d", &n);
        scanf("%s", a+1);
        scanf("%s", b+1);
        ans=n+n;
        for(i=1;i<=n;i++) if(check(i)) ans=min(ans,n+n-i);
        printf("%d\n", ans);
        message(current_case);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <climits>
using namespace std;
#define rep(i,l,r) for(int (i)=(int)(l);(i)<(int)(r);(i)++)
#define ll long long
#define ve vector
#define umap unordered_map
#define iter iterator


int main() {
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int x = tx-sx, y = ty-sy;
    rep(i,0,y) cout<<'U';
    rep(i,0,x) cout<<'R';
    cout<<'U';
    rep(i,0,x+1) cout<<'L';
    rep(i,0,y+1) cout<<'D';
    rep(i,0,x+1) cout<<'R';
    rep(i,0,y) cout<<'U';
    cout<<'R';
    rep(i,0,y+1) cout<<'D';
    rep(i,0,x+1) cout<<'L';
    cout<<'U'<<endl;

    return 0;
}

Measured memory_bytes: 256
x,k,d = input().split()
x = int(x)
k = int(k)
d = int(d)
ans = 0
if abs(x) >= abs(k*d):
    ans =  abs(x) - abs(k*d)
else:
    kaisuu = int(abs(x)/d)
    k_2 = k - kaisuu
    if k_2%2 == 0:
        ans = abs(x) - d*kaisuu 
    else:
        ans = abs((abs(x) - d*kaisuu) - abs(d))
print(int(ans))

Measured memory_bytes: 9220
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

a1 = []
for h_i in range(h):
    if "#" in a[h_i]:
        a1.append(a[h_i])

a2 = []
for w_i in range(w):
    for h_i in range(len(a1)):
        if a1[h_i][w_i] == "#":
            break
    else:
        a2.append(w_i)

for i in range(len(a2)):
    a2[i] -= i

for ele in a2:
    for h_i in range(len(a1)):
        a1[h_i].pop(ele)

for h_i in range(len(a1)):
    print("".join(a1[h_i]))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr ll INF = 1e18;
int main(){ 
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());

  if (a[0] == 0) {
    cout << 0 << endl;
    return 0;
  }
  ll res = 1;
  for (int i = 0; i < n; i++) {
    if (res > INF / a[i]) {
      cout << -1 << endl;
      return 0;
    }
    res *= a[i];
  }
  cout << res << endl;
  return 0;
} 


Measured memory_bytes: 4012
# C - Train Ticket
from itertools import product
S = input()
n = len(S)-1
total =0
for i in list(product(["-","+"],repeat=n)):
    bag=""
    for ind,val in enumerate(S):
        if ind ==0:
            bag+=val
        else:
            bag+=i[ind-1]+val
    if eval(bag)==7:
        print(bag+"=7")
        exit()


Measured memory_bytes: 3060
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();

        int v = Integer.parseInt(a+b);
        int x = (int)Math.sqrt(v);
        if (x * x == v) System.out.println("Yes");
        else System.out.println("No");

        return;
    }

}

Measured memory_bytes: 21716
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int ar[]=new int[3];
		ar[0]=sc.nextInt();
		ar[1]=sc.nextInt();
		ar[2]=sc.nextInt();
		Arrays.sort(ar);
		if(ar[0]==5&&ar[1]==5&&ar[2]==7)
		System.out.println("YES");
		else
		System.out.println("NO");
	}
}


Measured memory_bytes: 21204
#include "bits/stdc++.h"
#define ll long long
using namespace std;
int main(){
ll N;
cin>>N;
vector<ll> a(N);
for(int i=0;i<N;i++){
  cin>>a[i];
}

ll nix=0;
for(ll i=0;i<N;i++){
  if(i%2==0)
  nix+=a[i];
  else
  nix-=a[i];
}

ll ans = nix;
cout<<ans<<" ";
for(int i=0;i<N-1;i++){
ans /=2;
ans = 2*(a[i]-ans);
  cout<<ans<<" ";
}


cout<<endl;
return 0;

}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

int main() {
	int x, y, z;
	cin >> x >> y >> z;

	swap(x, y);
	swap(x, z);

	printf("%d %d %d\n", x, y, z);
	return 0;
}

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

 int a=0,b=0;
 int ans=0;
   
  cin >> a >> b ;
  ans = a % 500;
  if(ans <= b){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
  

}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)
 
#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
 
const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;
 
// typedef long long ll;
#define int long long
#define double long double
 
template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}
 
typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int A, B, K; cin >> A >> B >> K;
  int all = A+B;
  all -= K;
  if(all <= 0){
    cout << 0 << ' ' << 0 << endl;
  } else {
    cout << max(all-B, 0ll) << ' ' << min(all, B) << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int d[5005];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int ans,n,m,x,k,q,cnt;
	cin>>k>>q;
	rep(i,0,k)cin>>d[i];
	rep(t,0,q){
		cin>>n>>x>>m;x%=m;n--;
		ans=cnt=0;
		rep(i,0,k)ans+=d[i]%m,cnt-=(d[i]%m==0);
		ans=ans*(n/k);ans+=x;cnt=cnt*(n/k);
		rep(i,0,n%k)ans+=d[i]%m,cnt-=(d[i]%m==0);
		cout<<n+cnt-ans/m<<'\n';
	}
	RE 0;
}



Measured memory_bytes: 384
import sys
n=int(input())
s=sorted([input() for i in range(n)])
ct=0
tmp=1
for i in range(n-1):
    if s[i] ==s[i+1]:
        tmp+=1
    else:
        if tmp>ct:
            ct=tmp
        tmp=1
if tmp > ct:
    ct = tmp
    
if tmp == 1:
    for i in range(n):
        print(s[i])
    sys.exit()

tmp=1
for i in range(n-1):
    if s[i] ==s[i+1]:
        tmp+=1
        if tmp == ct:
            print(s[i])
    else:
        tmp=1
        

Measured memory_bytes: 19332
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

inline void setmin(int &x, int y) { if (y < x) x = y; }
inline void setmax(int &x, int y) { if (y > x) x = y; }
inline void setmin(ll &x, ll y) { if (y < x) x = y; }
inline void setmax(ll &x, ll y) { if (y > x) x = y; }

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 52;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, k;
    cin >> n >> k;
    cout << ((n + 1) / 2 >= k ? "YES\n" : "NO\n");
    return 0;
}


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

signed main(){

  int n,k; cin >> n >> k;
  vector<int> v(n+1);
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    v[a]++;
  }

  sort(v.begin(),v.end());
  int cnt = (v.end()-lower_bound(v.begin(),v.end(),1)) - k;
  //cout << cnt << endl;
  if(cnt <= 0) cout << 0 << endl;
  else {
    int ans = 0;
    for(auto p = lower_bound(v.begin(),v.end(),1); p != v.end(); p++){
      if(cnt <= 0) break;
      cnt--;
      ans += *p;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;
int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
    stack<int> S;
    S.push(r);
    color[r] = c;
    while ( !S.empty() ) {
        int u = S.top();
        S.pop();
        for ( int i = 0; i < G[u].size(); i++ ){
            int v = G[u][i];
            if ( color[v] == NIL ) {
                color[v] = c; S.push(v);
            }
            
        }
    }
        }

void assignColor() { int id = 1;
    for(int i=0; i<n; i++) color[i]=NIL;
    for(int u=0; u<n; u++){
        if(color[u] ==NIL) dfs(u,id++);
    }
    }

int main() {
    int s, t, m, q;
    cin >> n >> m;

    for ( int i = 0; i<m; i++){
         cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
         }
    assignColor();
    cin >> q;
    
         for ( int i = 0; i < q; i++ ) {
             cin >> s >> t;
             if ( color[s] == color[t] ) {
                 cout << "yes" << endl;
                 
             } else {
                     cout << "no" << endl;
                 
             }
         }
         return 0; }



Measured memory_bytes: 9000
N = int(input())
A = list(map(int,input().split()))

if N <= 2:
    print(1)
    exit()

d = []
for i in range(N-1):
    if A[i+1] - A[i] > 0:
        d.append(1)
    elif A[i+1] - A[i] < 0:
        d.append(-1)

flag = [True]*len(d)

ans = 1
for i in range(len(d)-1):
    if flag[i]:
        if d[i] == -d[i+1]:
            ans += 1
            flag[i+1] = False
print(ans)

Measured memory_bytes: 14252
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	heiseiEndsAt := 20190430

	var s string
	fmt.Scan(&s)

	s = strings.Replace(s, "/", "", 2)

	date, _ := strconv.Atoi(s)
	if heiseiEndsAt < date {
		fmt.Println("TBD")
	} else {
		fmt.Println("Heisei")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

string s;
const int maxn = 1e5+5;
int ans[maxn];

void solve(int l, int r) {
    for (int i = l; i < r; i++) {
        if (s[i] == 'L' && s[i+1] == 'R') {
            solve(l,i);
            solve(i+1,r);
            return;
        }
    }
    int split = l;
    for (int i = l; i < r; i++) {
        if (s[i] == 'R' && s[i+1] == 'L') {
            split = i;
            break;
        }
    }
    int t = 0;
    for (int i = split; i >= l; i--, t^=1) {
        if (t == 0) ans[split]++;
        else ans[split+1]++;
    }
    t = 1;
    for (int i = split + 1; i <= r; i++, t^=1) {
        if (t == 0) ans[split]++;
        else ans[split+1]++;
    }
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> s;
    int n = s.size();
    s = '#' + s;
    solve(1,n);
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << ' ';
    }
    cout << '\n';
}



Measured memory_bytes: 1004
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define ll long long
#define be(v) v.begin(), v.end()
ll INF = 1000100100010;

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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int h,w;
  cin >> h >> w;
  char b1[60][60];
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      cin >> b1[i][j];
    }
  }
  char b2[60][60];
  const int px[8] {-1,0,1,-1,1,-1,0,1};
  const int py[8] {-1,-1,-1,0,0,1,1,1};
  for (int x=0; x<h; x++) {
    for (int y=0; y<w; y++) {
      if (b1[x][y] == '#') {
        b2[x][y] = '#';
        continue;
      }
      int num = 0;
      for (int c=0; c<8; c++) {
        if (b1[x+px[c]][y+py[c]] == '#') {
          num += 1;
        }
      }
      b2[x][y] = '0'+num;
    }
  }
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      cout << b2[i][j];
    }
  cout << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int x,y,t;
scanf("%d%d",&x,&y);
if(x<y){//xをでかいほうに持ってくる
	t=x;
	x=y;
	y=t;
}
for(;;){//ユークリッドの互除法
if(y==0)break;	
t=x%y;
x=y;
y=t;
}
printf("%d\n",x);
  return 0;
}



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

int main() {
  int A, B;
  int K = -1;
  cin >> A >> B;
  for(int i=0; i<=1000000000; i++) {
    if(abs(A-i) == abs(B-i)) {
      K = i;
      break;
    }
  }
  if(K == -1)
    cout << "IMPOSSIBLE" << endl;
  else
    cout << K << endl;
  return 0;
    
}

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

int main()
{
    int k;
    string s;
    cin >> k >> s;
    int s_len = s.size();
    if(s_len > k)
    {
        string head = s.substr(0, k);
        cout << head + "..." << endl;
    }
    else cout << s << endl;
    
    return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    reverse(a.begin(), a.end());
    for (int i = 0; i < n - 1; i++) {
        cout << a[i] << " ";
    }
    cout << a[n - 1] << endl;
    return 0;
}



Measured memory_bytes: 3064
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int m = sc.nextInt();
      	int a;
      	for(int i = 0; i < m; i++){
        	a = sc.nextInt();
          	n -= a;
        }
      	if(n < 0) System.out.println(-1);
      	else System.out.println(n);
    }
}

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


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

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	mod int = 1e9 + 7
)

func main() {
	A := make([][]int, 3)
	for i := 0; i < 3; i++ {
		A[i] = make([]int, 3)

		for j := 0; j < 3; j++ {
			A[i][j] = getInt()
		}
	}

	N := getInt()
	bingo := make([][]bool, 3)
	for i := 0; i < 3; i++ {
		bingo[i] = make([]bool, 3)
	}

	for n := 0; n < N; n++ {
		b := getInt()

		for i := 0; i < 3; i++ {
			for j := 0; j < 3; j++ {
				if A[i][j] == b {
					bingo[i][j] = true
				}
			}
		}
	}

	for i := 0; i < 3; i++ {
		if bingo[i][0] && bingo[i][1] && bingo[i][2] {
			fmt.Println("Yes")
			return
		}
	}

	for i := 0; i < 3; i++ {
		if bingo[0][i] && bingo[1][i] && bingo[2][i] {
			fmt.Println("Yes")
			return
		}
	}

	if (bingo[0][0] && bingo[1][1] && bingo[2][2]) || (bingo[0][2] && bingo[1][1] && bingo[2][0]) {
		fmt.Println("Yes")
		return
	}

	fmt.Println("No")
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p % 2 == 0 {
		t := powMod(n, p / 2)
		return calcMod(t * t)
	} else {
		return n * powMod(n, p - 1)
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N;
  cin>>N;
  if(N%2){
    cout<<0<<endl;
    return 0;
  }
  N/=2;
  ll ans=0;
  VL F(28);
  F[0]=1;
  rep(i,27) F[i+1]=F[i]*5;
  rep(i,27) ans+=N/F[i+1];
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
    public static void main(String args[])throws IOException{
        final int tou = 4, kai = 3, number = 10;
        int[][][] x = new int[tou][kai][number];
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String n = br.readLine();
        String s;
        while((s=br.readLine())!=null){
            String[] str = s.split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            int c = Integer.parseInt(str[2]);
            int d = Integer.parseInt(str[3]);
            if(!(a>tou || b>kai || c>number || d>9)){
                switch(a){
                    case 1: x[a-1][b-1][c-1] += d; break;
                    case 2: x[a-1][b-1][c-1] += d; break;
                    case 3: x[a-1][b-1][c-1] += d; break;
                    case 4: x[a-1][b-1][c-1] += d; break;
                }
            }
            else break;
        }
        for(int i=0; i<x.length; i++){
            for(int j=0; j<x[i].length; j++){
                for(int k=0; k<x[i][j].length; k++){
                    System.out.print(" "+x[i][j][k]);
                }
                System.out.println("");
            }
            if(i<tou-1){
                System.out.println("####################");
            }
        }
    }
}

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

main() {
    int N; cin >> N;
    if(N%111==0) cout << N << endl;
    else cout << (N/111+1)*111 << endl;

    return 0;
}

Measured memory_bytes: 256
N = input()
N = int(N)
rest = []
for i in range(N):
    a,b = input().split(" ")
    b = int(b)
    rest.append([a,b,i+1])
rest.sort(key=lambda x: (x[0], -x[1]),reverse=False)
for i in range(N):
    print(rest[i][2])





Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    ll n;
    cin >> n;
    vector<pair<int,int>>prime;
    int ans = 0;
    for(ll i = 2;i*i<=n;i++) {
        int cnt = 0;
        if(n%i == 0) {
            while(n%i==0) {
                cnt++;
                n /= i;
            }
            int cur = 1;
            while(cnt>=cur) {
                cnt -= cur;
                cur++;
                ans++;
            }
        }
    }
    if(n != 1) ans++;
    cout << ans << endl;
}
    




Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#define PII pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
inline int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9') { if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar();}
	return f==1?x:-x;
}
inline void print(int x){
	if(x<0) x=~x+1,putchar('-');
	if(x>=10) print(x/10);
	putchar((x%10)|48);
}
int n,m;
int fa[100010];
inline int find(int x){
	return fa[x]==x?x:find(fa[x]);
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;++i) fa[i]=i;
	for(int i=1;i<=m;++i){
		int a=read(),b=read();
		int fx=find(a),fy=find(b);
		if(fx!=fy) fa[fx]=fy;
	}
	int ans=-1;
	for(int i=1;i<=n;++i) if(fa[i]==i) ++ans;
	print(ans);
}

Measured memory_bytes: 4024
object Main extends App {
    for (Array(a, b, n) <- io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))) {
        val x = (0 until n).foldLeft((a, 0))((p, _) => (p._1 % b * 10, p._2 + p._1 % b * 10 / b))
        println(x._2)
    }
}

Measured memory_bytes: 44112
#include <stdio.h>


int main()
{
    double r=0,S=0,circ=0;
    
    scanf("%lf/n",&r);
    
    S=3.141592653589*r*r;
    circ=2*3.141592653589*r;
    
    printf("%f %f\n",S,circ);
    
    return 0;
}


Measured memory_bytes: 1968
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

n,m=LI()
c=[]
x=[inf]*n
ans=True
g=[[] for _ in range(n)]
for i in range(m):
    l,r,d=LI_()
    d+=1
    g[l].append((r,d))
    g[r].append((l,-d))
    c.append((l,r,d))

v=[inf]*n
vs=[-1]*n

def bfs(st):
    if v[st]!=inf:
        return True
    q=[st]
    v[st]=0
    vs[st]=0
    while q:
        
        c=q.pop()
        for nb,d in g[c]:
            if vs[nb]==0:
                continue
            else:
                q.append(nb)
                vs[nb]=0
                if v[nb]==inf:
                    v[nb]=v[c]+d
                elif v[nb]!=v[c]+d:
                    show(c+1,nb+1,v)
                    return False
    return True

for i in range(n):
    if bfs(i):
        continue
    else:
        print('No')
        exit()

for i in range(m):
    l,r,d=c[i]
    if v[l]+d!=v[r]:
        print('No')
        exit()
        
print('Yes')




Measured memory_bytes: 120348
#include<bits/stdc++.h>
using namespace std;
int n,a[60];
int main() {
	scanf("%d",&n);
	bool flag=1;
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		if(a[i]<a[i-1]) flag=0;
	}
	if(flag) {
		printf("YES");
		return 0;
	}
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++) {
			flag=1;
			swap(a[i],a[j]);
			for(int k=2;k<=n;k++) if(a[k]<a[k-1]) flag=0;
			if(flag) {
				printf("YES");
				return 0;
			}
			swap(a[i],a[j]);
		}
	printf("NO");
	return 0;
}

Measured memory_bytes: 256