akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
vector<T> compress(vector<T>&a, vector<T>&b) {
	vector<T>ret;
	ret.insert(ret.end(), all(a));
	ret.insert(ret.end(), all(b));
	sort(all(ret));
	ret.erase(unique(all(ret)), ret.end());
	for (T &o : a)o = distance(ret.begin(), lower_bound(all(ret), o));
	for (T &o : b)o = distance(ret.begin(), lower_bound(all(ret), o));
	return ret;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> x1(N), y1(N), x2(N), y2(N); rep(i, 0, N) { cin >> x1[i] >> y1[i] >> x2[i] >> y2[i]; }
	auto zipx = compress(x1, x2), zipy = compress(y1, y2);
	vector<vector<int>>field(zipx.size(), vector<int>(zipy.size(), 0));
	rep(i, 0, N) {
		field[x1[i]][y1[i]]++;
		field[x2[i]][y2[i]]++;
		field[x1[i]][y2[i]]--;
		field[x2[i]][y1[i]]--;
	}
	rep(i, 0, zipx.size())rep(j, 1, zipy.size())field[i][j] += field[i][j - 1];
	rep(i, 0, zipy.size())rep(j, 1, zipx.size())field[j][i] += field[j - 1][i];
	int ans(0);
	rep(i, 0, zipx.size() - 1)rep(j, 0, zipy.size() - 1) {
		if (field[i][j] > 0)ans += (zipx[i + 1] - zipx[i])*(zipy[j + 1] - zipy[j]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 128160
from math import *
a, b, h, m = list(map(int, input().split()))

angle = radians(abs(360 / 12 * h + 360 / 12 / 60 * m - 360 / 60 * m))
print((a**2 + b**2 - 2*a*b*cos(angle))**0.5)
#print(abs(360 / 12 * h - 360 / 60 * m))


Measured memory_bytes: 9488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    ll x, k, d;
    cin(x); cin(k); cin(d);

    x = abs(x);

    ll left = x / d;
    if (left >= k) {
        print(x - k * d);
        return 0;
    } else {
        ll position = x - left * d;

        if ((k - left) % 2 == 0) {
            print(position);
        } else {
            print(abs(position - d));
        }
        return 0;
    }
}

Measured memory_bytes: 3620
S = input()
S = S[::-1]

words = ['dreamer', 'eraser', 'dream', 'erase']
for i in range(4):
    K = words[i]
    words[i] = K[::-1]

T = ''
T_next = ''

while True:
    if len(T) + 5 > len(S):
        break
    for i in range(4):
        S_next = S[len(T):len(T + words[i])]
        T_next = words[i]
        flag = False
        #print(S_next)
        #print(T_next)
        #print()
        if S_next == T_next:
            flag = True
            T += T_next
            #print(T)
            #print()
            #input()
            if T == S:
                print('YES')
                exit()
            break
    if flag == False:
        break
    #input()

print('NO')



Measured memory_bytes: 79380
f :: Int -> Int
f x = x*x

integrate:: (Int -> Int) -> Int -> Int -> Int -> Int
integrate func from to step 
	| from + step == to = 0
	| otherwise = let next = from + step
	                  rect = step * func(next)
                  in
                    rect + integrate func next to step

main = do
	c <- getContents
	let i = map read $ lines c :: [Int]
	    o = map (integrate f 0 600) i
	mapM_ print o

Measured memory_bytes: 4040
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void A_task();

int main()
{
	A_task();
	fflush(stdout);
	return 0;
}

static void A_task()
{
	int A, B;
	getint(A, B);
	printf("%d\n", A * B);
}



Measured memory_bytes: 3816
// C - Sum of gcd of Tuples(Easy)
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int gcd(int x, int y){
    return (x%y) ? gcd(y, x%y) : y;
}

int main(){
    int k;
    cin >> k;
    int ans = 0;
    for(int i=1; i<=k; i++){
        for(int j=1; j<=k; j++){
            for(int l=1; l<=k; l++){
                int a = gcd(i, gcd(j, l));
                ans += a;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    //input
    int angle = sc.nextInt();

    //output
    //least common multiple
    int lcm = 360; //360 is the higher number given range of angle
    while( lcm % angle != 0 ){ //if not divisible, add 360
      lcm += 360;
    }
    System.out.println( lcm/angle );

  }
}


Measured memory_bytes: 27064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cerr<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}

using Data = pair<ll, vi>;

int main(){
    vl n(3);
    int k;cin >> n[0] >> n[1] >> n[2] >> k;
    vector<vl> v(3);
    for(int i=0;i<3;++i){
        v[i].resize(n[i]);
        rep(j,n[i]) cin >> v[i][j];
        sort(v[i].rbegin(), v[i].rend());
    }
    priority_queue<Data> que;
    set<Data> se;
    que.push(Data(v[0][0] + v[1][0] + v[2][0], vi({0, 0, 0})));
    for(int i=0;i<k;++i){
        auto c = que.top();que.pop();
        cout << c.first << "\n";

        for(int j=0;j<3;++j){
            if(c.second[j]+1 < n[j]){
                ll sum = c.first - v[j][c.second[j]] + v[j][c.second[j]+1];
                auto num = c.second; num[j]++;
                auto d = Data(sum, num);
                if(!se.count(d)) se.insert(d), que.push(d);
            }
        }
    }
}

Measured memory_bytes: 1408
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Split(bufio.ScanWords)
	var K int
	Arr := [32]int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}

	K = nextInt()
	fmt.Println(Arr[K-1])

}

func nextInt() int {
	stdin.Scan()
	i, err := strconv.Atoi(stdin.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextStr() string {
	stdin.Scan()
	i := stdin.Text()
	// if err != nil {
	// 	panic(err)
	// }
	return i
}


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

int main() {
  ll n; cin >> n;
  vector<ll> a;
  for (ll i = 0; i < n; i++) {
    ll x; cin >> x; a.push_back(x);
  }
  sort(a.begin(), a.end());
  ll mx = a[n-1];
  
  ll ub = n; ll lb = -1;
  while (ub-lb > 1) {
    ll mid = (ub+lb)/2;
    (a[mid] <= a[n-1]/2? lb:ub) = mid;
  }
  if (lb == n-1) {cout << a[n-1] << " " << a[n-2] << endl;}
  else {
    if (a[n-1]-a[lb+1] > a[lb]) {cout << a[n-1] << " " << a[lb+1] << endl;}
    else {cout << a[n-1] << " " << a[lb] << endl;}
  }
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = (ll)(1e9 + 7);
const int MAX_N = 205;
ll dp[MAX_N][MAX_N];

int main2() {
  int N = nextInt();
  string v;
  REP(i, N) {
    string s; cin >> s;
    if (s == "U") v.push_back('U');
    if (s == "D") v.push_back('D');
  }
  N = v.size();
  CLR(dp, 0);
  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= N; j++) {
      dp[i][j] %= MOD;
      if (dp[i][j] == 0) continue;
      if (v[i] == 'U') {
        dp[i+1][j] += j * dp[i][j] % MOD;
        dp[i+1][j+1] += dp[i][j];
      } else if (v[i] == 'D') {
        if (j-1 >= 0) dp[i+1][j-1] += j * j * dp[i][j] % MOD;
        dp[i+1][j] += j * dp[i][j] % MOD;
      }
    }
  }
  ll ans = dp[N][0] % MOD;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    int ans = 1002003004;

    rep(i,n){
        int c, t; cin >> c >> t;
        if(t <= T) ans = min(ans,c);
    }

    if(ans == 1002003004) dunk("TLE");
    else  dunk(ans);
    
}

Measured memory_bytes: 256
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

S=input()
N=len(S)
K=intput()
L=[list()]*26
ans=[]
for i in range(N):
    L[ston(S[i])].append(i)
for l in L:
    for i in l:
        for j in range(i+1,min(i+K+1,N+1)):
            s=S[i:j]
            if bisect_left(ans,s)==bisect_right(ans,s):
                insort_left(ans,s)
    if len(ans)>=K:
        print(ans[K-1])
        exit()

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

int main()
{
    char a[4];
    int flag=0,i;


        flag=0;
        scanf("%s",a);

        if(a[1]=='a'||a[0]=='a'||a[2]=='a')
            flag++;
        if (a[0]=='b'||a[1]=='b'||a[2]=='b')
            flag++;
        if (a[0]=='c'||a[1]=='c'||a[2]=='c')
            flag++;

        if (flag==3)
            printf("Yes\n");
        else
            printf("No\n");



    return 0;
}


Measured memory_bytes: 256
def solve(n, arr):
    s = sum(arr)

    k = int(round(s / len(arr), 0))

    cost = 0

    for num in arr:
        cost += (k-num) ** 2

    return cost


n = int(input().strip())
arr = list(map(int, input().strip().split()))

print(solve(n, arr))


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

using namespace std;

int N;
int num[102];
long long int a[102][22];

long long int dp(int d,int sum){
    if(sum > 20 || sum < 0) return 0;

    if(a[d][sum] >= 0) return a[d][sum];

    if(d == N-1){
        if(sum == num[N]){
            return a[d][sum] = 1;
        }else{
            return a[d][sum] = 0;
        }
    }

    long long int b = 0;
    int n = num[d+1]; 
    if(d ==0){
        b += dp(d+1 , sum + n);
    }else{
        b += dp(d+1 , sum + n) + dp(d+1 , sum - n);
        return a[d][sum] = b;
    }
}

int main(){
    fill_n(num,101,0);
    fill_n(*a,101*22,-1);

    cin >>N;
    for(int i = 1;i <= N;i++){
        cin >> num[i];
    }

    cout << dp(0,0) << endl;
}

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

int main()
{
  int n,m,c;
  cin>>n>>m>>c;
  int b[m];
  rep(i,m) cin >> b[i];
  vector<vector <int>> a(n, vector<int>(m));
  rep(i,n){
   	rep(j,m){
      cin >> a[i][j];
    }
  }
  int sum, ans=0;
  rep(i,n){
    sum=0;
   	rep(j,m){
      sum += a[i][j]*b[j];
    }
    if(sum+c > 0) ans++;
//    cout << sum << " " << sum+c << " "<< ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define int         long long
#define ld          long double
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define sd(t)       scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii         cout << "hii" << endl
#define okay        cout << "okay" << endl
#define hey         cout << "hey" << endl
const int INF = 1e12;
const int MOD = 1e9+7;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.x << ' ' << v.y; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.x << "=>" << i.y << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
 
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("jjj.txt", "w", stdout);
    #endif
}

const int N = 2e4+10;
int dp[N];

int f(int val, int sum){

    if(val > sum) return 0;
    if(val == sum) return 1;

    if(dp[val]!=-1) return dp[val];

    int ans = 0;
    for(int i=3; i<=sum; i++){
        ans += f(val+i, sum)%MOD;
        ans %= MOD;
    }

    return dp[val] = ans;
}

void solve(){  

    memset(dp, -1, sizeof(dp));
    int sum;
    cin >> sum;

    cout << f(0, sum) << endl;
}              


int32_t main(){
    fast();
    int t = 1;
    // cin>> t;
    for(int i=1; i<=t; i++){
        // cout << "Case #" << i << ": ";
        solve();
    }
    starboy1299();
}

Measured memory_bytes: 3944
N, A, B, C, D = map(int, input().split())
S = input()
if C == D:
    print("No")
elif C < D:
    for i in range(B, D):
        if S[i:i+2] == "##":
            print("No")
            exit()
    for i in range(A, C):
        if S[i:i+2] == "##":
            print("No")
            exit()
    print("Yes")
else:
    for i in range(B, D):
        if S[i:i+2] == "##":
            print("No")
            exit()
    for i in range(A, C):
        if S[i:i+2] == "##":
            print("No")
            exit()
    for i in range(B-2, D-1):
        if S[i:i+3] == "...":
            print("Yes")
            exit()
    print("No")


Measured memory_bytes: 3572
n = gets.chomp("").to_i
b = gets.split(" ").map(&:to_i)

sum = 0
n.times do |i|
  if i != 0 && (i+1) != n
    if b[i] > b[i-1]
      sum += b[i-1]
    else
      sum += b[i]
    end
  elsif i+1 == n
    sum += b[i-1]
  else
    sum += b[0]
  end
end

puts sum


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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a.at(i);
    vector<bitset<30> > b(N);
    for(int i=0; i<N; i++) b.at(i) = a.at(i);
    bitset<30> odd;
    for(int i=0; i<N; i++) odd = odd ^ b.at(i);
    for(int i=0; i<N; i++) b.at(i) = b.at(i) ^ odd;
    for(int i=0; i<N; i++) cout << b.at(i).to_ullong() << endl;
}

Measured memory_bytes: 5584
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	string S;
	int k;
	cin>>k>>S;
	if(S.size()<=k)cout<<S;
	else{
		for(int i=0;i<k;i++){
			cout<<S[i];
		}
		cout<<"...";
	}
	return 0;
}

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

int main() {
    string s, t; cin >> s >> t;
    int n = t.size();
    int m = 0;
    for (int i = 0; i < s.size(); ++i) {
        bool ok = true;
        int cnt = 0;
        for (int j = 0; j < t.size(); ++j) {
            if (i + j >= s.size()) {
                ok = false;
                break;
            }
            if (s[i + j] == t[j]) ++cnt;
        }
        if (ok) {
            m = max(m, cnt);
        }
    }
    cout << n - m << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
string s;
int n;
int main(){
    cin>>n>>s;
    int a=0;
    for(int i=0;i+2<n;++i){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')a++;
    }cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){
int N,A;
cin>>N>>A;
if(N%500<=A)cout<<"Yes"<<endl;
else cout<<"No"<<endl;

return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001

int main() {
    ll n;cin >> n;
    bool e=false;
    if(n%2==0) e=true;

    if(!e){
        cout << 0 << endl;
        return 0;
    }

    ll a=0;
    n /= 10;
    a += n;
    while(n>=5){
        n /= 5;
        a += n;
        
    }    

    cout << a << endl;

    return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// x座標に関しての差分(左、下、右、上)
const int di[] = { -1,0,1,0 };
const int dj[] = {0, -1, 0, 1};

int main() {
	// 表の大きさ
	int h, w;
	cin >> h >> w;
	// 初期位置	
	int si, sj;
	cin >> si >> sj;
	// 目的地
	int ti, tj;
	cin >> ti >> tj;
	// indexを0スタートにするためにデクリメント
	si--, sj--, ti--, tj--;
	// 表の状態を表す
	vector<string> s(h);
	rep(i, h) {
		cin >> s[i];
	}
	// 距離の初期値
	const int INF = 1e9;
	// 初期値との距離(コスト)を表す配列
	vector<vector<int>> dist(h, vector<int>(w, INF));
	// 01-BFS
	// コストが0は前から、1の時は後ろから入れる
	// 取り出すときはすべて前から取り出す
	// これでコストの低いものから取り出されるようになる
	deque<P> q;
	// 初期位置の距離は0 
	dist[si][sj] = 0;
	// 前から初期位置のpariを入れる
	q.emplace_back(si, sj);
	//dequeが空ではないときは
	while (!q.empty()) {
		int i = q.front().first;
		int j = q.front().second;
		int d = dist[i][j];
		q.pop_front();
		// 左、下、右、上の4方向動かす
		rep(v, 4) {
			int ni = i + di[v], nj = j + dj[v];
			// 座標は0以上という制限あり
			// niが0以下であったりHWの枠をoverしていたら以降の処理をしない
			if (ni < 0 || ni >= h || nj<0 || nj>w) continue;
			// 壁であったら処理をしない
			if (s[ni][nj] == '#') continue;
			// すでに訪れている場合処理をしない
			if (dist[ni][nj] <= d) continue;
			// 上の3つの処理をくぐりぬけたときにコスト0として処理を行う
			dist[ni][nj] = d;
			// 前から入れる
			// コスト0の処理
			q.emplace_front(ni, nj);
		}
		// 魔法で飛ぶとき
		// 四方八方5x5の部分はコスト(距離)1で飛べる
		for (int ei = -2;ei <= 2;++ei) {
			for (int ej = -2;ej <= 2;++ej) {
				int ni = i + ei, nj = j + ej;
				if (ni < 0 || ni >= h || nj<0 || nj>w) continue;
				if (s[ni][nj] == '#') continue;
				if (dist[ni][nj] <= d) continue;
				dist[ni][nj]= d + 1;
				q.emplace_back(ni,nj);

			}
		}
	}

	int ans = dist[ti][tj];
	if (ans == INF) ans = -1;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 10176
#include <iostream>
using namespace std;
int main(){
	int m;
	cin >> m;
	while( m-- > 0 ){
		int money, year, n;
		cin >> money >> year >> n;
		int Max = 0;
		while( n-- > 0 ){
			int type, commi;
			double rate;
			cin >> type >> rate >> commi;
			int m1 = money, m2 = 0;
			for( int i = 0; i < year; i++ ){
				if( type == 0 ){
					m2 += m1 * rate;
				}else{
					m1 += m1 * rate;
				}
				m1 -= commi;
			}
			m1 += m2;
			if( Max < m1 ) Max = m1;
		}
		cout << Max << endl;
	}
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
int main() {
  ll a, b;
  cin >> a >> b;
  cout << a * b << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define INF 1<<29

using namespace std;

const int MAX_V = 1005;
// 辺を表す構造体（行き先、容量、逆辺）
struct edge{ int to, cap, rev; };

vector<edge> G[MAX_V];	// グラフの隣接リスト表現
bool used[MAX_V];			// DFS ですでに調べたかのフラグ

// from から to へ向かう容量 cap の辺をグラフに追加する
void add_edge (int from, int to, int cap ){
	G[from].push_back ((edge){to, cap, G[to].size() } );
	G[to].push_back ((edge){from, 0, G[from].size()-1 } );
}

// 増加バスを DFS で探す
int dfs (int v, int t, int f ){
	if (v == t ) return f;
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++ ){
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0 ){
			int d = dfs (e.to, t, min (f, e.cap ) );
			if (d > 0 ){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			} // end if
		} // end if
	} // end for

	return 0;
}

// s から t への最大流を求める
int max_flow (int s, int t ){
	int flow = 0;
	for (;; ){
		memset (used, false, sizeof (used ) );
		int f = dfs (s, t, INF );
		if (f == 0 ) return flow;
		flow += f;
	} // end for
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.1163", "r", stdin );
	int n, m;
	while (scanf ("%d %d", &n, &m ), n, m ){
		rep (i, MAX_V ) G[i].clear();
		// 0 〜 n-1: bule card n〜n+m-1: red card
		// n+m : source n+m+1: sink
		vector<int> cards (n+m, 0 );
		rep (i, n ){
			scanf ("%d", &cards[i] );
			add_edge(n+m, i, 1 );
		} // end rep
		rep (j, m ){
			scanf ("%d", &cards[n+j] );
			add_edge(n+j, n+m+1, 1 );
		} // end rep

		rep (i, n ){
			rep (j, m ){
				if (__gcd (cards[i], cards[n+j] ) != 1 ){
					add_edge (i, n+j, 1 );
				} // end if
			} // end rep
		} // end rep
		int res = max_flow (n+m, n+m+1 );
		printf ("%d\n", res );
	} // end while
		
	return 0;
}

Measured memory_bytes: 7600
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
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 end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    /*
    vector<ll> X(N);
    string s,t;
    in >> s >> t;
    vector<string> s,t;
    s.resize(N);
    ll N;
    in >> N;
    */

   ll H,M,h,m,K;
    in >> H>>M>>h>>m>>K;

    ll ans = (h-H)*60 + (m-M) - K;
    out << ans << endl;
    
    
    

    
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int A,B;
    cin >>A>>B;
    if ((A*B)%2==1) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << ele << endl
#define print10(ele) cout << fixed << setprecision(10) << ele << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int n, m;
  cin >> n >> m;
  vector<ivec> ship(n);
  n--;
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    ship[a].push_back(b);
    ship[b].push_back(a);
  }

  bool ok = false;

  REP(i, ship[n].size()) {
    int to = ship[n][i];
    REP(j, ship[to].size()) {
      if (ship[to][j] == 0) ok = true;
    }
  }

  print((ok ? "POSSIBLE" : "IMPOSSIBLE"));
  return 0;
}

Measured memory_bytes: 12016
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const S = input[0][0];

  return S.replace("2017", "2018");
};

console.log(main(read()));


Measured memory_bytes: 29632
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
#define rep(i,a,b) for(ll i=a;i<b;i++)
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}
int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a(n+1),d(n+1);
    rep(i,0,m) {
        ll k;
        cin>>k;
        a[k]=1;
    }
    d[0]=1;
    if(a[1]) d[1]=0;
    else d[1]=1;
    rep(i,0,n-1){
        if(a[i+2]) d[i+2]=0;
        else d[i+2]=(d[i+1]+d[i])%MOD;
    }
    cout<<d[n];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    string S;
    cin >> S;
    bool up,first=true;
    long long int ans=0,count=1,last=0;
    if(S[0]=='<'){
        up = true;
    }else{
        up = false;
    }

    for(int i=1;i<S.size();i++){
        first=false;
        if(S[i]=='<' && up){
            count++;
        }else if(S[i]=='>' && !up){
            count++;
        }else{
            if(up){
                if(count!=1){
                    ans += count*(count+1)/2;
                }else{
                    ans++;
                }
                last = count;
                up = false;
            }else{
                if(count!=1){
                    ans += count*(count-1)/2;
                }

                if(last<count){
                    ans += count-last;
                }
                last = count;
                up=true;
            }
            count=1;
        }
    }

    if(up){
                if(count!=1){
                    ans += count*(count+1)/2;
                }else{
                    ans++;
                }
                last = count;
            }else{
                if(count!=1){
                    ans += count*(count-1)/2;
                }

                if(last<count){
                    ans += count-last;
                }
            }
            
        cout << ans << endl;
}

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    vector<string> s(3);
    rep(i, 3) {
        cin >> s[i];
        reverse(all(s[i]));
    }

    // 処理
    int now = 0;
    while (s[now].size() > 0) {
        char card = s[now].back();
        s[now].pop_back();
        now = card - 'a';
    }

    // 出力
    char ans = 'A' + now;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
using namespace std;
int main(void){
    int n,m;
    cin >> n >> m;
    
    vector<vector<int>> vec(m);
    
    for(int i = 0;i < m;i++){
          int k;
          cin >> k;
          
          vec[i].resize(k);
          for(int j = 0;j < k;j++){
                cin >> vec[i][j];
                vec[i][j]--;
          }
    }
    
    vector<int>p(m);//スイッチの偶奇どちらでつくか
    for(int i = 0;i < m;i++){
          cin >> p[i];
    }
    
    int ans = 0;
    for(int i = 0;i < 1 << n;i++){
          bool ok = true;
          for(int j = 0;j < m;j++){
                int c = 0;
                for(int id:vec[j]){
                      if((i >> id) & 1){
                            c++;
                      }
                }
                if(c % 2 != p[j]){
                      ok = false;
                }
          }
          if(ok){
                ans++;
          }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
import java.util.Scanner;
import java.util.Arrays;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int[] distance = new int[3];
        for(int i = 0; i < 3; i++){
            distance[i] = scan.nextInt();
        }        

        // answer
        Arrays.sort(distance);
        System.out.println(distance[0] + distance[1]);

    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;

    int cnt[26];
    fill_n(cnt, 26, 0);

    for(int i=0; i<N; i++)
        cnt[S[i]-'a']++;

    long long ans = 1;
    for(int i=0; i<26; i++){
        ans *= (cnt[i]+1) % MOD;
        ans %= MOD;
    }
    ans = (ans + MOD - 1) % MOD;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int N;

vector<string> ans;

void dfs(string a, int used_count){
    //cout << a << " " << used_count << endl;
    if (a.size() == N){
        ans.push_back(a);
        return;
    }

    rep(i,used_count+1){
        char next_char = 'a'+i;
        if (i == used_count){
            dfs(a+next_char, used_count+1);
        }
        else{
            dfs(a+next_char, used_count);

        }
    }

}

int main(){
    cin >> N;

    dfs("a", 1);

    //sort(ans.begin(), ans.end());
    rep(i,ans.size()){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 7284
n = int(input())
a = input().split()
a = [int(m) for m in a]
dic = {}
dic2 = {}
for i in range(n + 1):
    dic[a[i]] = 0
    dic2[a[i]] = []
f = 0
s = 0
for i in range(n + 1):
    dic[a[i]] += 1
    dic2[a[i]].append(i)
    if dic[a[i]] == 2:
        f = dic2[a[i]][0]
        s = i
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
mod = 10**9+7 #出力の制限
N = n + 1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
 
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
 
 
for i in range(n + 1):
    if i == 0:
        print(n)
    else:
        if f + n - s >= i:
            if (cmb(n + 1, i + 1, mod) - cmb(f + n - s, i, mod)) >= 0:
                print(cmb(n + 1, i + 1, mod) - cmb(f + n - s, i, mod))
            else:
                print(cmb(n + 1, i + 1, mod) - cmb(f + n - s, i, mod) + mod)
        else:
            print(cmb(n + 1, i + 1, mod))

Measured memory_bytes: 48904
import java.util.*;


class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int A =  sc.nextInt();
		int B =  sc.nextInt();
		int C =  sc.nextInt();
		int D =  sc.nextInt();
		
		int total = Math.min(A,B) + Math.min(C,D);
		
		System.out.println(total);
	}
}


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

using namespace std;

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

    int n,x,t,temp,result;

    cin>>n>>x>>t;

    temp = n;
    result = 0;

    if(n%x == 0)
        result = t*(n/x);
    else
        result = t*((n/x)+1);
    /*while(temp>0)
    {
        temp = temp - x;
        result = result + t;
    }*/

    cout<<result<<"\n";

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int preva,prevb,prevc;
    cin>>preva>>prevb>>prevc;
    for(int i=1;i<n;i++){
        int x,y,z;
        cin>>x>>y>>z;
        x=x+max(prevb,prevc);
        y=y+max(preva,prevc);
        z=z+max(preva,prevb);

        preva=x;
        prevb=y;
        prevc=z;
    }
   cout<<max(preva,max(prevb,prevc));
}

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

int m = 0;

class Dice{
public:
int n, face[6];

void scan(){
  for( int i = 0; i < 6; i++){
    cin >> face[i];
  }
}

void move1(){
     n = face[1];
     face[1] = face[2];
     face[2] = face[4];
     face[4] = face[3];
     face[3] = n;
}	      

void move2(){
     n = face[0];
     face[0] = face[4];
     face[4] = face[5];
     face[5] = face[1];
     face[1] = n;
}	 

void move3(){
     n = face[0];
     face[0] = face[2];
     face[2] = face[5];
     face[5] = face[3];
     face[3] = n;
}	 

};

void serch(Dice p1, Dice p2){
  for( int s = 0; s < 4; s++){
    m = 0;
    for( int i = 0; i < 4; i++){
      m = 0;
      for( int j = 0; j < 4; j++){
        m = 0;
        for( int k = 0; k < 6; k++){
          if( p1.face[k] != p2.face[k] ) break;
          m += 1;
        }
        if( m == 6 ) break;
        p1.move1();
      }
      if( m == 6 ) break;
      p1.move2();
   } 
   if( m == 6 ) break;
   p1.move3();
 }

  if( m == 6 ) cout << "Yes" << endl;
  else cout << "No" << endl;
}           

int main(){
  Dice p1, p2;
  
  p1.scan();
  p2.scan();
  
  serch(p1, p2);

  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll i;
    for(i=0;i<b;i++)
        c*=a;
    return c;
}
ll hell=998244353;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    ll n,i;
    cin>>n;
    ll a[n];
    ll b[n];
    ll sum1=0;
    ll sum2=0;
    for(i=0;i<n;i++)
        {cin>>a[i];
        sum1+=a[i];
        }
    for(i=0;i<n;i++)
        {cin>>b[i];
        sum2+=b[i];
        }
    if(sum2>sum1)
        cout<<"-1";
    else
    {
        sum1=0;
        sum2=0;
        vector<ll> v;
        ll c=0;
        for(i=0;i<n;i++)
        {
            if(a[i]<b[i])
                {sum1+=(b[i]-a[i]);
                c++;
                }
            else
            {   if(a[i]-b[i])
                    v.pb(a[i]-b[i]);
            }
        }
        if(c==0)
        {
            cout<<"0";
            return 0;
        }
        sort(all(v));
        reverse(all(v));
        for(i=0;i<v.size();i++)
        {
            sum2+=v[i];
            if(sum2>=sum1)
                break;
        }
        cout<<c+i+1;
    }
    return 0;
}






Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}

int ans = 0;
int n,k,dp[N];
vector < int > G[N]; 

void dfs(int i,int p = 0){
	// printf("%d\n",i);
	REP(j,G[i].size()){
		dfs(G[i][j],i);
		dp[i] = max(dp[i],dp[G[i][j]]);	
	}
	dp[i]++;
	if(dp[i]==k){
		if(p!=0)	ans++;
		dp[i] = 0;
	}
}


int main(){
 // 	freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
	scanf("%d %d",&n,&k);
	// if(k!=1)	ans++;
	REP(i,n){
		int x;scanf("%d",&x);x--;
		if(i) G[x].pb(i);
		else if(i!=x) ans++;
	}
	dfs(0);
	printf("%d\n",ans);
	return 0;
}




Measured memory_bytes: 33408
from collections import Counter
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
c=Counter(a)
ans=["No"]*n
for i in range(n):
    if c[i+1]>q-k:
        ans[i]="Yes"
for i in range(n):
    print(ans[i])

Measured memory_bytes: 11892
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    int min = 1;
    int max = n;
    for(int i = 0; i < m; ++i){
        int l, r;
        cin >> l >> r;
        if(min < l){
            min = l;
        }
        if(max > r){
            max = r;
        }
    }
    if(max - min > -1){
        cout << max - min + 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

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

int main(){
    int x;
    cin >> x;
    if(x==0){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	string s; cin >> s;
	ll n = s.size();

	ll j = n - 1, i = 0;
	ll cnt = 0;
	while(i < j) {
		ll xi = 0, xj = 0;
		while (i < n && s[i] == 'x') i++, xi++;
		while (j >= 0 && s[j] == 'x') j--, xj++;
		if (i >= n && j < 0) {
			cnt += abs(xi - xj);
			break;
		} else if (i >= n && j >= 0 || i < n && j < 0) {
			cout << -1 << endl;
			return 0;
		}

		if (s[i] != s[j]) {
			cout << -1 << endl;
			return 0;
		}
		cnt += abs(xi - xj);
		i++; j--;
	}

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 512