akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 998244353;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

ll fastPow(ll x, ll n)
{
    if (n == 0)
        return 1;
    if (n % 2 == 0)
        return fastPow(x * x % MOD, n / 2);
    else
        return x * fastPow(x, n - 1) % MOD;
}

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

    int n, a[310];
    int s = 0;

    cin >> n;
    REP(i, n)
    {
        cin >> a[i];
        s += a[i];
    }

    ll dp[2][100000];
    ll dp2[2][100000];

    memset(dp, 0, sizeof(dp));
    memset(dp2, 0, sizeof(dp2));

    dp[0][0] = 1;
    dp2[0][0] = 1;

    int cur = 0;
    int nex = 1;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= s; j++)
        {
            dp[nex][j] = 0;
            dp2[nex][j] = 0;
        }

        for (int j = 0; j < s; j++)
        {
            (dp[nex][j] += dp[cur][j] * 2) %= MOD;
            (dp2[nex][j] += dp2[cur][j]) %= MOD;
            if (j + a[i - 1] <= s)
            {
                (dp[nex][j + a[i - 1]] += dp[cur][j]) %= MOD;
                (dp2[nex][j + a[i - 1]] += dp2[cur][j]) %= MOD;
            }
        }

        swap(cur, nex);
    }

    ll res = fastPow(3, n);

    for (int i = (s + 1) / 2; i <= s; i++)
        res = (res - 3 * dp[cur][i] + 3 * MOD) % MOD;

    if (s % 2 == 0)
        (res += 3 * dp2[cur][s / 2]) %= MOD;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
void dprintf(const char *format, ...) {
  va_list arg;
  va_start (arg, format);
  vfprintf(stderr, format, arg);
  va_end(arg);
}
#define debug(arg) cerr << #arg << " = " << arg << endl;
#else
#define dprintf(...)
#define debug(x)
#endif
using ll = long long;

const int MOD = 1e9 + 7;

struct Matrix {
  vector<vector<int>> mat;
  
  Matrix(int n) {
    this->mat = vector<vector<int>>(n, vector<int>(n, 0));
  }
  
  int size() const {
    return mat.size();
  }
  
  const vector<int> &operator[] (int line) const {
    return mat[line];
  }
  
  vector<int> &operator[] (int line) {
    return mat[line];
  }
};

Matrix operator * (const Matrix &a, const Matrix &b) {
  int n = a.size();
  vector<vector<ll>> tmp =
      vector<vector<ll>>(n, vector<ll>(n, 0));
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        tmp[i][j] += (ll)a[i][k] * b[k][j];
        if (tmp[i][j] >= 8LL * MOD * MOD) {
          tmp[i][j] -= 8LL * MOD * MOD;
        }
      }
    }
  }
  Matrix answer(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      answer[i][j] = tmp[i][j] % MOD;
    }
  }
  return answer;
}

Matrix power(Matrix base, long long exp) {
  int n = base.size();
  Matrix answer(n);
  for (int i = 0; i < n; i++) {
    answer[i][i] = 1;
  }
  while (exp > 0) {
    if (exp % 2 == 1) {
      answer = answer * base;
    }
    base = base * base;
    exp /= 2;
  }
  return answer;
}

int main() {
  int n;
  long long k;
  scanf("%d%lld", &n, &k);
  Matrix g(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &g[i][j]);
    }
  }
  g = power(g, k);
  ll answer = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      //printf("%d ", g[i][j]);
      answer += g[i][j];
    }
    //printf("\n");
  }
  answer %= MOD;
  printf("%lld\n", answer);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  vector<string> ans;
  while (n--)
  {
    string messengers, message;
    cin >> messengers >> message;
    reverse(messengers.begin(), messengers.end());
    int len = message.size();
    for (int i = 0; i < messengers.size(); ++i)
    {
      if (messengers[i] == 'J')
      {
        rotate(message.rbegin(), message.rbegin() + 1, message.rend());
      }
      else if (messengers[i] == 'C')
      {
        rotate(message.begin(), message.begin() + 1, message.end());
      }
      else if (messengers[i] == 'E')
      {
        string tmp = "";
        tmp += message.substr(len % 2 == 0 ? len / 2 : len / 2 + 1, len / 2);
        if (len % 2 == 1)
          tmp += message[len / 2];
        tmp += message.substr(0, len / 2);
        message = tmp;
      }
      else if (messengers[i] == 'A')
      {
        reverse(message.begin(), message.end());
      }
      else if (messengers[i] == 'P')
      {
        for (int j = 0; j < len; ++j)
        {
          if ('0' <= message[j] && message[j] <= '9')
            message[j] = char((10 + message[j] - 1 - '0') % 10 + '0');
        }
      }
      else if (messengers[i] == 'M')
      {
        for (int j = 0; j < len; ++j)
        {
          if ('0' <= message[j] && message[j] <= '9')
            message[j] = char((message[j] + 1 - '0') % 10 + '0');
        }
      }
    }
    ans.push_back(message);
  }
  for (auto &e : ans)
    cout << e << endl;

  return 0;
}



Measured memory_bytes: 3020
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <set>
#include <queue>
#include <vector>

using namespace std;

constexpr static int MAXN = 2e5 + 10;

int n, k;
int a[MAXN];
int cnt[MAXN];

bool step() {
    for (int i = 0; i < n; i++)
        cnt[i] = 0;
    for (int i = 0; i < n; i++) {
        int l = max(0, i - a[i]);
        int r = min(n - 1, i + a[i]) + 1;
        cnt[l]++;
        cnt[r]--;
    }
    bool changed = false;
    int b = 0;
    for (int i = 0; i < n; i++) {
        b += cnt[i];
        changed |= (a[i] != b);
        a[i] = b;
    }
    return changed;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int j = 0; j < k; j++) {
        if (!step())
            break;
    }
    for (int i = 0; i < n; i++)
        cout << a[i] << (i + 1 == n ? '\n' : ' ');
}


Measured memory_bytes: 4716
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    string s;
    cin >> s;
    int red = 0,blue = 0;
    int ans = 0;
    for(int i = 0;i < s.length();i++){
        if(s[i] == '1'){
            //青が来た
            if(red > 0){
                red--;
                ans += 2;
            }else{
                blue++;
            }
        }else{
            if(blue > 0){
                blue--;
                ans += 2;
            }else{
                red++;
            }
        }
    }
    //cout << red << " " << blue << endl;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
import std.stdio,std.string,std.conv;

int main()
{
	string s;
	while((s = readln.chomp).length != 0)
	{
		string[] _s = s.split(",");
		int n = _s[0].to!int;
		double w = _s[1].to!double;
		double h = _s[2].to!double;

		if(25.0 <= w/(h*h))
		{
			n.writeln;
		}
	}
	return 0;
}

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

int main() {
 long long int N,K;
 cin>>N>>K;
 vector<long long int> A(N), F(N);
 vector<pair<long long int, pair<long long int, long long int>>> B(N);
 for(int i=0;i<N;i++) cin>>A[i];
 for(int i=0;i<N;i++) cin>>F[i];
 sort(A.begin(), A.end());
 sort(F.begin(), F.end(), greater<long long int>());
 long long int lower = 0, upper = 1e12;
 while(lower < upper){
   long long int mid = (lower + upper) / 2;
   long long int tmp = 0;
   for(int i=0;i<N;i++){
     if(A[i] - mid/F[i] > 0) tmp += A[i] - mid/F[i];
   }
   if(tmp <= K){
     upper = mid;
   }
   else{
     lower = mid + 1;
   }
 }
 cout<<lower<<endl;
}

Measured memory_bytes: 8192
extern crate core;

use std::io::{self, Read};
use std::cmp;
const N: i64 = 1000000007;

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let list = input
        .split_whitespace()
        .map(|x| x.parse::<i64>().unwrap())
        .collect::<Vec<_>>();
    let n = list[0];
    let m = list[1];
    if (n - m).abs() >= 2 {
        0
    } else {
        let min = fact_mod(cmp::min(n, m));
        if n == m {
            mul(mul(min, min), 2)
        } else {
            mul(mul(min, min), cmp::max(n, m))
        }
    }.to_string()
}

fn fact_mod(n: i64) -> i64 {
    let mut now = 1;
    for i in 1..n + 1 {
        now = mul(now, i);
    }
    now
}

fn mul(a: i64, b: i64) -> i64 {
    ((a % N) * (b % N)) % N
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!(super::run($input.to_string()), $output.to_string());
                }
            )*
        }
    }
}

tests! {
    test1: "2 2" => "8",
    test2: "3 2" => "12",
    test3: "1 8" => "0",
    test4: "100000 100000" => "530123477",
}


Measured memory_bytes: 4352
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
#define foR for

// FHCまでにスタックオーバーフローの罠を解決する


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

    ll n,k;
    cin>>n>>k;
    ll a[n];
    ll ma = 0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        chmax(ma,a[i]);
    }
    ll low=0,up=ma+1,mid;
    while(up-low>1){
        mid=(up+low)/2;
        ll cnt = 0;
        // all mid lower
        for(int i=0;i<n;i++){
            cnt += (a[i]-1) / mid;
        }
        if(cnt <= k){
            up=mid;
        }
        else{
            low=mid;
        }
    }
    cout << up << endl;
}

Measured memory_bytes: 5192
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int F[100][10];
int P[100][11];


int main() {

	int n; cin >> n;

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

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

	int ans = -(1<<30);
	

	for (int i = 1; i < (1 << 10); i++) {
		int ansbuf = 0;
		for (int k = 0; k < n; k++) {
			int matchedpair = 0;
			
			for (int j = 0; j < 10; j++) {
				if ((i >> j) & 1) {
					
					if (F[k][j] == 1) {
						matchedpair++;
					}
				
				}
			}
			ansbuf += P[k][matchedpair];
		}

		ans = max(ans, ansbuf);
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
	int a, b, c, d, e, f;
	while(cin >> a >> b >> c >> d >> e >> f){
		float detab = a*e-b*d;
		float deta = c*e-b*f;
		float detb = a*f-c*d;
		float x = deta/detab;
		float y = detb/detab;
		if(x == -0)
			x = 0;
		if(y == -0)
			y = 0;
		cout << fixed << setprecision(3);
		cout << x << " " << y << endl;
	}
}
//1 2 3 4 5 6
//2 -1 -2 -1 -1 -5
//2 -1 -3 1 -1 -3
//2 -1 -3 -9 9 27


Measured memory_bytes: 3136
n, m = map(int, input().split())
s = []
for _ in range(m):
    _s = list(map(int, input().split()))
    s +=[_s[1:]]
p = list(map(int, input().split()))

def on(l):
    for i in range(m):
        _s = s[i]
        cnt = 0
        for j in _s:
            cnt += l[j-1]
        if not cnt%2==p[i]:
            return 0
    return 1

from itertools import product

ans = 0
for x in product([0, 1], repeat=n):
    ans += on(x)

print(ans)


Measured memory_bytes: 39408
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
x, y = [], []
for i in range(h):
    c = 0
    for j in range(w):
        if a[i][j] == "#":
            c = 1
            break
    if c == 0:
        x.append(i)
for i in range(w):
    c = 0
    for j in range(h):
        if a[j][i] == "#":
            c = 1
            break
    if c == 0:
        y.append(i)
for i in range(h):
    if not i in x:
        for j in range(w):
            if not j in y:
                print(a[i][j], end = "")
        print()

Measured memory_bytes: 4596
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int ai;
    cin >> ai;
    while (ai % 2 == 0) {
      ++ans;
      ai /= 2;
    }
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main()
{
	int h , w;
	cin>>h>>w;
	char arr[h+1][w+1];
	int  dp[h+1][w+1];
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin>>arr[i][j];
			dp[i][j]=0;
		}
	}
	for(int i=1;i<=w;i++)
	{
		if(arr[1][i]=='#')
		  break;
		dp[1][i]=1;
	}
	for(int i=1;i<=h;i++)
	{
		if(arr[i][1]=='#')
		   break;
		dp[i][1]=1;
	}
	for(int i=2;i<=h;i++)
	{
		for(int j=2;j<=w;j++)
		{
			if(arr[i][j]!='#')
			  dp[i][j]=(dp[i-1][j] + dp[i][j-1])%mod;
		}
	}
	cout<<dp[h][w]<<endl;
}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    d = d * 2 + 1;

    cout << (n + d - 1) / d << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  
  vector<int> vec(N);
  for (int i=0;i<N;i++) {
    cin>>vec.at(i);
  }
  
  vec.push_back(0);
  int sum=0;
  for (int i=0;i<N;i++) {
    if (vec.at(i) > vec.at(i+1)) {
      sum+=vec.at(i) - vec.at(i+1);
    }
  }
  
  cout<<sum<<endl;
}


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

int mod = 998244353;

int bm(int b, int p, int m) {
    if(p == 0) return 1%m;
    int t = bm(b,p/2,m);
    t = (1ll*t*t)%m;
    if(p&1) return 1ll*t*b%m;
    return t;
}

const int M = 1e6 + 100;
int sz[M];
int dp[M];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];

        for(int j = 1; j <= 1000; j++) {
            if(v[i]%j == 0) {
                int d = v[i]/j;
                if(d < j) break;
                dp[j] += v[i];
                if(dp[j] >= mod) dp[j] -= mod;
                if(d != j) {
                    dp[d] += v[i];
                    if(dp[d] >= mod) dp[d] -= mod;
                }
            }
        }
    }

    int ans = 0;
    for(int i = M-1; i >= 1; i--) {
        dp[i] = 1ll*dp[i]*dp[i]%mod;
        for(int j = i + i; j < M; j += i) {
            dp[i] -= dp[j];
            if(dp[i] < 0) dp[i] += mod;
        }
        ans += 1ll*bm(i, mod-2, mod)*dp[i]%mod;
        ans %= mod;
    }
    for(int i = 0; i < n; i++) {
        ans -= v[i];
        ans %= mod;
    }
    ans = 1ll*ans*bm(2,mod-2,mod)%mod;
    ans %= mod;
    ans += mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5120
import sys
#input = sys.stdin.buffer.readline

def main():
    N,M = map(int,input().split())
    sa = [list(str(input())) for _ in range(N)]
    sb = [list(str(input())) for _ in range(M)]
    
    ans = False
    for i in range(N-M+1):
        for j in range(N-M+1):
            if sa[i][j] == sb[0][0]:
                count = 0
                for k in range(M):
                    for l in range(M):
                        if sa[i+k][j+l] == sb[k][l]:
                            count += 1
                if count == M**2:
                    ans = True
    
    if ans:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1200000
#define HUGE_NUM 99999999999999

int main(){

	int limit;
	ll* table = new ll[NUM];

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = sqrt(NUM);

	for(int i=2;i<=limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	int index = 0;
	ll* prime_table = new ll[550000];

	for(int i = 2; i < NUM; i++){
		if(table[i] == 1){
			prime_table[index++] = i;
		}
	}

	ll A,B;
	scanf("%lld %lld",&A,&B);

	ll left,right;

	if(A-B <= 2){
		left = 2;
	}else{
		left = A-B;
	}

	right = A+B;

	if(left > right){
		printf("0\n");
		return 0;
	}

	ll* check = new ll[right-left+1];
	for(int i = 0; i < right-left+1; i++){
		check[i] = HUGE_NUM;
	}

	bool* is_fox = new bool[right-left+1];
	for(int i = 0; i < right-left+1; i++)is_fox[i] = true;

	ll tmp,count,start;

	for(int i = 0; prime_table[i] <= sqrt(right); i++){

		if(left%prime_table[i] == 0){
			start = 0;
		}else{
			start = prime_table[i]*(left/prime_table[i]+1)-left;
		}

		if(left+start > right)continue;

		for(int k = start; k < right-left+1; k += prime_table[i]){

			if(!is_fox[k])continue;

			tmp = left+k;

			count = 0;

			while(tmp%prime_table[i] == 0){
				tmp /= prime_table[i];
				count++;
			}

			if(check[k] < count){
				is_fox[k] = false;
			}else{
				check[k] = count;
			}
		}
	}

	int ans = 0;

	for(int i = 0; i < right-left+1; i++){
		if(is_fox[i])ans++;
	}

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

	return 0;
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    ll n,q;
    ll sum=0;
    cin>>n;
    map<ll,ll> mp;
    rep(i,n){
        int a;
        cin>>a;
        sum+=a;
        mp[a]++;
    }
    cin>>q;
    rep(i,q){
        ll b,c;
        cin>>b>>c;
        ll x=mp[b];
        mp[b]=0;
        mp[c]+=x;
        sum-=x*b;
        sum+=x*c;
        cout<<sum<<endl;
    }
    return 0;
}

//a=97,z=122

Measured memory_bytes: 9492
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int l = in.nextInt();
            int r = in.nextInt();
            int d = in.nextInt();
            int ans = 0;
            for (int i = l; i <= r; i++) {
                if (i % d == 0) {
                    ans++;
                }
            }

            out.println(ans);
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 33992
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <queue>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}

int64_t gcd(int64_t a,int64_t b){
    if(a < b)
    {
        int64_t temp = a;
        a = b ;
        b = temp;
    }
    int64_t copya = a;
    int64_t copyb = b;
    int64_t r = a%b ;
    while (r != 0)
    {
        a = b ;
        b = r ;
        r = a%b ;
    }
    return b ;
    
}


int main(){    
    string s ;
    cin >> s ;
    int ans = 0 ;
    int now = 0 ;
    for (int i = 0; i < 3; i++)
    {
        if (s.at(i) == 'R' )
        {
            now ++ ;
            ans = max(ans,now) ;
        }else
        {
            now = 0 ;
        }
        
        
    }
    cout << ans << endl ;
    
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = LLONG_MAX;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll n, k;
vl a;
/******* define variable end *******/
vector<bool> seen3;

ll dfs3(vector<vector<ll>> &G, ll v, ll count) {
    seen3[v] = true; // v を訪問済にする
    count++;
    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen3[next_v]) break; // next_v が探索済だったらスルー
        return dfs3(G, next_v, count); // 再帰的に探索
    }
    return count;
}
// 深さ優先探索
vector<bool> seen;

pair<ll, ll> dfs(vector<vector<ll>> &G, ll v, ll count) {
    seen[v] = true; // v を訪問済にする
    count++;
    ll tmp = 0;
    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) {tmp = next_v;break; // next_v が探索済だったらスルー
        }
        return dfs(G, next_v, count); // 再帰的に探索
    }
    return make_pair(dfs3(G, tmp, 0),count);
}




ll dfs2(vector<vector<ll>> &G, ll v, ll count, ll mo) {
    count++;
    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
    	if(mo == count){
    		return next_v;
    	}
        return dfs2(G, next_v, count, mo); // 再帰的に探索
    }
    return v;
}

int solve() {
	cin >> n >> k;
	vector<vector<ll>> G(n);
	seen.resize(n);
	seen3.resize(n);
	a.resize(n);
	REP(i, n){
		cin >> a[i];
		G[i].push_back(a[i]-1);
	}
	pair<ll, ll> loo = dfs(G, 0, 0);
	ll mo;
	ll ktmp = k;
	if(loo.first == loo.second){
		if(ktmp <= loo.first){
			while(ktmp <= loo.first){
				ktmp += loo.first;
			}
		}
		mo = ktmp % loo.first;
	}else{
		if(ktmp <= loo.second){
			while(ktmp-loo.second <= loo.first){
				ktmp += loo.first;
			}
		}
		mo = (ktmp-loo.second) % loo.first;
	}
	ll anstmp;
	if(k >= mo + loo.second){
		anstmp = dfs2(G, 0, 0, mo+loo.second);
	}else{
		anstmp = dfs2(G,0, 0, k);
	}
	cout << anstmp + 1 << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 15876
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;


int main() {

	int N;
	string S;
	cin >> S;

	N = S.size();
	int ans = 0;
	for (int i = 0; i < (N)/2; i++) {
		if (S[i] != S[(N-1) - i]) {
			S[(N-1) - i] = S[i];
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int N = 1e2 + 10;
const int mod = 1e9 + 7;



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

    ll a, b;
    cin >> a >> b;
    cout << a * b / __gcd(a, b);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define MAXN maxn

using namespace std;

int N, A, B;
int t, sum, res;

signed main()
{
  IO;
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++) {
    t = i;
    sum = 0;
    while (t) {
      sum += t % 10;
      t /= 10;
    }
    if (A <= sum && sum <= B) {
      res += i;
    }
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=105;
int adj[maxn][maxn];
int g[maxn],used[maxn];
int n;
bool dfs(int x){
  for(int i=1; i<=n; i++){
    if(adj[x][i]&&!used[i]){
      used[i]=1;
      if(g[i]==0||dfs(g[i])){
      	g[i]=x;
      	return 1;
      }
    }
  }
  return 0;
}
int a[maxn],b[maxn],c[maxn],d[maxn];
int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
  	scanf("%d%d",&a[i],&b[i]);
  }
  for(int i=1;i<=n;i++){
  	scanf("%d%d",&c[i],&d[i]);
  }
  memset(adj,0,sizeof(adj));
  memset(g,0,sizeof(g));
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
    	if(a[i] < c[j] && b[i] < d[j]) adj[i][j] = 1;
    }
	}
  int ans=0;
  for(int i=1;i<=n;i++){
    memset(used,0,sizeof(used));
    if(dfs(i)) ans++;
  }
  printf("%d\n",ans);
  return 0;
}

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

int main() {

    long long int n;

    cin >> n;

    int ans = 12;

    for(long long int i=1; i*i<=n; i++){

        long long int b = n/i;

        /*if(i > b){
            break;
        }*/

        if(i*b == n){

            string s_i,s_b;

            stringstream ss;

            ss << i;
            ss >> s_i;

            stringstream sss;

            sss << b;
            sss >> s_b;

            ans = min(ans,static_cast<int>(max(s_i.size(),s_b.size())));

        }

    }

    cout << ans << endl;

    return 0;
}

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

namespace ABC_D
{
    class D053
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Dictionary<int, int> dic = new Dictionary<int, int>();
            for(int i = 0; i < A.Length; i++)
            {
                if (!dic.ContainsKey(A[i])) dic.Add(A[i], 0);
                dic[A[i]]++;
            }

            int m = dic.Count;
            int k = N - m;
            int r = k % 2 == 1 ? m - 1 : m;
            Console.WriteLine(r);
        }

    }
}


Measured memory_bytes: 24160
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

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

const int INF = 1 << 30;
const long long INFL = 1LL << 60;

ll MOD;
struct mint {
	ll x;
	mint(ll x=0):x((x%MOD+MOD)%MOD){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
	mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
	mint& operator*=(const mint a) {(x*=a.x)%=MOD; return *this;}
	mint operator+(const mint a) const {mint res(*this); return res+=a;}
	mint operator-(const mint a) const {mint res(*this); return res-=a;}
	mint operator*(const mint a) const {mint res(*this); return res*=a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
 		return a;
	}

	// For prime mod.
	// Do not use if MOD is not prime number !!
	mint inv() const { return pow(MOD-2);}
	mint& operator/=(const mint a) { return (*this) *= a.inv();}
	mint operator/(const mint a) const {mint res(*this); return res/=a;}
};

int n;
vvi g;
vi par;
vector<mint> dp, rdp;

void dfs(int s) {
    mint cnt = 1;
    for(auto i: g[s]) {
        if(i == par[s]) continue;
        par[i] = s;
        dfs(i);
        cnt *= dp[i] + 1;
    }
    dp[s] = cnt;
}

void rdfs(int s) {
    int m = g[s].size();
    vector<mint> fmul(m + 1, 1), bmul(m + 1, 1);
    rep(i, m) {
        if(g[s][i] == par[s]) fmul[i + 1] *= fmul[i] * (rdp[s] + 1);
        else fmul[i + 1] *= fmul[i] * (dp[g[s][i]] + 1);
    }
    for(int i = m - 1; i >= 0; i--) {
        if(g[s][i] == par[s]) bmul[i] *= bmul[i + 1] * (rdp[s] + 1);
        else bmul[i] *= bmul[i + 1] * (dp[g[s][i]] + 1);
    }
    rep(i, m) {
        int j = g[s][i];
        if(j == par[s]) continue;
        rdp[j] = fmul[i] * bmul[i + 1];
        rdfs(j);
    }
}

int main() {
//	cout << fixed << setprecision(15);
    cin >> n >> MOD;

    g = vvi(n, vi(0));
    rep(i, n - 1) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    par = vi(n, -1);
    dp = vector<mint>(n);
    dfs(0);

    rdp = vector<mint>(n);
    rdfs(0);

    rep(i, n) {
        mint ans = 1;
        for(auto j: g[i]) {
            if(j == par[i]) ans *= rdp[i] + 1;
            else ans *= dp[j] + 1;
        }
        cout << ans.x << endl;
    }
}


Measured memory_bytes: 21248
#include<bits/stdc++.h>
using namespace std;
#define rep(_,a,b) for(int _=a;_<b;_++)
#define per(_,a,b) for(int _=b-1;_>=a;_--)
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;

//A
int main(){
    int n;
    scanf("%d",&n);
    if(n%1000==0) cout<<0<<endl;
    else cout<<n/1000*1000+1000-n<<endl;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
      ll n;
      cin >> n;
      vector < ll > v;
      while(n){

            ll temp = n%26;
            n/=26;

            if (temp==0)n--;

            v.push_back(temp);
      }

//      for (int i=0 ; i<v.size() ; i++){
//            cout << v[i] << endl;
//      }

      for (int i = v.size()-1 ; i>=0 ; i--){

            char ch = 'a';
            if (v[i]==0)cout << 'z';
            else {
                  v[i]--;
                  ch+=v[i];
                  cout << ch;
            }
      }
      cout << endl;

      return 0;
}



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

using namespace std;

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

    string s;
    cin >> s;
    string ans = "Yes";
    for (int i = 0; i < s.size(); ++i) {
        if ((i & 1 and s[i] == 'R') or ((i & 1) == 0 and s[i] == 'L')) {
            ans = "No";
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
from collections import deque
N,M = map(int,input().split())

es = [[] for i in range(N)]
for i in range(M):
  a,b = map(lambda x:int(x)-1,input().split())
  es[a].append(b)
  es[b].append(a)

a = b = 1
visited = [1,1] + [0]*(N-2)
q = deque([0])
while q:
  fr = q.popleft()
  for to in es[fr]:
    if visited[to]: continue
    q.append(to)
    visited[to] = 1
    a += 1

q = deque([1])
while q:
  fr = q.popleft()
  for to in es[fr]:
    if visited[to]: continue
    q.append(to)
    visited[to] = 1
    b += 1

if a > b: a,b = b,a
unused = N-a-b
b += unused

ans = a*(a-1)//2 + b*(b-1)//2 - M
print(ans)

Measured memory_bytes: 23320
function Main(input) {
  var input = input.split("\n");
  var data = input[0].split(" ");
  var N = parseInt(data[0]);
  var A = parseInt(data[1]);
  var B = parseInt(data[2]);
  var string = input[1];

  var count = 0;
  var abroadRank = 0;

  for(var i= 0; i < string.length; i++){
    if(string.charAt(i) == "a"){
      if(count < (A+B)){
        count++;
        console.log("Yes");
      }else{
        console.log("No");
      }
    }else if(string.charAt(i) == "b"){
      abroadRank++;
      if(count < (A+B) && abroadRank <= B){
        count++;
        console.log("Yes");
      }else{
        console.log("No");
      }
    }else{
      console.log("No");
    }
  }

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

void main_()
{
    ll N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    auto min_traffic = min({ A, B, C, D, E });
    auto ans = (N + min_traffic - 1) / min_traffic + 4;

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll x;
    cin >> x;

    if(x < 1200){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }

    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type& a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	string s;
	cin>>s;
	s+='.';
	
	string t="";
	REP(i,s.size()){
		if(s[i]=='B' and s[i+1]=='C'){
			t+='D';
			i++;
		}else t+=s[i];
	}
	
	llong ans=0;
	llong cnt=0;
	for(int i=t.size()-1;i>=0;--i){
		if(t[i]=='D') cnt++;
		else if(t[i]=='A') ans+=cnt;
		else cnt=0;
	}
	
	cout<<ans<<endl;
}//refering to exp.

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
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;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int n, limit;
	cin >> n >> limit;
	vector<int> v(n);
	rep(i, n) cin >> v[i];

	int ret = 0;
	for(int i = 0; i <= min(limit, n); i++) {
        for(int j = 0; j <= i; j++) {
            vector<int> now;
            for(int k = 0; k < j; k++) now.push_back(v[k]);
            for(int k = 0; k < i - j; k++) now.push_back(v[n - 1 - k]);
 
            sort(all(now));
            int nowsum = 0;
            for(int k = 0; k < now.size(); k++) {
                if(k < limit - i && now[k] < 0) continue;
                nowsum += now[k];
            }
 
            ret = max(ret, nowsum);
        }
    }

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
'use strict'
const main = (input: string) => {
    const std: string[] = input.split('\n')
    const n: number = ~~std.shift()
    const sArray: string[] = std.shift().split(' ')
    const s: string[] = sArray.shift().split('')
    const t: string[] = sArray.shift().split('')
    let result: string[] = []
    for (let i = 0; i < n; i++) {
      result.push(s[i])
      result.push(t[i])
    }
    console.log(result.join(''))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())


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

int main() {
    int N, X, T;
    cin >> N >> X >> T;
    int ans;
    if (N % X == 0) {
        ans = T * (N / X);
    }
    else {
        ans = T * (N / X + 1);
    }

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


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    int k,t;cin>>k>>t;
    vector<int>a(t);
    rep(i,t){
        cin>>a[i];
    }
    sort(a.begin(),a.end());

    int ans=max(a[t-1]-1-(k-a[t-1]),0);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,list[101],
      i,
      t,sum=0;
  
  scanf("%d", &n);
  
  for(i=1;i<=100;i++){list[i]=0;}
  for(i=0;i<n;i++){
    scanf("%d", &t);
    if(list[t] == 0){
      list[t] = 1;
      sum++;
    }
  }
  
  printf("%d", sum);
  return 0;
}

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

void init_list(int *list, int n);
int game(int *list, int n, int m);

int main(void)
{
    int n,m;
    int i,j;
    int list[1000];

    while (1){
        scanf("%d %d", &n, &m);
        if (n == 0 && m == 0){
            break;
        }
        
        i = 1;
        for (j = 2; j <= n; j++){
            i = (i + m) % j;
            if (i == 0){
                i = j;
            }
        }
        printf("%d\n", i);
    }
    
    return (0);

}


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

int main(){
    long long int l;
    long long int r;
    long long int min;
    cin >> l >> r;
    if(r-l>=2019){
        min = 0;
    }else{
        min = 2019;
        for(int i=l; i<=r; i++){
            for(int j=i+1; j<=r; j++){
                if(((i%2019)*(j%2019))%2019 < min){
                    min = ((i%2019)*(j%2019))%2019;
                }
            }
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
s = []
for i in range(m):
  x = list(map(int, input().split()))
  s.append(x)
p = list(map(int, input().split()))

ans = 0

for i in range(2 ** n):
  pat = []
  t = 0
  for j in range(n):
    if (i >> j) & 1:
      pat.append(True)
    else:
      pat.append(False)
  for k in range(m):
    cnt = 0
    for l in s[k][1:]:
      if pat[l-1]:
        cnt += 1
    if cnt % 2 == p[k]:
      t += 1
  if t == m:
    ans += 1
    
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
 
using llong = long long int;
 
const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
 
int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int n;
    cin >> n;
    vector<llong> A(n + 1), B(n);
    rep(i, n + 1) cin >> A[i];
    rep(i, n) cin >> B[i];
 
    llong ans = 0;
    rep(i, n) {
        ans += min(A[i], B[i]);
        if (B[i] > A[i]) {
            llong tmp = A[i + 1];
            ans += abs(max(0LL, A[i + 1] - (B[i] - A[i])) - A[i + 1]);
            A[i + 1] = max(0LL, A[i + 1] - (B[i] - A[i]));
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)

{  

   int n,i,a,b;  

   int  ai[10001];

   long c;  

   scanf("%d",&n);    

   for(i=0;i<n;i++)

   {  

         scanf("%d",&ai[i]);   

         if(i == 0)

         {    

               a=ai[0];    

               b=ai[0];   

         }   

         else

         {        

              if(a<=ai[i])

             {     

                   a=ai[i];    

             }    

             if(b>=ai[i])

            {     

                    b=ai[i];    

           }   

      }          

   }   

   c=0;  

   for(i=0;i<n;i++)

   {   

         c += ai[i];  

   }  

   printf("%d %d %ld\n",b,a,c);    

   return 0;

}

Measured memory_bytes: 636