akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

int main()
{
    ll n;
    cin >> n;
    vll a(n);
    rep(i,n)cin >> a[i];
    sort(all(a));
    //rep(i,n)cout << a[i] << endl;

    ll tmp1=0,tmp2=0,cnt=0;

    repr(i,n){
        if(i > 0 && a[i] == a[i-1]){
            tmp1 = a[i];
            break;
        }
    }

    rep(i,n)if(a[i] == tmp1)cnt++;
    if(cnt >= 4){
        cout << tmp1*tmp1 << endl;
        return 0;
    }

    repr(i,n){
        if(i > 0 && a[i] != tmp1 && a[i] == a[i-1]){
            tmp2 = a[i];
            break;
        }
    }
    //cout << tmp1 << " " << tmp2 << endl;

    cout << (ll)tmp1*tmp2 << endl;
    return 0;
}

Measured memory_bytes: 1024
/*package????????????*/
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
  public static void main(String[] args) {
    try {
      BufferedReader stdReader =
        new BufferedReader(new InputStreamReader(System.in));
      String line;
      while ((line = stdReader.readLine()) != null) { 
    	  int x = Integer.parseInt(line);
        System.out.println(x*x*x);
      }
      stdReader.close();
    } catch (Exception e) {
      e.getStackTrace();
      /*?????´??????0??????*/
      System.exit(0); 
    }
  }
}

Measured memory_bytes: 24392
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class345
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var A = new int[10, 10];
            long ans = 0;
            for(int i = 1; i <= N; i++)
            {
                int l = i.ToString()[0] - '0';
                int r = i % 10;
                A[l, r] += 1;
            }
            for(int i = 1; i < 10; i++)
            {
                for(int j = i; j < 10; j++)
                {
                    ans += A[i, j] * A[j, i];
                    if (i != j)
                        ans += A[j, i] * A[i, j];
                }
            }
            Console.WriteLine(ans);
        }
    }
    
}


Measured memory_bytes: 15312
#include<bits/stdc++.h>
//#include <iostream>
//#include <iomanip>
//#include <vector>
//#include <cmath>
//#include <algorithm>
using namespace std;


#define F first
#define PB push_back
#define MP make_pair

typedef  long long ll;

ll p = pow(10, 9) + 7;





int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int pl = 0;
    while(a > 0 && c > 0){
        if(pl % 2 == 0){
            c -= b;
        }else{
            a -= d;
        }
        pl++;
    }
    if(a > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int n;cin>>n;
    int ac=0,wa=0,tle=0,re=0;
    vector<string>s(n);
    rep(i,n)cin>>s.at(i);
    rep(i,n){
        if(s.at(i)=="AC"){
            ac++;
        }else if (s.at(i)=="WA"){
            wa++;
        }else if(s.at(i)=="TLE"){
            tle++;
        }else if(s.at(i)=="RE"){
            re++;
        }
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
    
}


Measured memory_bytes: 6388
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;

int main(){
	int a,d,n,i,j,p[1000000];
	for(i=2;i<1000000;i++){
		p[i]=0;
	}
	p[0]=1;p[1]=1;
	for(i=2;i<1000;i++){
		if(p[i]==0){
			for(j=2;j<(1000000/i);j++){
				p[i*j]=1;
			}
		}
	}
	while(1){
		int c=0;
		cin>>a>>d>>n;
		if(a+d+n==0)break;
		i=0;
		while(1){
			if(p[a+i*d]==0){
				c++;
			}
			if(c==n)break;
			i++;
		}
		cout<<a+i*d<<endl;
	}
    return 0;
}

Measured memory_bytes: 5064
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int32_t main() {
  uint32_t n;
  cin >> n;

  vector<char> arr;
  for (uint32_t i = 0; i < n; i++) {
    char c;
    cin >> c;
    arr.push_back(c);
  }

  vector<int32_t> nums;
  for (uint32_t i = 0; i < arr.size(); i++) {
    for (uint32_t j = i + 1; j <= arr.size() && j <= i + 4; j++) {
      string num = "";
      for (uint32_t k = i; k < j; k++) {
        string s{arr[k]};
        num += s;
      }
      nums.push_back(stoi(num));
    }
  }

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

  uint32_t index = 0;
  for (int32_t i = 0; i < 10000; i++) {
    bool found = false;
    while (nums[index] == i) {
      index++;
      found = true;
    }

    if (!found) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3204
#include<cstdio> 
main()
{ 
int A,B,C;
 scanf("%d %d %d",&A,&B,&C);
if(A==5 && B==5 && C==7)
 printf("YES");
else  if(A==5 && B==7 && C==5)
 printf("YES");
else if(A==7 && B==5 && C==5)
  printf("YES");
else printf("NO");
 return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
//#define %d %lld
//#define int long long
typedef long long ll;
#define sqr(x) ((x)*(x))
#define pb push_back 
const int N=2002,M=1e9+7;
void Max(int &x,int y){if(y>x)x=y;}void Min(int &x,int y){if(y<x)x=y;}
void inc(int &x,int y){x+=y;if(x>=M)x-=M;}void dec(int &x,int y){x-=y;if(x<0)x+=M;}
int pw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%M)if(y&1)z=1ll*z*x%M;return z;}
void read(int *a,int n){for (int i=1;i<=n;i++) scanf("%d",&a[i]);}
//struct node{int to,ne}e[];
//void add(int x,int y){e[++tot]=(node){y,h[x]},h[x]=tot;}
int n,m,i,j,f[N][N],a[N],b[N];
signed main(){
	scanf("%d%d",&n,&m);
	read(a,n),read(b,m);
	for (i=0;i<=n;i++) f[i][0]=1;
	for (i=0;i<=m;i++) f[0][i]=1;
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++) inc(f[i][j],(1ll*f[i-1][j]+f[i][j-1]-(a[i]!=b[j])*f[i-1][j-1]+M)%M);
	printf("%d",f[n][m]);
}

Measured memory_bytes: 15872
#include"bits/stdc++.h"
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> a(N);
    int count_a=0;
    int count_b=0;
    int max=0;

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

    for(int i=0;i<N;i++){
        if(i%2==0){
            for(int j=0;j<N;j++){
                if(a[j]>max){
                    max=a[j];
                }
            }
            for(int j=0;j<N;j++){
                if(a[j]==max){
                    a[j]=0;
                    break;
                }
            }         
            count_a+=max;
            max=0;
        }
        if(i%2==1){
            for(int j=0;j<N;j++){
                if(a[j]>max){
                    max=a[j];
                }
            }
            for(int j=0;j<N;j++){
                if(a[j]==max){
                    a[j]=0;
                    break;
                }
            }   
            count_b+=max;
            max=0;
        }
    }
    int c=count_a-count_b;
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String line2 = sc.nextLine();

		int count = 0;

		for (int i = 0; i < line.length(); i++) {
			StringBuilder r = new StringBuilder();
			r.append(line.substring(line.length() - 1, line.length()));
			r.append(line.substring(0, line.length() - 1));
			line = r.toString();
			if (line.contains(line2)) {
				System.out.println("Yes");
				count++;
				break;
			}
		}
		if (count == 0) {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 26332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define int ll
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 5e5 + 10;
const ll LINF = LLONG_MAX;
int a,b,c,d,ans;
str s1,s2,s;
int32_t main() {
    fast();
    int a,b;
    cin >> a >> b;
    int a1=__gcd(a,b);
    int lc=a*b/a1;
    cout<<lc;
    return 0;
}
 

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

int main(){
  int array[32] = {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 n;
  cin >> n;
  cout << array[n - 1] << endl;

  return 0;
}


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

void bubblesort(char Cp1[],char Cp2[], int N);
void selectionsort(char Cp1[],char Cp2[], int N);
bool isStable(char Cp1[],char Cp2[], int N);

int main()
{
	int N;
	cin >> N;
	char *Cp1 = new char[N];
	char *Cp2 = new char[N];
	char *Cp3 = new char[N];
	char *Cp4 = new char[N];

	for(int i=0;i<N;i++){
		cin >> Cp1[i] >> Cp2[i];
		Cp3[i] = Cp1[i];
		Cp4[i] = Cp2[i];
	}
	
	bubblesort(Cp1,Cp2,N);
	selectionsort(Cp3,Cp4,N);

	for(int i=0;i<N;i++){
		if(0<i) cout << ' ';
		cout << Cp1[i] << Cp2[i];
	}
	cout << endl;
	cout << "Stable\n";


	for(int i=0;i<N;i++){
		if(0<i) cout << ' ';
		cout << Cp3[i] << Cp4[i];
	}
	cout << endl;

	if(isStable(Cp1,Cp3,N)){
		cout << "Stable\n";
	}else{
		cout << "Not stable\n";
	}

	delete []Cp1;
	delete []Cp2;

	return 0;

}

void bubblesort(char Cp1[], char Cp2[],int N)
{
	for(int i=0;i<N-1;i++){
		for(int j=N-1;j>=i+1;j--){
			if(Cp2[j] < Cp2[j-1]){
				swap(Cp1[j],Cp1[j-1]);
				swap(Cp2[j],Cp2[j-1]);
			}	
		}
	}	
}

void selectionsort(char Cp1[], char Cp2[], int N)
{
	int minv;
	for(int i=0;i<N-1;i++){
		minv = i;
		for(int j=i;j<N;j++){
			if(Cp2[j] < Cp2[minv]) minv = j;
		}
		swap(Cp1[i],Cp1[minv]);
		swap(Cp2[i],Cp2[minv]);
	}
}

bool isStable(char Cp1[], char Cp2[], int N)
{
	for(int i=0;i<N;i++){
		if(Cp1[i] != Cp2[i]) return false;
	}
	return true;
}

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

using namespace std;

int main(){
	int n;

	scanf("%d", &n);

	for(int i = 0 ; i < n ; i++){
		int ai;

		scanf("%d", &ai);

		if(ai % 2 == 0){
			if(!(ai % 3 == 0 || ai % 5 == 0)){
				printf("DENIED\n");
				return 0;
			}
		}
	}

	printf("APPROVED\n");

	return 0;
}

Measured memory_bytes: 256
line = gets.chomp.split(" ").map{|n| n.to_i}
a=line[0]
b=line[1]
c=line[2]
d=line[3]

if ((a-c).abs <= d) || ((a-b).abs<=d && (b-c).abs<=d)
  puts 'Yes'
else
  puts 'No'
end



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

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(a-b >= 0){
    cout << "delicious" << endl;
  }else if(x+a-b >= 0){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl; 
  }
  
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }
    vvl dp(h, vl(w, 0));
    dp[0][0] = 1;
    for (int i = 1; i < h; ++i) {
        if (s[i][0] == '.')
            dp[i][0] = 1;
        else
            break;
    }
    for (int i = 1; i < w; ++i) {
        if (s[0][i] == '.')
            dp[0][i] = 1;
        else
            break;
    }

    for (int i = 1; i < h; ++i) {
        for (int j = 1; j < w; ++j) {
            if (s[i][j] == '.') {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
    return 0;
}

Measured memory_bytes: 9216
import numpy as np

H, W = map(int, input().split())
a = np.zeros(shape=(H, W), dtype=bool)
for i in range(H):
  a[i] = [s == "." for s in input()]

y = [True] * H
for i in range(H):
  if all(a[i,:]):
    y[i] = False

x = [True] * W
for i in range(W):
  if all(a[:,i]):
    x[i] = False

ans = []
for i in range(H):
  if not y[i]:
    continue
  s = ""
  for j in range(W):
    if not x[j]:
      continue
    s = "".join([s, "." if a[i,j] else "#"])
  ans.append(s)

print(*ans, sep="\n")


Measured memory_bytes: 12512
#include<iostream>
using namespace std;
int main(){
int a[10];
for(int i=0;i<10;i++)
cin>>a[i];
for(int i=0;i<10;i++)
		for(int j=i+1;j<10;j++)
			if(a[i]<a[j]){
				int temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
	for(int i=0;i<3;i++)
		cout<<a[i]<<endl;
	return 0;
}

Measured memory_bytes: 1160
//You can die anytime, but living takes true courage.
//Every journey begins with a single step. We just have to have patience.
//Life is not a game of luck. If you wanna win, work hard.
//It’s more important to master the cards you’re holding 
//than to complain about the ones your opponent was dealt.
//If you just submit yourself to fate, then that’s the end of it.




/*

struct P {
int x, y;
bool operator<(const P &p) {
if (x != p.x) return x < p.x;
else return y < p.y;
}
};


bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}

*/





/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  Akshay Vashishtha 

//It’s just pathetic to give up on something before you even give it a shot.
//Knowing you’re different is only the beginning. If you accept these differences 
you’ll be able to get past them and grow even closer.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/   
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#define lld long long int 
#define vll vector<long long int>
#define vs vector<string> 
#define vint vector<int> 
#define vp vector<pair<int,int>>
//#define tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
#define forl(i,a,b) for(int i = a ; i <= b ; i++)
#define forln(i,a,b) for(int i = a; i < b ; i++)
lld mod = 1e9 + 7;
#define ps push_back
#define mk make_pair
#define F first 
#define S second 
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL)
#define sv()                  int t; scanf("%d",&t); while(t--)
using namespace std;


//I too will obtain everything that I desire. Not because someone asked me to do it, 
//but because I know in my heart that I have something worth fighting for. 
//Whatever you do, enjoy it to the fullest. That is the secret of life.

int main()
{
	lld res = 0ll , k ;
  cin>>k;
  forl(i,1,k){
    forl(j,1,k){
      forl(l,1,k){
        res += __gcd(i,__gcd(j,l));
      }
    }
  }
  cout<<res<<endl;
	return 0;
}




Measured memory_bytes: 3636
N = int(input())
X = list(map(int, input().split()))

s = sum(X)
s2 = sum(x*x for x in X)

ans = 10**15
X.sort()

for p in range(X[0], X[-1]+1):
    r = s2 - 2 * p * s + N * p * p
    ans = min(ans, r)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=8001 ;
int main()
{
   fast ;
   ll a,b,c,k ; cin>>a>>b>>c>>k ;

   ll ans=0 ;
   ans=min(a,k) ;
   k-=min(a,k) ;
   k-=min(b,k) ;
   ans-=min(k,c) ;
   cout<<ans ;

}




Measured memory_bytes: 3608
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author houghstc
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <cstring>
#include <climits>
#include <numeric>

using namespace std;
using pii = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;

const int MOD = 1e9+7;

const int maxn=1e6+23;
int a[maxn], vis[maxn];

class ECoprime {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        for(int i = 0; i < n; ++i) {
            in >> a[i];
            vis[a[i]]++;
        }
        int g = a[0];
        for(int i = 1; i < n; ++i)
        {
            g = gcd(a[i], g);
        }
        if(g > 1) {
            out << "not coprime" << endl;
            return;
        }

        bool flag = false;
        for(int i = 2; i < maxn; ++i)
        {
            int cnt = 0;
            for(int j = 0; j < maxn; j+=i) {
                cnt += vis[j];
//                if(vis[j] == 1)
//                    cout << "i: " << i << ", j: " << j << endl;
            }
            if(cnt > 1) {
                flag = true;
                //cout << "i: " << i << ", cnt: " << cnt << endl;
                goto done;
            }
        }
        done:
            out << (flag ? "setwise coprime" : "pairwise coprime") << endl;
    }
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ECoprime solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 11368
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let nums = get_line().split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect::<Vec<usize>>();
    let (n, m) = (nums[0], nums[1]);

    let mut switches: Vec<Vec<u64>> = Vec::new();

    for _ in 0..m {
        let nums = get_line().split_whitespace()
            .map(|n| n.parse().unwrap())
            .collect::<Vec<u64>>();
        switches.push(nums[1..].to_vec());
    }

    let flags = get_line().split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect::<Vec<u64>>();

    let mut count = 0;

    for bit in 0..(1 << n) {
        let mut result = true;
        for i in 0..m {
            let hoge = &switches[i];
            let ret = hoge.iter().map(|&x| bit & (1 << (x - 1)) != 0)
                .fold(0, |sum, x| sum + if x { 1 } else { 0 });

            if ret % 2 != flags[i] {
                result = false;
                break;
            }
        }
        if result { count += 1; }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
    string S;
    cin >> S;
    int len = S.size();

    ll sum = 0;
    for(int i = 0; i < 1<<len-1; i++){
        int digit = 1;
        for(int j = 0; j < len; j++){
            int num = S[len - j - 1] - '0';
            if(i&1<<(j-1)) digit = 1;

            sum += (ll)num * digit;
            digit *= 10;
        }
    }

    cout << sum << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,i,nm,h,l;
  char ch;
  l = 4,h = 13 ;
  int month[4][13] = {{0}};
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf(" %c %d",&ch,&nm);
    if('S' == ch){
      month[0][nm-1]=1;
    }else if('H' == ch){
      month[1][nm-1]=1;
	}else if('C' == ch){
      month[2][nm-1]=1;
    }else if('D' == ch){
      month[3][nm-1]=1;
    }
  }
  for(l=0;l<4;l++){
    for(h=0;h<13;h++){
      if(month[l][h] != 1){
	if(l==0){
	  printf("S %d\n",h+1);
	}else if(l==1){
	  printf("H %d\n",h+1);
	}else if(l==2){
	  printf("C %d\n",h+1);
	}else if(l==3){
	  printf("D %d\n",h+1);
	}
      }
    }
  }
      return 0;
  }



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

B = [0.0]*N
sum = 0.0

for i in range(N):
    B[i] = 1/A[i]
    
B.sort()

for i in range(N):
    sum = sum + B[i]
    
print(1/sum)
    

Measured memory_bytes: 3060
N,H,W = list(map(int,input().split()))
lis = []
ans = 0
for i in range(N):
    lis.append(list(map(int,input().split())))
for i in range(N):
    if((lis[i][0]>=H)and(lis[i][1]>=W)):
        ans =ans+1
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
const ll INF=1e11;
int par[100000]; //親
ll diff_weight[100000];
int height[100000];  //木の深さ

void init (int n){
    for (int i=0;i<n;i++){
        par[i]=i;
        height[i]=0;
        diff_weight[i]=0;
    }
}
int find (int x){
    if (par[x]==x){
        return x;
    }
    else{
        int f=find(par[x]);
        diff_weight[x]+=diff_weight[par[x]];
        return par[x] = f;
    }
}
ll weight(int x){
    find(x);
    return diff_weight[x];
}
bool unite (int x, int y,ll w){
    w+=weight(x);
    w-=weight(y);
    x=find(x);
    y=find(y);
    if (x==y) return false;
    if (height[x] < height[y]){
        swap(x,y);
        w=-w;
    }
    if (height[x]==height[y]) {
        height[x]++;
    }
        par[y]=x;
        diff_weight[y]=w;
        return true;
}

bool same (int x, int y){
    return find(x) == find(y);
}
ll diff(int x, int y){
    return weight(y)-weight(x);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,M;
    cin>>N>>M;
    if (M==0) cout <<"Yes"<<"\n";
    else {
        init (N);
        rep(i,0,M){
            int l,r,d;
            cin>>l>>r>>d;
            l--; r--;
            if (same(l,r)){
                if (diff(l,r)!=d){
                    cout << "No" <<"\n";
                    return 0;
                }
            }
            else {
                unite(l,r,d);
            }
        }
        cout <<"Yes"<<"\n";
    }
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#define ll long long
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    
    ll a[100005],i;
    ll b[100005];
    for(i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
        if(a[i]>=1e5)
            a[-2]=0;
    }
        
    for(i=0;i<100005;i++)
        b[i]=0;
    
    if(a[0]!=0)
            printf("0\n");
    else
    {
        ll ans=1;
        for(i=0;i<n;i++)
            b[a[i]]++;
        for(i=1;i<n;i++)
        {
            ans*=b[a[i]-1];
            ans%=998244353;
        }

        printf("%lld\n",ans);
    }
    return 0;
}


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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par,sz,vis,dis;
vector<vi> graph;
vector<vector<pair<li,li>>> wgraph;

void init(li n)
{
    par.resize(n);
    sz.resize(n);
    wgraph.resize(n);
    dis.resize(n);
    vis.resize(n);
    graph.resize(n);

    f(i,0,n-1)
    {
        par[i]=i;
        sz[i]=1;
        dis[i]=1e18;
    }
}

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    li r_a=root(a);
    li r_b=root(b);

    if(par[r_a]!=r_b)
    { 
        if(sz[r_a]<sz[r_b])
        {
            par[r_a]=par[r_b];
            sz[r_b]+=sz[r_a];
            sz[r_a]=0;
        }
        else
        {
            par[r_b]=par[r_a];
            sz[r_a]+=sz[r_b];
            sz[r_b]=0;
        }
    }
}

int main()
{   

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

    string s;

    cin>>s;

    li n=s.length();

    while(n--)
        cout<<"x";

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
char a[2][3];
using namespace std;
int main(){
  int go=0;
  for (int i=0;i<2;i++)
    cin>>a[i];
  for (int j=0;j<3;j++)
    if (a[0][j] != a[1][2-j])
      go++;
  if (go == 0)
  puts("YES");
  else
  puts("NO");
  system ("pause");
  return 0;
  }

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

typedef long long ll;
using namespace std;

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

    ll a, b;
    if (A - K <= 0) a = 0;
    else a = A - K;
    if (a==0) {
        if (B - (K - A) <= 0) b = 0;
        else b = B - (K - A);
    } else {
        b = B;
    }

    cout << a << " " << b;
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n, x, m, vmin = 1e9;
  cin >> n >> x;
  int sum = 0;
  for(int i = 0; i < n; ++i)
  {
    cin >> m;
    sum += m;
    vmin = min(vmin, m);
  }
  cout << n + (x - sum) / vmin;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3652
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t) {
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push_back


#define MOD 1000000009LL
#define EPS 1e-8


int main(){

    string o,e;
    //,ans;
    vector<char> ans;
    cin>>o;
    cin>>e;
  //  cout<<o<<" "<<e;
  int n=o.size()+e.size(),a=0,b=0;

//cout<<n<<endl;
  for(int i=0;i<n;i++){
        if((i+1)%2==0){//機数
            ans.push_back(e[a]);a++;
        }else{
            ans.push_back(o[b]);b++;
        }
  }

for(int j=0;j<ans.size();j++){
    cout<<ans[j];
}
cout<<endl;
  //cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int r,g,b;
    cin>>r>>g>>b;
    int rgb;
    rgb=(r*100)+(g*10)+b;
    if(rgb%4==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int N;
lint A[410];
lint dp[410][410];
lint memo[410][410];

lint rec(int l,int r)
{
	if(memo[l][r]!=-1)
		return memo[l][r];

	if(l==r)
	{
		memo[l][r]=0;
		return memo[l][r];
	}

	lint ret=1e18;
	for(int i=l;i<r;i++)
	{
		if(dp[l][r]==dp[l][i]+dp[i+1][r])
		{
			ret=min(ret,rec(l,i)+rec(i+1,r));
		}
	}
	
	memo[l][r]=dp[l][r]+ret;
	return memo[l][r];
}

int main()
{
	for(int i=0;i<410;i++)
		for(int j=0;j<410;j++)
			dp[i][j]=1e18;

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

	for(int i=0;i<N;i++)
		dp[i][i]=A[i];
	for(int k=2;k<=N;k++)
	{
		for(int l=0,r=l+k-1;l<=N-k;l++,r++)
		{
			for(int i=l;i<r;i++)
			{
				dp[l][r]=min(dp[l][r],dp[l][i]+dp[i+1][r]);
			}
		}
	}
	
	for(int i=0;i<410;i++)
		for(int j=0;j<410;j++)
			memo[i][j]=-1;
	
	cout << rec(0,N-1) << endl;
	return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int h, w, sum[500][500];
  char mas[500][500];

  while(cin >> h >> w, h){
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        cin >> mas[i][j];
      }
    }
    for(int i = 0; i < h; i++){
      int cnt = 0;
      for(int j = w - 1; j >= 0; j--){
        if(mas[i][j] == '.'){
          sum[i][j] = cnt +++ 1;
        }else{
          sum[i][j] = cnt = 0;
        }
      }
    }
    int ret = 0;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){ //とりあえず起点を決める
        int minw = w - j;
        for(int k = i; k < h; k++){
          minw = min( minw, sum[k][j]);
          ret = max( ret, minw * (k - i + 1));
        }
      }
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 2376
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
q = gets.to_i
b = Array.new(q).map{Array.new}
q.times do |i|
  b[i] = gets.chomp.split(" ").map(&:to_i)
end
sum = a.inject(:+)
hash = Hash.new(0)
a.each do |x|
  hash[x] += 1
end
q.times do |i|
  hash[b[i][1]] += hash[b[i][0]]
  sum += hash[b[i][0]] * (b[i][1] - b[i][0])
  hash[b[i][0]] = 0
  puts sum
end

Measured memory_bytes: 29676
#include <iostream>

using namespace std;

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K <= A) {
    cout << K << endl;
  } else if (K <= B) {
    cout << A << endl;
  } else {
    cout << A - (K - A - B) << endl;
  }
}

Measured memory_bytes: 3612
a,b = map(int,input().split())
S = [list(map(int,input().split())) for i in range(a)]
CP = [list(map(int,input().split())) for i in range(b)]
for s in S:
  count = 0
  ab = 10**9
  p = 10**9
  for i,cp in zip(range(b),CP):
    total = abs(s[0]-cp[0]) + abs(s[1]-cp[1])
    count +=1
    if ab > total:
      ab = total
      p = i+1
      
  print(p)

Measured memory_bytes: 3064
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
5
1 2 1 1 3
---+/
/+---test
4
1 3 2 1
---+/
/+---test
5
1 2 3 4 5
---+/
/+---test
1
1000000000
---+/

void main(string[] args) {
  readln;
  auto H = readln.split.map!(to!long).array;

  long prev = H[0];
  foreach (ref height; H[1..$]) {
    if (prev < height) --height;

    if (prev > height) {
      "No".writeln;
      return;
    }
    prev = height;
  }
  "Yes".writeln;
}


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

using namespace std;

using ll = long long;

int main(){
    string s; cin >> s;
    if(s[0] == s[1] && s[1] == s[2])cout << s;
    else if(s[0] >= s[1] && s[0] >= s[2]) cout << s[0] << s[0] << s[0];
    else cout << char(s[0] + 1) << char(s[0] + 1) << char(s[0] + 1);
    return 0;
}


Measured memory_bytes: 256
N,K =(int(i) for i in input().split())
x = list((int(i) for i in input().split()))
i = 0
t_min = float("inf")
while i+K-1 <= N-1 :
  left = abs(x[i])+abs(x[i+K-1]-x[i])
  right = abs(x[i+K-1])+abs(x[i+K-1]-x[i])
  if min(left,right)<t_min:
    t_min = min(left,right)
  i += 1
print(t_min)

Measured memory_bytes: 20380
// luogu-judger-enable-o2
#include <cstdlib>
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cmath>
#define ll long long
const ll INF=0x3f3f3f3f;
#define mod 1000000007
#define mem(a,b) memset(a,b,sizeof(a))
#define  INF 0x3f3f3f3f
//__builtin_popcount
using namespace std;
//priority_queue
const ll MAX=100000;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}

ll F[100003];
ll Find(ll a)
{
    return F[a]<0?a:F[a]=Find(F[a]);
}
ll same(ll a,ll b)
{
    if(Find(a)==Find(b))return 1;
    return 0;
}
void up(ll a,ll b)
{
    ll x,y;
    x=Find(a);
    y=Find(b);//cout<<F[x]<<" "<<F[y]<<endl;
    if(x!=y)
        F[y]+=F[x],F[x]=y;


}
int main()
{
  ll a;
  cin>>a;
  cout<<3*a*a;
}



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

int main() {
  int N;
  cin >> N;
  
  long long ans=0;
  for (int i=1; i<N+1; i++) {
    if ( i%3==0 || i%5==0 ) {
      continue;
    }
    else {
      ans+=i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;string s;
    cin >> n >> s;
    int ans=0;
    char ret=s[0];
    rep(i,n-1){
        if(ret==s[i+1]) continue;
        ret = s[i+1];
        ans++;
    }
    cout << ans+1 << endl;
}
//ABC143C

Measured memory_bytes: 512
N=int(input())
G=[[] for i in range(N)]
for i in range(N-1):
    a,b,c=map(int,input().split())
    a,b=a-1,b-1
    G[a].append([b,c])
    G[b].append([a,c])
Q,K=map(int,input().split())
K-=1
INF=float("inf")
D=[INF for i in range(N)]
D[K]=0
stack=[(K,g[0],g[1]) for g in G[K]]
while(stack):
    a,b,c=stack.pop()
    if D[b]!=INF:
        continue
    D[b]=D[a]+c
    stack.extend([(b,g[0],g[1]) for g in G[b]])
for i in range(Q):
    x,y=map(int,input().split())
    x,y=x-1,y-1
    print(D[x]+D[y])


Measured memory_bytes: 106400
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() {
	getInt()
	S := getString()
	
	cnt := 0
	
	before := ' '
	for _, c := range S {
		if before != c {
			cnt++
			before = c
		}
	}
	
	fmt.Println(cnt)
}

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 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: 1024
#include<bits/stdc++.h>
using namespace std;

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string n; cin>>n;
	vector<int>v;
	int ans=0;
	for(auto&&i:n)ans+=(i-'0'),v.emplace_back(i-'0');
	for(int i=0;i<v.size();++i){
		if(v.at(i)==0)continue;
		int tans=v.at(i)-1;
		for(int j=0;j<v.size();++j){
			if(i==j)continue;
			else if(j<i)tans+=v.at(j);
			else tans+=9;
		}
		ans=max(tans,ans);
	}
	cout<<ans<<"\n"s;
}


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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

int main()
{
    solve();
}

void solve()
{
    int n;
    in(n);
    int ans = 0;
    rep1(j, n)
    {
        int cnt = 0;
        rep1(i, j)
        {
            if (i % 2 == 1)
            {
                if (j % i == 0)
                {
                    cnt++;
                }
            }
        }
        if (cnt == 8)
        {
            ans++;
        }
    }
    out(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  string s;
  cin >>s;
  int lnum=0, rnum=0;
  rep(i, n){
    if(s[i]=='('){
      lnum++;
    } else {
      if(lnum>0){
        lnum--;
      } else {
        rnum++;
      }
    }
  }
  int lnum2=0, rnum2=0;
  for(int i=n-1; i>=0; i--){
    if(s[i]==')'){
      rnum2++;
    } else {
      if(rnum2>0){
        rnum2--;
      } else {
        lnum2++;
      }
    }
  }
  rep(i, rnum){
    s='('+s;
  }
  rep(i, lnum2){
    s=s+')';
  }
  cout << s << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n;
	vector<double> v1, v2;
	double ans = 0;
	double tsum = 0;

	cin >> n;

	v1.push_back(0);
	v2.push_back(0);

	REP(i, n) {
		double a;
		cin >> a;
		v1.push_back(a + v1[i]);
		tsum += a;
	}

	REP(i, n) {
		double b;
		cin >> b;
		v2.push_back(b);
	}

	v1.push_back(tsum);
	v2.push_back(0);

	double prev = 0;

	REP(i, tsum * 2) {
		double nowt = 0.5 * (i + 1);
		double nowv = nowt;

		FOR(j, 1, n + 2) {
			if (nowt < v1[j - 1] && nowv > v2[j] + (v1[j - 1] - nowt)) {
				nowv = v2[j] + (v1[j - 1] - nowt);
			}
			else if (nowt > v1[j] && nowv > v2[j] + (nowt - v1[j])) {
				nowv = v2[j] + (nowt - v1[j]);
			}
			else if (nowt >= v1[j - 1] && nowt <= v1[j] && nowv > v2[j]) {
				nowv = v2[j];
			}
		}
		
		ans += 0.25 * (prev + nowv);
		prev = nowv;
	}

	cout << fixed;
	cout << setprecision(5) << ans << endl;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int cur = 0;
	vector <int> x;
	vector <int> y;
	int sx, sy;
	cin >> sx >> sy;
	int beg = 0;
	while (beg < s.size() && s[beg] == 'F') {
		sx--;
		beg++;
	}
	bool isx = true;
	for (int i = beg; i < s.size(); ++i) {
		if (s[i] == 'F') {
			cur++;
		}
		else {
			if (cur) {
				if (isx) {
					x.push_back(cur);
				}
				else {
					y.push_back(cur);
				}
			}
			cur = 0;
			isx = !isx;
		}
	}
	if (cur) {
		if (isx) {
			x.push_back(cur);
		}
		else {
			y.push_back(cur);
		}
	}
	vector <vector<bool> > canx(2, vector <bool> (20001, false));
	vector <vector<bool> > cany(2, vector <bool> (20001, false));
	canx[0][10000] = true;
	cany[0][10000] = true;
	cur = 1;
	for (int i = 0; i < x.size(); ++i) {
		for (int j = 0; j < canx[0].size(); ++j) {
			if (canx[!cur][j]) {
				canx[!cur][j] = false;
				canx[cur][j + x[i]] = canx[cur][j - x[i]] = true;
			}
		}
		cur = !cur;
	}
	cur = 1;
	for (int i = 0; i < y.size(); ++i) {
		for (int j = 0; j < cany[0].size(); ++j) {
			if (cany[!cur][j]) {
				cany[!cur][j] = false;
				cany[cur][j + y[i]] = cany[cur][j - y[i]] = true;
			}
		}
		cur = !cur;
	}
	if (sx < -8000 || sx > 8000 || sy < -8000 || sy > 8000) {
		cout << "No" << endl;
		return 0;
	}
	if (canx[x.size() & 1][sx + 10000] && cany[y.size() & 1][sy + 10000]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>A(N+1);
  vector<int>B(N+1);
  vector<int>C(N);
  vector<int>D(N);
  for(int i=0;i<N;i++){
    cin>>C[i];
    A[C[i]]++;
  }
  for(int i=0;i<N;i++){
    cin>>D[i];
    B[D[i]]++;
  }
  for(int i=1;i<N+1;i++){
    if(A[i]+B[i]>N){
      puts("No");return 0;
    }
  }
  puts("Yes");
  for(int i=0;i<N;i++){
    A[i+1]+=A[i];
    B[i+1]+=B[i];
  }
  int count=0;
  for(int i=0;i<N;i++)count=max(count,A[i+1]-B[i]);
  for(int i=0;i<N;i++)cout<<D[(i+N-count)%N]<<(i!=N? " ":"");
  cout<<"\n";
}

Measured memory_bytes: 6436
function main(D){
    if(D==22){
      console.log("Christmas Eve Eve Eve");
    } else if (D==23){
        console.log("Christmas Eve Eve");
    } else if (D==24){
        console.log("Christmas Eve");
    } else if (D==25){
        console.log("Christmas");
    } 
    }
    main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC137A
{
    class Program
    {
        static void Main(string[] args)
        {
            var word = Console.ReadLine().Split();
           double a = double.Parse(word[0]);
           double b = double.Parse(word[1]);
            double max = a + b;


            if (max <= (a * b))
            
                max = a * b;

                else if (max <= (a - b))
                    max = a - b;
            
            Console.WriteLine(max);
            Console.ReadKey();
            


        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
 
using namespace std;
 
void call(int n){
    for (int i = 1;i <= n; i++) {
        int x = i;
        if (x %  3 == 0) {
            cout << " " << i;
            continue;
        }   
        while (x) {
            if (x % 10 == 3) {
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }
    cout << endl;
}
 
int main() {
    int n;
    cin >> n;
    call(n);
    return 0;
}

Measured memory_bytes: 3060
N, M = map(int, input().split())
Lumps = [[]] * M
for i in range(M):
  Lumps[i] = list(map(int, input().split()))[1:]
p = list(map(int, input().split()))
ans = 0
s = 0

for j in range(2 ** N):
  ss = format(s, "010b")[10 - N:]
  m = 0
  for k in range(M):
    if sum([int(ss[i-1]) for i in Lumps[k]]) % 2 == p[k]:
      m += 1
    else:
      break
  if m == M:
    ans += 1
  s += 1
print(ans)

Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n]={};
    int x,y,z;
    int h;
    cin >> x;
    for(int i=0;i<x;i++){
        cin >> h;
        a[h-1]|=1<<0;
    }
    cin >> y;
    for(int i=0;i<y;i++){
        cin >> h;
        a[h-1]|=1<<1;
    }
    cin >> z;
    for(int i=0;i<z;i++){
        cin >> h;
        a[h-1]|=1<<2;
    }
    int m=0;
    for(int i=0;i<n;i++)
        if((a[i]&(1<<2))&&((!(a[i]&(1<<0)))||(a[i]&(1<<1))))
           m++;
    cout << m << endl;
    return 0;
}



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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((ll)((a) + (b) - 1)/(ll)(b))

signed main(){
    int a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if(a > b) swap(a,b);
    if(a + t*v < b + t*w){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 3652