akhauriyash/Code-Regression huggingface dataset:
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

lo n,m,b[li],a[li],k,flag,t;
lo cev;
PII p[li];
string s;
vector<lo> v;

int main(void){
	scanf("%lld",&n);
	FOR{
		scanf("%lld %lld",&k,&m);
		p[i].se=k;
		p[i].fi=m;
	}
	sort(p+1,p+n+1);
	FOR{
		if(cev+p[i].se<=p[i].fi){cev+=p[i].se;continue;}
		printf("No\n");return 0;
	}
	printf("Yes\n");
	return 0;
}


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

int             g_flag = 0;

void    print_answer(char *nums, char *option)
{
        int             i;
        char    answer[9];

        for (i = 0; i < 3; i++)
        {
                answer[i * 2] = nums[i];
                answer[i * 2 + 1] = option[i];
        }
        answer[6] = nums[3];
        answer[7] = '=';
        answer[8] = '7';
        answer[9] = '\0';
        printf("%s\n", answer);
}

int             check_seven(char *nums, char *option)
{
        int i;
        int sum;

        sum = nums[0] - '0';
        for (i = 0; i < 3; i++)
        {
                if (option[i] == '+')
                        sum += nums[i + 1] - '0';
                else
                        sum -= nums[i + 1] - '0';
        }
        if (sum == 7)
                return (1);
        else
                return (0);
}

void    culc_seven(char *nums, char *option, int i)
{
        if (g_flag == 1)
                return ;
        if (i == 3)
        {
                if (check_seven(nums, option))
                {
                        print_answer(nums, option);
                        g_flag = 1;
                }
                return ;
        }
        option[i] = '+';
        culc_seven(nums, option, i + 1);
        option[i] = '-';
        culc_seven(nums, option, i + 1);
}

int             main(void)
{
        char nums[5];
        char option[4] = "0000";

        scanf("%s", nums);
        culc_seven(nums, option, 0);
        return (0);
}

Measured memory_bytes: 1636
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
const int INF = 1001001001;
int main()
{
  int N, X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;
  vector<int> ans(N);
  rep(i, N)
  {
    vector<int> dist(N, INF);
    queue<int> q;
    auto push = [&](int v, int d) {
      if (dist.at(v) != INF)
      {
        return;
      }
      dist.at(v) = d;
      q.push(v);
    };
    push(i, 0);
    while (!q.empty())
    {
      int v = q.front();
      q.pop();
      int d = dist.at(v);
      if (v - 1 >= 0)
      {
        push(v - 1, d + 1);
      }
      if (v + 1 < N)
      {
        push(v + 1, d + 1);
      }
      if (v == X)
      {
        push(Y, d + 1);
      }
      if (v == Y)
      {
        push(X, d + 1);
      }
    }
    rep(j, N)
    {
      ans.at(dist.at(j))++;
    }
  }
  rep(i, N) { ans.at(i) /= 2; }
  for (int i = 1; i <= N - 1; i++)
  {
    cout << ans.at(i) << endl;
  }
}


Measured memory_bytes: 256
program min_cost_cycle
  implicit none
  integer :: n, a(100000), b(100000), c(200000,2), u(100000), i, k
  integer(8) :: y, z, xw, h, t
  a = 0
  b = 0
  c = 0
  u = 0
  read(*,*) n
  do i = 1, n
    read(*,*) a(i), b(i)
    c(i,1) = a(i)
    c(i,2) = i
    c(n+i,1) = b(i)
    c(n+i,2) = -i
  end do
  y = sum(int(a(1:n),8))
  z = sum(int(b(1:n),8))
  call merge_sort(c(1:2*n,1:2))
  xw = sum(int(c(1:n,1),8))
  do i = 1, n
    k = abs(c(i,2))
    u(k) = u(k)+1
  end do
  if (maxval(u(1:n)).eq.1) then
    h = xw
    xw = 10000000000000000_8
    do i = 1, n
      if (c(i,2).eq.-c(n+1,2)) then
        t = h-c(i,1)+c(n+2,1)
      else
        t = h-c(i,1)+c(n+1,1)
      end if
      xw = min(xw,t)
    end do
  end if
  write(*,'(i0)') min(y,z,xw)
  stop
contains
  subroutine merge_sort(c)
    implicit none
    integer, intent(inout) :: c(:,:)
    integer :: n, m, l, u, i
    n = size(c(:,1))
    m = n
    l = 1
    do while (m.gt.1)
      do i = 1, m/2
        u = min(2*i*l,n)
        call merger(c(2*(i-1)*l+1:(2*i-1)*l,:),c((2*i-1)*l+1:u,:))
      end do
      l = 2*l
      m = (m+1)/2
    end do
    return
  end subroutine merge_sort
  subroutine merger(c1,c2)
    implicit none
    integer, intent(inout) :: c1(:,:), c2(:,:)
    integer :: c(size(c1(:,1))+size(c2(:,1)),size(c2(1,:)))
    integer :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(c1(:,1))
    n2 = size(c2(:,1))
    do while ((i1.le.n1).and.(i2.le.n2))
      if (c1(i1,1).le.c2(i2,1)) then
        c(i1+i2-1,:) = c1(i1,:)
        i1 = i1+1
      else
        c(i1+i2-1,:) = c2(i2,:)
        i2 = i2+1
      end if
    end do
    if (i1.le.n1) then
      c(i1+i2-1:n1+n2,:) = c1(i1:n1,:)
    else if (i2.le.n2) then
      c(i1+i2-1:n1+n2,:) = c2(i2:n2,:)
    end if
    c1 = c(1:n1,:)
    c2 = c(n1+1:n1+n2,:)
    return
  end subroutine merger
end program min_cost_cycle

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

int main() {
	string S;
	cin >> S;
	int a = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'o') a += 100;
	}
	cout << 700 + a << endl;
	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl                endl

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int x, int y) {                                                             //return x^y in order(log(y))
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}

class CFolia {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    N++;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int> cum(N);
    rep(i, N) {
      cum[i] = A[i];
    }
    rep(i, N - 1) {
      cum[N - 2 - i] += cum[N - i - 1];
    }
    int sum = 0;
    int now = 1;
    rep(i, N) {
      sum += now;
      now -= A[i];
      if (i == N - 1) break;
      if (now <= 0) {
        cout << -1 << endl;
        return;
      }
      if (now * 2 <= cum[i + 1]) {
        now *= 2;
      } else {
        now = cum[i + 1];
      }
    }
    if (now < 0) {
      cout << -1 << endl;
      return;
    }
    cout << sum << endl;
  }
};


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


Measured memory_bytes: 4796
#include <stdio.h>
int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i < 10; i++) {
		if ((N / i < 10) && (N%i == 0)) {
			printf("Yes\n");
			break;
		}
	}
	if (i == 10)
		printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	ll n,c,k,ans=0;
	cin>>n>>c>>k;
	vector<ll> t(n);
	rep(i,n)cin>>t[i];
	//今の時刻を取る.
	sort(all(t));

	ll now=t[0],wait=1;
	FOR(i,1,n){
		if(t[i]>now+k){
			now=t[i];
			wait=0;
			ans++;
		}
		wait++;
		if(wait==c){
			wait=0;
			ans++;
			if(i+1<n)now=t[i+1];
		}
	}
	if(wait!=0)ans++;
	cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(){
   
 int H, W, i, j;
   
 while(1) {
  scanf("%d%d",&H,&W);
  if(H == 0 && W == 0) break;
   for(i = 1; i <= H; i++) {
    for(j = 1; j <= W; j++) {
     if((i+j)%2 == 0) {
      printf("#");
     } else {
      printf(".");
     }
    }
    printf("\n");
   }
   printf("\n");
 }
   
 return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <string>
#include <stack>
#include <algorithm>
using namespace std;

int char_to_int(char c) {
    return static_cast<int>(c -'0');
}

int m_rule(string expr) {
    stack<int> s;
    for(int i=0; i<expr.size(); ++i) {
        if(expr[i] == '*') {
            int l = s.top();
            s.pop();
            s.push(l * char_to_int(expr[i+1]));
            i++;
        } else if('0' <= expr[i] && expr[i] <= '9') {
            s.push(char_to_int(expr[i]));
        }
    }
    int ret = 0;
    while(!s.empty()) {
        ret += s.top();
        s.pop();
    }
    return ret;
}

int l_rule(string expr) {
    int ret = 0;
    for(int i=0; i<expr.size(); ++i) {
        if(expr[i] == '*') {
            ret *= char_to_int(expr[i+1]);
            i++;
        } else if(expr[i] == '+') {
            ret += char_to_int(expr[i+1]);
            i++;
        } else {
            ret = char_to_int(expr[i]);
        }
    }
    return ret;
}

int main() {
    string expr;
    int ans;
    cin >> expr >> ans;

    int m = m_rule(expr);
    int l = l_rule(expr);
    if(m == ans && l == ans) {
        cout << "U" << endl;
    } else if(m == ans) {
        cout << "M" << endl;
    } else if(l == ans) {
        cout << "L" << endl;
    } else {
        cout << "I" << endl;
    }
}


Measured memory_bytes: 3224
N = int(input())
A = [int(x) for x in input().split()]
 
if 0 in A:
    out = 0
    for i in A:
        out += abs(i)
    print(out)
else:
    count = 0
    for i in A:
        if i < 0:
            count += 1
    
    if count%2 == 0:
        out = 0
        for i in A:
            out += abs(i)
        print(out)
    else:
        count = 10 ** 9
        for i in A:
            if abs(i) < count:
                count = abs(i)
        
        out = 0
        for i in A:
            out += abs(i)
        out = out - count*2
        
        print(out)

Measured memory_bytes: 64752
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;

bool check(string s) {
	string rev = s;
	reverse(rev.begin(), rev.end());
	return s == rev;
}

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

	int N, L;
	cin >> N >> L;

	set<string> sset;
	map<string, int> m;
	for(int i = 0; i < N; i++) {
		string s;
		cin >> s;
		m[s]++;
		sset.insert(s);
	}

	string s1, s2;
	for(auto s : sset) {
		string rev = s;
		reverse(rev.begin(), rev.end());
		if(m.count(rev) == 0 || m[rev] == 0) continue;

		int cnt = s == rev ? m[s] / 2 : min(m[s], m[rev]);

		for(int i = 0; i < cnt; i++) {
			s1 += s;
			s2 += s;
		}
		m[s] -= cnt;
		m[rev] -= cnt;
	}

	reverse(s2.begin(), s2.end());

	string mid;
	for(auto s : sset) {
		if(m[s] && check(s)) {
			mid = s;
			break;
		}
	}

	cout << s1 + mid + s2 << endl;
}

Measured memory_bytes: 3340
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <iomanip>

using namespace std;

int main(){
	int N, M;
	long ans = 0;
	vector<tuple<long, long>> AB;

	cin >> N >> M;

	for(int i = 0; i < N; ++i){
		long Ai, Bi; cin >> Ai >> Bi;
		AB.push_back(make_tuple(Ai, Bi));
	}

	sort(begin(AB), end(AB));

	int tmp = 0;
	for(int i = 0; i < N; ++i){
		tmp = M - get<1>(AB[i]);
		if(tmp > 0){
			ans += get<0>(AB[i]) * get<1>(AB[i]);
			M -= get<1>(AB[i]);
		}else{
			ans += get<0>(AB[i]) * M;
			break;
		}
	}

	cout << setprecision(16) << ans << endl;

	return 0;
}


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

int main(int argc, char const *argv[])
{
	int n;
	while(~scanf("%d",&n)){
		bool f=false;
		for (int i = n; i >0 ; --i)
		{
			if ((int)((double)i*1.08)==n)
			{
				printf("%d\n",i );
				f=true;
				break;

			}
		}
		if (!f)
		{
			printf(":(\n");
		}
	}
	return 0;
}

Measured memory_bytes: 764
#include <stdio.h>
#define INF 100000000

int Dijkstra(const int D[128][128],int n,int s,int f){
	int i,dist[128],done[128];
	
	for(i=0;i<n;i++){
		dist[i] = INF;
		done[i] = 0;
	}
	dist[s] = 0;
	for(;;){
		int e = -1;
		for(i=0;i<n;i++){
			if(done[i]==0 && (e == -1 || dist[i] < dist[e])){
				e = i;
			}
		}
		if(e == -1)break;
		done[e] = 1;
		
		if(e == f) return dist[e];
		for(i=0;i<n;i++){
			int pw = dist[e] + D[e][i];
			if(pw < dist[i])
				dist[i] = pw;
		}
	}
	return INF;
}


int main(void){
	int n,k;
	
	while(scanf("%d%d",&n,&k),n,k){
		int t,start,goal,c=0;
		int island1,island2,ans[4000],price;
		int D[128][128]={0};
		
		for(int j=0;j<128;j++){
			for(int k=0;k<128;k++){
				D[j][k]=INF;
				if(j==k)D[j][k]=0;
			}
		}
		
		for(int i=0;i<k;i++){
			scanf("%d",&t);
			if(t==0){
				scanf("%d %d", &start, &goal);
				ans[c] = Dijkstra(D,n+1,start,goal);
				if(ans[c]==INF){
					ans[c]=-1;
				}
				c++;
			}
			else {
				scanf("%d %d %d", &island1, &island2, &price);
				if(D[island1][island2] > price){
					D[island1][island2] = price;
					D[island2][island1] = price;
				}
					
			}
		}
		for(int i=0;i<c;i++){
			printf("%d\n",ans[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 848
#include<bits/stdc++.h>
using namespace std;
int main() {
  char s[10];
  cin >> s;
  sort(s, s+4);
  if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes" << endl; 
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    string s,t;cin>>s>>t;
    ll cnt=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i])cnt++;
    }
    cout<<cnt<<"\n";
}


Measured memory_bytes: 3800
"""

AtCoder Beginner Contest 129  E - Sum Equals Xor

XORは桁上がりがないので、A xor B がA+Bより大きくなることはない（最大でもA+Bまで）
なので、 A xor B = A + B が成立するのは、AとBを二進数でみたときに、両方1が立っているbitがないこと。

桁DPの文脈で考えると、
dp1,2[i] : AやBの左からi文字目までを決めたときに、
・dp2 : その時点でのA+BがL以下になることがわかっている（左からi番目までについて、A+Bのp桁目は0だが、Lのp桁目は1、みたいなのが存在する（先頭～p-1までは一致してもしなくてもOK））AとBの組の個数
・dp1 : その時点ではA+BがL以下になるか分からないAとBの組の個数（その時点まではLのi桁目までと一致する組の数）



遷移について、
Lのi桁目が
・0の場合
 - dp1 : dp2から遷移するとL以下になることが確定するので、dp2から遷移してくることはない＆A+Bのiビット目に1が立つとLを上回るので、0になるしかなく、i桁目は両方0の１通りで遷移
 - dp2 : dp1から遷移してきてi番目に0をいれても、L以下になるか確定しないので、dp1からの遷移はない。一方で。dp2から遷移してくる場合、既にL以下であることが確定しているので、A,B = 1,1以外の３パターンをとれる
・1の場合
 - dp1 : dp2から遷移してくるのを考えると、dp2の時点で既にL以下になるのが確定しているので、dp2からは遷移できない。一方で、dp1から遷移してくる場合、i桁目までLと同じになるので、A,Bの一方が1で他方が0の２通りをとれる
 - dp2 : dp1から遷移して A,B=0,0 をとればL以下が確定＆dp2から遷移して 1,1 以外の3通りの遷移

"""


L = input()
N = len(L)
MOD = 10**9 + 7

dp1 = [0] * (N+1)
dp2 = [0] * (N+1)
dp1[0] = 1


for i in range(N):
    if L[i] == "0":
        dp1[i+1] = dp1[i] # (0,0)
        dp2[i+1] = dp2[i] * 3 # (1,1)以外の3つ
    else:
        dp1[i+1] = dp1[i] * 2 # (1,0), (0,1)
        dp2[i+1] = dp2[i] * 3 + dp1[i] # dp2から遷移してくる場合は(1,1)以外の3つ、dp1から遷移してくる場合は1にならないとよいので(0,0)

    dp1[i+1] %= MOD
    dp2[i+1] %= MOD

print((dp1[-1] + dp2[-1]) % MOD)

Measured memory_bytes: 11124
(defun AddSubMul (a b)
  (let ((n (+ a b)) (m (- a b)) (l (* a b)))
    (max n m l)))

(defun split-string (str)
  (let ((string-position (position #\Space str)))
    (cond
      ((null string-position) (list str))
      (t (cons (subseq str 0 string-position) (split-string (subseq str (1+ string-position))))))))

(format t "~A~%" 
  (apply #'AddSubMul (mapcar #'parse-integer (split-string (read-line)))))

Measured memory_bytes: 12516
use proconio::*;
use proconio::marker::Usize1;

fn run() {
    input! {
        n: usize,
        m: usize,
        h: [u32; n],
        e: [(Usize1, Usize1); m],
    }
    let mut a = vec![1; n];
    for (x, y) in e {
        if h[x] <= h[y] {
            a[x] = 0;
        }
        if h[x] >= h[y] {
            a[y] = 0;
        }
    }
    let ans: u32 = a.into_iter().sum();
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 6428
io = STDIN
n=io.gets.to_i
$a=io.gets.split.map(&:to_i)
def check(i)
  if $a[i]==i+1 &&
    $a[i+1]==i+2
    $a[i+1],$a[i]=$a[i],$a[i+1]
    $ans+=1
    return true
  else
    return false
  end
end
$ans=0
top=0
lst=n-2
turn=:top
while top<=lst
  if turn == :top
    if check(top)
      turn = :lst
    else
      top+=1
    end
  else
    if check(lst)
      turn = :top
    else
      lst-=1
    end
  end
end
$a.each_with_index do |x,i|
  if x==i+1
    $ans+=1
  end
end
puts $ans


Measured memory_bytes: 8076
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define def(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(ll i=a;i<n;i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        ll a,b,n; cin>>n>>a>>b;
        ll ans = n/(a+b)*a;
        ans+=min(a,n%(a+b));
        cout<<ans;
    }   
}



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

#define mp make_pair
#define pb push_back

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int MAX_N = 100000;
int n,k;
int x[MAX_N];

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

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

  int t = INT_MAX;
  for (int i = 0; i+k-1 < n; i++) {
    if (x[i] < 0 && x[i+k-1] >= 0) {
      t = min(t, -x[i] + x[i+k-1] + min(-x[i], x[i+k-1]));
    } else {
      t = min(t, max(abs(x[i]), abs(x[i+k-1])));
    }
  }
  cout << t << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int main()
{
	char a[5];
	scanf("%s",&a);
	if(a[1] == a[2] && (a[0] == a[1] || a[2] == a[3]))
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    string s; cin>>s;
    cout<<s;
    if (s[sz(s)-1] == 's') cout << "es"<< endl;
    else co ("s");
}

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


Measured memory_bytes: 3628
N,K = map(int,input().split())
M = (N-1)*(N-2)//2

if M >= K:
    print(M-K+N-1)
    for i in range(1,N):
        print(1,1+i)
    tmp = 0
    for i in range(2,N):
        for j in range(i+1,N+1):
            if tmp == M-K:
                break
            print(i,j)
            tmp += 1
else:
    print(-1)

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var N = ReadLine();
        WriteLine(N.Length == 1 ? int.Parse(N) : N.Skip(1).Count(x => x == '9') == N.Length - 1 ? N.Select(x => int.Parse(x + "")).Sum() : ((int.Parse(N.First() + "") - 1).ToString() + "9999999999999999".Substring(0, N.Length - 1)).Select(x => int.Parse(x + "")).Sum());
    }
}

Measured memory_bytes: 11348
A,B,C = map(int,input().split())
count = 0
while A%2 == 0 and B%2 == 0 and C%2 == 0 and count < 10**5:
  A_copy = A
  B_copy = B
  A = (B+C)/2
  B =(A_copy+C)/2
  C = (A_copy+B_copy)/2
  count += 1
if count == 10**5:
  print(-1)
else:
  print(count)

Measured memory_bytes: 67420
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define PI 3.14159265359
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n); rep(i,n) cin >> a[i];
    vector<int> lm(n);
    vector<int> rm(n);
    for(int i=1; i<n; ++i) lm[i] = max(lm[i-1], a[i-1]);
    for(int i=n-2; i>=0; --i) rm[i] = max(rm[i+1], a[i+1]);
    rep(i,n) cout << max(rm[i], lm[i]) << "\n";
}

Measured memory_bytes: 3968
import java.util.*;

public class Main {
	final static long MODULO = 1_000_000_000 + 7;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int T = Integer.parseInt(sc.next());
		int[] D = new int[N];
		for (int i = 0; i < N; ++i) {
			D[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(D);
		long ans = 1;
		int s = 0;
		for (int i = 0; i < N; ++i) {
			while (s < i && D[s] < D[i] - T) {
				++s;
			}
			ans = (ans * (i - s + 1)) % MODULO;
		}
		System.out.println(ans);

	}
}

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

int main(){
  double data;
  cin>>data;
  data=data/1000;
  int k=10,flag=0;
  for(int i=0;i<3;i++){
    data=data*k;
    if((int)data==7){
      flag=1;
      break;
    }
    
    data=data-(int)data;
  }
  if(flag==1)cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 3724
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

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 chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
const int MAX = 10000;
class shuturyoku_unko {
public:
	char C[MAX * 4];
	constexpr shuturyoku_unko() : C() {
		rep(i, MAX) {
			int X = i;
			rep(j, 4) {
				C[i * 4 + 3 - j] = '0' + X % 10;
				X /= 10;
			}
		}
	}
};
constexpr shuturyoku_unko f;
const int dm = 1 << 17;
char *dn = cn, * di = dn, * owad = dn + dm - 20;
inline void putint(int X) {
	if (owad < di) {
		fwrite(dn, 1, di - dn, stdout);
		di = dn;
	}
	if (X >= 10000) {
		if (X >= 100000) {
			memcpy(di, f.C + X / 10000 * 4 + 2, 2);
			memcpy(di + 2, f.C + X % 10000 * 4, 4);
			di += 6;
		}
		else {
			memcpy(di, f.C + X / 10000 * 4 + 3, 1);
			memcpy(di + 1, f.C + X % 10000 * 4, 4);
			di += 5;
		}
	}
	else {
		if (X >= 1000) memcpy(di, f.C + X * 4, 4), di += 4;
		else if (X >= 100) memcpy(di, f.C + X * 4 + 1, 3), di += 3;
		else if (X >= 10) memcpy(di, f.C + X * 4 + 2, 2), di += 2;
		else memcpy(di, f.C + X * 4 + 3, 1), di += 1;
	}
	*di++ = '\n';
}
const int bm = 500001;
int BIT[bm];
void add(int A) {
	while (A > 0) {
		BIT[A]++;
		A -= A & -A;
	}
}
int query(int A) {
	int ret = 0;
	while (A < bm) {
		ret += BIT[A];
		A += A & -A;
	}
	return ret;
}
int L[500001], R[500001], C[500001], ne[500001];
int are[500001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), Q = getint();
	rep1(i, N) C[i] = getint();
	rep1(i, Q) {
		L[i] = getint();
		int r = getint();
		ne[i] = R[r];
		R[r] = i;
	}
	rep1(i, N) {
		if (are[C[i]]) add(are[C[i]]);
		are[C[i]] = i;
		
		for (int r = R[i]; r; r = ne[r]) {
			L[r] = i - L[r] - query(L[r]) + 1;
		}
	}

	rep1(i, Q) putint(L[i]);
	fwrite(dn, 1, di - dn, stdout);


	Would you please return 0;
}

Measured memory_bytes: 14992
#include <stdio.h>
#include <math.h>
int main(void) {
    long int a, b, n, m, i;
    long int sum = 0;
    scanf("%ld", &n);
    scanf("%ld\n", &m);
    for(i = 1; i <= m; i++) {
        scanf("%ld\n", &a);
        sum = sum + a;
    }
    b = n - sum;
    if(b < 0) {
        printf("-1\n");
    }
    else {
        printf("%ld\n", b);
    }
    return 0;
}

Measured memory_bytes: 2148
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	while(scanf("%d",&n) && n){
		string a;
		cin >> a;
		for(int i=0;i<n;i++){
			string b;
			int ro=1;
			for(int i=1;i<a.size();i++){
				if(a[i-1]==a[i]){
					ro++;
				}else{
					string ru;
					while(ro){
						int r=ro%10;
						ru.push_back(r+'0');
						ro/=10;
					}
					ro=1;
					reverse(ru.begin(),ru.end());
					b+=ru;
					b.push_back(a[i-1]);
				}
			}
					string ru;
					while(ro){
						int r=ro%10;
						ru.push_back(r+'0');
						ro/=10;
					}
					ro=1;
					reverse(ru.begin(),ru.end());
					b+=ru;
					b.push_back(a[a.size()-1]);
					a=b;
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 1368
#define MyDebug
#include <bits/stdc++.h>

#define rep(i, first, to) for(ll i = first; i < to; ++i)
#define REP(i, first, to) for(ll i = first; i <= to; ++i)

#ifdef MyDebug
	#define debug(x) cerr << #x << " : " << x << endl
	#define debugP(x) cerr << x << endl
#else
	#define debug(x)
	#define debugP(x)
#endif

using namespace std;
typedef long long ll;

ll n, a, b, c, d;
bool isOk(ll y1, ll y2) {
	return y1 <= b && b <= y2;
}
void solve() {
	cin >> n >> a >> b >> c >> d;

	ll u = a, v = a;
	ll delta = d - c;
	if (isOk(u + c * (n - 1), v + d * (n - 1)) || isOk(u - d * (n - 1), v - c * (n - 1))){
		cout << "YES" << endl;
		return;
	}
	REP(i, 3, n) {
		if (i % 2 == 1) {
			u = u - delta;
			v = v + delta;
			//debug(u);
			//debug(v);
			//cerr << endl;
			if (isOk(u + c * (n - i), v + d * (n - i)) || isOk(u - d * (n - i), v - c * (n - i))){
				cout << "YES" << endl;
				return;
			}
		}

		if (n % 2 == 1) {
			if (isOk(u, v)) {
				cout << "YES" << endl;
				return;
			}
		}	
	}
	cout << "NO" << endl;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define re register
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define per(i,n,m) for(int i=m;i>=n;i--)
#define rrep(i,m,n) for(register int i=m;i<=n;i++)
#define rper(i,n,m) for(register int i=m;i>=n;i--)
#define ull unsigned  long long
using namespace std;
const int INF =1e9+10;
const int N = 1e2 + 10;    ll x,k,d;
signed main() {
    cin>>x>>k>>d;
    if(!x){
        if(k&1)cout<<d;
        else cout<<0;
        return 0;
    }
    if(x<0){
        ll tmp=(-x)/d;
        ll dis=x+tmp*d;
        if(k<=tmp){
            cout<<abs(x+k*d);
            return 0;
        }else{
            k-=tmp;
            ll dis2=abs(x+tmp*d);
            ll dis3=dis+d;
            if(k&1){
                cout<<abs(dis3);
            }else{
                cout<<abs(dis2);
            }
            return 0;
        }
    }
    if(x>0){
        ll tmp=(x)/d;
        ll dis=x-tmp*d;
        if(k<=tmp){
            cout<<abs(x-k*d);
            return 0;
        }else{
            k-=tmp;
            ll dis2=abs(x-tmp*d);
            ll dis3=dis-d;
            if(k&1){
                cout<<abs(dis3);
            }else{
                cout<<abs(dis2);
            }
            return 0;
        }
    }
    return 0;
}


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

int main(){
    char a[11];
    cin >> a ;
    if(a[0]=='Y'){
        if(a[1]=='A'){
            if(a[2]=='K'){
                if(a[3]=='I'){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


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

namespace _20200802ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] nd = Console.ReadLine().Split(" ");
            double N = double.Parse(nd[0]);
            double D = double.Parse(nd[1]);

            int distances = 0;
            for(var i = 1; i <= N; i++)
            {
                string[] xy = Console.ReadLine().Split(" ");
                double x = double.Parse(xy[0]);
                double y = double.Parse(xy[1]);

                double result = System.Math.Sqrt((x*x)+(y*y));

                if(result <= D)
                {
                    distances++;
                }
            }
            Console.WriteLine(distances);
        }

        static int[] arrayGen()
        {
            string[] input = Console.ReadLine().Split(" ");
            int[] output = new int[input.Length];
            for(var i = 0; i< input.Length; i++)
            {
                output[i] = int.Parse(input[i]);
            }
            return output;
        }
    }
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

const ll M = 1000000009;

const int matrix_siz = 75;
struct sq_matrix{
	ll n;
	ll a[matrix_siz][matrix_siz];
	void init(int n_){
		n = n_;
		rep(i,n){
			rep(j,n){
				if(i == j)a[i][j] = 1;
				else a[i][j] = 0;
			}
		}
	}
	sq_matrix operator * (const sq_matrix y) {
		sq_matrix ret; ret.n = this->n;
		rep(i,this->n){
			rep(j,this->n){
				ret.a[i][j] = 0;
				rep(k,this->n){
					ret.a[i][j] += this->a[i][k] * y.a[k][j];
					ret.a[i][j] %= M;
				}
			}
		}
		return ret;
	}
};

sq_matrix sq_matrix_powers[62];
void sq_matrix_powers_init(sq_matrix x,int n){
	sq_matrix_powers[0] = x;
	rep1(i,61)sq_matrix_powers[i] = sq_matrix_powers[i-1]*sq_matrix_powers[i-1];
}
sq_matrix sq_matrix_pow(ll k){
	sq_matrix ret; ret.init(sq_matrix_powers[0].n);
	rep(i,61)if((k>>(ll)i)%2 == 1)ret = ret * sq_matrix_powers[i];
	return ret;
}

int main(){
	int test = 0;
	while(1){
		test ++;
		ll w,h,n;
		vector<P> vec;
		scanf("%lld%lld%lld",&w,&h,&n);
		if(w == 0)break;
		else printf("Case %d: ",test);
		rep(i,n){
			ll a,b;
			scanf("%lld%lld",&a,&b);
			if(b != 1)vec.pb( P(b,a-1) );
		}
		sor(vec);
		
		sq_matrix a; a.n = w;
		rep(i,w){
			rep(j,w){
				if(abs(i-j) <= 1)a.a[i][j] = 1;
				else a.a[i][j] = 0;
			}
		}
		sq_matrix_powers_init(a,w);
		sq_matrix ret; ret.init(w);
		ll loc = 1;
		rep(i,vec.size()){
			ret = ret*sq_matrix_pow(vec[i].fr-1-loc);
			loc = vec[i].fr;
			sq_matrix b = a;
			while(i < vec.size() && vec[i].fr == loc){
				rep(j,w)b.a[j][vec[i].sc] = 0;
				i ++;
			}
			i --;
			ret = ret*b;
		}
		ret = ret*sq_matrix_pow(h-loc);
		cout << ret.a[0][w-1] << endl;
	}
}
	

Measured memory_bytes: 4384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main()
{
    int X,Y ,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> numA(A);
    vector<int> numB(B);
    vector<int> numC(C);
    rep(i,A) cin >> numA[i];
    rep(i,B) cin >> numB[i];
    rep(i,C) cin >> numC[i];

    sort(numA.begin(), numA.end());
    reverse(numA.begin(), numA.end());
    sort(numB.begin(), numB.end());
    reverse(numB.begin(), numB.end());
    
    vector<int> numAll(X+Y+C);
    rep(i,X) numAll.push_back(numA[i]);
    rep(i,Y) numAll.push_back(numB[i]);
    rep(i,C) numAll.push_back(numC[i]);

    sort(numAll.begin(), numAll.end());
    reverse(numAll.begin(), numAll.end());

    int64_t count = 0;
    int T;
    T = X + Y;
    rep(i,T){
        count = count + numAll[i];
    }

    cout << count << endl; 
    
    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 2100, mod = 924844033;

ll dp[N][N][2], res[N], foo[N];
ll fact[N];

int main(){
	int n, k; cin >> n >> k;
	for(int i=0; i<=n; i++)
		dp[i][0][0] = 1;


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

			dp[i][j][0] += dp[i - 1][j][0] + dp[i - 1][j][1];
			dp[i][j][0] %= mod;

			if(j>1){
				dp[i][j][0] += dp[i - 2][j - 2][0] + dp[i - 2][j - 2][1];
				dp[i][j][0] %= mod;
			}

			dp[i][j][1] = dp[i - 1][j - 1][1];
			dp[i][j][1] += (2LL * dp[i - 2][j - 1][0] + 2LL * dp[i - 2][j - 1][1]) % mod;
			dp[i][j][1] %= mod;

		}

	res[0] = 1;
	int sum = 0;

	for(int r=0; r<k; r++){
		int tool;
		if(r < (n%k))
			tool = (n + k - 1)/k;
		else tool = n/k;

		for(int i=0; i<=sum+tool; i++)
			foo[i] = 0;

		for(int i=0; i<=tool; i++)
			for(int j=0; j<=sum; j++){
				foo[i + j] += (1LL * res[j] * (dp[tool][i][0] + dp[tool][i][1])) % mod;
				foo[i + j] %= mod;
			}

		sum += tool;
		for(int i=0; i<=sum; i++)
			res[i] = foo[i];
	}

	fact[0] = 1;
	for(int i=1; i<=n; i++)
		fact[i] = (1LL * fact[i - 1] * i) % mod;

	ll ans = fact[n];
	for(int i=1; i<=n; i++){
		if(i % 2){
			ll bad = (1LL * fact[n - i] * res[i]) % mod;
			ans += mod - bad; ans %= mod;
		}else{
			ll good = (1LL * fact[n - i] * res[i]) % mod;
			ans += good; ans %= mod;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 66048
using System;


namespace tst
{
    class Program
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] x= Console.ReadLine().Split(' ');
            string s = x[0];
            string t = x[1];
            bool flag = true;//boolでsとt交互に表示
            for (int i = 0; i < 2*n; i++){
                if (flag)
                {//偶数番目
                    Console.Write(s[i / 2]);
                    flag = false;
                }
                else
                {//奇数番目
                    Console.Write(t[(i - 1) / 2]);
                    flag = true;
                }
            }
            Console.WriteLine();
        }

    }
}

Measured memory_bytes: 13140
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


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

    else
    {
        cout << "No";
    }
    
    cout << endl;
}


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

int main() {
	int n,k; cin >> n >> k;
  	vector<int> sunuke(n,0);	
  
  	for(int i = 0;i < k;i++) {
    	int num; cin >> num;
      	for(int j = 0;j < num;j++) {
        	int tmp; cin >> tmp;
          	sunuke[tmp - 1]++;
        }
    }
  	int result = 0;
  	for(int i = 0;i < sunuke.size();i++) {
    	if(sunuke[i] == 0) result++;
    }
    
	cout << result << "\n";
}

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


int main() {
    vector<int> a(3);
    for(int i=0;i<3;i++){
        cin>>a.at(i);
    }

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

    int count=0;
    for(int i=0;i<3;i++){
        if(i==0){
            count+=0;
        }else{
            count += (a.at(i)-a.at(i-1));
        }
    }
    cout<<count<<endl;
    return 0;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
#define MOD 1000000007
#define INF 1000000
#define PI 3.14159265358979323846264338327950L
#define MAX_N 200010

int par[MAX_N];//親の番号
int siz[MAX_N];//木のサイズ
int par1[MAX_N];//親の番号
int siz1[MAX_N];//木のサイズ
//int rnk[MAX_N];

void init(int n)
{
  //根の定義・・・par[i]=iの時iを根という
  //最初全てが根
  for (int i=0;i<=n;i++){
    par[i]=i;
    siz[i]=1;
  }
}

void init1(int n)
{
  for (int i=0;i<=n;i++){
    par1[i]=i;
    siz1[i]=1;
  }
}

//木の根を求める
int root(int x){
  if (par[x]==x){  //xが根の時
    return (x); 
  }else{
    par[x]=root(par[x]);//xを、xの親の根につなぎ直す
    return par[x]; //経路圧縮
  }
}

int root1(int x){
  if (par1[x]==x){  //xが根の時
    return (x); 
  }else{
    par1[x]=root1(par1[x]);//xを、xの親の根につなぎ直す
    return par1[x]; //経路圧縮
  }
}

//x,yが同じ集合に属しているか、つまり同じ根に繋がっているか
bool same(int x,int y){
  return ( root(x)==root(y) );
}
bool same1(int x,int y){
  return ( root1(x)==root1(y) );
}

//x,yの属する集合を合併する
bool merge(int x, int y) {
   x = root(x); y = root(y);
   if (x == y) return false;
   if (siz[x] < siz[y]) swap(x, y);
   siz[x]+=siz[y];
   par[y] = x; //ランクが大きい方に小さい方を繋げる
   return true;
}

bool merge1(int x, int y) {
   x = root1(x); y = root1(y);
   if (x == y) return false;
   if (siz1[x] < siz1[y]) swap(x, y);
   siz1[x]+=siz1[y];
   par1[y] = x; //ランクが大きい方に小さい方を繋げる
   return true;
}

int treesize(int x)
{
  return (siz[root(x)]); 
}

int main()
{
  int N,K,L;cin>>N>>K>>L;
  init(N);init1(N);
  for (int i=1;i<=K;i++)
  {
    int a,b;cin>>a>>b;
    merge(a,b);
  }
  for (int i=1;i<=L;i++)
  {
    int a,b;cin>>a>>b;
    merge1(a,b);
  }
  
  //ここでi,jでforを二回回してしまうとTLE
  //mapを使ってペアを数えてあげる？？？
  map<P,int> m;
  for (int i=1;i<=N;i++)
  {
    pair<int,int> p=make_pair(root(i),root1(i));
    m[p]++;
  }
  
  int count=0;
  for (int i=1;i<=N;i++)
  {
    pair<int,int> q=make_pair(root(i),root1(i));
    cout<<m[q]<<" "; 
  }
  
}


Measured memory_bytes: 15104
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <deque> 

using namespace std;


int n;
char s[200010];
struct Section
{
	char type;
	int count;
	
	int lChWhiteSum;
	int lChBlackSum;
	
	int rChWhiteSum;
	int rChBlackSum;
};
std::vector<Section> ss;


int main()
{
	scanf("%d\n", &n);
	scanf("%s", s);
	
	char curCh = s[0];
	int curCount = 0;
	Section newSection;	
	
	for (int i = 0 ; i < n ; i++)
	{
		if (curCh == s[i])
		{
			curCount++;
		}
		else
		{
			newSection.type = curCh;
			newSection.count = curCount;
			ss.push_back(newSection);
				
			curCount = 1;
			curCh = s[i];
		}
	}
	
	newSection.type = curCh;
	newSection.count = curCount;
	ss.push_back(newSection);
	
	//===============
	
	if (ss[0].type == '#')	//black
	{
		ss[0].lChWhiteSum = ss[0].count;
		ss[0].lChBlackSum = 0;
	}
	else	//white
	{
		ss[0].lChWhiteSum = 0;
		ss[0].lChBlackSum = ss[0].count;
	}
	
	for (int i = 1 ; i < ss.size() ; i++)
	{
		ss[i].lChWhiteSum = ss[i - 1].lChWhiteSum;
		ss[i].lChBlackSum = ss[i - 1].lChBlackSum;
		
		if (ss[i].type == '#')	//black
			ss[i].lChWhiteSum += ss[i].count;
		else
			ss[i].lChBlackSum += ss[i].count;
	}
	
	//================
	
	int szSS = ss.size();
	if (ss[szSS - 1].type == '#')	//black
	{
		ss[szSS - 1].rChWhiteSum = ss[szSS - 1].count;
		ss[szSS - 1].rChBlackSum = 0;
	}
	else	//white
	{
		ss[szSS - 1].rChWhiteSum = 0;
		ss[szSS - 1].rChBlackSum = ss[szSS - 1].count;
	}
	
	for (int i = szSS - 2 ; i >= 0 ; i--)
	{
		ss[i].rChWhiteSum = ss[i + 1].rChWhiteSum;
		ss[i].rChBlackSum = ss[i + 1].rChBlackSum;
		
		if (ss[i].type == '#')	//black
			ss[i].rChWhiteSum += ss[i].count;
		else
			ss[i].rChBlackSum += ss[i].count;
	}
	
	
	//================
	
	int minCount = ss[0].rChBlackSum;
	if (minCount > ss[0].rChWhiteSum)
		minCount = ss[0].rChWhiteSum;
		
		
	for (int i = 0 ; i < ss.size() - 1 ; i++)
	{
		curCount = ss[i].lChWhiteSum + ss[i + 1].rChBlackSum;
		if (minCount > curCount)
			minCount = curCount;
	}
	
	//不需要再验证末尾了 
	
	printf("%d\n", minCount);
	
	return 0;
}

Measured memory_bytes: 8432
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}

main :: IO ()
main = do
  [a, b, c, d] <- map read . words <$> getLine
  putStrLn $ if a + b > c + d
                then "Left"
                else if a + b < c + d
                        then "Right"
                        else "Balanced"


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define erep(i, a, b) for (int i = a; i <= (int)(b); i++)
#define per(i, a, b) for (int i = (b)-1; i > (a); i--)
#define eper(i, a, b) for (int i = ((int)(a)); i >= b; i--)
#define pb push_back
#define mp make_pair
#define INF (1 << 30) - 1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

const int N_MAX = 40, M_MAX = 10;
int n, ma, mb, a[N_MAX + 1], b[N_MAX + 1], c[N_MAX + 1],
    dp[N_MAX + 1][N_MAX * M_MAX + 1][N_MAX * M_MAX + 1], ans = INF;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> ma >> mb;
  rep(i, 0, n) cin >> a[i] >> b[i] >> c[i];
  erep(i, 0, n) erep(j, 0, N_MAX * M_MAX) erep(k, 0, N_MAX * M_MAX)
      dp[i][j][k] = INF;

  dp[0][0][0] = 0;
  rep(i, 0, n) {
    erep(j, 0, N_MAX * M_MAX) {
      erep(k, 0, N_MAX * M_MAX) {
        if (dp[i][j][k] == INF)
          continue;
        dp[i + 1][j][k] = min(dp[i][j][k], dp[i + 1][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]);
      }
    }
  }
  erep(j, 0, N_MAX * M_MAX) {
    erep(k, 0, N_MAX * M_MAX) {
      if (j == 0 && k == 0)
        continue;
      if (j * mb == k * ma)
        ans = min(ans, dp[n][j][k]);
    }
  }
  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 25984
#include <bits/stdc++.h>
using namespace std;
int n;
int sol[100010], h[100010];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> h[i], sol[i] = 2000000000;

    sol[1] = 0;
    for (int i = 1; i <= n; i++) {
        int j = min(n, i + 1);
        sol[j] = min(sol[j], sol[i] + abs(h[i] - h[j]));

        j = min(n, i + 2);
        sol[j] = min(sol[j], sol[i] + abs(h[i] - h[j]));
    }

    cout << sol[n];
    return 0;
}





Measured memory_bytes: 1024