akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n + 1), b(n);
  REP(i, n + 1) { cin >> a[i]; }
  REP(i, n) { cin >> b[i]; }
  ll ans = 0;

  REP(i, n) {
    ll t = min(a[i], b[i]);
    ans += t;
    a[i] -= t;
    b[i] -= t;
    ll u = min(b[i], a[i + 1]);
    a[i + 1] -= u;
    ans += u;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}
		int ans = a[0];
		for(int i=1;i<n;i++) {
			ans = gcd(ans,a[i]);
		}
		System.out.println(ans);
		in.close();
	}
	
	public static int gcd(int a,int b) {
		if(b==0) return a;
		else return gcd(b,a%b);
	}

}


Measured memory_bytes: 49768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <cstring>
#include <cctype>
#include <ctime>
#include <climits>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <tuple>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <complex>
#include <random>
#include <cassert>
#include <chrono>
#include <cstdint>
#include <functional>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#ifndef M_PI
#define M_PI 3.141592653589793238462643383279
#endif

#define int long long

#define mp make_pair
#define mt make_tuple
#define fr first
#define sc second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(), x.end()
#define get0 get<0>
#define get1 get<1>
#define get2 get<2>
#define get3 get<3>

#define debug(x) cerr << #x << " = " << x << ", line = " << __LINE__ << endl

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef tuple<long long, long long, long long> tlll;
typedef tuple<int, int, int> tiii;
typedef tuple<int, int, int, int> tiiii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MOD = 1e9 + 7;



int32_t main()
{
#ifdef chikibambony
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int j = 0; j < n; ++j) {
        cin >> b[j];
    }
    reverse(all(b));
    int c = -1;
    for (int i = 0; i < n; ++i) {
        if (a[i] == b[i]) {
            c = a[i];
            break;
        }
    }
    int l = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] == c && b[i] == c) {
            l = i;
            break;
        }
    }
    int r = -1;
    for (int i = n - 1; i >= 0; --i) {
        if (a[i] == c && b[i] == c) {
            r = i;
            break;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (a[i] != c && b[i] != c && l <= r) {
            swap(b[i], b[l]);
            ++l;
        }
    }

    if (l <= r) {
        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";

    for (int i = 0; i < n; ++i) {
        cout << b[i] << ' ';
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 6312
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<int, int, int> tp;
///-------------------------

int main()
{
    Phuong_; /// <3333
    map<string, int> mp;
    int n;
    cin >> n;
    while (n--){
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << '\n';
    cout << "WA x " << mp["WA"] << '\n';
    cout << "TLE x " << mp["TLE"] << '\n';
    cout << "RE x " << mp["RE"] << '\n';
    return 0;
}


Measured memory_bytes: 3664
n,a,b=map(int,input().split())

s=input()
ans=[]
cnt=a+b
tmp=1
for i in range(len(s)):
    if s[i]=="a":
        if cnt>0:
            ans.append("Yes")
            cnt-=1
        else:
            ans.append("No")
    elif s[i]=="b":
        if cnt>0 and tmp<=b:
            ans.append("Yes")
            tmp+=1
            cnt-=1
        else:
            ans.append("No")
    else:
        ans.append("No")

for i in range(len(s)):
    print(ans[i])

Measured memory_bytes: 4784
h, w = map(int, input().split())
s = []
for i in range(h):
    s.append(list(input()))
ans = []
for i in range(h):
    temp = []
    for j in range(w):
        if s[i][j] == "#":
            temp.append("#")
        else:
            count = 0
            for k in range(3):
                for l in range(3):
                    if 0 <= i + k - 1 <= h - 1 and 0 <= j + l - 1 <= w - 1:
                        if k == 1 and l == 1:
                            pass
                        else:
                            if s[i + k - 1][j + l - 1] == "#":
                                count += 1
            temp.append(str(count))
    ans.append(temp)
for i in range(h):
    print("".join(ans[i]))

Measured memory_bytes: 3188
#include<stdio.h>

int main(void){

	int a,b,c,sum=0,i;

	scanf("%d %d %d",&a,&b,&c);

	for(i=a;i<=b;i++){

		if( c % i == 0)
			sum++;

	}

	printf("%d\n",sum);

	return 0;


}

Measured memory_bytes: 596
#include<iostream>
using namespace std;
bool B(int n)
{
	for (int i = 1; i <= 9; i++)
	{
		for (int g = 1; g <= 9; g++)
		{
			if (g * i == n)
				return true;
		}
	}
	return false;
}
int main()
{
	int n;
	
	cin >> n;
	
	cout <<( B(n) ? "Yes" : "No" )<< "\n";
	
		
	return 0;
}

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

namespace ConsoleApp11
{
    class Class49
    {
        static void Main()
        {
            HashSet<int> hash = new HashSet<int>();
            int N = int.Parse(Console.ReadLine());
            for(int i = 0; i < N; i++)
            {
                int read = int.Parse(Console.ReadLine());
                if (hash.Contains(read))
                    hash.Remove(read);
                else
                    hash.Add(read);
            }
            Console.WriteLine(hash.Count);
        }
    }
}


Measured memory_bytes: 19420
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}
signed main() {
	int n, k;
	cin >> n >> k;
	int a = 1, ans = 0;
	while (a <= n) {
		ans++;
		a *= k;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b;
    int sum;
    scanf("%d %d",&a,&b);
    sum=a+b;
    if(a==b){
        printf("0\n");
    }else{
    if(sum%2==0){
        printf("%d\n",sum/2);
    }else{
        printf("IMPOSSIBLE\n");
    }}
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

vector<pair<char,int>> runLength(string s) {
  int n = sz(s);
  vector<pair<char,int>> res;
  rep(i,n) {
    int cnt = 1;
    while(i < n-1 && s[i] == s[i+1]) {
      cnt++;
      i++;
    }
    res.push_back(pair<char,int>(s[i],cnt));
  }
  return res;
}
  
int main() {
  string s;
  cin >> s;
  ll K;
  cin >> K;
  int slen = sz(s);
  rep(i,slen) {
    if(s[i] != s[0]) break;
    if(i == slen-1) {
      cout << slen * K / 2 << endl;
      return 0;
    }
  }
  vector<pair<char,int>> rl = runLength(s);
  
  if(s[0] == s[slen-1]) {
    ll ans = 0;
    rep(i,sz(rl)) {
      ans += rl[i].second / 2;
    }
    ans *= K;
    int a = rl[0].second;
    int b = rl[sz(rl)-1].second;
    ans -= (K-1) * (a/2+b/2-(a+b)/2);
    cout << ans << endl;
  } else {
    ll ans = 0;
    rep(i,sz(rl)) {
      ans += rl[i].second / 2;
    }
    ans *= K;
    cout << ans << endl;
  }
  
  return 0;
}

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

using namespace std;

#define rep(i , j , k) for (int i = j; i < k; i++)
#define pb push_back
#define for_all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef long double ld;

inline void fileIO(string s) {
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

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

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

constexpr int N = 1e3 + 10;

int H , W;
string s[N];
int dist[N][N];
pii q[N * N];
int L , R;

inline void input() {
	cin >> H >> W;
	rep(i , 0 , H)
		cin >> s[i];
}

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

inline bool valid(int x, int y) {
	return x >= 0 && y >= 0 && x < H && y < W;
}

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

	input();

	memset(dist, 63,sizeof(dist));
	rep(i , 0 , H)
			rep(j , 0 , W)
				if (s[i][j] == '#') {
					dist[i][j] = 0;
					q[R++] = {i , j};
				}

	int res = 0;

	while (L < R) {
		int x , y;
		tie(x , y) = q[L++];
		rep(i , 0 , 4) {
			int _x = x + dx[i];
			int _y = y + dy[i];
			if (valid(_x , _y) && dist[_x][_y] > dist[x][y] + 1) {
				dist[_x][_y] = dist[x][y] + 1;
				q[R++] = {_x , _y};
			}
		}
	//	cout << x << ' ' << y << ' ' << dist[x][y] << endl;
		smax(res , dist[x][y]);
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 13312
#include<bits/stdc++.h>
using ll = long long;
using P = std::pair<ll,ll>;

int main(){
        ll n;
        scanf("%lld", &n);

        ll mn = 1e18;
        std::vector<P> pt(n);
        for(ll i=0; i<n; i++) scanf("%lld %lld", &pt[i].first, &pt[i].second);

        ll size = 0;
        std::vector<P> pp(n*(n+1)/2);
        for(ll i=0; i<n-1; i++) for(ll j=i+1; j<n; j++){
                pp[size] = P(pt[i].first-pt[j].first, pt[i].second-pt[j].second);
                size++;
        }


        ll ans = n;
        for(ll i=0; i<size; i++){
                ll cnt = n;
                for(ll j=0; j<size; j++){
                        ll tx, ty, nx, ny;
                        std::tie(tx, ty) = pp[i];
                        std::tie(nx, ny) = pp[j];
                        if(tx==nx&&ty==ny || tx==-nx&&ty==-ny) cnt--;
                }
                ans = std::min(ans, cnt);
        }
        printf("%lld\n", ans);
        return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int count = 0;
			int N = in.nextInt();
			int A = in.nextInt();
			int B = in.nextInt();
			int C = in.nextInt();
			int X = in.nextInt();
			if(A == 0 &&B == 0&&C == 0&&N == 0&&X == 0)break;
			int[]Y = new int [N];
			for(int i = 0;i < N;i++){
				Y[i] = in.nextInt();
			}
			for(int i = 0;i <= 10000;i++){
				if(Y[count] == X){
					count++;
				}
				if(count == N){
					System.out.println(i);
					break;
				}
				X = (A * X + B) % C;
				if(i == 10000){
					System.out.println(-1);
				}
			}
		}
	}
}

Measured memory_bytes: 30108
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
 
void shuffle(int h, char *s0) {
  int length;
  length = strlen(s0);
  char temp[length-h+1],s1[length+1];
  strcpy(temp,s0+h);
  strncpy(s1, s0, h);
  s1[h]='\0';
  sprintf(s0, "%s%s", temp, s1);
}
 
 
int main() {
  int i,h;
  char s0[201];
  while(1) {
    scanf("%s", s0);
    if(strcmp(s0, "-") == 0) break;
    scanf("%d", &i);
    for(;i>0;i--){
      scanf("%d", &h);
      shuffle(h, s0);
    }
    printf("%s\n", s0);
    memset(s0, '\0', 200);
  }
  return 0;
}


Measured memory_bytes: 2040
#include <stdio.h>
#include <stdlib.h>
int main(){
  int *A,N,i,j,v,n;
  scanf("%d",&N);

  if(N<1||100<N)exit(1);

  A=(int*)malloc(N*sizeof(int));
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(n=0;n<N;n++){
    printf("%d",A[n]);
    if(n<N-1)printf(" ");
  }
  printf("\n");
  for(i=1;i<=N-1;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    for(n=0;n<N;n++){
      printf("%d",A[n]);
      if(n<N-1)printf(" ");
    }
    printf("\n");
  }  
  free(A);
  return 0;
}

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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define dbg(x) cerr<<#x<<" : "<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
clock_t time_p=clock();
void timer(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}

template <typename Arg1> ostream& operator << (ostream& out, const vector<Arg1> &a) {out<<"[ ";for(const auto &x:a)out<<x<<" ";return out<<"]";}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    string s,t;
    cin>>n;
    cin>>s;
    cin>>t;

    string a;
    rep(i,n){
        a.pb(s[i]);
        a.pb(t[i]);
    }
    cout<<a<<endl;;


    timer();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
    string s;
    cin >> s;
    cout << s.at(0) << s.at(1) << s.at(2) << endl;
}

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

int a[5];

int main() {
    for (int i = 0; i < 5; i++) {
        scanf("%d", &a[i]);
    }
    int K;
    scanf("%d", &K);
    int diff = *max_element(a, a + 5) - *min_element(a, a + 5);
    if (diff <= K) {
        puts("Yay!");
    } else {
        puts(":(");
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N, K;
    read(N, K);
    vector<int> d(K);
    vector<vector<int>> A(K);
    for(int i = 0; i < K; i++){
        read(d[i]);
        A[i].resize(d[i]);
        for(int j = 0; j < d[i]; j++){
            read(A[i][j]);
        }
    }
    vector<bool> v(N, false);
    for(int i = 0; i < K; i++){
        for(int j = 0; j < d[i]; j++){
            v[A[i][j] - 1] = true;
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(v[i]) ans++;
    }
    write(N - ans);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

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

  string T = S;
  rep(i, N) {
    rep(j, sz(T) - 1) {
      if (T[j] == '(' && T[j + 1] == ')') {
        T.erase(T.begin() + j, T.begin() + j + 2);
        continue;
      }
    }
  }

  int cnt_l = 0, cnt_r = 0;
  rep(i, sz(T)) {
    if (T[i] == ')')
      cnt_r++;
    else
      cnt_l++;
  }

  reverse(all(S));
  rep(i, cnt_r) {
    S.pb('(');
  }

  reverse(all(S));
  rep(i, cnt_l) {
    S.pb(')');
  }

  cout << S << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
def dfs(h, w, grid):
    grid[h][w] = 0

    # 八方向を探索
    for dh in range(-1, 2):
        for dw in range(-1, 2):
            nh = dh + h
            nw = dw + w

            # 場外だった場合はするー(番兵)
            if nh < 0 or nw < 0:
                continue
            if grid[nh][nw] == 0:
                continue
            # 次に進む
            dfs(nh, nw, grid)
while True:
    grid = []
    W, H = map(int, input().split())
    if W == 0 and H == 0:
        break
    grid.append([0] * (W+2))
    grid += [[0] + list(map(int, input().split())) + [0] for _ in range(H)]
    grid.append([0] * (W+2))

    cnt = 0
    for h in range(1, H+1):
        for w in range(1, W+1):
            if grid[h][w] == 0:
                continue
            dfs(h, w, grid)
            cnt += 1
    print(cnt)


Measured memory_bytes: 8092
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    string S = Console.ReadLine();

    bool C(int n)
    {
        for(int i = 0; i < n / 2; i++)
        {
            if (S[i] != S[i + n / 2])
            {
                return false;
            }
        }
        return true;
    }

    public void Solve()
    {
        int a = -1;
        for(int ans = 2; ans < S.Length; ans += 2)
        {
            if (C(ans))
            {
                a = ans;
            }
        }
        Console.WriteLine(a);
    }
}


Measured memory_bytes: 11092
n= int(input())
s = [0]*n
t = [0]*n
u = [0]*n
v = {}
for i in range(n):
  a, b = input().split()
  s[i] = a
  t[i] = int(b)
x = input()

u[n-1]=0
v[s[n-1]]=0
for i in range(n-2,-1,-1):
  u[i] = t[i+1]+u[i+1]
  v[s[i]] = u[i]

print(v[x])

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
bool is_integer(double x)
{
  return floor(x) == ceil(x);
}
int main()
{
  long long int a, b, c, d;
  cin >> a >> b >> c >> d;
  long long int p;
  p = b * d;
  if (p < a * d)
    p = a * d;
  if (p < a * c)
    p = a * c;
  if (p < b * c)
    p = b * c;
  cout << p << endl;
}



Measured memory_bytes: 3632
A,B,C,X,Y = map(int,input().split())

p1 = X *A +Y *B

p2 = 2 * max(X,Y) * C

if X > Y:
    p3 = 2 * Y * C + (X-Y) *A
else:
    p3 = 2 * X * C + (Y-X) *B

print(min(p1,p2,p3))

Measured memory_bytes: 3060
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        n: usize,
        k: usize,
        r: usize,
        s: usize,
        p: usize,
        mut t: Chars,
    }

    let mut ans = 0;

    for num in 0..n {
        if num >= k {
            if t[num] != t[num - k] {
                match t[num] {
                    'r' => ans += p,
                    's' => ans += r,
                    'p' => ans += s,
                    _ => {},
                }
            } else {
                t[num] = 'c';
            }
        } else {
            match t[num] {
                'r' => ans += p,
                's' => ans += r,
                'p' => ans += s,
                _ => {},
            }
        }
    }

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


Measured memory_bytes: 2576
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class C
{
	public static void Main()
	{
		int N = Int32.Parse(Console.ReadLine());
		string[] args;
		
		List<int> A = new List<int>(N);		
		args = Console.ReadLine().Split(' ');
		for(int i = 0; i < N; i++)
			A.Add(Int32.Parse(args[i]));
		A.Sort();

		List<int> B = new List<int>(N);		
		args = Console.ReadLine().Split(' ');
		for(int i = 0; i < N; i++)
			B.Add(Int32.Parse(args[i]));
		B.Sort();

		List<int> C = new List<int>(N);		
		args = Console.ReadLine().Split(' ');
		for(int i = 0; i < N; i++)
			C.Add(Int32.Parse(args[i]));
		C.Sort();

		long[] numAB = new long[N];
		int iA = N - 1;
		for(int i = N - 1; i >= 0; i--)
		{
			while((iA >= 0) && (A[iA] >= B[i]))
				iA--;
			numAB[i] = (iA >= 0) ? iA + 1 : 0;
		}

		long[] numBC = new long[N];
		int iC = 0;
		for(int i = 0; i < N; i++)
		{
			while((iC < N) && (B[i] >= C[iC]))
				iC++;
			numBC[i] = (iC < N) ? (N - iC) : 0;
		}

		long ans = 0;
		for(int i = 0; i < N; i++)
			ans += numAB[i] * numBC[i];
		Console.WriteLine(ans);
	}
}





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

ab = []

for i in range(n):
    a, b = map(int, input().split())
    a = b - a
    ab.append([a, b])

ab.sort(key=lambda x: (x[1], x[0]))

flag = True
time = 0
for i in range(n):
    a, b = ab[i]
    time += b - a
    if time > b:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 52424
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-10, PI = acos(-1);
const int N = 3e5 + 9, M = 1e5 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll x[N], y[N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n;
  cin >> n;
  vector<pair<long double, pair<ll, ll>>> vec;
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
    vec.push_back({atan2(x[i], y[i]), {x[i], y[i]}});
  }
  sort(vec.begin(), vec.end());
  double best = 0;
  for (int i = 0; i < n; ++i) {
    ll X = 0, Y = 0;
    for (int j = 0; j < n; ++j) {
      int nxt = (i + j);
      if(nxt >= n)
        nxt -= n;
      X += vec[nxt].second.first, Y += vec[nxt].second.second;
      best = max(best, sqrt(X * X + Y * Y));
    }
  }
  cout << best;
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;

	ll s1 = 0;
	ll kotae1 = 0;
	ll s2 = 0;
	ll kotae2 = 0;
	rep(i, N) {
		int a;
		cin >> a;
		s1 += a;
		s2 += a;
		if (i & 1) {
			if (s1 <= 0) {
				kotae1 += 1 - s1;
				s1 = 1;
			}
			if (s2 >= 0) {
				kotae2 += s2 + 1;
				s2 = -1;
			}
		}
		else {
			if (s2 <= 0) {
				kotae2 += 1 - s2;
				s2 = 1;
			}
			if (s1 >= 0) {
				kotae1 += s1 + 1;
				s1 = -1;
			}
		}
	}
	co(min(kotae1, kotae2));

	Would you please return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	char a; cin >> a;
	a += 1;
	cout << a << endl;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <math.h>
#define MAX 50
#define EPS 10e-10

int main(void)
{
	int n1,n2;
	int i;
	int angle,asum;
	float s1,s2;

	while(1){
		s1 = s2 = 0.0;
		
		asum = 0;
		scanf("%d",&n1);
		if(n1 == 0){ break; }
		for(i=0;i<n1-1;i++){
			scanf("%d",&angle);
			asum += angle;
			s1 += sinf((float)angle/180.0*3.141592);
		}
		angle = 360-asum;
		s1 += sinf((float)angle/180.0*3.141592);
		
		asum = 0;
		scanf("%d",&n2);
		if(n2 == 0){ break; }
		for(i=0;i<n2-1;i++){
			scanf("%d",&angle);
			asum += angle;
			s2 += sinf((float)angle/180.0*3.141592);
		}
		angle = 360-asum;
		s2 += sinf((float)angle/180.0*3.141592);
		
		if(s1 > s2-EPS && s1 < s2+EPS ){
			printf("0\n");
		}
		else if(s1 > s2){
			printf("1\n");		
		}
		else{
			printf("2\n");		
		}
	}
	return 0;
}

Measured memory_bytes: 1756
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')

#
#import numpy as np

def main():
	n,x,y=MI()
	ans=[0]*(n)

	for i in range(1,n):
		for j in range(i+1,n+1):
			dis=min(j-i,abs(x-i)+abs(y-j)+1,abs(x-j)+abs(y-i)+1)
			ans[dis]+=1


	print(*ans[1:],sep="\n")




if __name__ == "__main__":
	main()

Measured memory_bytes: 44892
#!/usr/bin/env python3
# sys.stdin.readline()
import numpy as np

import math

n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
B = [-A[i]+A[i+1] for i in range(m-1)]
B.sort()
print(sum(B[0:max(m-n,0)]))

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

int main(){
  int A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F;
  set<int> w,s;
  //入れられる水の重量を列挙する。
  for(int i = 0;i <= 30; i++){
    for(int j = 0; j <= 30;j++){
      int t = 100 * A * i + 100 * B * j;
      if(t <= F && t > 0) w.insert(t);
    }
  }
  //入れられる砂糖の重量を列挙する。
  for(int i = 0; i <= 3000; i++){
    for(int j = 0; j <= 3000;j++){
      int t = C * i + D * j;
      if(t <= F) s.insert(t);
    }
  }
  double max_M = 0;
  int ans_s_w = 0;
  int ans_s = 0;
  for(auto x: w){
    for(auto y: s){
      //重量がF以下であること
      if(x + y > F ) continue;
      //砂糖が溶け切っていること。
      if( y >  x / 100 * E) continue;
      double t = (double)100 * y / ( x + y );
      if(max_M <= t ){
        max_M = t;
        ans_s_w = x + y;
        ans_s = y;
      }
    }
  }
  cout << ans_s_w << " " <<  ans_s;
}

Measured memory_bytes: 384
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;


int main() {
    int a,b;
    cin >> a >> b;
    if(a * b % 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
const main = stdin => {
  const input = stdin.trim().split('\n')
  const A = BigInt(input[0])
  const B = BigInt(input[1])

  if (A > B) {
    console.log('GREATER')
  } else if (A < B) {
    console.log('LESS')
  } else {
    console.log('EQUAL')
  }
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29628
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N;   cin>>N;
  string S; cin>>S;
  bool ok = N % 2 == 0;
  N /= 2;
  REP(i,N) {
    if(S[i] != S[N+i]) {
      ok = false;
      break;
    }
  }
  YesNo(ok);
 return 0;
}


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


int main()
{
	ll bills[] = {10000, 5000, 1000};
	bool possible = false;
	int xx = -1, yy = -1, zz = -1;
	int n, y;
	cin>>n>>y;
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <= n-i; ++j)
		{
			int k = n - (i+j);
			if ((i*10000) + (j * 5000) + (k * 1000) == y)
			{
				possible = true;
				xx = i;yy = j;zz = k;
				break;
			}
		}
		if (possible)
		{
			break;
		}
	}
	printf("%d %d %d\n", xx, yy, zz);

	return 0;
}

Measured memory_bytes: 256
#s = input()
#n = int(input())
n,k = map(int,input().split())
#lst1 = list(map(int,input().split()))
ans = 0
while True:
    if n//k >= 1:
        n//=k
        ans += 1
    else:
        ans += 1
        break
print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	ll n, k; cin >> n >> k;
	vector<ll> neg, pos;
	for (int i = 0; i < n; i++) {
		ll a; cin >> a;
		(a >= 0 ? pos : neg).push_back(abs(a));
	}
	sort(pos.begin(), pos.end());
	sort(neg.begin(), neg.end());
	auto cnt = [&](ll mid) -> ll {
		if (mid >= 0) {
			ll ret = 0;
			for (ll i : pos) {
				if (i == 0) {
					ret += pos.size() - 1;
					continue;
				}
				ret += upper_bound(pos.begin(), pos.end(), mid / i) - pos.begin();
				if (i <= mid / i) ret--;
			}
			for (ll i : neg) {
				ret += upper_bound(neg.begin(), neg.end(), mid / i) - neg.begin();
				if (i <= mid / i) ret--;
			}
			ret /= 2;
			ret += pos.size() * neg.size();
			return ret;
		}
		else {
			ll ret = 0;
			for (ll i : pos) {
				if (i == 0) continue;
				ret += neg.end() - lower_bound(neg.begin(), neg.end(), (-mid + i - 1) / i);
			}
			return ret;
		}
	};
	ll lo = -2e18, hi = 2e18;
	while (hi - lo > 1) {
		ll mid = lo + (hi - lo) / 2;
		if (cnt(mid) < k) lo = mid;
		else hi = mid;
	}
	cout << hi << endl;
	return 0;
}


Measured memory_bytes: 2548
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n, k;
vi a;
vi food;

signed main(){
    I(n); I(k);
    a.resize(n);
    REP(i,n) I(a[i]);
    sort(all(a), greater<int>());
    food.resize(n);
    REP(i,n) I(food[i]);
    sort(all(food));

    REP(i,n) cerr << a[i] << " " ; cerr << endl;
    REP(i,n) cerr << food[i] << " " ; cerr << endl;

    int lo = -1;
    int hi = a[0] * food[n-1] + 1;
    while(abs(lo-hi) > 1){
        int mid = (lo+hi)/2;
        int tgt = 0;
        if (mid > 0){
            REP(i,n) tgt += max(0LL, a[i] - mid / food[i]);
        } else {
            tgt = accumulate(all(a), 0LL);
        }
        // cerr << mid << " " << tgt << endl;
        (tgt <= k ? hi : lo) = mid;
    }
    cout << hi << endl;
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main()
{
  int N;
  bool hist[8] = { };
  int high = 0;

  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a < 3200) hist[a/400] = true;
    else high++;
  }

  int sum = 0;
  for (int i = 0; i < 8; i++) {
    if (hist[i]) sum++;
  }
  if (sum == 0) cout << 1 << ' ';
  else cout << sum << ' ';
  
  cout << sum + high << endl;

  return 0;
}


Measured memory_bytes: 256
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = gets.chomp.to_i

p a[k-1]


Measured memory_bytes: 1788
// Problem : D - Knapsack 1
// Contest : Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(long long int i=0;i<n;i++)
#define FORR(i,n) for(long long int i=n;i>=0;i--)
#define pb push_back
#define vlli vector<long long int>
#define slli set<long long int>
#define mlli map<long long int,long long int>
#define lli long long int 
#define test lli tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define MOD 1000000007
using namespace std;
lli n,w,arr[101][2],dp[101][100001];
// w v
lli go(lli ind,lli W){
	if(ind==n || W==0) return 0;
	if(dp[ind][W]!=-1) return dp[ind][W]; 
	if(arr[ind][0]<=W){
		// lli a;
		dp[ind][W]=max(go(ind+1,W),(go(ind+1,W-arr[ind][0])+arr[ind][1]));
		return dp[ind][W];
	}
	else{
		dp[ind][W]= go(ind+1,W);
		return dp[ind][W];
	}
}
void solve(){
	cin>>n>>w;
	FOR(i,n){
		cin>>arr[i][0]>>arr[i][1];
	}	
	cout<<go(0,w);
		
}


int32_t main() {
	set(dp,-1);
    	solve();
    return 0;
}


Measured memory_bytes: 79232
f = [0, 1, 2, 6, 24, 120, 720, 5040, 40320]

def get_order(a, n):
    res = 0
    check = [1] * (n + 1)
    check[0] = 0
    for i, c in enumerate(a):
        s = sum(check[:c])
        res += s * f[n - i - 1]
        check[c] = 0
    return res

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

print(abs(get_order(P, N) - get_order(Q, N)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>
#define f first
#define se second
#define pb push_back
#define ft fflush(stdout)
 
 
using namespace std;
 
 
const int N = 3e5;
const int PLS = 3e5 + 123;
const ull mod = 1e9 + 7;
const ll inf = 1e16;


ull n, k;
vector <vector <ull> > a, b;

vector <vector <ull> > pw(vector <vector <ull> > &c, ll x) {
    vector <vector <ull> > d, t;
    t.clear();
    t.resize(n);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            t[i].pb(0);
    if (x == 1) {
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                t[i][j] = c[i][j];
        return t;
    }
    if (x % 2 == 0) {
        d = pw(c, x / 2);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                    t[i][j] = (t[i][j] + (d[i][k] * d[k][j]) % mod) % mod;
    } else {
        d = pw(c, x - 1);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                    t[i][j] = (t[i][j] + (d[i][k] * c[k][j]) % mod) % mod;
    }
    return t;
}


int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    cin >> k;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        a[i].resize(n);
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
    }
    b = pw(a, k);
    ll ans = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            ans = (ans + b[i][j]) % mod;
    cout << ans;
}

Measured memory_bytes: 3456
#include <stdio.h>

int main(void)
{
	int A, B, i, ans = 0;
	scanf("%d %d", &A, &B);

	for (i = 0; i < 2; i++) {
		if (A <= B) {
			ans += B;
			B--;
		}

		else {
			ans += A;
			A--;
		}
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 128
/*=============================================================================================================================/*
                                               Bismillahir Rahmanir Rahim

      _     ____  ___  ____   _   _  _         ___  ____   _         _     __  __
     / \   / ___||_ _|| __ ) | | | || |       |_ _|/ ___| | |       / \   |  \/  |
    / _ \  \___ \ | | |  _ \ | | | || |        | | \___ \ | |      / _ \  | |\/| |
   / ___ \  ___) || | | |_) || |_| || |___     | |  ___) || |___  / ___ \ | |  | |
  /_/   \_\|____/|___||____/  \___/ |_____|   |___||____/ |_____|/_/   \_\|_|  |_|

   _   __           __  __  __
  |_) (_  _  o__   /   (_  |_
  |_)o__)(_  || |  \__ __) |__

    ___                    _   _      _                _ _               __   ___                 _         _        _
   / __|_ _ ___ ___ _ _   | | | |_ _ (_)_ _____ _ _ __(_) |_ _  _   ___ / _| | _ ) __ _ _ _  __ _| |__ _ __| |___ __| |_
  | (_ | '_/ -_) -_) ' \  | |_| | ' \| \ V / -_) '_(_-< |  _| || | / _ \  _| | _ \/ _` | ' \/ _` | / _` / _` / -_|_-< ' \
   \___|_| \___\___|_||_|  \___/|_||_|_|\_/\___|_| /__/_|\__|\_, | \___/_|   |___/\__,_|_||_\__, |_\__,_\__,_\___/__/_||_|
                                                            |__/                           |___/


   FB: https://facebook.com/SIAsibul
   Gmail: asibulislam8@gmail.com

/*=============================================================================================================================*/

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vii;
typedef vector<pil> vil;
typedef vector<pli> vli;
typedef vector<pll> vll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,n) for(ll i=0;i<(n);i++)
#define f1(i,n) for(ll i=1;i<=(n);i++)
#define f2(i,a,n) for(ll i=(a);i<=(n);i++)
#define fr(i,n,a) for(ll i=(n);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define nl "\n"


const int INF = 1e9 + 5;
const int MXN = 2e5 + 5;
const int MOD = 1e9 + 7;


void solve(){
    string s, t; cin >> s >> t;
    int c = 0;
    f0(i, s.size()) if(s[i] != t[i]) c++;
    cout << c << nl;
}

int main(){
    ll t;
    //cin >> t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
 }


Measured memory_bytes: 3784
#include<bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    int L,R,d;
    cin >> L >> R >> d;
    int a = L/d;
    if(L%d==0) a=a-1;
    int b = R/d;
    cout << b-a << endl;
    return 0;
}

Measured memory_bytes: 3560
#include <cstdio>

int main() {
  int N;
  scanf("%d", &N);

  int sum = 0;
  int min = 110;
  for (int i = 0; i < N; ++i) {
    int s;
    scanf("%d", &s);
    sum += s;
    if (s % 10 > 0 && min > s)
      min = s;
  }
  if (sum % 10 == 0) sum -= min;
  if (sum % 10 == 0) sum = 0;
  printf("%d\n", sum);
}


Measured memory_bytes: 504
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }

int main() {
    int N;
    set<int> A;
    cin >> N;
    for (size_t i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        if(A.find(a) != A.end()){
            cout << "NO" << endl;
            return 0;
        }
        A.insert(a);
    }
    cout << "YES" << endl;
    

}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  string s;
  cin>>s;
  int ans=0;
  REP(i,3){
    if(s[i]=='1')ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
s = gets.chomp
h = {}
s.each_char do |c|
  if h.has_key?(c) then
    h[c] = h[c] + 1
  else
    h[c] = 1
  end
end
if h.size == 2 && h[h.keys[0]] == 2 then
  puts 'Yes'
else
  puts 'No'
end

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

using namespace std;


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

	vector<long long> w(n + 1), v(n + 1);
	vector<vector<long long>> dp(n + 1, vector<long long>(W + 1));

	for(int i = 1; i <= n; i++)
		cin >> w[i] >> v[i];

	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j <= W; j++)
		{
			dp[i][j] = dp[i - 1][j];

			if(j >= w[i])
				dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
		}
	}

	cout << dp[n][W] << endl;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;

int main(){
    int N, K;
    cin >> N >> K;
    ll ans = 0;
    for (int b=K+1; b<=N; b++) {
        int p = N / b;
        int r = N % b;
        ans += p * (b - K);
        ans += max(0, r + 1 - K); 
        if (K == 0) ans--;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
 int K;
 cin >> K;
 int sum=0;

 for(int a=1; a<=K; a++) {
  for (int b=1; b<=K; b++) {
   for (int c=1; c<=K; c++) {
    int gcd_ab;
    gcd_ab=gcd(a, b);
    int gcd_abc;
    gcd_abc=gcd(gcd_ab, c);
    sum += gcd_abc;
   }
  }
 }
 cout << sum << endl;
}

Measured memory_bytes: 3612