akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()


using namespace std;
typedef long long ll;

const ll Inf = 0;

class RMQ {
  int n;
  ll *dat;

  ll q(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return Inf;
    if (a <= l && r <= b) return dat[k];
    else {
      ll lhs = q(a, b, k*2+1, l, (l+r)/2);
      ll rhs = q(a, b, k*2+2, (l+r)/2, r);
      return lhs + rhs;
    }
  }

 public:

  explicit RMQ(int n_) {
    n = 1;
    while (n < n_) n <<= 1;
    dat = new ll[n*2];
    REP(i,n*2) dat[i] = Inf;
  }

  ~RMQ() { delete[] dat; }

  void update(int k, int a) {
    k += n-1;
    dat[k] += a;
    while (k > 0) {
      k = --k / 2;
      dat[k] += a;
    }
  }

  // Returns the min value of [a, b)
  ll query(int a, int b) {
    return q(a, b, 0, 0, n);
  }
};


int main(int argc, char *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
    
  int n, q, c, x, y;
  cin >> n >> q;
  n++;
  RMQ rmq(n);
  REP(i,q){
    cin >> c >> x >> y;
    if (c == 0) {
      rmq.update(x, y);
    } else {
      cout << rmq.query(x, y+1) << '\n';
    }
  }
  cout << flush;

  return 0;
}

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

int main(){
    const int N = 32;
    vector<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 i;


    cin >> i;
    cout << a[i - 1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    double W,H,x,y;
    cin >> W >> H >>x>>y;
    int ans=0;
    if(W==2*x && H==2*y) ans=1;
    cout << fixed << setprecision(14);
    cout << (double) W*H/2.0 << " " << ans << endl;




}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

using ll = long long;

int main() {
	int n;
	cin >> n;
	ll fact = 1;
	const int mod = 1e9 + 7;
	for (int i = 1; i <= n; i++) {
		fact *= i;
		fact %= mod;
	}
	cout << fact << '\n';
	return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// input に a,b,c がそれぞれ１つ存在すること
    
    if(input.indexOf('a') >= 0
       && input.indexOf('b') >= 0
       && input.indexOf('c') >= 0){
      console.log("Yes");
    }else{
      console.log("No");
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
#include <set>

using namespace std;

int main()
{
   set<int> s;
   int number = 0;
   int n = 0;
   cin >> n;
   for(int i = 0; i < n; ++i){
       cin >> number;
       set<int>::iterator it;
       it = s.find(number);
       if(it != s.end()){
           s.erase(number);
       }
       else{
           s.insert(number);
       }
   }
   cout << s.size() << endl;
   
   return 0;
}

Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int result = 0, left = 0, right = 0;
        for (int i = 0; i < n; i++) {
            left = scanner.nextInt();
            right = scanner.nextInt();
            result += right - left + 1;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 26824
#include <iostream>
using namespace std;
using llong = long long;

llong x, y, z;
llong ans[10005];

int main() {
    llong n;
    cin >> n;
    for (x = 1; x <= n; x++) {
        for (y = 1; y <= n; y++) {
            if (x * x + y * y > n) break;
            for (z = 1; z <= n; z++) {
                if (x * x + y * y + z * z + x * y + y * z + z * x > n) break;
                ans[x * x + y * y + z * z + x * y + y * z + z * x]++;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 3584
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            long K = in.nextLong();

            int[] a = new int[N];
            int[] b = new int[N];
            for (int i = 0; i < N; i++) {
                a[i] = in.nextInt();
                b[i] = in.nextInt();
            }

            ArrayList<Pair<Integer, Integer>> numberAndCountPairs = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                numberAndCountPairs.add(new Pair<Integer, Integer>(a[i], b[i]));
            }
            Collections.sort(numberAndCountPairs);

            long sum = 0;
            for (int i = 0; i < numberAndCountPairs.size(); i++) {
                sum += numberAndCountPairs.get(i).second;
                if (sum >= K) {
                    System.out.println(numberAndCountPairs.get(i).first);
                    return;
                }
            }

            throw new AssertionError();
        }
    }
}

class Pair<T extends Comparable<T>, S> implements Comparable<Pair<T, S>> {
    public T first;
    public S second;

    public Pair(T t, S s) {
        this.first = t;
        this.second = s;
    }

    private int hash = 0;

    @Override
    public int hashCode() {
        if (hash == 0) {
            final int prime = 31;
            int result = 1;
            result = prime * result + ((first == null) ? 0 : first.hashCode());
            result = prime * result + ((second == null) ? 0 : second.hashCode());
            hash = result;
        }
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Pair<T, S> other = (Pair<T, S>) obj;
        if (first == null) {
            if (other.first != null)
                return false;
        } else if (!first.equals(other.first))
            return false;
        if (second == null) {
            if (other.second != null)
                return false;
        } else if (!second.equals(other.second))
            return false;
        return true;
    }

    @Override
    public int compareTo(Pair<T, S> o) {
        return first.compareTo(o.first);
    }
}

Measured memory_bytes: 85836
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  bool ok = 1;
  while(n){
    if(n%10 == 7)ok&=0;
    n/=10;}
  if(ok)cout<<"No\n";
  else cout<<"Yes\n";
}

Measured memory_bytes: 3676
#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010

int main(){
	string s;cin>>s;
	bool a[4]={};
	rep(i,s.size()){
		if(s[i]=='N')a[0]=1;
		if(s[i]=='S')a[1]=1;
		if(s[i]=='E')a[2]=1;
		if(s[i]=='W')a[3]=1;
	}bool c=(a[0]&&a[1])||(a[2]&&a[3]);
	if((a[0]^a[1])||(a[2]^a[3]))c=0;
	cout<<(c?"Yes":"No")<<endl;
}

//sub-EOF


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

#define int long long
#define inf (int)1000000007

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n); i >= 0; i--)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)
#define rfor(i, s, t) for(int i = (t) - 1; i >= (s); i--)

int a[114514];

signed main() {
  int n;
  cin >> n;
  int s = 0;
  int sw = 0;
  rep(i, n) {
    cin >> a[i];
    s += a[i];
    sw += i + 1;
  }
  bool ok = true;
  if(s % sw != 0) {
    ok = false;
  }
  else {
    int b = s / sw;
    rep(i, n) {
      if(a[i] < b || (a[i] + b - a[(i + 1) % n]) % n != 0) {
        ok = false;
        break;
      }
    }
  }
  if(ok) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


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

int main(){
	int x, a,b;
	cin >> x;
	if(x==1){
		cout << "Hello World" << endl;
	}else{
		cin >> a >> b;
		cout << a+b << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>
#include <queue>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int n,a,b;cin>>n>>a>>b;
  cout << min(n*a, b) << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC143
{
    class A
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //int N = int.Parse(Console.ReadLine());
            //string S = Console.ReadLine();
            int A = input[0];
            int B = input[1];
            int sum = A - 2 * B;
            if (0 < sum) Console.WriteLine(sum);
            else Console.WriteLine(0);
        }
    }
}


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

int main() {
  ll n,ma,mb;
  cin>>n>>ma>>mb;
  ll dp[n+2][420][420];
  rep(i,n+2)rep(j,420)rep(k,420)dp[i][j][k]=INF;

  dp[0][0][0]=0;
  rep(i,n){
    ll a1,b1,c1;
    cin>>a1>>b1>>c1;

    rep(j,400)rep(k,400){
      dp[i+1][j+a1][k+b1]=min(dp[i+1][j+a1][k+b1],dp[i][j][k]+c1);
      dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
    //  cout<<dp[i+1][j+a1][k+b1]<<" "<<i+1<<" "<<j+a1<<"a"<<k+b1<<"b"<<endl;
    }

  }

  ll ans=INF;

  for(int i=1;i<=400;i++)for(int j=1;j<=400;j++){

    if (i%ma==0 and j%mb==0){
      if (i/ma==j/mb){
        ans=min(ans,dp[n][i][j]);
      //  cout<<ans<<"i"<<i+1<<"j"<<j+1<<endl;
      }

    }
  }
  if (ans==INF)ans=-1;
cout<<ans;

}


Measured memory_bytes: 58112
s = [True for i in range(200000)]
s[0] = False
s[1] = False
n = int(input())
for i in range(2,len(s)):
  if not s[i]:
    continue
  for j in range(i+i, len(s), i):
    s[j] = False
for i in range(n, len(s)):
  if s[i]:
    print(i)
    break

Measured memory_bytes: 52464
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  V a(n);
  rep(i,n) cin >> a[i];
  V s(n+1);
  rep(i,n) {
    s[i+1] = gcd(s[i],a[i]);
  }
  V t(n+1);
  for (ll i = n-1; i >= 0; --i) {
    if (i == n-1) t[i] = a[i];
    else {
      t[i] = gcd(t[i+1], a[i]);
    }
  }
  ll ans = 0;
  for (ll i = 1; i <= n; ++i) {
    ll tmp = gcd(s[i-1],t[i]);
    ans = max(ans,tmp);
  }
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 5568
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<vi>
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){
  string S; cin>>S;
  ll ans=S.size(),cnt=0;
  rep(i,0,S.size()){
    if(S[i]=='S') cnt++;
    else{
      if(cnt>0){
        cnt--;
        ans-=2;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
s = int(input())

def f(n):
    if n % 2 == 0:
        return int(n / 2)

    else:
        return int(3*n + 1)

x = []

x.append(s)
y = 1
while True:
    y += 1
    s = f(s)
    if s in x:
        print(y)
        exit()
    x.append(s)




Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 200009 /// I wanna be the wind
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e14 + 9;
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll fastpow(ll a, ll b){
    ll calc=1;
    for(;b>=1LL;b/=2LL){
        if((b&1LL))calc=mult(calc,a);
        a=mult(a,a);
    }
    return calc;
}
ll soma(ll a,ll b){
    if(a+b>MOD)return a+b-MOD;
    else return a+b;
}
ll subt(ll a,ll b){
    if(a-b<0)return a-b+MOD;
    else return a-b;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    ll ans = fastpow(10,n);
    cout<<subt(ans,subt(soma(fastpow(9,n),fastpow(9,n)),fastpow(8,n)))<<'\n';
    return 0;  
}   

Measured memory_bytes: 3652
N, C = gets.split.map &:to_i
X, V = $<.map{|s|s.split.map &:to_i}.transpose
Vcusum = [sum = 0] + V.map{|v| sum += v }
RVcusum = [sum = 0] + V.reverse.map{|v| sum += v }
RX = X.reverse.map{|x| C - x }

max_idx = 0
max = 0
Vtbl = (0...N).map{|i|
  t = Vcusum[i+1]-X[i]
  if t > max
    max = t
    max_idx = i
  end
  max_idx
}

max_idx = 0
max = 0
RVtbl = (0...N).map{|i|
  t = RVcusum[i+1]-RX[i]
  if t > max
    max = t
    max_idx = i
  end
  max_idx
}

rl = (0...N-1).map{|i|
  t = Vcusum[i+1]-X[i]
  j = RVtbl[N-i-2]
  t + [0, -X[i] + RVcusum[j+1]-RX[j]].max
}.max || 0
lr = (0...N-1).map{|i|
  t = RVcusum[i+1]-RX[i]
  j = Vtbl[N-i-2]
  t + [0, -RX[i] + Vcusum[j+1]-X[j]].max
}.max || 0
p [Vcusum[N]-X[N-1], RVcusum[N]-RX[N-1], rl, lr, 0].max


Measured memory_bytes: 19320
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
    int dp[45];
    dp[0] = 1;
    dp[1] = 1;
    int n;
    cin >> n;
    for(int i=2;i<=44;i++){
        dp[i] = dp[i-1] + dp[i-2];
    }
    cout << dp[n] << endl;


}



Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int input[] = new int[3];
		
		input[0] = scan.nextInt();
		input[1] = scan.nextInt();
		input[2] = scan.nextInt();
		
		int tmp;
		if(input[0] > input[1]){
			tmp = input[0];
			input[0] = input[1];
			input[1] = tmp;
		}
		if(input[1] > input[2]){
			tmp = input[1];
			input[1] = input[2];
			input[2] = tmp;
		}
		if(input[0] > input[1]){
			tmp = input[1];
			input[1] = input[0];
			input[0] = tmp;
		}
		
		System.out.println(input[0] + " " + input[1] + " " + input[2]);
	}

}

Measured memory_bytes: 26296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for(int i = (l); i < (r); ++i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
//-------
const int N = 101010;
int n;
int a[N], x[N], y[N];
int main() {
	scanf("%d", &n);
	rep(i, 1, n + 1) scanf("%d%d%d", a + i, x + i, y + i);
	bool ans = 1;
	rep(i, 1, n + 1) {
		int t = a[i] - a[i - 1];
		int d = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
		ans &= t >= d && (t & 1) == (d & 1);
	}
	puts(ans ? "Yes" : "No");
	return 0;
}



Measured memory_bytes: 1408
from math import log

def n_number(num:int , n:int)->list:
    #n進数に直す
    ans = []
    while num > 0:
        ans.append(num%n)
        num = num // n
    return ans[::-1]


def main():
    N = int(input())
    ans = N
    for six in range(N + 1):
        ans = min(ans,sum(n_number(six,6)) + sum(n_number(N - six,9)))
    print(ans)
    return
        
if __name__ == "__main__":
    main()

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

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

    vector<ll> vala(a);
    vector<ll> valb(b);
    for(ll i=0;i<a;i++) {
        cin >> vala.at(i);
    }
    for(ll i=0;i<b;i++) {
        cin >> valb.at(i);
    }

    ll ans = 1e10;
    ll x, y, c;
    for(int i=0;i<m;i++) {
        cin >> x >> y >> c; x--; y--;
        ans = min(ans, vala.at(x)+valb.at(y)-c);
    }

    sort(vala.begin(), vala.end());
    sort(valb.begin(), valb.end());
    ans = min(ans, vala.at(0)+valb.at(0));

    cout << ans << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int64_t sum=0;
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
        sum += a.at(i);
    }
    
    sort(a.begin(),a.end());
    
    cout << a.at(0) << " " << a.at(n-1) << " " << sum << endl;
}


Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int N;
    vector<int> num(3);
    cin >> N >> num[0] >> num[1] >> num[2];
    vector<string> s(N);
    REP(i, N) cin >> s[i];


    vector<char> ans;
    REP(i, N){
        // 選ばれているものを数字に変換
        int c1 = s[i][0] - 'A';
        int c2 = s[i][1] - 'A';
        int c3 = 3-c1-c2;
        if(num[c1]+num[c2] == 0 or (num[0] < 0 or num[1] < 0 or num[2] < 0)){
            cout << "No" << endl;
            return 0;
        }

        bool flag = true;
        for(auto c: s[i]){
            int idx = c-'A';
            string next;
            next += c; 
            next += c3+'A';
            sort(next.begin(), next.end());
            if((num[idx] == 0) or (i+1 < N and num[idx] == 1 and num[c3] == 0 and s[i+1] == next)){
                ans.push_back(c);
                ++num[idx];
                --num[(idx == c1)? c2: c1];
                flag = false;
                break;
            }
        }
        // そうでない場合は、なんでも良い
        if(flag){
            ans.push_back(s[i][0]);
            ++num[c1];
            --num[c2];
        }
    }
    cout << "Yes" << endl;
    for(auto c: ans) cout << c << endl;

    return 0;
}

Measured memory_bytes: 5480
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 = sc.nextInt();
        
        int b = sc.nextInt();
        
        int c = sc.nextInt();
        
         int intNum;

        if(a > b){
            intNum = a;
            a = b;
            b = intNum;
            }
            if(b >c){
                intNum = b;
                b = c;
                c = intNum;
                }
                if(a>b){
                     intNum = a;
                    a = b;
                     b = intNum;
                }
      System.out.println(a + " " + b + " " + c);
  
            }
}





Measured memory_bytes: 26212
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    
    ans = 0
    for i in range(n):
        ans += min(a[i], b[i])
        # 勇者iがまだi+1番目のモンスターを倒せる場合
        if b[i] > a[i]:
            # 残りの倒せる体数かi+1番目のモンスター全部
            ans += min(b[i] - a[i], a[i+1])
            # 残りのモンスターの数 か 全部倒された
            a[i+1] = max(a[i+1] - (b[i] - a[i]), 0)

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 18624
import math
import statistics
import itertools

n = int(input())
xl = []
yl = []

for i in range(n):
    x,y = map(int, input().split())
    xl.append(x)
    yl.append(y)

def d(x1,y1,x2,y2):
    return math.sqrt((x1-x2)**2 + (y1-y2)**2)

dd = []
for m in itertools.permutations(range(n)):
    dsum = 0
    for i in range(n-1):
        ii = m[i]
        iii = m[i+1]
        dsum += d(xl[ii], yl[ii], xl[iii], yl[iii])
    dd.append(dsum)
ans = statistics.mean(dd)

print(ans)

Measured memory_bytes: 6492
#include <stdio.h>

int main(void)
{
    //iとjはループ変数、nは入力する数
    int i, j, n;
    //入力される棟、階、部屋、人数
    int building_num, floor_num, room_num, people_num;
    //棟毎の人数を格納
    int building1[3][10] = {0};
    int building2[3][10] = {0};
    int building3[3][10] = {0};
    int building4[3][10] = {0};

    scanf("%d", &n);

    for(i = 0; i < n; i++){
        scanf("%d %d %d %d", &building_num, &floor_num, &room_num, &people_num);

        switch(building_num){
            case 1:
                building1[(floor_num - 1)][(room_num - 1)] += people_num;
                break;
            case 2:
                building2[(floor_num - 1)][(room_num - 1)] += people_num;
                break;
            case 3:
                building3[(floor_num - 1)][(room_num - 1)] += people_num;
                break;
            case 4:
                building4[(floor_num - 1)][(room_num - 1)] += people_num;
                break;
            default:
                break;
        }
    }

    for(i = 0; i < (3 * 4); i++){
        if(((i % 3) == 0) && (i != 0)){
            printf("####################\n");
        }
        for(j = 0; j < 10; j++){
            switch(i / 3){
                case 0:
                    printf(" %d",building1[i % 3][j]);
                    break;
                case 1:
                    printf(" %d",building2[i % 3][j]);
                    break;
                case 2:
                    printf(" %d",building3[i % 3][j]);
                    break;
                case 3:
                    printf(" %d",building4[i % 3][j]);
                    break;
                default:
                    break;
            }
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2048
N = int(input())
S = list(input())


alpha = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
         "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U",
         "V", "W", "X", "Y", "Z"]

for index_i, i in enumerate(S):
    for index_j, j in enumerate(alpha):
        if i == j:
            if index_j + N > len(alpha) - 1:
                index_j = index_j + N - (len(alpha) - 1)
                index_j = index_j - 1
                S[index_i] = alpha[index_j]
            else:
                S[index_i] = alpha[index_j+N]
        else:continue

print("".join(S))

Measured memory_bytes: 3064
#include<stdio.h>
int main(void) {
	double n;
	scanf("%lf", &n);
	int k = n;
	if (k % 2 == 0) {
		printf("%f", 0.5);
	}
	else {
		printf("%f", (n + 1) / 2 / n);
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    // data (from stdin)
    int a;
    std::cin >> n;
    vector<int> v;
    for (int i=0; i<n; ++i){
        std::cin >> a;
        v.push_back(a);
    }
    for (int i=0; i<n; ++i){
        if(i!=n-1){std::cout << v[n-1-i] << " ";}
        else {std::cout << v[n-1-i] << endl;}
    }
}




Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a,b;
  cin>>a>>b;
 if( b>=a%500)
   cout<<"Yes";
  else
    cout<<"No";
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  string s; cin>>s;
  ll n=s.size();
  
  char now=s[0];
  ll ans=0;
  rep(i,n){
    if(now!=s[i]){
      ans++;
      now=s[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<vector<int>> g(n, vector<int>(n));
    vector<vector<bool>> need(n, vector<bool>(n, true));
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            cin >> g[i][j];
        }
    }
    for(int k = 0; k < n; k++)
    {
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                if(i == j || j == k || i == k) continue;
                if(g[i][j] == g[i][k] + g[k][j])
                {
                    need[i][j] = false;
                    need[j][i] = false;
                }
                else if(g[i][j] > g[i][k] + g[k][j])
                {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }
    long long ans = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            if(need[i][j]) ans += g[i][j];
        }
    }
    cout << ans / 2 << endl;
}



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

int main(void) 
{
	char a[4], b[4];
	int c, d, e, f, g, i, j;

	while (cin >> c >> d)
	{
		if (c == 0 && d == 0)break;
		f = 0, g = 0;
		e = 1000;
		for (i = 0; i < 4; i++)
		{
			a[i] = c / e;
			b[i] = d / e;
			c -= a[i] * e;
			d -= b[i] * e;
			e /= 10;
		}

		for (i = 0; i < 4; i++)
		{
			for (j = 0; j < 4; j++)
			{
				if (a[i] == b[j])
				{
					if (i == j)
					{
						f++;
					}
					else
					{
						g++;
					}
				}
			}
		}
		cout << f << " " << g << endl;
	}
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> L(N);
	for (auto &x : L) {
		cin >> x;
	}
	sort(L.begin(), L.end());

	long long ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			auto lb = lower_bound(L.begin() + j + 1, L.end(), L[i] + L[j]);
			ans += lb - (L.begin() + j + 1);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat
int dp[2005][2005];
int mat[2005][2005];

int main(int argc, char const *argv[])
{
	sync;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	int n,a,b;
	cin>>n>>a>>b;
	memset(dp,0,sizeof(dp));
	memset(mat,0,sizeof(mat));
	for(int i=1;i<n;i++)
	{
		mat[i][i+1]=1;
		mat[i+1][i]=1;
	}
	mat[a][b]=1;
	mat[b][a]=1;
	for(int i=1;i<n;i++)
	{
		dp[i][i+1]=1;
		dp[i+1][i]=1;
		for(int j=i+2;j<=n;j++)
		{
			dp[i][j]=dp[i][j-1]+1;
			dp[j][i]=dp[i][j];
		}
	}

	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			dp[i][j]=min(dp[i][j],dp[i][a]+dp[b][j]+1);
			dp[i][j]=min(dp[i][j],dp[i][b]+dp[j][a]+1);
		}
	}
	int ans[n+5]={0};
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			ans[dp[i][j]]++;
		}
	}
	for(int i=1;i<n;i++)
	{
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 31744
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Random;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static final int INF = 1 << 30;
	static long[][] hash = new long[32][32];
	static long finish;

	public static void main(String[] args) {
		Random rnd = new Random();
		for (int i = 0; i < 32; ++i) {
			for (int j = 0; j < 32; ++j) {
				hash[i][j] = rnd.nextLong();
			}
		}
		for (int i = 0; i < 4; ++i) {
			for (int j = 2; j <= 7; ++j) {
				finish ^= hash[i * 8 + j - 1][i * 8 + j];
			}
		}
		int T = sc.nextInt();
		for (int i = 0; i < T; ++i) {
			System.out.println(solve());
		}
	}

	static int solve() {
		ArrayList<Board> cur = new ArrayList<Board>();
		HashSet<Long> hashes = new HashSet<Long>();
		cur.add(new Board());
		hashes.add(cur.get(0).h);
		int i = 0;
		for (; !cur.isEmpty(); ++i) {
			ArrayList<Board> next = new ArrayList<Board>();
			for (Board b : cur) {
				if (b.h == finish) return i;
				for (int j = 0; j < 32; ++j) {
					if (b.f[j] == INF && b.f[j - 1] != INF && (b.f[j - 1] & 7) != 7) {
						Board created = new Board(b, j);
						if (hashes.contains(created.h)) continue;
						hashes.add(created.h);
						next.add(created);
					}
				}
			}
			cur = next;
		}
		return -1;
	}

	static class Board {
		int[] f = new int[32];
		long h;

		Board() {
			for (int i = 0; i < 4; ++i) {
				for (int j = 1; j <= 7; ++j) {
					int v = sc.nextInt();
					int suit = v / 10 - 1;
					int num = v % 10;
					int card = suit * 8 + num;
					if (num == 1) {
						f[i * 8 + j] = INF;
						f[suit * 8] = card;
					} else {
						f[i * 8 + j] = card;
						h ^= hash[i * 8 + j][card];
					}
				}
			}
		}

		Board(Board orig, int pos) {
			this.h = orig.h;
			for (int i = 0; i < 4; ++i) {
				for (int j = 0; j < 8; ++j) {
					this.f[i * 8 + j] = orig.f[i * 8 + j];
					if (orig.f[i * 8 + j] == orig.f[pos - 1] + 1) {
						this.f[i * 8 + j] = INF;
						this.h ^= hash[i * 8 + j][orig.f[pos - 1] + 1];
					}
				}
			}
			this.f[pos] = orig.f[pos - 1] + 1;
			this.h ^= hash[pos][orig.f[pos - 1] + 1];
		}
	}
}

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

using namespace std;

int main() {
    int L, R, d;    cin >> L >> R >> d;
    int ans = 0;
    for (int i = L; i <= R; i++) {
        if (i % d == 0) {
            ans++;
        }
    }
    cout << ans;
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}

Measured memory_bytes: 3520
//
// Created by kuroneko on 2019-07-06.
//

using namespace std;

#include <iostream>
#include <vector>
#include <cmath>

typedef long long ll;

int main() {
    int N; cin >> N;
    int w[N];
    int sum = 0;

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

    int max_sum = sum;

    int min_abs = 1e9;
    for (int i = 0; i < N; i++) {
        sum -= w[i];
        min_abs = min(min_abs, abs(sum - max_sum + sum));
    }
    cout << min_abs << endl;
    return 0;
}

Measured memory_bytes: 888
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	int x = int.Parse(ReadLine());
	if (x == 7 || x == 5 || x == 3)
	{
	    WriteLine("YES");
	}
	else
	{
	    WriteLine("NO");
	}
    }
}


Measured memory_bytes: 13140
namespace ABC141.B
{
    using System.Collections.Generic;
    using System.Linq;
    using static System.Console;

    public class Program
    {

        public static void Main(string[] args)
        {
            WriteLine(Solve(ReadLine()) ? "Yes" : "No");
        }

        public static bool Solve(string step) =>
            step.Where((c, i) => i % 2 == 0).All(c => c == 'R' || c == 'U' || c == 'D') &&
            step.Where((c, i) => i % 2 == 1).All(c => c == 'L' || c == 'U' || c == 'D');

    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;

int main(){
  int n,k;
  cin>>n>>k;
  int a[n],ng=0,ok=1e9+1,mid,tk;
  for(int i=0;i<n;i++)cin>>a[i];
  while(ok-ng>1){
    mid=ng+(ok-ng)/2;
    tk=0;
    for(int i=0;i<n;i++)tk+=max(0,a[i]/mid-(a[i]%mid==0 ? 1 : 0));
    (tk<=k ? ok : ng)=mid;
  }
  cout<<ok<<endl;
}


Measured memory_bytes: 4364
import std.algorithm;
import std.stdio;
import std.string;

void main()
{
	auto n = readln;
	auto s = readln.strip;
	auto lts = new int[ s.length ];
	auto rts = new int[ s.length ];
	auto result = int.max;
	
	lts[ 0 ] = 0;
	rts[ $-1 ] = 0;
	
	for( int index = 1; index < s.length; index++ )
	{
		lts[ index ] = lts[ index - 1 ] + ( s[ index - 1 ] == 'E' ? 0 : 1 );
	}
	for( int index = cast( int ) s.length-2; 0 <= index; index-- )
	{
		rts[ index ] = rts[ index + 1 ] + ( s[ index + 1 ] == 'W' ? 0 : 1 );
	}
	for( int index = 0; index < s.length; index++ )
	{
		result = min( result, lts[ index ] + rts[ index ] );
	}
	
	writeln( result );
}


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

using namespace std;
using ll = long long;
int arr[100005];

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i=0; i<m; i++){
        int l, r;
        scanf("%d %d", &l, &r);
        arr[l]++;
        arr[r+1]--;
    }
    int cur = 0, res = 0;
    for(int i=0; i<=100005; i++){
        cur += arr[i];
        res += cur == m;
    }
    printf("%d\n", res);
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

int n, k;
vi a;

bool core(int key) {
	if (a[key] >= k) return true;
	vector<bool> dp(k, false), dp2(k, false);
	dp[0] = true;
	Loop(i, n) {
		Loop(j, k) {
			if (dp[j]) {
				dp2[j] = true;
				if (i != key && j + a[i] < k) {
					dp2[j + a[i]] = true;
				}
			}
		}
		dp = dp2;
	}
	for (int j = k - a[key];j < k;++j) {
		if (dp[j]) return true;
	}
	return false;
}

int binary_search(int left, int right) {
	if (left + 1 >= right) return left;
	int judge = false;
	int mid = (left + right) / 2;
	judge = core(mid);
	if (judge) return binary_search(left, mid);
	else return binary_search(mid, right);
}

int main() {
	 cin >> n >> k;
	 a.resize(n);
	 Loop(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	//[left, right)は、不必要なもののうち最大のものを含む
	bool judge; //必要ならtrue
	int k = binary_search(0, n);
	int ans;
	if (k == 0) {
		if (core(0)) ans = 0;
		else ans = 1;
	}
	else {
		ans = k + 1;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N, temp;
  cin >> N;
  int A[N];
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A, A+N);
  int count = N-2;
  long long ans;
  ans = A[N-1];
  //cout << ans;
  temp = 2;
  while(count > 0){
    ans += A[N-1-(temp/2)];
    count--;
    temp++;
    //cout << ans << ", ";
  }
  cout << ans;
}

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

int main() {
  
  int x=1;
  int N,K;
  cin >> N >> K;
  
  for (int i=0; i<N; i++){
    if(x >= K)
      x += K;
    else
      x *= 2;
  }
  
  cout << x << endl;
  
}


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


void func() {
    int N;
    cin >> N;
    int values[N],cost[N];
    for (int i = 0; i < N; ++i) {
        cin >> values[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> cost[i];
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (values[i] > cost[i]) {
            ans += values[i] - cost[i];
        }
    }
    cout << ans << endl;
}
int main() {
    func();
    return 0;
}


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






l knapSack(l W, l wt[], l val[], l n) 
{ 
   l i, w; 
   l K[n+1][W+1]; 
  
   // Build table K[][] in bottom up manner 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
} 


int main()
{
    l n , W;
    cin>>n>>W;
     l wt[n];
     l val[n];
     for( l i = 0 ;i< n ;i++)
     {
         cin>>wt[i]>>val[i];
     }
     l ans = 0 ; 
     ans = knapSack(W, wt, val, n);
     cout<<ans;
}

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

using namespace std;

const int INF = 1e9 + 7;

void solve()
{
  int n;
  cin >> n;
  string str;
  cin >> str;
  int left = 0;
  string str2;
  for(int i = 0; i < str.size(); i++) {
    if (str[i] == '(') {
      left++;
    } else {
      if(left) {
        left--;
      }else {
        str2 = '(' + str2;
      }
    }
    str2 += str[i];
  }
  int right = 0;
  string ans;
  for (int i = str2.size() - 1; i >= 0; i--) {
    if (str2[i] == ')') {
      right--;
    } else {
      right++;
    }
    ans = str2[i] + ans;
  }
  ans += string(max<int>(right, 0), ')');
  cout << ans << "\n";
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;++i) cin >> a[i];
  sort(a,a+n);
  int ans = abs(a[n-1] - a[0]);
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
int_list = [int(x) for x in input().split()]

# int_listの各整数をyに書き換えるときのコストの総和を計算
def calc_cost(int_list, y):
    cost = 0
    for x in int_list:
        cost += (x - y)**2
    return cost

cost_list = [calc_cost(int_list, y) for y in range(min(int_list), max(int_list)+1)]
print(min(cost_list))

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

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;

int main(){
    int n,x;
    std::cin >> n>>x;
    VEC(int,a,n);
    int aa=0;
    rep(i,n){
        aa+=a[i];
        if(aa>x){
            std::cout << i+1 << std::endl;
            exit(0);
        }
    }
    std::cout << n+1 << std::endl;
}

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define ALL(v) begin(v), end(v)

/* REPmacro */
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (s); i >= (n); i--)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define rrep(i, n) RFOR(i, n - 1, 0)
#define rrepi(i, n) RFOR(i, n, 1)

/* debug */
#define pp(v) cerr << #v "=" << (v) << endl;

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using vs = vector<string>;
using Graph = vvi;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* iostream */
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define TIME system("date +%M:%S.%N")
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }
template<class T> T div_ceil(const T &a, const T &b) { return (a + b - 1) / b; }

int main() {
  int n,k;cin>>n>>k;
  vi h(n);cin>>h;
  vi dp(n+k+1,INF);dp[0]=0;
  rep(i,n-1) {
    repi(j,k) {
      chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
  }
  int ans = dp[n-1];
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <utility>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    if (t * s >= d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3616