akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;cin>>s;
  ll n = s.size();
  for(int i=1;i<n;i++){
    if((n-i)%2)continue;
    bool fl = true;
    for(int j=0;j<(n-i)/2;j++){
      if(s[j] != s[j+(n-i)/2])fl  =false;
    }
    if(fl){
      cout<<n-i<<endl;
      return 0;
    }
  }

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int max(int W,int R)
{
  return (W >= R) ? W : R;
}

int array_min(int array[],int e)
{
  int min = array[0];
  
  for(int i=1; i<e; i++)
    if(min > array[i])
      min = array[i];
  
  return min;
}

int main(void)
{
  int n;
  int left_w = 0,right_r=0;
  
  scanf("%d",&n);
  char c[n];
  int maxs[n+1];
  scanf("%s",c);
  
  for(int i=0; i<n; i++){
    if(c[i] == 'R')
      right_r++;
  }
  
  maxs[0] = max(left_w,right_r);
    
  for(int i=0; i<n; i++){
    if(c[i] == 'W')
      left_w++;
    else
      right_r--;
    
    maxs[i+1] = max(left_w,right_r);
  }
  
  printf("%d\n",array_min(maxs,n+1));
  
  return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<algorithm>
#include<bitset>
using namespace std;
long long func(long long x) {
    if(x%4==0) {
      return x;
    }
    else if(x%4==1) {
      return 1;
    }
    else if(x%4==2) {
      return x+1;
    }
    else {
      return 0;
    }
  }
int main() {
  long long a,b;
  cin >> a >> b;
  cout << (func(a-1)^func(b)) << endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<long> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    for (int i = h.size() - 1; i > 0; i--) {
        if (h[i - 1] - h[i] > 1) {
            cout << "No" << endl;
            return 0;
        } else if (h[i - 1] - h[i] == 1) {
            h[i - 1]--;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
//作者:中国江苏南京丁天行
//from CrAzYUnIoN
//I prefer being hacked to being FST
using namespace std;
//数组不要开小了
char a[55][55],b[55][55];
int n,m;
bool ok;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++)scanf(" %c",a[i]+j);
    }
    for(int i=1;i<=m;i++){
            for(int j=1;j<=m;j++)scanf(" %c",b[i]+j);
    }
    for(int i=1;i<=n-m+1;i++){
            for(int j=1;j<=n-m+1;j++){
                    bool o=1;
                    for(int x=0;x<m;x++){
                            for(int y=0;y<m;y++)if(a[i+x][j+y]!=b[x+1][y+1])o=0;
                    }
                    if(o)ok=1,i=n,j=n;
            }
    }
    if(ok)puts("Yes");
    else puts("No");
	//system("pause");
	return 0;
}


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

int main(){
  int h,w,d;
  cin>>h>>w>>d;
  vector<pair<int,int>> a(h*w);
  rep(i,h)rep(j,w){
    int x;
    cin>>x;
    a[x-1]={i,j};
  }
  
  vector<int> c(h*w);
  rep(i,h*w){
    if(i>=d) c[i]=c[i-d]+abs(a[i-d].first-a[i].first)
                 +abs(a[i-d].second-a[i].second);
  }  
  int q;
  cin>>q;
  rep(i,q){
    int l,r;
    cin>>l>>r;
    l--; r--;
    cout<<c[r]-c[l]<<endl;
  }
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef pair<int, bool> ib;

#define FOR(a, b, c) for(int a = b; a < c; ++a)
#define RFOR(a, b, c) for(int a = b; a >= c; --a)
#define mp(a, b) make_pair(a, b)
#define all(v) v.begin(), v.end()

#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define vb vector<bool>
#define fst first
#define snd second
#define MAXN 310
#define MAXM 44100
#define LOGMAXN 20
#define INF 1000000007
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007LL


int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, k, q;
	while(cin >> n >> k >> q)
	{
		vi freq(n, k);
		FOR(i, 0, q)
		{
			int a;
			cin >> a;
			a--;
			freq[a]++;
		}
		FOR(i, 0, n)
		{
			if(freq[i] - q > 0)
				printf("Yes\n");
			else
				printf("No\n");
		}
	}
	return 0;
}


Measured memory_bytes: 1024
import copy
import time
t1 = time.time()

def calc(T):
    res = 0
    L = [0]*26
    for i in range(D):
        res += S[i][T[i]-1]
        L[T[i]-1] = i+1
        for j in range(26):
            res -= C[j]*(i+1-L[j])
    return res

D = int(input())
C = [int(c) for c in input().split()]
S = [[int(s) for s in input().split()] for _ in range(D)]

T = [0]*D
for i in range(D):
    temp = -1
    for j in range(26):
        if temp < S[i][j]:
            temp = S[i][j]
            idx = j+1
    T[i] = idx

T2 = [0]*D
L = [0]*26
for i in range(D):
    p = -10**15
    for j in range(26):
        d = S[i][j]
        for k in range(26):
            if k == j:
                continue
            d -= C[k]*(i+1-L[k])
        if p < d:
            p = d
            idx = j+1
    T2[i] = idx

p1 = calc(T)
p2 = calc(T2)
if p2 > p1:
    T = copy.deepcopy(T2)
    p = p2
else:
    p = p1

import random
while time.time()-t1 < 1.2:
    i = random.randint(0, D-1)
    for j in range(26):
        temp = copy.deepcopy(T)
        temp[i] = j+1
        newp = calc(temp)
        if p < newp:
            T[i] = j+1
            p = newp

i = 0
next = 1
while time.time()-t1 < 1.9:
    for j in range(26):
        temp = copy.deepcopy(T)
        temp[i] = j+1
        newp = calc(temp)
        if p < newp:
            T[i] = j+1
            p = newp
    i += next
    if i == -1:
        i = 1
        next = 1
    elif i == D:
        i = D-2
        next = -1

for t in T:
    print(t)

Measured memory_bytes: 86964
#include<stdio.h>
#include<string.h>
#include<math.h>
 
 
int main(){
   int n,m;
   scanf("%d %d", &n,&m);
   if(n==m){
     printf("Yes");
   } else{
    	printf("No"); 
   }
	return 0;
 
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
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 long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long MOD = 1'000'000'007LL;
const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


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

	ll N, T; scanf("%lld %lld", &N, &T);
	ll MAX = 100500;
	vector<ll> t(MAX);
	for (ll i = 0; i < N; i++) {
		ll l, r; scanf("%lld %lld", &l, &r);
		t[l]++; t[r]--;
	}
	ll now = 0;
	ll res = 0;
	for (ll i = 0; i < MAX; i++) {
		now += t[i];
		chmax(res, now);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>

int main() {
	int N;
	int A[3010];

	std::cin >> N;

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

	long long ans = 0;

	for (int i = 0; i < N; i++)
		ans += (A[i] - 1);

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy

def main():
	num = int(input())
	
	clocks = []
	for _ in range(num):
		clock = int(input())
		clocks.append(clock)
		
	ans = 1
	for clock in clocks:
		ans = lcm(ans, clock)
	print(ans)
			
def gcd(a, b):
	if a > b:
		a, b = b, a
		
	while a > 0:
		a, b = b % a, a
	return b
	
def lcm(a, b):
	g = gcd(a, b)
	return a // g * b
	
if __name__ == "__main__":
	main()
	

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

int main() {
	int A, B, C;
	std::cin >> A >> B >> C;
	int K;
	std::cin >> K;
	for (int i = 0; i < K; i++) {
		int M = std::max(A, std::max(B, C));
		if (M == A) {
			A *= 2;
		}
		else if (M == B) {
			B *= 2;
		}
		else if (M == C) {
			C *= 2;
		}
		M *= 2;
	}
	std::cout << A + B + C << std::endl;
}

Measured memory_bytes: 256
n = raw_input()

A = map(int, raw_input().split())

for i, key in enumerate(A):

    j = i - 1

    while(j >= 0 and A[j] > key):
        A[j+1] = A[j]
        j -= 1

    A[j+1] = key

    for x in A:
        print x,
    print

Measured memory_bytes: 4204
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define FOR(a,b,c) for(int a = (b); a <= (c); a++)
#define RFOR(a,b,c) for(int a = (b); a >= (c); a--)
#define all(x) (x).begin(), (x).end()
#define vi vector <int>
#define vvi vector <vi>
#define ll long long
#define vll vector <ll>
#define vvl vector <vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ep emplace
#define fs first
#define sd second
using namespace std;

int main() {
	FIO;
	int a, b; cin >> a >> b;
	FOR(i, 1, 10000) {
		int x = (int)(i * 0.08);
		int y = (int)(i * 0.1);
		if (x == a && y == b) return cout << i << '\n', 0;
	}
	cout << -1 << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k,a,b,ans=0;
    cin>>k>>a>>b;
    ll diff=b-a;
    if(a+2>=b||k-a<1)
        {cout<<1+k<<endl;return 0;}
    else
    {
        k -= a - 1;
        ll ans = a;
        if(k % 2 == 1)ans++, k--;
        ans += (b - a) * (k / 2);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) a.begin(), a.end()
typedef long long int ll;
using namespace std;

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

    int n;
    cin >> n;

    for (int i = n / 7; i >= 0; i--) {
        for (int j = 0; j <= n / 4; j++) {
            int sum = 7 * i + 4 * j;
            if (sum == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+100;
int mem[N],num1,pown[N],pown1[N];
char s[N];
int f(int x)
{
	if(x==0)return 0;
	if(mem[x])return mem[x];
	int t=x,cnt=0;
	while(t)cnt+=(t&1),t>>=1;
	return mem[x]=f(x%cnt)+1;
}
int main()
{
	int n,modn=0,modn1=0;
	scanf("%d%s",&n,s);
	for(int i=0;i<n;i++)if(s[i]=='1')num1++;
	pown[0]=1%(num1+1);
	if(num1-1)pown1[0]=1%(num1-1);
	for(int i=1;i<=n;i++)
	{
		pown[i]=pown[i-1]*2%(num1+1);
		if(num1-1)pown1[i]=pown1[i-1]*2%(num1-1);
	}
	for(int i=0;i<n;i++)
	{
		modn=(modn*2+s[i]-'0')%(num1+1);
		if(num1-1)modn1=(modn1*2+s[i]-'0')%(num1-1);
	}
	for(int i=0;i<n;i++)
	{
		if(s[i]=='0')
		{
			int t=(modn+pown[n-i-1])%(num1+1);
			printf("%d\n",f(t)+1);
		}
		else
		{
			if(num1==1)printf("0\n");
			else
			{
				int t=(modn1-pown1[n-i-1]+num1-1)%(num1-1);
				printf("%d\n",f(t)+1);
			}

		}
	}
	return 0;
}


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

int main() {
  string s;
  cin  >> s;
  if (s.at(0) == s.at(1)) {
    if (s.at(1) == s.at(2)) {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
  else {
    cout << "Yes" << endl;
  }
  return 0;
}


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

const int MOD = 1000000007;

int main(){
	int n,T;
	cin>>n>>T;
	vector<int> v(n);
	for(int i=0;i<n;i++) cin>>v[i];
	sort(v.begin(),v.end());
	int p = 0;
	vector<long long> dp(n+1);
	dp[0] = 1;
	for(int i=0;i<n;i++){
		while(p < n && v[p]-v[i]<=T) p++;
		dp[i+1] = dp[i] * (p-i) % MOD;
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=998244353;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		int[][][] dp=new int[n+1][][];
		dp[0]=new int[1][];
		dp[0][0]=new int[]{1,0,0,0};
		int m=0;
		long p=0;
		long[][] dp2=new long[n+1][];
		dp2[0]=new long[]{1,0,0,0};
		for(int i=0;i<n;i++){
			int a=sc.I;
			dp[i+1]=new int[m+a+1][];
			for(int j=0;j<a;j++){dp[i+1][j]=new int[4];}
			for(int j=0;j<=m;j++){
				dp[i+1][j+a]=new int[4];
				for(int k=0;k<4;k++){
					dp[i+1][j+a][k]=(dp[i+1][j+a][k]+dp[i][j][k])%mod;
					dp[i+1][j][k|1]=(dp[i+1][j][k|1]+dp[i][j][k])%mod;
					dp[i+1][j][k|2]=(dp[i+1][j][k|2]+dp[i][j][k])%mod;
				}
			}
			m+=a;
			dp2[i+1]=new long[4];
			for(int j=1;j<=3;j++){dp2[i+1][j]=(((dp2[i][j]*j)%mod)+((dp2[i][j-1]*j)%mod))%mod;}
		}
		for(int j=m/2+(m%2);j<=m;j++){p=(p+dp[n][j][3])%mod;}
		Console.WriteLine("{0}",(dp2[n][3]-((p*3)%mod)+mod)%mod);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef set<ll> si;
typedef map<string, ll> msi;
#define hell 1000000007
#define MAX 1000000000
#define max_int 1000000
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define pi 3.1415926536
#define r0 return 0
#define rep(i,a,b) for(ll i = a;i<b;i++)

// void solve() 
// {


//     return;
// }

ll binpow(ll a, ll b) 
{
    if (b == 0)
        return 1;
    ll res = binpow(a, b / 2);
    if (b % 2)
        return res*res*a;
    else
        return res*res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    // int t=1;
    // cin>>t;
    // while(t--)
    // {
    //     solve();     
    // }

    ll x;
    cin>>x;
    int i=1;
    ll ans=100;
    while(ans<x)
    {
        ans*=1.01;
        i++;
    }
    cout<<i-1;



}
 

Measured memory_bytes: 3648
def card_game_for_two(N: int, A: list) -> int:
    sorted_A = sorted(A, key=lambda x: - x)
    alice = sum(a for i, a in enumerate(sorted_A) if i % 2 == 0)
    bob = sum(a for i, a in enumerate(sorted_A) if i % 2 == 1)
    return alice - bob


if __name__ == "__main__":
    N = int(input())
    A = map(int, input().split())
    ans = card_game_for_two(N, A)
    print(ans)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1LL<<59)

#define int ll

#define MAX_V 1000

struct edge{int to,cost;};
vector<edge> G[MAX_V];

int shortest_path(int s,vector<int> &d){
    int v = d.size();
    rep(i,d.size())d[i]=INF;
    d[s]=0;
    rep(loop,v*3){
        bool update = false;
        rep(i,MAX_V){
            for(auto e:G[i]){
                if(d[i]<INF/2 && d[e.to] > d[i]+e.cost){
                    if(loop>=v-1 && e.to==v-1)return true;
                    d[e.to] = d[i]+e.cost;
                    update = true;
                }
            }
        }
        if(!update)break;
    }
    return false;
}

signed main(){
    int v,e;
    cin>>v>>e;
    rep(i,e){
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        G[a].pb(edge{b,-c});
    }
    vector<int> d(v);
    bool f=shortest_path(0,d);
    if(d[v-1]>=INF/2||f)cout<<"inf"<<endl;
    else cout<<-d[v-1]<<endl;
}



Measured memory_bytes: 384
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int p0=0, p1=0;
		
		for(int i=0; i<n; i++)
		{
			String in0 = scanner.next();
			String in1 = scanner.next();
			
			if(in0.compareTo(in1) == 0)
			{
				p0 += 1;
				p1 += 1;
			}
			else if(in0.compareTo(in1) > 0)
			{
				p0 += 3;
			}
			else 
			{
				p1 += 3;
			}
		}
		System.out.println(p0+" "+p1);
	}
}

Measured memory_bytes: 30236
#include <stdio.h>
int main(void){
	int n,m,i,ans[50]={0};
	scanf("%d%d",&n,&m);
	int road[m][2];
	for(i=0;i<m;i++){
		scanf("%d%d",&road[i][0],&road[i][1]);
		ans[road[i][0]-1]++;
		ans[road[i][1]-1]++;
	}
	for(i=0;i<n;i++){printf("%d\n",ans[i]);}
	return 0;
}

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

typedef long long ll;
typedef long double ld;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=0;i<10;i++)
	{
		int temp=c*a-b;
		cout<<temp<<"\n";
		c=temp;
	}
			
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<utility>
#define ll long long
#define fr first
#define sd second

using namespace std;

struct Node
{
    int data;
    struct Node* left;
    struct Node* right;
    Node(int x) {
        data =x;
        left=NULL;
        right=NULL;
    }
};

#define Node struct Node

int dp[100005];
int calc(int a[], int i, int k)
{
    if(i==0)
        return dp[i]=0;
    int temp=INT_MAX;
    for(int j=1;j<=k;j++)
    {
        if(i-j>=0)
        {
            if(dp[i-j]==-1)
                dp[i-j]=calc(a,i-j,k);
            temp=min(temp,abs(a[i]-a[i-j])+dp[i-j]);
        }
    }
    return dp[i]=temp;
}

int main()
{
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        memset(dp,-1,sizeof(dp));
        cout<<calc(a,n-1,k)<<endl;
    }
}











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

int main()
{
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;

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

    vector<vector<vector<int>>> dp(N + 1, vector<vector<int>>(500, vector<int>(500, 10000)));
    dp[0][0][0] = 0;

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 500; j++)
        {
            for (int k = 0; k < 500; k++)
            {
                if (dp[i][j][k] == 10000)
                {
                    continue;
                }
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
                dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
            }
        }
    }

    int ans = 10000;
    for (int i = 1; i < 500; i++)
    {
        for (int j = 1; j < 500; j++)
        {
            if (i * Mb == j * Ma)
            {
                ans = min(ans, dp[N][i][j]);
            }
        }
    }
    if (ans == 10000)
    {
        ans = -1;
    }
    cout << ans << endl;
}


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

const int nmax=1e5+10;
int check[nmax];
int prime[nmax];
void prim()
{
    check[1]=1;
    int tot=0;

    for(int i=2;i<nmax;i++)
    {

       if(!check[i])
        {
            prime[tot++]=i;
        }

        for(int j=0;j<tot;j++)
        {
            if(i*prime[j]>nmax)
            {
                break;
            }
            check[i*prime[j]]=1;
            if(i%prime[j]==0)
                break;
        }
    }
}

int main()
{
    prim();
    int sum=0;
    int result[nmax];
    for(int i=1;i<nmax;i++)
    {
        if(i%2==1)
        {
            if(check[i]==0&&check[(i+1)/2]==0)
                sum++;
        }
        result[i]=sum;
    }
    int n;
    int l,r;
    cin>>n;
    while(n--)
    {
        cin>>l>>r;
        cout<<result[r]-result[l-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1408
from itertools import product
n, m = map(int, input().split())
ls = []
for _ in range(m):
    k, *s, = map(lambda x: int(x)-1, input().split())
    ls.append(s)
p = list(map(int, input().split()))
it = ["01"]*n

ans = 0
for b in product(*it):
    base_2 = "".join(b)
    for j in range(m):
        switchs = ls[j]
        cond = p[j]
        on_cnt = 0
        for switch in switchs:
            if int(base_2[switch]):
                on_cnt += 1
        if on_cnt % 2 != cond:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064
from sys import stdin
n,d = map(int, stdin.readline().rstrip().split())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]

count =0
for i in range(0,n):
    if x[i]**2 + y[i]**2 <= d**2:
        count += 1

print(count)


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

using namespace std;
#define ll long long
ll dp[3005][3005];//dp[i][j] -> we get j heads from first i coins 

int main(){
  int n;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++){
  	cin>>a[i];
    dp[i][i]=a[i];
  }
  for(int i=n-1;i>=0;--i){
  	for(int j=i+1;j<n;++j){
    	dp[i][j] = max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
    }
  }
  cout<<dp[0][n-1];
  return 0;
}

Measured memory_bytes: 70016
gets
a = gets.split(" ").map(&:to_i)

count = 0

x = 0
a.size.times do |i|
    x = i
    
    (i...a.size).each do |j|
        if a[j] < a[x] then
            x = j
        end
    end

    if i != x then
        a[i], a[x] = a[x], a[i]
        count += 1
    end
end

print a.join(" "), "\n"
print count, "\n"



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

int rec(vector<vector<int>>& s, vector<int>& p, vector<int>&sw, int n)
{
    if (n == sw.size()) {
        for (int i = 0; i < p.size(); i++) {
            int on = 0;
            for (int j = 0; j < s[i].size(); j++) {
                if (sw[s[i][j] - 1]) {
                    on++;
                }
            }
            if (p[i] != on % 2) {
                return 0;
            }
        }
        return 1;
    }
    int ans = 0;
    ans += rec(s, p, sw, n + 1);
    sw[n] = 1;
    ans += rec(s, p, sw, n + 1);
    sw[n] = 0;
    return ans;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m, vector<int>());
    for (int i = 0; i < m; i++) {
        int k;
        cin >> k;
        s[i].assign(k, 0);
        for (int j = 0; j < k; j++) {
            cin >> s[i][j];
        }
    }
    vector<int> p(m);
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }
    vector<int> sw(n);
    int ans = rec(s, p, sw, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)

int toNum(int nums[], int n)
{
  int res=0;
  for(int i=0; i<n; i++){
    res+= nums[n-i-1] * pow(10.0,i);
  }
  return res;
}

int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(6);

  int n;
  string str;

  cin >> n;
  REP(i,n){
    cin >> str;
    int nums[str.size()];
    REP(j,str.size()){
      nums[j] = str[j]-'0';
    }
    sort(nums, nums+str.size());
    int min=toNum(nums, str.size());
    sort(nums, nums+str.size(), greater<int>() );
    int max=toNum(nums, str.size());

    cout << max - min << endl;
  }

  return 0;
}

Measured memory_bytes: 1224
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<complex>
#include<deque>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,b,a) for(int i=b;i>=a;--i)
#define gcd(a,b) __gcd(a,b)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=1e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
ll a,b,c;
int main(){
	cin>>a>>b>>c;
	if(c-a-b>0&&4*a*b<(c-a-b)*(c-a-b))puts("Yes");
	else puts("No");
	return 0;
}


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

public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		List<String> result = new ArrayList<String>();
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				String str = stdIn.next();
				String[] s = str.split(",");
				int[] card = new int[14];
				for(int i = 0; i < s.length; i++){
					card[Integer.parseInt(s[i])-1]++;
				}
				card[13] = card[0];
				int zero = 0;
				int max = 0;
				int countMax = 1;
				int count = 1;
				for(int i = 0; i < 13; i++){
					if( card[i] == 0 ){
						zero++;
					}
					if( card[i] > max ){
						max = card[i];
					}
				}
				if( max == 1 ){
					for(int i = 0; i < 13; i++){
						if( card[i] == 1 && card[i+1] == 1 ){
							count++;
							if( countMax < count ){
								countMax = count;
							}
						}
						if( card[i] == 0 ){
							count = 1;
						}
					}
				}
				
				if( max == 4 ){
					 result.add("four card");
				} else if( max == 3 ){
					if( zero == 11 ){
						result.add("full house");
					} else {
						result.add("three card");
					}
				} else if( max == 2 ){
					if( zero == 10 ){
						result.add("two pair");
					} else {
						result.add("one pair");
					}
				} else if( countMax == 5 ){
					result.add("straight");
				} else {
					result.add("null");
				}
			}
			for(String str : result){
				System.out.println(str);
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

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

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, a;
    cin >> x >> a;
    if(x < a) cout << '0' << endl;
    else{
        cout << "10" << endl;
    }


}









Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,dp[2005][2005];
const ll mod=1e9+7;
int main(){
	for(int i=0;i<2005;i++){
		dp[i][0]=1;
		for(int j=1;j<=i;j++)
			dp[i][j]=(dp[i-1][j]+dp[i-1][j-1])%mod;
	}
	cin >> n >> k;
	for(int i=1;i<=k;i++)
		cout << (dp[k-1][i-1]*dp[n-k+1][i])%mod << endl;
    return 0;
}

Measured memory_bytes: 30208
#include <stdio.h>
#define MAX 10001
#define NIL -1
typedef struct node{
    int parent;
    int left;
    int right;
}Node;



Node T[MAX];
int n,D[MAX],H[MAX];
 
void setDepth(int u,int d){
    if(u == NIL)
        return;
    D[u]=d;
    setDepth(T[u].left,d+1);
    setDepth(T[u].right,d+1);
}



int setHeight(int u){
    int h1=0,h2=0;
    if(T[u].left != NIL)
        h1=setHeight(T[u].left)+1;
    if(T[u].right != NIL)
        h2=setHeight(T[u].right)+1;
    return H[u]=(h1>h2?h1:h2);
}



int getSibling(int u){
    if(T[u].parent == NIL)
        return NIL;
    if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
        return T[T[u].parent].left;
    if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
        return T[T[u].parent].right;
    return NIL;
}
 
void print(int u){
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ",getSibling(u));
    int deg=0;
    if(T[u].left != NIL)
        deg++;
    if(T[u].right != NIL)
        deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);


    
    if(T[u].parent == NIL)
        printf("root\n");
    else if(T[u].left == NIL && T[u].right == NIL)
        printf("leaf\n");
    else
        printf("internal node\n");
}
 
int main(void){
    int v,l,r,root=0,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        T[i].parent=NIL;
    for(i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].left=l;
        T[v].right=r;
        if(l != NIL)
            T[l].parent=v;
        if(r != NIL)
            T[r].parent=v;
    }
    for(i=0;i<n;i++)
        if(T[i].parent == NIL)
            root=i;
    setDepth(root,0);
    setHeight(root);
    for(i=0;i<n;i++)
        print(i);
    return 0;
}



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

using namespace std;

int main()
{
    int n, temp=0;

    cin>>n;

    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
            if(i*j==n){
                temp++;
                }
            }
    }

    if(temp>0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

int n;
ll a[200010];

int main() {
    cin >> n;
    rep(i, n) cin >> a[i+1];

    if (n % 2 == 0) {
        for (int i = n; i >= 2; i -= 2) {
            cout << a[i] << ' ';
        }
        for (int i = 1; i <= n - 1; i += 2) {
            cout << a[i] << ' ';
        }
    } else {
        for (int i = n; i >= 1; i -= 2) {
            cout << a[i] << ' ';
        }
        for (int i = 2; i <= n - 1; i += 2) {
            cout << a[i] << ' ';
        }
    }
    cout << endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
   ll x;cin >>x;
   ll mx=1;
    for (ll i = 2; i <=x; ++i) {
        ll k=i*i;
        while(k<=x){
            mx=max(mx,k);
            k*=i;
        }
    }
    cout <<mx<<endl;
}


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

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

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> V(N);
  vector P(N, 0);
  for (int i = 0, x, y; cin >> x >> y; i++) {
    V.at(i) = {x, y};
    cin >> P.at(i);
  }

  int M = 1 << N;
  vector X(M, vector(N, 0));
  auto Y = X;
  for (int m = 0; m < M; m++) {
    for (int i = 0; i < N; i++) {
      auto [x, y] = V.at(i);
      X.at(m).at(i) = abs(x);
      Y.at(m).at(i) = abs(y);
      for (int j = 0; j < N; j++) {
        if (m >> j & 1) {
          auto [x2, y2] = V.at(j);
          chmin(X.at(m).at(i), abs(x - x2));
          chmin(Y.at(m).at(i), abs(y - y2));
        }
      }
    }
  }

  vector ans(N + 1, LONG_MAX);
  for (int m = 0; m < M; m++) {
    int cnt = __builtin_popcount(m);
    for (int i = m; i >= 0; i--) {
      i &= m;
      long tmp = 0;
      for (int j = 0; j < N; j++) {
        if (!(m >> j & 1)) {
          tmp += (long) min(X.at(i).at(j), Y.at(m - i).at(j)) * P.at(j);
        }
      }
      chmin(ans.at(cnt), tmp);
    }
  }
  for (auto a : ans) cout << a << "\n";
}

Measured memory_bytes: 9848
import heapq


n = int(input())
a = list(map(int, input().split()))

cnt = 0
while True:
    max_a = max(a)
    max_ind = a.index(max_a)
    if max_a <= n-1:
        break
    decrease = max_a // n
    max_a = max_a % n
    for i in range(n):
        if i == max_ind:
            a[i] = max_a
        else:
            a[i] += decrease
    cnt += decrease
    
    min_a = min(a)
    min_ind = a.index(min_a)    
    if min_a <= n-1:
        continue
    decrease = min_a - (n - 1)
    for i in range(n):
        a[i] -= decrease
    cnt += decrease * n

print(cnt)

Measured memory_bytes: 3188
//Harjot Singh Student NIT JALANDHAR	

#include<bits/stdc++.h>
using namespace std;

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

typedef int ll;

int main()
{
    

    ll n=0;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++)
    	cin>>arr[i];
    ll dp[n];
    dp[1]=abs(arr[1]-arr[0]);
    dp[0]=0;
    for(int i=2;i<n;i++)
    {
    	dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);

    }
    cout<<dp[n-1]<<endl;
  
  	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define eps LDBL_EPSILON
#define moder 1000000007
#define double long double
#define INF intONG_MAX/10000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	int n;
	cin >> n;
	cout << (n - 2) * 180 << endl;
	return 0;
}

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

int cnt[501];

int main()
{
	int n;
	while (cin >> n, n) {
		fill(cnt, cnt + 501, 0);
		int p = 0;
		cnt[p] = 1;
		for (int i = 0; i < n; i++) {
			string w;
			cin >> w;
			p += w.size();
			cnt[p] = i + 2;
		}
		vector<int> v = { 5, 7, 5, 7, 7 };
		vector<int> sum(6);
		for (int i = 0; i < 5; i++) {
			sum[i + 1] = sum[i] + v[i];
		}
		for (int i = 0; i <= 400; i++) {
			bool ok = true;
			for (int j = 0; j < 6; j++) {
				ok &= cnt[i + sum[j]] > 0;
			}
			if (ok) {
				cout << cnt[i] << endl;
				break;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define int long long

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n, k;
string s;

signed main()
{
    cin >> n >> k;
    cin >> s;

    if (s[k-1] == 'A') s[k-1] = 'a';
    if (s[k-1] == 'B') s[k-1] = 'b';
    if (s[k-1] == 'C') s[k-1] = 'c';

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m;
int f[100004],h[100004];
int F(int x){
	if(f[x]==x)return x;
	int pa=F(f[x]);
	h[x]+=h[f[x]],f[x]=pa;
	return f[x];
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)f[i]=i;
	for(int i=1;i<=m;i++){
		int L,R,D;scanf("%d%d%d",&L,&R,&D);
		int l=F(L),r=F(R);
		if(l==r){
			if(h[R]-h[L]!=D){
				puts("No");
				return 0;
			}
		}else{
			f[r]=l;
			h[r]=D+h[L]-h[R];
		}
	}
	puts("Yes");
}

Measured memory_bytes: 4532
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "vector"
#include "string"
#include "map"
#include "algorithm"
#include "functional"
#include "set"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;



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

	cin >> N;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2)ans -= v[i];
		else ans += v[i];
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 200005;
const ll mod = 1000000007;

ll fac[N], ifac[N], inv[N];

void pre(){
	fac[0] = fac[1] = ifac[0] = ifac[1] = inv[1] = 1;
	for(int i = 2; i < N; i++){
		fac[i] = (fac[i - 1]*i)%mod;
		inv[i] = (mod - mod/i)*inv[mod%i]%mod;
		ifac[i] = (ifac[i - 1]*inv[i])%mod;
	}
}

inline ll ncr(int n, int r){
	if(r < 0 || r > n)return 0;
	return fac[n]*(ifac[r]*ifac[n - r]%mod)%mod;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	pre();
	int h, w, a, b;
	cin>>h>>w>>a>>b;
	ll ans = 0;
	for(int i = b + 1; i <= w; i++){
		// (1, 1) -> (h - a, i) --- (h - a + 1, i) -> (h, w);
		ll tmp = ncr(h - a + i - 2, i - 1)*ncr(a - 1 + w - i, w - i)%mod;
		ans += tmp; if(ans >= mod)ans -= mod;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;


int main(){
    int R[MAX], n;

    cin >> n;
    for(int i = 0; i < n; i++) cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for(int i = 1; i < n; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}



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

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    string a;
   	ll b =0 ;
   	ll c = 0; 
    cin >> a;
    for (int z=0;z<a.size();z++){
    	if (a[z] == '0')b++;
    	else c++;
    }
    cout << min(c,b)*2 << endl;
    cin >> a;
}

Measured memory_bytes: 512
N=int(input())
S=input()

cs=0
mincs=1000
enc={'(':1,')':-1}

for c in S:
    cs+=enc[c]
    mincs=min(mincs,cs)

while mincs<0:
    S='('+S
    mincs+=1
    cs+=1

while cs>0:
    S=S+')'
    cs-=1

print(S)


Measured memory_bytes: 38384
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip> 
#include<map>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
ll gcd(ll a, ll b){
    return b?gcd(b,a%b):a;
}
ll lcm(ll a, ll b){
    return a/gcd(a,b)*b;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll t;
    while (cin >> t)
    {
        if(t%10==7||t/10%10==7||t/100==7)cout<<"Yes\n";
        else cout<<"No\n";
    }
}



Measured memory_bytes: 3652
(defun ans (s)
   (setq s (sort s #'string<))
   (if (and (equal (aref s 0) (aref s 1))
            (equal (aref s 2) (aref s 3))
            (not (equal (aref s 1) (aref s 2))))
       "Yes"
       "No"))

(format t "~a~%" (ans (read-line)))

Measured memory_bytes: 3944
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for(long long i = (n-1);i>=0;i--)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n,m;
  cin >> n >> m;
  
  int x[n],y[m];
  REP(i,n){
    cin >> x[i];
  }
  
  REP(i,m){
    cin >> y[i];
  }
  
  ll sumx = 0;
  REP(i,n){
    sumx += i*x[i]-(n-i-1)*x[i];
    sumx %= MOD;
  }
  
  ll sumy = 0;
  REP(i,m){
    sumy += i*y[i]-(m-i-1)*y[i];
    sumy %= MOD;
  }
  
  cout << sumx*sumy%MOD << endl;
  
  return 0;
  
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    int n;
    cin>>n;
    ll ans=1;
    for(int i=1;i<=n;i++)
    {
        ans*=i;
        ans%=MOD;
    }
    cout<<ans;
  }  
  return 0;
}

Measured memory_bytes: 256
N,M,C=map(int,input().split())
B = list(map(int,input().split()))
As=[]
for i in range(N):
  As.append(list(map(int,input().split())))
co = 0
for i in range(N):
  d = 0
  for j in range(M):
    d+= As[i][j]*B[j]
  d+=C
  if d > 0:
    co+=1
print(co)

Measured memory_bytes: 9124
#include<stdio.h>
int main()
{
	char a, b;
	scanf("%c %c", &a, &b);
	if(a == 'H')
	{
		if(b == 'D')
			printf("D\n");
			else
				printf("H\n");
	}
	else
	{
		if(b == 'D')
			printf("H\n");
			else
				printf("D\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N; cin >> N;
  using std::array;
  vector<array<int, 10>> isOpened(N);
  for (auto& row : isOpened) {
    for (auto& f : row) {
      cin >> f;
    }
  }
  vector<array<ll, 11>> weight(N);
  for (auto& row : weight) {
    for (auto& w : row) {
      cin >> w;
    }
  }

  int itr = 1 << 10;
  vector<ll> result{};
  while (--itr) {
    ll sum{};
    for (int i = 0; i < N; ++i) {
      int c{};
      for (int jikan = 0; jikan < 10; ++jikan) {
        auto isEigyochu = (itr & 1 << jikan) != 0;
        if (isEigyochu && isOpened[i][jikan]) {
          ++c;
        }
      }
      sum += weight[i][c];
    }
    result.push_back(sum);
  }
  auto ans = boost::max_element(result);
  cout << *ans << CRLF;

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int k, r;
	cin >> k >> r;
	if (k < 10) {
		r += 100 * (10 - k);
	}
	cout << r << endl;
}


Measured memory_bytes: 256
N, M = [int(_) for _ in input().split()]
l = 1
r = N
ans = []
for _ in range(M - M // 2):
    ans += [l, r]
    l += 1
    r -= 1
if (r - l) % 2 == (l + N - r) % 2:
    r -= 1
for _ in range(M // 2):
    ans += [l, r]
    l += 1
    r -= 1
ans = ans[:2 * M]
print('\n'.join(f'{a} {b}' for a, b in zip(ans[::2], ans[1::2])))


Measured memory_bytes: 23608
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


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

Measured memory_bytes: 256