akhauriyash/Code-Regression huggingface dataset:
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long A, B, C;
    scan(A, B, C);
    bool a = A == B && A != C;
    bool b = A == C && A != B;
    bool c = B == C && A != B;
    if (a || b || c)
    {
        writeln("Yes");
        return;
    }
    writeln("No");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <numeric>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> A(H, vector<char>(W));
    vector<vector<int>> dist(H, vector<int>(W, INF));
    queue<P> que;
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            cin >> A[i][j];
            if(A[i][j] == '#'){
                dist[i][j] = 0;
                que.push(P(i, j));
            }
        }
    }
    while(!que.empty()){
        P p = que.front();
        que.pop();
        int x = p.first;
        int y = p.second;
        int d = dist[x][y];
        
        for(int i = 0; i < 4; ++i){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx < 0 || nx >= H || ny < 0 || ny >= W)      continue;
            if(A[nx][ny] == '#')      continue;
            if(dist[nx][ny] <= d + 1)       continue;
            
            dist[nx][ny] = d + 1;
            que.push(P(nx, ny));
        }
    }
    
    int ans = 0;
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 13328
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
  long long m = 0;
  while (n) {
    m += n % 10;
    n /= 10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void Comuse() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

#define comuse Comuse()
// nCk(comuseを使え)
long long combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// pCk(comuseを使え)
long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a, long long b) {
  long long n;
  n = a / __gcd(a, b) * b;
  return n;
}

// auto A = div(n)
vector<long long> div(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a, long long n, long long mod) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans = ans * a % mod;
    }

    a = a * a % mod;

    n >>= 1;
  }

  return ans;
}

void solve();

const int MAX_N = 131072;
// segment tree
int NN;
int seg[MAX_N * 2 - 1];
void seguse() {
  for (int i = 0; i < 2 * NN - 1; i++) {
    seg[i] = INT_MAX;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;
  solve();
}

///////////////////////////////////////////////////////////

long double L;
void solve() {
  cin >> L;
  cout << (L / 3) * (L / 3) * (L / 3) <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		int A,B,C,X;
		int x=0;
		int target=0;

		for(;;){
			n=sc.nextInt();
			if(n==0){
				return;
			}
			A=sc.nextInt();
			B=sc.nextInt();
			C=sc.nextInt();
			X=sc.nextInt();
			int sum=0;
			
			for(int i=0;i<n;i++){
				target = sc.nextInt();
			    if(i==0){
					x=X;
				}
				if(i==0&&x==target){
					continue;
				}else{
				    for(int j=1;;j++){
				    	x=A*x+B;
					    x%=C;
					    if(x==target){
						    sum+=j;
							break;
				        }else if(j>10000){
							sum=10001;
							break;
						}
				    }
				}
			}
			
			if(sum>10000){
				System.out.println(-1);
			}else{
			    System.out.println(sum);
			}
				  
		}	

	}
}


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

using namespace std;

#define PI 3.1415926535897932


int main(){
    char s[200001];
    int ans=-1,chk=-1;
    scanf("%s",s);
    for (int i=0;i<strlen(s);i++) {
        if (s[i]=='A' && ans==-1) ans=i;
        if (s[i]=='Z') chk=i;
    }
    printf("%d\n",chk-ans+1);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



//bit全探索
vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int main(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])cout << "Yes";
    else cout << "No";
}



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

const int inf = 1<<20;

int main()
{
	int p[6][2] = 
	{
		{2  ,380},
		{3  ,550},
		{5  ,850},
		{2*5,380*5*0.80},
		{3*4,550*4*0.85},
		{5*3,850*3*0.88}
	};

	int dp[51] = {0};
	for(int i=1; i<51; i++) dp[i] = inf;

	int x;
	for(int j=0; j<6; j++)
	for(int i=0; i<51; i++)
	{
		x = p[j][0]+i;
		if(!(x<51)) break;

		if(dp[x]>dp[i]+p[j][1])
		{
			dp[x]=dp[i]+p[j][1];
		}
	}

	int g;
	while(cin >> g, g)
	{
		cout << dp[g/100] << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		String b = stdIn.next();
		int c = stdIn.nextInt();
		
		if (b.charAt(0) == '+') {
			System.out.println(a + c);
		} else {
			System.out.println(a - c);
		}
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

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

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

  double DP[N + 1][N + 1];
  for (int i = 0; i < N + 1; i++){
    for (int j = 0; j < N + 1; j++){
      DP[i][j] = 0;
    }
  }
  DP[0][0] = 1;
  
  for (int i = 1; i < N + 1; i++){
    for (int j = 0; j <= i; j++){
      DP[i][j] = P[i - 1] * DP[i - 1][j - 1] + (1 - P[i - 1]) * DP[i - 1][j];
    }
  }

  double ans = 0;
  for (int i = N / 2 + 1; i < N + 1; i++){
    ans += DP[N][i];
  }
  cout << setprecision(16) << ans << endl;
  


  return 0;
}


Measured memory_bytes: 70528
# /usr/bin/python
# -*- coding: utf-8 -*-
import math


N = int(input())
An = list(map(int, input().split()))

if N%2 == 0:
  Bn = An[-1::-2] + An[0::2]
else:
  Bn = An[-1::-2] + An[1::2]

for b in Bn:
  print(b,end=" ")

Measured memory_bytes: 93652
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		
		std::ios::sync_with_stdio(false);
		 cin.tie(0);
		 cout.tie(0);
		int a,b;
		cin>>a>>b;
		cout<<a-b+1<<endl;
		
		return 0;
	}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target("avx512vl")
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

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

  int N;
  int a[200000], b[200000];
  cin >> N;
  rep(i, N) cin >> a[i];
  rep(i, N) cin >> b[i];
  int ans = 0;
  rep(i, N) rep(j, N) ans ^= a[i] + b[j];
  cout << ans << endl;
}

Measured memory_bytes: 5224
use std::io::prelude::*;
use std::str::FromStr;
pub struct Scanner<R: Read>(R);
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self(reader)
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| (b as char).is_whitespace())
            .take_while(|&b| !(b as char).is_whitespace())
            .collect::<Vec<u8>>();
        unsafe { std::str::from_utf8_unchecked(token.as_slice()) }
            .parse()
            .ok()
            .expect("Can't parse it.")
    }
    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let mut sc = Scanner::new(stdin.lock());
    let mut out = std::io::BufWriter::new(stdout.lock());
    solve(&mut sc, &mut out);
    out.flush().ok().unwrap();
}
fn solve(sc: &mut Scanner<std::io::StdinLock>, out: &mut std::io::BufWriter<std::io::StdoutLock>) {
    let (N, Y): (i32, i32) = (sc.read(), sc.read());

    for a in 0..=N {
        for b in 0..=N - a {
            if 10000 * a + 5000 * b + 1000 * (N - a - b) == Y {
                println!("{} {} {}", a, b, N - a - b);
                return;
            }
        }
    }

    println!("-1 -1 -1");
}


Measured memory_bytes: 2136
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

long long n, a, b, ans = 0;

bool solve( long long m )
{
	return ( m >= 1 && ( n == ( m + 1 ) * ( n / m ) ) );
}

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n;
	for( long long i = 1; i * i <= n; ++i )
	{
		if( n % i == 0 )
		{
			a = i; b = n / i;
			if( solve( a - 1 ) )
			{
				ans += a - 1;
			}
			if( a != b && solve( b - 1 ) )
			{
				ans += b - 1;
			}
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}




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

	for (int i = 1; y * i + z * (i + 1) <= x; i++) {
		cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <array>
#include <algorithm>
#include <set>
#include <iomanip>
#include <cstdio>
#include <queue>

using namespace std;

#define int long long

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

    int in;
    int ans = 0;

    string s;

    cin >> s;

    for (int i = 0; i < 3; ++i)
    {
        if (s[i] == '1')
        {
            ans++;
        }

    }
    cout << ans << endl;

}

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

if N%2==0:
    dp = [[0]*2 for _ in range(N)]
    dp[0][0] = A[0]
    dp[1][1] = A[1]
    
    for i in range(2, N):
        if i==2:
            dp[i][0] = dp[i-2][0]+A[i]
        else:
            dp[i][0] = dp[i-2][0]+A[i]
            dp[i][1] = max(dp[i-3][0]+A[i], dp[i-2][1]+A[i])
    
    print(max(dp[N-2][0], dp[N-1][1]))
else:
    dp = [[0]*3 for _ in range(N)]
    dp[0][0] = A[0]
    dp[1][1] = A[1]
    dp[2][2] = A[2]
    
    for i in range(2, N):
        if i==2:
            dp[i][0] = dp[i-2][0]+A[i]
        elif i==3:
            dp[i][0] = dp[i-2][0]+A[i]
            dp[i][1] = max(dp[i-2][1]+A[i], dp[i-3][0]+A[i])
        else:
            dp[i][0] = dp[i-2][0]+A[i]
            dp[i][1] = max(dp[i-3][0]+A[i], dp[i-2][1]+A[i])
            dp[i][2] = max(dp[i-4][0]+A[i], dp[i-3][1]+A[i], dp[i-2][2]+A[i])
    
    print(max(dp[N-3][0], dp[N-2][1], dp[N-1][2]))

Measured memory_bytes: 112796
#include<stdio.h>
int main(){
	long int n_balls;
	scanf("%ld", &n_balls);
	long int value_for[n_balls+1];
	//各ballのvalueはn_ballsを超えない
	long int n_value[n_balls+1];
	for(int value_i = 1; value_i <= n_balls; value_i++)
		n_value[value_i] = 0;

	for(int ball_i = 1; ball_i <= n_balls; ball_i++){
		scanf("%ld", &value_for[ball_i]);
		n_value[value_for[ball_i]]++;
	}

	long int total_pairs = 0;
	for(int value_i = 1; value_i <= n_balls; value_i++)
		//nC2 == n*(n-1)/2
		total_pairs += n_value[value_i] * (n_value[value_i] - 1) / 2;
	for(int ball_i = 1; ball_i <= n_balls; ball_i++){
		int ex_count = (n_value[value_for[ball_i]] > 0 ? 
						n_value[value_for[ball_i]] - 1 : 0);
		printf("%ld\n", total_pairs - ex_count);
	}

	return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b}) << "\n";
    return 0;
}

Measured memory_bytes: 256
//Andrew Yang
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <fstream>
#include <string>
#include <string.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>	
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <climits>
using namespace std;
#define FOR(index, start, end) for(int index = start; index < end; index++)
#define RFOR(index, start, end) for(int index = start; index > end; index--)
#define FOREACH(itr, b) for(auto itr = b.begin(); itr != b.end(); itr++)
#define RFOREACH(itr, b) for(auto itr = b.rbegin(); itr != b.rend(); itr++)
#define INF 1000000000
#define M 1000000007
typedef long long ll;
typedef pair<int, int> pii;
int t[100001];
int main(void)
{
	int n, c, k;
	cin >> n >> c >> k;
	FOR(i, 0, n)
	{
		scanf("%d", &t[i]);
	}
	sort(t, t + n);
	int j = 0;
	int ans = 0;
	FOR(i, 0, n)
	{
		if (t[i] - t[j] > k  || i - j + 1 > c)
		{
			ans++;
			j = i;
		}
	}
	cout << ans + 1 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    ll n;
    cin >> n;
    ll ans = 0;
    FOR(i, 1, n) {
        ans += i;
    }
    cout << ans << "\n";
}


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

int main() {
    string s;
    cin >> s;
    if (s.length()%2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    else {
        for (int i = 0; i < s.length(); i++) {
            if (i%2==0 && s[i]!='h' || i%2==1 && s[i]!='i') {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}

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

using namespace std;
#define ll long long int

bool find(int x , ll a1[], ll b1[] , int n , int m, int k)
{
    // cout << x << endl;
    for(int i = 0 ; i <= x ; i ++)
    {
        int j = x - i;
        if( i <=n && j <= m)
        {
            ll total = a1[i] + b1[j];
            // cout << x << " " << total << endl;
            if(k >= total)
            return true;
        }        

    }
    return false;
}

int main()
{
   ll t;
   t = 1;	
   //cin t;
   while(t--){
      ll n,m,k;
      cin >> n >> m >>k;
      ll a[n] , b[m]; 
      ll a1[n + 1] , b1[m + 1];
      a1[0] = 0;
      b1[0] = 0;
      for(int i = 0; i < n ; i ++)
      {
          cin >> a[i];
          a1[i + 1] = a1[i] + a[i];
      } 
      for(int i = 0; i < m ; i ++)
      {
          cin >> b[i];
          b1[i + 1] = b1[i] + b[i];
      }        
      int ans = 0;   
      int l = 0;
      int r = n + m;
      while(l <= r)
      {
          int mid = l + (r - l) / 2;
          if(find(mid,  a1 , b1 , n , m , k))
          { 
              ans = mid;
              l = mid + 1;
          }
          else
          r= mid - 1;
      }
      cout << ans << endl;
   }
}


Measured memory_bytes: 9892
#include "iostream"
using namespace std;

int main()
{

	int x[100][100];
	int y[100][100];
	long c[100][100];

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

	// c[100][100]の初期化
	for (int i = 0; i <100; ++i) {
		for (int j = 0; j < 100; ++j) {
			c[i][j] = 0;
		}
	}


	//インプット１x
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> x[i][j];
		}
	}

	//インプット２y
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j < l; ++j) {
			cin >> y[i][j];
		}
	}

	//アウトプット
	for (int i = 0; i < n; i++){

		for (int j = 0; j < l; ++j) {

			for (int k = 0; k < m; k++){

				c[i][j] += x[i][k] * y[k][j];

			}

			cout << c[i][j];


			if (l-1!=j){
				cout << " ";
			}

		}




		cout << endl;

	}


	return 0;
}



Measured memory_bytes: 3280
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	ll k ;
	string str ;
	cin>> k >> str ;
	ll n = str.length();
	for(ll i=0;i<n ; i++){
		char ch=str[i];
		ll a=str[i]-'A';
		a=(a+k)%26;
		// cerr<<a<<" ";
		ch=(char)('A'+a);
		cout<<ch;
	}

	return 0;
}

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

int solve(int n, int k, vector<int>h){
  vector<int>dp(n, INF);
  dp[0] = 0;
  for (int i=0; i<n; i++){
    for (int j=i+1; j<=i+k; j++){
      if (j<n){
        dp[j] = min(
          dp[j],
          dp[i] + abs( h[i] - h[j] )
        );
      }
    }
  }
  return dp[n-1];
}

int main(){
  int n,k; cin>>n>>k;
  vector<int>h(n);
  rep(i,n) cin>>h[i];
  cout << solve(n,k,h) << endl;
  return 0;
}

Measured memory_bytes: 4580
#include <stdio.h>
#include <stdlib.h>


#define	ll_int	long long int


int Binary_Search(ll_int *box, int n, ll_int num)
{
	int mid;
	int left, right;


	left = 0;
	right = n - 1;
	while(left <= right){
		mid = (left + right) / 2;

		if(num == box[mid])
			return mid;
		else if(num < box[mid])
			right = mid - 1;
		else if(box[mid] < num)
			left = mid + 1;
	}

	return left;
}


int main()
{
	int n, q;
	ll_int *box, num;
	int pos, pos2;
	int i, j;


	scanf("%d", &n);

	box = (ll_int *)malloc(sizeof(ll_int) * n);

	for(i = 0; i < n; i++)
		scanf("%lld", &box[i]);


	scanf("%d", &q);

	for(i = 0; i < q; i++){
		scanf("%lld", &num);

		pos = Binary_Search(box, n, num);
		if(0 <= pos && pos < n){
			while(0 <= pos && num <= box[pos])
				pos--;

			pos2 = pos;
			while(++pos2 <= n - 1 && box[pos2] <= num);

			printf("%d %d\n", pos + 1, pos2);
		}else
			printf("%d %d\n", n, n);
	}

	return 0;
}


Measured memory_bytes: 2640
n = gets.to_i
as = gets.split.map(&:to_i)
bs = []
(n - 1).step(0, -2) do |i|
  bs.push(as[i])
end
(n % 2).step(n - 1, 2) do |i|
  bs.push(as[i])
end
puts bs.join(' ')


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

int main(){
	int n;
	cin>>n;
	vector<string> s(n);
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	
	int ans=0;
	
	for(int i=0;i<n;i++){
		int flag=1;
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				if(s[j][k]!=s[k][j])flag=0;
			}
		}
		ans+=flag;
		string tmp=s[0];
		for(int i=0;i<n-1;i++)s[i]=s[i+1];
		s[n-1]=tmp;
	}
	cout<<ans*n<<endl;
}

Measured memory_bytes: 512
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int A, B, C, X, Y;
ll c = 0;

int main()
{
  cin >> A >> B >> C >> X >> Y;

  if (A + B < 2 * C)
    c = A * X + B * Y;
  else if (X == Y)
    c = X * 2 * C;
  else if (X < Y)
    c = X * 2 * C + (Y - X) * min(B, 2 * C);
  else
    c = Y * 2 * C + (X - Y) * min(A, 2 * C);

  cout << c << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int m,f,r;
  cin >> m >> f >> r;
  while(m!=-1||f!=-1||r!=-1){
    if(m==-1||f==-1) cout << "F" << endl;
    else if(m+f>=80) cout << "A" << endl;
    else if(m+f>=65) cout << "B" << endl;
    else if(m+f>=50) cout << "C" << endl;
    else if(m+f>=30)
      if(r>=50) cout << "C" << endl;
      else cout << "D" << endl;
    else cout << "F" << endl;

    cin >> m >> f >> r;
  }
  return 0;
}




Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string bans(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n,x;cin>>n>>x;
  int ans=n;
  int mn=INT_MAX;
  vector<int> m(n);
  rep(i,n){
    cin>>m[i];
    x-=m[i];
    mn=min(mn,m[i]);
  }
  ans+=(x/mn);
  cout << ans << endl;
  return 0;
}


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

int N, K;
map<int, int> A;

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        int A_in;
        cin >> A_in;
        A[A_in]++;
    }

    vector<int> freq;
    for (auto itr = A.begin(); itr != A.end(); itr++) {
        int val = itr->second;

        freq.push_back(val);
    }

    int ans = 0;
    if (freq.size() > K) {
        sort(begin(freq), end(freq));

        for (int i = 0; i < freq.size() - K; i++) {
            ans += freq[i];
        }
    }

    cout << ans << endl;    

    return 0;
}


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

int main() {
  long n,k;
  cin >> n >> k;

  vector<long> vec(100001);
  for(int i=0; i<n; i++){
    int a,b;
    cin >> a >> b;
    vec[a] += b;
  }
  long cnt = 0;
  for(int i=0; i<100002; i++){
    cnt += vec[i];
    if(cnt >= k){
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <bitset>
#include <utility>
#include <sstream>
#include <fstream>
#include <stack>
#include <cstdlib>
#include <complex>
#include <set>

using namespace std;

#define INF 1070000000000000LL
#define pb push_back
#define irep(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) irep(i,0,n)

typedef long long lint;
typedef pair<int, int> pint;
struct Edge{
    int to,weight;
};
typedef vector<vector<Edge> > Graph;


int main(){
    lint a[5],n;
    lint min_a = INF;
    lint ans = 0;
    cin >> n;
    rep(i,5)cin >> a[i];
    rep(i,5){
	if(min_a != min(min_a, a[i])){
	    min_a = a[i];
	}
    }
    ans = (n + (min_a - 1))/min_a + 4;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

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

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

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
    } else {
        cout << min(a - 1, n - b) + 1 + (b - a - 1) / 2 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3600
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::prelude::BufRead;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;

const MAX: u64 = 1_000_000_000;

fn main() {
    let s = read::<u64>();
    let res = if s % MAX == 0 { 0 } else { MAX - s % MAX }; 
    let new_s = s + res;
    println!("0 0 1000000000 {} 1 {}", res, new_s / MAX);
}

#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf
        .trim()
        .parse()
        .unwrap();
}

#[allow(dead_code)]
fn read_vector<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();
}

#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    use std::io::prelude::*;
    let stdin = stdin();
    return stdin
        .lock()
        .lines()
        .map(|line| line
            .unwrap()
            .split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect())
        .collect();
}

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



int main(){
    string s;
    cin>>s;

    int l = s.length();

    for(int i=l-1; i>0; --i){
        if(i%2 != 0) continue;
        bool flag = true;
        for(int j=0; j<i/2; ++j){
            if(s[j] != s[j+i/2]) flag = false;
        }
        if(flag){
            cout<<i<<endl;
            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        long sum = 0;
        long max = 0;

        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        for(int i=0; i<k; i++) {
            sum += (a[i] + 1);
        }
        max = sum;
        for(int i=k; i<n; i++) {
            sum += (a[i] + 1);
            sum -= (a[i-k] + 1);
            max = Math.max(max, sum);
        }


        System.out.println((double)(max) / 2) ;


    }


}


Measured memory_bytes: 81028
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>

#define INF 1e9
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define LOG(x) cerr << #x << " = " << (x) << endl

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;

    map<int, int> a;
    REP(i, H) {
        string s;
        cin >> s;
        REP(j, W) {
            a[s[j] - 'a']++;
        }
    }

    int x4 = (H / 2) * (W / 2);
    int x2 = (H / 2) * (W % 2) + (W / 2) * (H % 2);
    int x1 = (W % 2) * (H % 2);
    
    for (auto i: a) {
        int j = i.second;
        if (x4 >= j / 4) {
            x4 -= j / 4;
            j = j % 4;
        }
        x2 -= j / 2;
        j = j % 2;
        x1 -= j;
    }

    if (x4 == 0 && x2 == 0 && x1 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main() {
	int n;
	cin>>n;
	int a[n];
	int dp[n+1];
	for(int i=0;i<n;i++)
	dp[i]=0;
	for(int i = 0 ; i < n ; i++)
	{
		cin>>a[i];
	}
	dp[0]=0;
	dp[1]=abs(a[0]-a[1]);
	for( int i = 2 ;i < n; i++)
	{
		dp[i]=min((dp[i-2]+abs(a[i]-a[i-2])),(dp[i-1]+abs(a[i]-a[i-1])));
	}
	cout<<dp[n-1];
	
	
}


Measured memory_bytes: 1024
#include <iostream>
#include <complex>
#include <vector>
#include <cmath>
using namespace std;
typedef complex<double> C;
#define EPS (1e-10)
#define EQ(a,b) (abs(a-b) < EPS)
#define EQV(a,b) (EQ(a.real(), b.real()) && EQ(a.imag(), b.imag()))
int n;
C s[101], e[101];
double cross(C a, C b) {
  return a.real() * b.imag() - a.imag() * b.real();
}

bool is_intersected(C& a1, C& a2, C& b1, C& b2) {
  return  cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS &&
          cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS;
}

C intersection(C& a1, C& a2, C& b1, C& b2) {
  C b = b2 - b1;
  double d1 = abs(cross(b, b1 - a1));
  double d2 = abs(cross(b, b1 - a2));
  double t = d1 / (d1 + d2);
  return a1 + (a2 - a1) * t;
}

void solve() {
  for(int i=0;i<n;i++)
  cin>>s[i].real()>>s[i].imag()>>e[i].real()>>e[i].imag();
  
  int res = 1;
  for (int i = 0; i < n; i += 1) {
    vector<C> iss;
    for (int j = 0; j < i; j += 1) {
      C ii = e[i] - s[i];
      C jj = e[j] - s[j];
      // üªª½s©
      //if (abs(cross(ii, jj)) < EPS) continue;
      // ð_ðßé
      if (!is_intersected(s[i], e[i], s[j], e[j])) continue;

      // pattern1
      C is = intersection(s[i], e[i], s[j], e[j]);
      // pattern2
      //C is2 = s[i] + ii * cross(jj, s[j]-s[i]) / cross(jj, ii);
      
      //debug
      //cout<<is.real()<<","<<is.imag()<<"|";
      //cout<<is2.real()<<","<<is2.imag()<<endl;

      // ð_ÌÀWªÍÍO©
      if (abs(is.real()) + EPS > 100.0) continue;
      if (abs(is.imag()) + EPS > 100.0) continue;
      // ùÉ¶ÝµÄ¢éð_©mF
      bool exist_flag = false;
      for (int i = 0; i < iss.size(); i += 1) {
        if (EQV(is, iss[i])) {
          exist_flag = true;
          break;
        }
      }
      // ¶ÝµÄ¢È©Á½ÌÅÇÁ
      if (!exist_flag) {
        iss.push_back(is);
      }
    }
    // ð_Ì + 1Ì¾¯ªðâ·
    res += iss.size() + 1;
  }
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

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

int fcost(vector<int> heights, int k)
{
    int n = heights.size();
    //cout<<"n: "<<n<<"\n";
    if (n < 2) return 0;
 
    vector<int> cost(n + k, numeric_limits<int>::max());
    cost[0] = 0;
 
    for (int i = 0; i < n; ++i)
    {
    	for(int j = 1; j <= k; j++)
    	{
	        cost[i + j] = min(cost[i+j], cost[i] + abs(heights[i+j] - heights[i]));
    	}
    }
    //cout<<n + k<<"cost size\n";
    
    // for(int i = 0; i < cost.size(); i++)
    // cout<<cost[i]<<"\n";
 
    return cost[n - 1];
}

int main()
{
	int n, k;
	cin>>n>>k;
	vector <int> h(n);
	for(int i = 0; i < n; i++)
	{
		cin>>h[i];
	}
	cout<<fcost(h, k)<<"\n";
	return 0;
}

Measured memory_bytes: 1408
def DP():
  n,m=map(int,input().split())
  dp=[0]*(m+2)
 
  for i in range(n):  #商品を一つずつ見ていく。
    w,v=(map(int,input().split()))
    for j in range(m+1,w,-1): #w~(限界-w)までのdpの箱に入れていく。(例)w,m=3,8なら3~5
      dp[j]=max(dp[j-w]+v,dp[j])
  return max(dp)
print(DP())

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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> T >> Q;
	if (T > Q) {
		cout << ">";
	}
	else if (T < Q) {
		cout << "<";
	}
	else {
		cout << "=";
	}
	
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
const static ll MOD = 1e9 + 7;
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;

void prob138() {
	int N; cin >> N;
	priority_queue<double,vector<double>,greater<double>> pq;
	for (int i = 0; i < N; i++) {
		double x;
		cin >> x;
		pq.push(x);
	}

	for (int i = 0; i < N - 1; i++) {
		double x = pq.top(); pq.pop();
		double y = pq.top(); pq.pop();
		double z = (x + y) / 2;
		pq.push(z);
	}

	printf("%.10lf\n", pq.top());
}

int main() {
	prob138();
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N - 1);
  for (int i = 0; i < N - 1; i++) cin >> B[i];
  A[0] = B[0];
  for (int i = 1; i < N - 1; i++) {
    A[i] = min(B[i - 1], B[i]);
  }
  A[N - 1] = B[N - 2];
  int ans = 0;
  for (int i = 0; i < N; i++) ans += A[i];
  cout << ans << endl;
}


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

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

template<typename T>
struct BIT {
    int n;
    vector<T> dat;

    BIT(int n=0){
        initialize(n);
    }

    void initialize(int nin){
        n = nin;
        dat.assign(n, 0);
    }

    T sum(int i){
        T s = 0;
        while(i >= 0){
            s += dat[i];
            i = (i & (i+1)) - 1;
        }
        return s;
    }

    T sum_between(int i, int j){
        return sum(j) - sum(i-1);
    }

    void plus(int i, T x){
        while(i < n){
            dat[i] += x;
            i |= i+1;
        }
    }

    // a[0]+...+a[ret] >= x
    int lower_bound(T x){
        if(x < 0) return -1;
        int ret = -1;
        int k = 1;
        while(2*k <= n) k <<= 1;
        for( ;k>0; k>>=1){
            if(ret+k < n && dat[ret+k] < x){
                x -= dat[ret+k];
                ret += k;
            }
        }
        return ret + 1;
    }
};

int main(){
    int N, Q;
    cin >> N >> Q;
    vector<int> C(N);
    for(int i=0; i<N; i++) cin >> C[i], C[i]--;
    vector<vector<pair<int, int>>> R2LQ(N);
    for(int i=0; i<Q; i++){
        int l, r;
        cin >> l >> r;
        R2LQ[r-1].emplace_back(l-1, i);
    }

    vector<int> last(N, -1);
    vector<int> ans(Q);

    BIT<int> bit(N);
    for(int r=0; r<N; r++){
        if(last[C[r]] >= 0) bit.plus(last[C[r]], -1);
        last[C[r]] = r;
        bit.plus(last[C[r]], 1);
        for(auto& [l, q] : R2LQ[r]) ans[q] = bit.sum_between(l, r);
    }
    for(int a : ans) cout << a << endl;
    return 0;
}


Measured memory_bytes: 33252
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

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

	ll cnt = 0;
	string T = S;
	rep(i, 0, N) {
		if (S[i] == '(') {
			cnt++;
		}
		else {
			cnt--;
			if (cnt < 0) {
				T = '(' + T;
				cnt++;
			}
		}
	}

	rep(i, 0, abs(cnt)) {
		if (cnt > 0)
		{
			T = T + ')';
		}
	}

	cout << T << endl;
}

Measured memory_bytes: 256
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1e5+10
#define mod 1e9 + 7
#define pii pair<int,int>
using namespace std;
const int N = 1e5 + 1;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
const int M = ((int)1e9 + 7);
int power(int x, int y){
    x %= M;
    int ans = 1;
    while(y){
        if(y & 1)
            ans = (ans * x) % M;
        y >>= 1LL;
        x = (x * x) % M;
    }
    return ans;
}
int add(int a, int b){
    return((a % M + b % M) % M);
}
int sub(int a, int b){
    return((a % M - b % M + M) % M);
}
int mul(int a, int b){
    return(((a % M) * (b % M)) % M);
}
int divi(int a, int b){
    return(mul(a, power(b, M - 2)) % M);
}
int powm(int a,int b,int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = ((res * a) % m);
        a = ((a * a) % m);
        b >>= 1;
    }
    return res;
}
vector<int> fact(1e5+1);
void pre(){
	fact[0] = 1;
	fact[1] = 1;
	for(int i=2;i<=1e5;i++){
		fact[i] = mul(fact[i-1] , i);
	}
}
int nCr(int n,int r){
	return mul(fact[n],divi(1,mul(fact[n-r],r)));
}
int process(int x,int n){
	return divi(mul(n,sub(n,1)),2);
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	pre();
	cin>>n;
	vector<int> v(61,0);
	for(int i=0;i<n;i++){
		cin>>a;
		for(int i=0;i<61;i++){
			if((1ll<<i)&a){
				v[i]++;
			}
		}
	}
	int ans = 0;
	for(int i=0;i<61;i++){
		ans = add(ans , mul(powm(2,i,1e9+7),sub(mul(v[i],sub(n,1)) , mul(v[i],sub(v[i],1)))));
	}
	cout<<ans;
	return 0;
}
//.........

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

int main() {
	int w, n, i, z, a, b;
	cin >> w >> n;
	vector<int> A(w);
	for (i = 0; i < w; i++) A[i] = i + 1;
	for (i = 0; i < n; i++) {
		scanf("%d,%d", &a, &b);
		z = A[a - 1];
		A[a-1] = A[b-1]; A[b-1] = z;
	}
	for (i = 0; i < w; i++) cout << A[i] << endl;
	return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
 
using namespace std;

/**************************************************************************/
int main()
{
	fastIO;
	ll t,n,i,j,k;
	cin>>n;
	ll ans = 0;
	Fo(i,1,n+1)
	{
		ll cnt = 0;
		if(i%2==0)continue;
		Fo(j,1,n+1)if(i%j==0)cnt++;
		if(cnt==8)ans++;
	}
	cout<<ans;
}/*************************************************************************/ 

Measured memory_bytes: 256
#!/usr/bin/env python

if __name__ == "__main__":
    num = int(input())
    
    AC = 0
    WA = 0
    TLE = 0
    RE = 0
    for i in range(num):
        case = input()
        if case == "AC":
            AC+=1
        if case == "WA":
            WA+=1
        if case == "TLE":
            TLE+=1
        if case == "RE":
            RE+=1
        
    print("AC x "+str(AC))
    print("WA x "+str(WA))
    print("TLE x "+str(TLE))
    print("RE x "+str(RE))
    

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


def solve(X: int):
    N = [0] * (X+1)
    for i in range(100, X+1):
        if 100 <= i <= 105:
            N[i] = 1
        else:
            s = sum(N[i-105:i-99])
            if s:
                N[i] = 1
    print(N[X])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


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

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int maxN = 711;

int n, m, i, j, x, y, S, D;
vector<int> list[maxN];

int cnt_S, cnt_D;
int assoc[maxN];
int from_S[maxN], from_D[maxN];
int last_S, last_D;
vector< pair<int, int> > data;
vector<int> knap;
int bonus;

bool possib[maxN];

int cnt_edges(int x) {
    return (x * (x - 1)) / 2;
}

void solve() {
    int i, j;

    cnt_S = 1;
    assoc[1] = 1;
    for (auto e : list[1]) from_S[e]++;
   

    bool any = true;
    while (any) {
        any = false;

        for (i = 1; i <= n; i++) {
            if (assoc[i]) continue;
            if (cnt_S == from_S[i] && cnt_D == from_D[i]) continue;
            if (cnt_S != from_S[i] && cnt_D != from_D[i]) {
                cout << -1;
                exit(0);
            }

            if (cnt_S == from_S[i]) {
                cnt_S++;
                assoc[i] = 1;
                for (auto e : list[i]) from_S[e]++;
                any = true;
        
                //cerr << i << " to RED1" << '\n';
                break;
            }

            if (cnt_D == from_D[i]) {
                cnt_D++;
                assoc[i] = 2;
                for (auto e : list[i]) from_D[e]++;
                any = true;

                //cerr << i << " to BLUE2\n";
                break;
            }
        }

        //for (i = 1; i <= n; i++) cerr << assoc[i] << ' ';
        //cerr << '\n';

        if (any) continue;

        data.pb(mp(cnt_S - last_S, cnt_D - last_D));
        last_S = cnt_S;
        last_D = cnt_D;

        for (i = 1; assoc[i] && i <= n; i++);
        if (i > n) break;

        cnt_S++;
        assoc[i] = 1;
        for (auto e : list[i]) from_S[e]++;
        any = true;

        //cerr << i << " to forced RED1\n";
    }
    
    for (auto e : data) {
        bonus += min(e.first, e.second);
        knap.pb(max(e.first, e.second) - min(e.first, e.second));
        if (knap.back() == 0) knap.pop_back();
    }

    possib[0] = true;
    for (auto e : knap) {
        for (j = n - e; j >= 0; j--)
            possib[j + e] |= possib[j];
    }

    int sol = cnt_edges(n); 
    for (i = 0; i <= n; i++) {
        if (!possib[i]) continue;
        sol = min(sol, cnt_edges(bonus + i) + cnt_edges(n - (bonus + i)));
    }

    cout << sol;
}

int main()
{
   // freopen("test.in","r",stdin);

    scanf("%d%d", &n, &m);
    for (i = 1; i <= m; i++) {
        scanf("%d%d", &x, &y);
        list[x].pb(y);
        list[y].pb(x);
    }

    if (m == cnt_edges(n)) {
        cout << cnt_edges(n / 2) + cnt_edges((n + 1) / 2);
        return 0;
    }

    solve();

    return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<int>v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  sort(v.begin(),v.end());
  
  long long a=0,b=0;
  
  for(int i=n-1;i>=1;i--){
    if(v[i]==v[i-1]){
      if(a==0)a=v[i];
      else if(b==0)b=v[i];
      else break;
      i--;
    }
  }
  cout<<a*b<<endl;
}


Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

constexpr int INF = 1e8;
constexpr int MOD = 1e9+7;

int main(void) {
    int a, b;
    while (cin >> a >> b) {
        cout << to_string(a+b).size() << endl;
    }
    return 0;
}

Measured memory_bytes: 3208