akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int K = sc.nextInt();
        System.out.println(a[K-1]);
    }
}


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

int main() {
	int N, A, B;
	
	cin >> N >> A >> B;
	
	int ans = 0;
	
	for (int i = 1; i <= N; ++i) {
		int n = i, sum = 0;
		
		while (n) {
			sum += n % 10;
			n /= 10;
		}
		
		if (sum >= A && sum <= B) {
			ans += i;
		}
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
<?php
define('MOD', 1000000007);

// 繰り返し二乗法
function power($a, $b){
    $res=1;
    while($b>0){
        if($b&1) $res=$res*$a%MOD;
        $a=$a*$a%MOD;
        $b>>=1;
    }
    return $res;
}

function comb($n, $r){
    global $fact, $fact_inv;
    return ($fact[$n]*$fact_inv[$r])%MOD*$fact_inv[$n-$r]%MOD;
}

fscanf(STDIN, "%d %d", $X, $Y);
if (($X + $Y) % 3 === 0) {
    $Z = $X + $Y;
    $ZZ = $Z / 3;
    $XX = $X - $ZZ;
    $YY = $Y - $ZZ;
    if ($XX < 0 || $YY < 0) {
        echo "0";
    } else {

        define('MAX', $XX + $YY + 1);

        $fact[0]=1;
        // 階乗の計算
        for ($i = 0; $i < MAX; $i++) {
            $fact[$i+1]=$fact[$i]*($i+1)%MOD;
        }
        $fact_inv[MAX]=power($fact[MAX], MOD-2);
        // 逆元の計算
        for($i=MAX-1; $i>=0; --$i) {
            $fact_inv[$i]=$fact_inv[$i+1]*($i+1)%MOD;
        }

        echo comb($XX + $YY, $XX);
    }
} else {
    echo "0";
}


Measured memory_bytes: 63980
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> x(M), y(M);
  for (int i = 0; i < M; i++)
  {
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
  }
  vector<int> ball(N, 1);
  vector<bool> red(N, false);
  red[0] = true;
  for (int i = 0; i < M; i++)
  {
    if (red[x[i]])
    {
      if (ball[x[i]] <= 1)
        red[x[i]] = false;
      red[y[i]] = true;
    }
    ball[x[i]]--;
    ball[y[i]]++;
  }
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (red[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
public class Main
{   
static class FastReader 	
{		
BufferedReader br; 		
StringTokenizer st; 		
public FastReader() 		
{ 			
br = new BufferedReader(new	InputStreamReader(System.in)); 		
} 		
String next() 		
{ 			
while (st == null || !st.hasMoreElements()) 			
{ 				
try				
{ 					
st = new StringTokenizer(br.readLine()); 				
} 				
catch (IOException e) 				
{ 					
e.printStackTrace(); 				
} 			
} 			
return st.nextToken(); 		
} 
		
int nextInt() 		
{ 			
return Integer.parseInt(next()); 		
} 
		
long nextLong() 		
{ 			
return Long.parseLong(next()); 		
} 
		
double nextDouble() 		
{ 			
return Double.parseDouble(next()); 		
		 } 
		
		String nextLine() 		
		 { 			
String str = ""; 			
			 try			
			{ 				
				 str = br.readLine(); 			
			 } 			
			 catch (IOException e) 			
			 { 				
				 e.printStackTrace(); 			
			 } 			
			 return str; 		
		 } 	
	 }
	
	 public static void main(String[] args){
		 FastReader scan=new FastReader();
		  int t = scan.nextInt();
		  HashMap<String,Integer> map = new HashMap<>();
		  for(int i=0;i<t;i++){
				String s = scan.next();
					if(map.containsKey(s))map.put(s,map.get(s)+1);
					else map.put(s,1);
			}
		if(map.containsKey("AC"))System.out.println("AC x " + map.get("AC"));
		else System.out.println("AC x " + 0);
		if(map.containsKey("WA"))System.out.println("WA x " + map.get("WA"));
		else System.out.println("WA x " + 0);
		if(map.containsKey("TLE"))System.out.println("TLE x " + map.get("TLE"));
		else System.out.println("TLE x " + 0);
		if(map.containsKey("RE"))System.out.println("RE x " + map.get("RE"));
		else System.out.println("RE x " + 0);
		
	} 
} 


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;++i){
        string s=to_string(i);
        if(s.size()%2==1)cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int main()
{
    int n;
    cin>>n;
    vector<int> vec(n);
    for(auto& it : vec) cin>>it;

    int ans = 1e9;
    for(int i = 1; i<=100; ++i)
    {
        int cur = 0;
        for(int j = 0; j<n; ++j)
        {
            cur += (vec[j]-i)*(vec[j]-i);
        }
        ans = min(cur, ans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def solve():
    N = input()
    least_digit = int(N[-1])
    if least_digit in set([2,4,5,7,9]):
        print("hon")
    elif least_digit in set([0,1,6,8]):
        print("pon")
    else:
        print("bon")

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

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

Measured memory_bytes: 256
//ABC135-A
#include <bits/stdc++.h>
#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 == b){
    cout << "0" << endl;
  }else if( (a+b)%2 ==0){
    cout << (a+b)/2 << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int n,x;
string s;
vector<pair<string,pair<int,int>>>v;
 
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s>>x;
		v.push_back({s,{-x,i+1}});
	}
	sort(v.begin(), v.end());
	for(auto i:v){
		cout<<i.second.second<<'\n';
	}
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int x, y, z, i;
int main(int argc, const char * argv[]){
    cin>>x>>y>>z;
    i = 0;
    for(i = 0; (i * y) + (i + 1) * z <= x; i++){}
    if(i * y + (i + 1) * z > x)i--;
    cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 3588
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            long A = in.Long();
            long B = in.Long();
            long C = in.Long();
            long K = in.Long();
            if (A + B >= K) {
                out.println(Math.min(A, K));
            } else {
                K -= A + B;
                out.println(A - K);
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public long Long() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 32736
# Problem: https://atcoder.jp/contests/abc047/tasks/abc047_b
# Python 1st Try

import sys
import numpy
# import pprint
# from collections import defaultdict
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(Width, Height, Point, x_position, y_position, control_id):
    result = 0
    # surface = [[0] * (Width+1) for _ in range(0, Height+1, +1)]
    surface = numpy.zeros((Width, Height), dtype=numpy.int)
    # pprint.pprint(surface)
    # algorithm
    # pprint.pprint(surface)
    for j in range(0, Point, +1):
        if control_id[j] == 1:
            for x in range(0, x_position[j], +1):
                for y in range(0, Height, +1):
                    surface[x][y] = 1
        elif control_id[j] == 2:
            for x in range(x_position[j], Width, +1):
                for y in range(0, Height, +1):
                    surface[x][y] = 1
        elif control_id[j] == 3:
            for x in range(0, Width, +1):
                for y in range(0, y_position[j], +1):
                    surface[x][y] = 1
        else:  # control_id[X] == 4
            for x in range(0, Width, +1):
                for y in range(y_position[j], Height, +1):
                    surface[x][y] = 1
    #  pprint.pprint(surface)
    for x in range(0, Width, +1):
        for y in range(0, Height, +1):
            if surface[x][y] == 0:
                result = result + 1
    return result


if __name__ == "__main__":
    W, H, N = MI()
    x_position = list()
    y_position = list()
    control_id = list()
    for j in range(0, N, +1):
        x_tmp, y_tmp, a_tmp = MI()
        x_position.append(x_tmp)
        y_position.append(y_tmp)
        control_id.append(a_tmp)
    print("{}".format(solver(W, H, N, x_position, y_position, control_id)))


Measured memory_bytes: 27004
#include <bits/stdc++.h>
using namespace std ;
using ll = long long ;
int main()
{
    int n ;
    cin >> n ;
    string s ;
    cin >> s ;
    if(s.size()<=n)
    {
        cout << s ;

    }
    else if (s.size()!= n) {

        for(int i=0 ;i<n ;i++)
        {
            cout << s[i] ;
        }
        cout <<"..." ;
    }



    return 0 ;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define INF 1000000
using namespace std;
int main()
{
	int n,m;
	cin >> n >> m;
	vector<vector<int> > dp(m+1,vector<int>(n+1,INF));
	int coin[m+1];
	for(int i=1; i<=m; i++)
	{
		scanf("%d",&coin[i]);
	}
	for(int i=0; i<=m; i++)
		dp[i][0] = 0;
	for(int i=1; i<=m; i++)
	{
		for(int j=1; j<=n; j++)
		{
			if(j - coin[i] < 0) dp[i][j] = dp[i-1][j];
			else dp[i][j] = min(dp[i-1][j], dp[i][j-coin[i]] + 1);
		}
	}/*
	for(int i=0; i<=m; i++)
	{
		for(int j=0; j<=n; j++)
			cout << dp[i][j] << " ";
		cout << endl;
	}*/
	cout << dp[m][n] << endl;
	return 0;
}


Measured memory_bytes: 7132
#include <iostream>

int main(){
   int N;
   std::cin >> N;
   int H[N];
   for(int i=0; i<N; ++i){
      std::cin >> H[i];
   }

   int index = -1;
   for(int i=0; i<N-1; ++i){
      if(H[i]==H[i+1]){
	 if(index<0) index = i; 
      }else if(H[i]-H[i+1]>=1){
	 if(index>-1){
	    for(int j=index; j<=i; ++j){
	       --H[j];
	    }
	    index = -1;
	 }else --H[i];
      }else{
	 index = -1;
      }
   }
   for(int i=0; i<N-1; ++i){
      if(H[i]-H[i+1]>0){
	 std::cout << "No" << std::endl;
	 return 0;
      }
   }
   std::cout << "Yes" << std::endl;
   return 0;

}


Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int& i : a) cin >> i;
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		int com, b, e;
		cin >> com >> b >> e;
		if (com == 0) {
			int ans = INT_MAX;
			for (int j = b; j < e; ++j) ans = min(a[j], ans);
			cout << ans;
		}
		else {
			int ans = INT_MIN;
			for (int j = b; j < e; ++j) ans = max(a[j], ans);
			cout << ans;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int D; cin >> D;
    veci C(26);
    vecveci S(D,veci(26));
    veci T(D);
    REP(i,26) cin >> C[i];
    REP(i,D) REP(j,26) cin >> S[i][j];
    REP(i,D) {
        cin >> T[i];
        --T[i];
    }
    int M; cin >> M;
    veci B(M),Q(M);
    REP(i,M) {
        cin >> B[i] >> Q[i];
        --B[i]; 
        --Q[i];
    }

    REP(i,M) {
        T[B[i]] = Q[i];
        ll score = 0;
        veci last(26);
        REP(j,D) {
            int d = j+1;
            last[T[j]] = d;
            score += S[j][T[j]];
            REP(k,26) {
                score -= C[k]*(d-last[k]);
            }
        }
        cout << score << endl;
    }
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int x, a, b; cin >> x >> a >> b;
    int diff = x-a;
    int i = 1;
    while(true){
        if(diff-b*i<0) break;
        diff-=b*i;
    }
    cout << diff << endl;
    return 0;
}

Measured memory_bytes: 256
//ABC171

#include <iostream>
#include <vector>
#include <utility>
#include <climits>
#include <random>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <string>

using namespace std;

int main(){
    int n, k, sum=0;
    cin >> n >> k;
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    for(int i=0; i<k; i++){
        sum += v.at(i);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3624
def main():
    import itertools
    import sys
    input = sys.stdin.readline
    
    from collections import defaultdict
    
    N,C = map(int,input().split())
    
    D = [list(map(int,input().split())) for i in range(C)]
    c = [list(map(int,input().split())) for i in range(N)]
    
    ans = float("inf")
    zero = defaultdict(int)
    one = defaultdict(int)
    two = defaultdict(int)
    
    for i in range(N):
        for j in range(N):
            if (i+j)%3 == 0:
                zero[c[i][j]] += 1
            if (i+j)%3 == 1:
                one[c[i][j]] += 1
            if (i+j)%3 == 2:
                two[c[i][j]] += 1
    
    L = [i for i in range(1,C+1)]
    for i, j, k in itertools.permutations(L, 3):
        tmp = 0
        for l in range(1,C+1):
            tmp += D[l-1][i-1]*zero[l] + D[l-1][j-1]*one[l] + D[l-1][k-1]*two[l]
        if tmp < ans:
             ans = tmp
    print(ans)
    
main()

Measured memory_bytes: 44636
import sys
input = sys.stdin.readline


def inpl():
    return list(map(int, input().split()))


N, W = inpl()
VW = [inpl() for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(N):
    for w in range(W + 1):
        if w < VW[i][1]:
            dp[i + 1][w] = dp[i][w]
        else:
            dp[i + 1][w] = max(dp[i][w], dp[i][w - VW[i][1]] + VW[i][0])

# print(dp[N])
print(dp[N][W])



Measured memory_bytes: 25520
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n, m, x;
  cin >> n >> m >> x;
  int count = 0;
  vector<int> a(m);
  rep(i,0,m) {
    cin >> a[i];
    if(a[i] < x) count++;
  }
  if(count < m-count) cout << count << endl;
  else cout << m - count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

signed main(){
  int a,b,c;cin>>a>>b>>c;
  cout << max((ll)0, c-(a-b)) << endl;
}


Measured memory_bytes: 764
#include <iostream>
#define NMAX 105
#define VALMAX 100005
using namespace std;
int n,w,j,i;
long long a[NMAX],b[NMAX],d[VALMAX],maxim,sol;
int main()
{
    cin>>n>>w;
    for(i=1;i<=n;i++)
        cin>>a[i]>>b[i];
    for(i=1;i<=n;i++)
    {
        for(j=maxim;j>=1;j--)
        {
            if(d[j]!=0 && j+a[i]<=w)
            {
                d[j+a[i]]=max(d[j+a[i]],d[j]+b[i]);
                maxim=max(maxim,j+a[i]);
            }
        }
        d[a[i]]=max(d[a[i]],b[i]);
        maxim=max(maxim,a[i]);
    }
    for(i=1;i<=w;i++)
        sol=max(sol,d[i]);
    cout<<sol;
    return 0;
}


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

using Int = long long;

int n;
Int a[200010];
Int s[200010];

bool cond(Int x)
{
	int p0 = 0, p1 = 0, p2 = 0;
	for (int i = 0; i < n; i++){
		p2 = i + n;
		while (p0 < p2 && s[p0] - s[i] < x) p0++;
		while (p1 < p2 && s[p1] - s[p0] < x) p1++;
		if (min({s[p0] - s[i], s[p1] - s[p0], s[p2] - s[p1]}) >= x) return true;
	}
	return false;
}

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

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

	for (int i = 0; i < 2 * n; i++){
		s[i + 1] = s[i] + a[i];
	}

	Int lb = 0, ub = 1e15;
	while (ub - lb > 1){
		Int md = (lb + ub) / 2;
		(cond(md) ? lb : ub) = md;
	}

	cout << lb << endl;
}

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

using ll = long long;
using pll = pair<ll, ll>;

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

    vector<pll> b(N); // first:min, second:balance 

    for (int i = 0; i < N; i++) {
        string S; cin >> S;
        for (const auto& ch : S) {
            if (ch == '(') {
                b[i].second++;
            } else {
                b[i].second--;
                b[i].first = min(b[i].first, b[i].second);
            }
        }
    }

    sort(b.begin(), b.end(), [](const pll& a, const pll& b) {
        bool sa = signbit(a.second), sb = signbit(b.second);
        if (sa == sb) {
            if (sa == 0) { // 正
                // if (a.first == b.first) {
                //     return a.second > b.second;
                // }
                return a.first > b.first;
            } else { // 負
                // if (a.first == b.first) {
                //     return a.second > b.second;
                // }
                return a.second - a.first > b.second - b.first;
            }
        }
        return sa < sb;
    });

    bool yes = true;
    int s = 0;
    for (int i = 0; i < N; i++) {
        if (s + b[i].first < 0) {
            yes = false;
            break;
        }
        s += b[i].second;
    }
    if (s != 0) yes = false;

    cout << (yes ? "Yes" : "No") << endl;
}


Measured memory_bytes: 18740
#include<bits/stdc++.h>
 using namespace std;
 typedef long long LL;
 const int P = 1000000007;
 LL f[1000001], v[1000001];
 LL rp(LL now, int k) 
 {
     LL will = 1;
     for (; k; k >>= 1, now *= now, now %= P) 
     {
         if (k & 1) will *= now, will %= P;
     }
     return will;
 }
 LL C(int n, int m) 
 {
     if(n < m) return 0;
     if(m == 0) return 1;
     return f[n] * rp(f[m], P - 2) % P * rp(f[n - m], P - 2) % P;
 }
 void init()
 {
     f[0] = 1; v[0] = 1;
     for (int i = 1; i <= 1000000; i++) //1e6以  内的组合数
     {
         f[i] = f[i - 1] * i % P;
     }
 }
 int main() 
 {
    init();
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    LL ans = 0;
    for(int i = b + 1; i <= w; i++) {
       // printf("C(%d, %d)\n", (h - a) + (b + i) - 2, h - a - 1);
        // printf("C(%d, %d)\n", a + (w - b - i + 1), a - 1);
        LL tmp = C((h - a) + i - 2, i - 1) * C(a + (w - i + 1) - 2, w - i) % P;
        ans = (ans + tmp) % P;
    }
    cout << ans << endl;
 }

Measured memory_bytes: 9728
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<complex>
using namespace std;

int main(){
    char str[102];
    int len,f,ans=0;
    while (fgets(str,102,stdin)!=NULL) {
        len=strlen(str)-1;
        f=1;
        for (int i=0;i<len/2;++i) {
            if(str[i]!=str[len-i-1]){
                f=0;
                break;
            }
        }
        if (f) ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3060
from collections import deque

N,M=map(int,input().split())
edge=[[] for _ in range(N+1)]

for i in range(M):
  A,B=map(int,input().split())
  edge[A].append(B)
  edge[B].append(A)

  
dist=[-1]*(N+1)
d=deque([1])

while d:
  x = d.popleft()
  for i in range(len(edge[x])):
    if dist[edge[x][i]]==-1:
      dist[edge[x][i]]=x
      d.append(edge[x][i])

print("Yes")
print(*dist[2:],sep='\n')


Measured memory_bytes: 98824
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let s = s.as_bytes();
    if s[2]==s[3] && s[4]==s[5]{
        println!("Yes", );
    } else {
        println!("No", )
    }
}

Measured memory_bytes: 4352
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    private static Set<Double> makeSet(int a, int b, int f) {
        Set<Double> set = new HashSet<>();
        for (int i = 0; i <= 3000; i++) {
            for (int j = 0; j <= 3000; j++) {
                double x = a * i + b * j;
                if (x > f) {
                    break;
                }
                set.add(x);
            }
        }
        return set;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int f = sc.nextInt();

        Set<Double> setWater = makeSet(100 * a, 100 * b, f);
        Set<Double> setSuger = makeSet(c, d, f);

        double water = 0;
        double suger = 0;
        for (Double w : setWater) {
            for (Double s : setSuger) {
                if (w + s > f || w == 0) {
                    continue;
                }
                if (100 * s / w <= e
                        && (water + suger == 0 || 100 * s / (w + s) > 100 * suger / (water + suger))) {
                    water = w;
                    suger = s;
                }
            }
        }
        System.out.println((int) (water + suger) + " " + (int) suger);
    }
}

Measured memory_bytes: 27028
/**
 *    author : HikaruEgashira
 *    created: 08.29.2020 21:03:00
**/
use proconio::input;
use proconio::marker::Chars;

#[proconio::fastout]
fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let (s, t): (Vec<char>, Vec<char>) = (s, t);

    let res = s
        .windows(t.len())
        .map(|a| a.iter().enumerate().filter(|&(i, &ai)| ai != t[i]).count())
        .min()
        .unwrap_or(t.len());

    println!("{}", res);
}


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

using namespace std;

void sum80(int* a, int* b);
int get80(string str, int* num);

int main(void){
	string a80, b80;
	int a[81], b[81];
	int i, N;
	cin>>N;
	i=0;
	bool flg=true;
	while(i<N){
		flg=true;
		cin>>a80;
		cin>>b80;
		if(get80(a80, a)<0 || get80(b80, b)<0){
			cout<<"overflow"<<endl;
			i++;
			continue;
		}
		sum80(a, b);
		i++;
	}
	return 0;
}

int get80(string str, int* num){
	int d=str.length();
	if(d<=80){
		for(int i=0; i<d; i++){
			num[i]=str[d-1-i]-'0';
		}
		for(int i=d;i<81; i++){
			num[i]=0;
		}
		return d;
	}else{
		return -1;
	}

}

void sum80(int* a, int* b){
	int s[81], amari;
	amari=0;
	for(int i=0; i<81; i++){
		s[i]=(a[i]+b[i]+amari)%10;
		if(a[i]+b[i]+amari>=10){
			amari=1;
		}else{
			amari=0;
		}
	}
	if(s[80]!=0){
		cout<<"overflow"<<endl;
	}else{
		bool flag=false;
		for(int i=79; i>=0; i--){
			if(flag==true || s[i]!=0 || i==0){
				flag=true;
				cout<<s[i];
			}
		}
		cout<<endl;
	}
}

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

using namespace std;

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

    long long N, H;
    cin >> N >> H;

    long long max_a = 0, res = 0, B[N];
    for (int i = 0; i < N; ++i) {
        long long a;
        cin >> a >> B[i];
        max_a = max(max_a, a);
    }

    sort(B, B + N, greater<int>());

    for (int i = 0; i < N; ++i) {
        H -= max(max_a, B[i]);
        res++;
        if (H <= 0) {
            cout << res << endl;
            return 0;
        }
    }

    cout << res + (H % max_a == 0 ? H / max_a : H / max_a + 1) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	vector<int> a(4);
	REP(i, 4) cin >> a[i];

	vector<int> b(2);
	REP(i, 2) cin >> b[i];

	sort(ALL(a), greater<int>());
	sort(ALL(b), greater<int>());

	int sum = 0;

	REP(i, 3) sum += a[i];
	sum += b[0];

	cout << sum << endl;

}



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

long long calcGcd(long long a, long long b)
{
    // a > bにする
    if (a < b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法*/
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

long long calcLcm(long long a, long long b)
{
    return a * b / calcGcd(a, b);
}

int main()
{
    long long a, b;

    cin >> a >> b;

    cout << calcLcm(a, b) << endl;
}


Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

t_hp = A
t_ap = B
a_hp = C
a_ap = D

while True :
    # attack takahashi
    a_hp = a_hp - t_ap
    if a_hp <= 0 :
        print('Yes')
        break

    # attack aoki
    t_hp = t_hp - a_ap
    if t_hp <= 0 :
        print('No')
        break


Measured memory_bytes: 9064
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()

def prime_factorization(n):
    assert(n>1)
    factor=[]
    for d in range(2,int(n**.5)+1):
        while(n%d==0):
            n//=d
            factor.append(d)
    if n!=1: factor.append(n)
    return factor

from fractions import gcd
def resolve():
    a,b=map(int,input().split())
    g=gcd(a,b)

    if(g==1):
        print(1)
        return

    S=set(prime_factorization(g))
    print(len(S)+1)
resolve()

Measured memory_bytes: 64236
#include <stdio.h>

int main(void)
{
	int a, b;
	char op;
	
	while (1) {
		scanf("%d %c %d", &a, &op, &b);
		
		switch (op) {
			case '+':
				printf("%d\n", a + b);
				break;
			case '-':
				printf("%d\n", a - b);
				break;
			case '*':
				printf("%d\n", a * b);
				break;
			case '/':
				printf("%d\n", a / b);
				break;
			default:
				goto END;
		}
	}
	END:
	return 0;
}

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

typedef string::iterator S;

struct Node{
    char id;
    Node* prev;
    Node* next;
};

int main(){
    int n,i;
    cin>>n;
    while(n--){
        string expr;
        cin>>expr;
        Node vs[26];
        for(i=0;i<26;i++){
            vs[i].id=0;
            vs[i].prev=NULL;
            vs[i].next=NULL;
        }
        Node* vp = vs;
        Node* fr = vp+1;
        Node* head = vp;
        S s = expr.begin();
        while( true ){
            vp->id = *s;
            s++;
            if( s == expr.end() ) break;
            if( *s == '-' ){
                if( vp->next == NULL ){
                    vp->next = fr;
                    (vp->next)->prev = vp;
                    fr++;
                }
                vp = vp->next;
            }else{
                if( vp->prev == NULL ){
                    vp->prev = fr;
                    (vp->prev)->next = vp;
                    fr++;
                    head = vp->prev;
                }
                vp = vp->prev;
            }
            s += 2;
        }
        while( head ){
            cout << head->id;
            head = head->next;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
(let* ((n (read))
       (a (make-array n))
       (cnt (make-hash-table))
       (total 0))
  (dotimes (i n)
    (let ((ai (read)))
      (setf (aref a i) ai
            (gethash ai cnt) (1+ (gethash ai cnt 0)))))
  (maphash
    (lambda (key val)
      (if (< key val)
          (incf total (- val key))
          (when (> key val) (incf total val))))
    cnt)
  (format t "~A~%" total))

Measured memory_bytes: 63840
#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,a,n) for(int i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
int main()
{
    fio;
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        ll a[n];
        rep(i,n)
        cin>>a[i];
        ll l=1,r=(ll)1e9,mid=0;
        ll res=INT_MAX;
        while(l<=r)
        {
            mid=l+(r-l)/2;
            int trials=0;
            rep(i,n)
            {
                if(a[i]>mid){
                trials+=((a[i]+mid-1)/mid)-1;
                }
            }
            if(trials>k)
            l=mid+1;
            else
            {
                r=mid-1;
                res=min(res,mid);
            }
        }
        cout<<res<<endl;
    }
}

Measured memory_bytes: 5144
n = int(input())

v = [int(i) for i in input().split(" ")]
c = [int(i) for i in input().split(" ")]

vc = []
for i in range(n):
  vc.append(v[i] - c[i])
vc.sort(reverse = True)

count = 0
for i in vc:
  if i <= 0 :
    break
  else:
    count += i
print(count)


Measured memory_bytes: 3060
n=int(input())
l=list(map(int,input().split()))
total=1000
z=[]
t=float("infinity")
for i in range(n):
	if len(z)==0:
		z.append(l[i])
	else:
		if z[-1]<l[i]:
			z.append(l[i])
		elif z[-1]>l[i]:
			if len(z)>1:
				f=total//z[0]
				total=total%z[0]
				total+=f*z[-1]
			z=[l[i]]
if len(z)>1:
	f=total//z[0]
	total=total%z[0]
	total+=f*z[-1]
print(total)

Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	vector<int> a(3);
	cin >> n;
	int dp[3][n];
	int ans = 0;
	for (int i{}; i < 3; i++) {
		cin >> a[i];
		dp[i][0] = a[i];
		ans = max(ans, a[i]);
	}
	if (n == 1) {
		cout << ans << endl;
		return 0;
	}
//	n--;
	for (int i{1}; i < n; i++) {
		for (auto &x : a) {
			cin >> x;
		}
		dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a[0];
		dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + a[1];
		dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + a[2];
	}
	cout << max(max(dp[0][n - 1], dp[1][n - 1]), max(dp[0][n - 1], dp[2][n - 1]));
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    long long n,a[200005];
    cin>>n;
    long long ans=0,sum[200005]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=n-1;i>=0;i--){
        if(i!=n-1){
            sum[i]=sum[i+1]+a[i];
        }
        else{
            sum[i]=a[i];
        }
        sum[i]%=(1000000000+7);
    }
    for(int i=0;i<n-1;i++){
        ans+=a[i]*sum[i+1]%(1000000000+7);
    }
    cout<<ans%(1000000000+7)<<endl;
  return(0);
}

Measured memory_bytes: 6772
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>


using namespace std;


using namespace std;

int main() {
    int A,B;
    cin>> A>>B;

    if(A>=13){

        cout<<B<<endl;
    }
    if (6<=A && A<=12){

        cout<<B/2<<endl;
    }
    if (5>=A){

        cout<<0<<endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
const long INF = 1e9;
const long MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < int(n); i++)

int check(stack<char> &Q)
{
    int water = 0, len = Q.size(), depth = 0;
    // cout << "check:";
    repi(i, len, 0)
    {
        // cout << Q.top() << " ";
        if (Q.top() == '\\')
        {
            water += 1 + --depth * 2;
        }
        else if (Q.top() == '/')
        {
            water += 1 + depth++ * 2;
        }
        else
        {
            water += 2 * depth;
        }
        Q.pop();
    }
    // cout << endl;
    return water / 2;
}

int main()
{
    string s;
    vector<int> ponds(0);
    stack<char> pond;
    cin >> s;
    int len = s.length();
    while (s.length())
    {
        //a:=\,b:=/,c:=_
        int a = 0, b = 0, cnt = 1;
        if (s[0] == '\\')
        {
            int j = 1;
            a++;
            while (s.length())
            {
                if (s[j] == '\\')
                {
                    a++;
                }
                else if (s[j] == '/')
                {
                    b++;
                }
                if (a == b)
                {
                    repi(k, j + 1, 0)
                    {
                        pond.push(s[0]);
                        s.erase(0, 1);
                    }
                    ponds.push_back(check(pond));
                    // cout << "s:" << s << endl;

                    break;
                }
                else if (j >= s.length())
                {
                    s.erase(0, 1);
                    // cout << "s(big):" << s << endl;
                    break;
                }
                else
                {
                    j++;
                }
            }
        }
        else
        {
            s.erase(0, 1);
            // cout << "s(else):" << s << endl;
        }
    }
    int sum = 0;
    repi(i, ponds.size(), 0)
    {
        sum += ponds[i];
    }
    cout << sum << endl
         << ponds.size();
    for (auto w : ponds)
    {
        cout << " " << w;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3280
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
map<string, ll>a;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}
string num[10] = { "pon","pon","hon","bon","hon","hon","pon","hon","pon","hon" };

int main() {
	double A, B, H, M;
	cin >> A >> B >> H >> M;
	double tmp1, tmp2;
	tmp1 = 360 * M / 60;
	tmp2 = 360 * (60*H+M)/(60*12);
	
	double tmp = A * A + B * B - 2 * A * B * cos(2*((tmp1 - tmp2)/360)*PI);
		double ans;
		
		ans = pow(tmp, 0.5);
		cout <<fixed<<setprecision(12)<<ans;
}



Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        int n = in.nextInt();
        long lcm = in.nextLong();
        while (n-- > 1) {
            long a = in.nextLong();
            long gcd = gcd(lcm, a);
            lcm = lcm / gcd * a;
        }
        System.out.println(lcm);
    }

    private static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }
}

Measured memory_bytes: 26308
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

int manhattan(pair<int, int> x, pair<int, int> y) {
    return abs(x.first - y.first) + abs(x.second - y.second);
}

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

    int h, w, d;
    cin >> h >> w >> d;

    map<int, pair<int, int>> valpos;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int aij;
            cin >> aij;
            valpos[aij] = {i, j};
        }
    }

    // costs[i]: 駒を問題の手順でi%d から iまで瞬間移動させるのに必要な魔力
    vector<int> costs(h * w + 1);

    for (int i = 1; i <= d; i++) {
        int x = i;
        costs[x] = 0;
        while (x + d <= h * w) {
            pair<int, int> pos = valpos[x], nextpos = valpos[x + d];
            const int cost = manhattan(pos, nextpos);

            costs[x + d] = costs[x] + cost;
            x += d;
        }
    }

    int q;
    cin >> q;
    for (int qi = 0; qi < q; qi++) {
        int l, r;
        cin >> l >> r;

        const int cost = costs[r] - costs[l];

        cout << cost << endl;
    }
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
const ll mod = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll s,w; cin >> s >> w;
    w >= s ? cout << "unsafe" << endl : cout << "safe" << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int m,d;
int main()
{
	scanf("%d%d",&m,&d);
	int x,y;
	int ans=0;
	for(int i=1;i<=m;++i)
		for(int j=1;j<=d;++j)
		{
			x=j/10;y=j%10;
			if(x>=2&&y>=2&&x*y==i)ans++;
		}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String ns = sc.next();
    String[] s = ns.split("");
    s[3] = "8";
    String answer = "";
    for (int i = 0; i < s.length; i++) {
      answer += s[i];
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 39296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RREP(i,n) for (ll i=n-1;i>=0;i--)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (ll)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
    IOS();
    int n;
    cin >> n;
    if (n&1) cout << n/2 << endl;
    else cout << n/2-1 << endl;
}


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

using namespace std;

typedef long long ll;

ll digit_sum(ll b, ll n) {
    if (n < b) return n;
    return digit_sum(b, n / b) + n % b;
}

vector<ll> divisors(ll n) {
    vector<ll> ret;
    for (ll i = 1LL; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.emplace_back(i + 1);
            if (n / i != i) ret.emplace_back(n / i + 1);
        }
    }
    sort(ret.begin(), ret.end());

    return ret;
}

int main() {
    ll n, s;
    cin >> n >> s;
    if (n < s) {
        cout << -1 << endl;
        return 0;
    } else if (n == s) {
        cout << n + 1 << endl;
        return 0;
    }

    vector<ll> list = divisors(n - s);
    for (ll b:list) {
        if (digit_sum(b, n) == s) {
            cout << b << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(non_snake_case)]
fn main() {
    input!{
        S: String,
    };
    let mut m = 0;
    let mut win = 0;
    for i in S.chars().into_iter() {
        m += 1;
        if i == 'o' {win += 1;}
    }
    println!("{}", if 15 + win - m >= 8 {"YES"} else {"NO"});
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
using namespace std;
  
int main(){
  int n;
  ll a, b, x, cur, sum = 0;
  cin >> n >> a >> b;
  cin >> cur;
  for(int i = 1; i < n; i++){
    cin >> x;
    sum += ((x - cur) * a < b ? (x - cur) * a : b);
    cur = x;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256