akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct point
{
	long long name; long long dist;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};

ll const MAX = 200005;
ll a[MAX];

int main() {
	ll n;
	cin >> n;
	REP(i, 1, n) {
		cin >> a[i];
	}
	SORT(a, n);
	if (a[n] - a[1] >= 2) {
		cout << "No" << endl;
		return 0;
	}
	ll unq = 0;
	if (a[n] == a[1] && a[1] == n - 1) {
		cout << "Yes" << endl;
		return 0;
	}
	REP(i, 1, n) {
		if (a[n] != a[i]) {
			unq++;
		}
		else {
			break;
		}
	}
	ll col = a[n] - unq;
	ll num = n - unq;
	if (col <= 0) {
		cout << "No" << endl;
	}
	else if (num/col >= 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;


int main(){
	
	int a,b,c;
	
	
	cin >> a >> b >> c;
	
	if(a==5 && b==5 && c==7){
		cout << "YES\n";
		return 0;
	}
	if(a==7 && b==5 && c==5){
		cout << "YES\n";
		return 0;
	}
	if(a==5 && b==7 && c==5){
		cout << "YES\n";
		return 0;
	}
	
	cout << "NO\n"; 
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n = 0;
  cin >> n;
  vector<int> v(n, 0);
  for(int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  int diff = 0;
  vector<int> c(v.begin(),v.end());
  sort(c.begin(), c.end());
  for(int i = 0; i < n; ++i) {
    if(v[i] != c[i]) {
      diff += 1;
    }
  }
  if(diff <= 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  vec a(n),b(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  for(ll i=0;i<n;i++) cin >> b[i];
  for(ll i=0;i<n-1;i++) {
    a[i+1]+=a[i];
  }
  for(ll i=n-1;i;i--) {
    b[i-1]+=b[i];
  }
  ll ans=0;
  for(ll i=0;i<n;i++) {
    ans=max(ans,a[i]+b[i]);
  }
  cout << ans << endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int ans{1};
    ans = ans * k;
    for (int i = 0; i < n - 1; i++) {
        ans = ans * (k - 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
/**
 *    This code has been written by YueGuang, feel free to ask me question. Blog: http://www.yx.telstudy.xyz
 *    created:
 */
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REP_(i, a, b) for(int i = a; i <= b; i++)
#define sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
typedef long long ll;

using namespace std;
const int maxn = 1e5+50;
//int a[maxn];
int main(){
    ll n, a, sum = 0; scanf("%lld", &n);
    for(int i = 0; i < n; i++){
        scanf("%lld", &a);
        sum += a;
    }
    sum -= n;
    cout << sum << endl;
}


Measured memory_bytes: 256
def input_int_list():
    return [int(x) for x in input().split()]

N = int(input())
A = input_int_list()
B = input_int_list()
C = input_int_list()

satisfaction = B[A[0] - 1]
last_dish = A[0]
for a in A[1:]:
    satisfaction += B[a - 1]
    if a == last_dish + 1:
        satisfaction += C[last_dish - 1]

    last_dish = a


print(satisfaction)


Measured memory_bytes: 3060
import scala.collection.mutable.ArrayBuffer

case class Dice(var d:Seq[String]) {
  private val s = Array(4,0,2,3,5,1)
  private val w = Array(2,1,5,0,4,3)
  private val h = Array(0,2,4,1,3,5)
  private val buf = ArrayBuffer.empty[Seq[String]]

  def rotateAll() = {
    buf += d
    buf += s.map(d)
    buf += s.map(s).map(d)
    buf += s.map(s).map(s).map(d)
    buf += w.map(d)
    buf += w.map(w).map(w).map(d)

    buf += h.map(d)
    buf += s.map(s).map(s).map(h).map(d)
    buf += w.map(h).map(d)
    buf += w.map(w).map(w).map(h).map(d)
    buf += s.map(h).map(d)
    buf += s.map(s).map(h).map(d)

    buf += h.map(h).map(d)
    buf += s.map(s).map(s).map(h).map(h).map(d)
    buf += w.map(h).map(h).map(d)
    buf += w.map(w).map(w).map(h).map(h).map(d)
    buf += s.map(h).map(h).map(d)
    buf += s.map(s).map(h).map(h).map(d)

    buf += h.map(h).map(h).map(d)
    buf += s.map(s).map(s).map(h).map(h).map(h).map(d)
    buf += w.map(h).map(h).map(h).map(d)
    buf += w.map(w).map(w).map(h).map(h).map(h).map(d)
    buf += s.map(h).map(h).map(h).map(d)
    buf += s.map(s).map(h).map(h).map(h).map(d)
  }

  def getAllRot = buf.toArray
  def getFaces = d
}

object Main extends App {
  val n = readInt
  val faces1 = readLine.split(" ")
  val dice1 = Dice(faces1)
  var same = false
  var i = 1

  dice1.rotateAll()
  while(!same && i < n) {
    val faces2 = readLine.split(" ").toSeq
    if(dice1.getAllRot.contains(faces2))
      same = true
    i += 1
  }

  if(same)
    println("No")
  else
    println("Yes")
}

Measured memory_bytes: 44240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int s, w;
    cin >> s >> w;
    if (w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}


Measured memory_bytes: 3580
//...START BY DOING WHAT IS NECESSARY, THEN WHAT IS POSSIBLE AND SUDDENLY YOU ARE DOING THE IMPOSSIBLE... 
// ................. WORK UNTILL YOUR IDOLS BECOME YOUR RIVALS................................

#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pb emplace_back
#define f first
#define mp make_pair
#define s second
#define delrep  a.erase(unique(a.begin(),a.end()),a.end());
#define all(a)  (a).begin(),(a).end()
#define sz(x)   (int)x.size()
#define lll __int64
const int N=2e6+5;
const int mod=998244353;
using namespace std;
int get_second( pair<int, int> i ){ return i.second; }  
int trail_zero(int n){while (n % 10 == 0) n /= 10 ; return n;}
typedef long long ll;
map<ll,ll> m11;
multiset<ll> s1;
map<int,pair<int,int>> m1;
vector<pair<int,int>>v;
vector<int>ans;
map<char,int>m4;
map<char,int>m5;
char s111[N];
ll p2[N],p3[N];
//ll h[N];
ll n,k,m,x,y,ans1=INT_MAX;
bool check(int a,int b) { if(a>=0 || a<n) return true; if(b>=0 || b<m) return true; else return false;}
int dx[]={0,-1,0,1};
int dy[]={1,0,-1,0};
char s[500][500];
vector<vector<ll>> adj(N);
vector<ll> vis(N),in(N),out(N),cnt(N);
vector<ll>ansx;
map<ll,ll>mx;
bool used[11111][11111];
void dfs( ll x, ll y )
{
    if( x<1 || x>10000 || used[x][y] || y>10000 ) return;
    if( x==m ) ans1=min(ans1, y);
    used[x][y]=1;
    dfs( x-1, y+1 );
    dfs( x*2, y+1 );
}
vector<pair<int, int>> e(100002), o(100002);
int main()
{
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    int v;
    cin >> v;
    if(i % 2 == 0) { e[v].first++; e[v].second=v; }
    else { o[v].first++;  o[v].second=v; }
  }
  sort(e.rbegin(), e.rend());
  sort(o.rbegin(), o.rend());
  int ans = n;
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < 2; j++){
      if(e[i].second == o[j].second) continue;
      ans = min(ans, n - e[i].first - o[j].first);
    }
  }
  cout << ans << endl;
  return 0;
}




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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define all(a) a.begin(),a.end()
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;

int main(){
    int n,m;
    cin >> n >> m;
    vs a(n),b(m);
    rp(i,n){
        cin >> a.at(i);
    }
    rp(i,m){
        cin >> b.at(i);
    }
    rp(i,n-m+1){
        rp(j,n-m+1){
            int cnt=0;
            rp(k,m){
                rp(l,m){
                    if(a.at(i+k).at(j+l)==b.at(k).at(l)){
                        cnt++;
                    }
                }
            }
            if(cnt==m*m){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << 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;

const int nmax=1000010;

vector<int> graph[nmax];
int parent[nmax][20]; // all is -1
int depth[nmax];

void dfs(int v,int p,int d){
	parent[v][0]=p;
	depth[v]=d;
	for(auto &v2:graph[v]) if(v2!=p) dfs(v2,v,d+1);
}

int lca(int u,int v){
	if(depth[u] < depth[v]) swap(u,v);
	for(int i=19;i>=0;--i) if((depth[u]-depth[v])>>i&1) u=parent[u][i];
	if(u==v) return u;
	for(int i=19;i>=0;--i){
		if(parent[u][i]!=parent[v][i]){
			u=parent[u][i];
			v=parent[v][i];
		}
	}
	return parent[u][0];
}

int main(void){
	int n; cin >> n;
	rep(i,n){
		int k; cin >> k;
		rep(j,k){
			int v; cin >> v;
			graph[i].push_back(v);
		}
	}

	// rep(i,n)rep(j,20) parent[i][j]=-1;
	dfs(0,-1,0);
	rep(i,n)rep(j,19) parent[i][j+1]=parent[parent[i][j]][j];

	int q; cin >> q;
	rep(i,q){
		int u,v; cin >> u >> v;
		cout << lca(u,v) << endl;
	}
	return 0;
}

Measured memory_bytes: 43188
input_list = list(input().split())
bill_num = int(input_list[0])
total_price = int(input_list[1])

yen_10000 = 10000
yen_5000 = 5000
yen_1000 = 1000
bill_num_list = []

for i in range(bill_num + 1):
    for j in range(bill_num - i + 1):
        k = 0
        k = bill_num - i - j
        total = i * yen_10000 + j * yen_5000 + k * yen_1000
        if  (i + j + k == bill_num) and (k >= 0) and (total == total_price):
            bill_num_list = [i, j, k]
            bill_num_list_str = list(map(str, bill_num_list))
            break

if bill_num_list == []:
    print('-1 -1 -1')
else:
    print(' '.join(bill_num_list_str))


Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>

using namespace std;

int main(void)
{
    int a[3];
    scanf("%d%d%d", &a[0], &a[1], &a[2]);
    sort(a, a + 3);
    printf("%d\n", (a[1] - a[0]) + (a[2] - a[1]));
    return 0;
}

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

void solve(long long A, long long B)
{
    if (B % A == 0)
    {
        cout << A + B << endl;
    }
    else
    {
        cout << B - A << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <string> 
using namespace std;
using int64 = long long;
typedef long long ll;
int main()
{

  ll H1,H2,M1,M2,N,K,W;
  cin>>H1>>M1>>H2>>M2>>K;
  W=H2-H1;
  W*=60;
  W+=M2-M1;
  W-=K;
  cout<<W;

  
  return 0;
}


Measured memory_bytes: 3568
def solve():
    N, K = map(int, input().split())
    ans = 0
    for b in range(max(1, K), N+1):
	    ans += (b-K)*(N//b)
	    if N % b >= K and K > 0:
		    ans += N % b - K + 1
	    elif N % b >= K:
		    ans += N % b
    print(ans)


solve()

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	hs := make([]int, n)
	cnt := 0
	res := 1
	for i := range hs {
		fmt.Scan(&hs[i])
	}
	// take a hi
	for i := 1; i < n; i++ {
		// loop before hi
		for j := 0; j < i; j++ {
			if hs[j] > hs[i] {
				cnt++
			}
		}
		if cnt == 0 {
			res++
		}
		cnt = 0
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
import fractions
from functools import reduce

def gcd(a, b):
  while b:
    a, b = b, a % b
    return a

def gcds(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n, x = map(int, input().split())
a_list = list(map(int, input().split()))
minimum = 10000000000
dist_list = []
for i,a in enumerate(a_list):
  minimum = min(abs(a - x), minimum)
  if i == 0:
    continue
  dist_list.append(abs(a_list[i-1] - a))

dist_list.append(minimum)

print(gcd_list(dist_list))



Measured memory_bytes: 16268
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
suff = 0
cont = 0
suff += B[A[0]-1]
cont = A[0]
for i in range(1,N):
    suff += B[A[i]-1]
    if A[i] - cont == 1:
        suff += C[cont-1]
    cont = A[i]
print(suff)

Measured memory_bytes: 3064
n = int(input())
c = [0]*n
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            N = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n >= N:
                c[N-1] += 1
for i in c:
    print(i)


Measured memory_bytes: 9268
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	f := func(v int) int {
		return ((v + 1) * v) >> 1
	}
	ap := f(1)
c:
	for i := 2; i <= 999; i++ {
		bp := f(i)
		for x := 1; x < 499500; x++ {
			if ap-x == a && bp-x == b {
				fmt.Println(x)
				break c
			}
		}
		ap = bp
	}
}


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

int main() {
    string num;
    long long ans;
    while (true) {
        cin >> num;
        if (num == "0") break;
        ans = 0;
        for (int i = 0; i < num.size(); ++i) {
            ans += num[i] - '0';
        }
        cout << ans << endl;
    }
    
    return 0;
}


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

#ifdef LOCAL
#include "../debug.h"
#else
#define debug(x...) 141
#endif
#define forn(i,x,n) for(int i = x; i < n; ++i)
#define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it)
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a,bb;
    double b;
    {
        cin>>a>>b;
        bb=(ll)(b*100+0.5);
        cout<<a*bb/100<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3740
# -*- coding: utf-8 -*-


class UnionFind(object):
    '''Represents a data structure that tracks a set of elements partitioned
       into a number of disjoint (non-overlapping) subsets.
    Landau notation: O(α(n)), where α(n) is the inverse Ackermann function.
    See:
    https://www.youtube.com/watch?v=zV3Ul2pA2Fw
    https://en.wikipedia.org/wiki/Disjoint-set_data_structure
    https://atcoder.jp/contests/abc120/submissions/4444942
    '''

    def __init__(self, number_count: int):
        '''
        Args:
            number_count: The size of elements (greater than 2).
        '''
        self.parent_numbers = [-1 for _ in range(number_count)]

    def find_root(self, number: int) -> int:
        '''Follows the chain of parent pointers from number up the tree until
           it reaches a root element, whose parent is itself.
        Args:
            number: The trees id (0-index).
        Returns:
            The index of a root element.
        '''
        if self.parent_numbers[number] < 0:
            return number

        self.parent_numbers[number] = self.find_root(self.parent_numbers[number])
        return self.parent_numbers[number]

    def get_group_size(self, number: int) -> int:
        '''
        Args:
            number: The trees id (0-index).
        Returns:
            The size of group.
        '''
        return -self.parent_numbers[self.find_root(number)]

    def is_same_group(self, number_x: int, number_y: int) -> bool:
        '''Represents the roots of tree number_x and number_y are in the same
           group.
        Args:
            number_x: The trees x (0-index).
            number_y: The trees y (0-index).
        '''
        return self.find_root(number_x) == self.find_root(number_y)

    def merge_if_needs(self, number_x: int, number_y: int) -> bool:
        '''Uses find_root to determine the roots of the tree number_x and
           number_y belong to. If the roots are distinct, the trees are combined
           by attaching the roots of one to the root of the other.
        Args:
            number_x: The trees x (0-index).
            number_y: The trees y (0-index).
        '''
        x = self.find_root(number_x)
        y = self.find_root(number_y)

        if x == y:
            return False

        if self.get_group_size(x) >= self.get_group_size(y):
            self.parent_numbers[x] += self.parent_numbers[y]
            self.parent_numbers[y] = x
        else:
            self.parent_numbers[y] += self.parent_numbers[x]
            self.parent_numbers[x] = y
        return True


def main():
    import sys
    input = sys.stdin.readline

    n, m = map(int, input().split())
    uf = UnionFind(n)

    for i in range(m):
        ai, bi = map(int, input().split())
        ai -= 1
        bi -= 1

        uf.merge_if_needs(ai, bi)

    ans = 0

    for j in range(n):
        ans = max(ans, uf.get_group_size(j))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14620
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		if (arr.length == 3) {
			char tmp = arr[0];
			arr[0] = arr[2];
			arr[2] = tmp;
		}
		System.out.println(arr);
	}
}


Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define MP make_pair
#define ET cout << "\n"
#define ALL(v) v.begin(),v.end()
#define MEM(i,j) memset(i,j,sizeof i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MOD=998244353;
ll J[300001],inv[300001],invJ[300001];

ll C(ll n,ll k)
{
	if(n<k) return 0;
	return J[n]*invJ[n-k]%MOD*invJ[k]%MOD;
}

int main()
{jizz
	ll n,a,b,k,t,x,ans;
	cin >> n >> a >> b >> k,ans=0;
	inv[1]=J[1]=invJ[1]=J[0]=invJ[0]=1;
	for(ll i=2;i<=n;++i)
		J[i]=J[i-1]*i%MOD,inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD,invJ[i]=invJ[i-1]*inv[i]%MOD;
	for(int i=0;i<=n && a*i<=k;++i)
	{
		x=k-a*i;
		if(x%b) continue;
		ans+=C(n,i)*C(n,x/b)%MOD,ans%=MOD;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 7296
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#include <cassert>
#define rep(i, x) for (int i = 0; i < (x); ++i)
#define rng(i, x, y) for (int i = (x); i < (y); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
void solve();
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solve();
    return 0;
}


// Main Code
void solve() {
    int n;
    cin >> n;
    map<int, int> d;
    rep(i, n) {
        int d_;
        cin >> d_;
        ++d[d_];
    }
    int m;
    cin >> m;
    map<int, int> t;
    rep(i, m) {
        int t_;
        cin >> t_;
        ++t[t_];
    }
    for (auto p: t) {
        if (d[p.first] < p.second) {
            cout << "NO\n";
            return;
        }
    }
    cout << "YES\n";
    return;
}


Measured memory_bytes: 22204
#include <stdio.h>

int main() {
  int N, i;
  char T[101], S[101], ans[201];
  scanf("%d %s %s", &N, S, T);
  for(i = 0; i < N; i++) {
    printf("%c%c", S[i], T[i]);
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();
  if (n <= k) {
    cout << s << endl;
  } else {
    rep(i,k) {
      cout << s[i];
    }

    cout << "..." << endl;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

char a[500000];
deque<char> que;

int main() {
  string s;
  cin >> s;
  rep(i, s.size()) {
    que.push_back(s[i]);
  }
  bool f = true;
  int Q;
  cin >> Q;
  rep(i, Q) {
    int temp;
    cin >> temp;
    if(temp == 1) {
      f ^= 1;
    } else {
      int tempf;
      char c;
      cin >> tempf >> c;
        if(f ^ (tempf - 1)) {
          que.push_front(c);
        } else {
          que.push_back(c);
        }
    }
  }
  if(f) {
    while(que.size()) {
      cout << que.front();
      que.pop_front();
    }
    cout << endl;
  } else {
    while(que.size()) {
      cout << que.back();
      que.pop_back();
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 4012
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> S(N+5,0);
  for(int i=0; i<M; i++){
    int l,r;
    cin >> l >> r;
    S[l]++;
    S[r+1]--;
  }
  vector<int> vec(N+5,0);
  for(int i=0; i<=N; i++){
    vec[i+1] = vec[i] + S[i];
  }
  int ans = 0;
  for(int i=0; i<=N+1; i++){
    if(vec[i] == M){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
// 17 52 ツィツ　WA18 -> 25ツ個エツ暗カツ閉ェツつゥツづつス?


#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
vector<string> data(12);

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

bool iscorrect(int y,int x){
	if(y>11 || y<0)return false;
	if(x<0 || x>5)return false;
	return true;
}

int cnt;
bool done[12][6];
void search(int y,int x,int c){
	if(data[y][x] != c)return;
	
	if(done[y][x])return;
	cnt++;
	done[y][x] = true;
	rep(i,4){
		int nx = x+dx[i];
		int ny = y+dy[i];
		if(iscorrect(ny,nx))search(ny,nx,c);
	}
}
void del(int y,int x,int c){
	if(data[y][x] != c)return;
	data[y][x] = '.';
	rep(i,4){
		int nx = x+dx[i];
		int ny = y+dy[i];
		if(iscorrect(ny,nx)){
			if(data[ny][nx]=='O')data[ny][nx]='.';
		}
	}
	rep(i,4){
		int nx = x+dx[i];
		int ny = y+dy[i];
		if(iscorrect(ny,nx))del(ny,nx,c);
	}
	
}
void down(){
	rep(x,12){
		rep(w,6){
			for(int i=0;i+1<12;i++){
				if(data[i+1][w] == '.'){
					swap(data[i+1][w],data[i][w]);
				}
			}
		}
	}
} 

bool iscell(int i,int j){
	return data[i][j] != 'O' && data[i][j] != '.';
}

int main(){
	int n;
	cin >>n;
	while(n--){
		rep(i,12){cin >> data[i];}
		down();
		vector<string> prev = data;
		rep(O,73){
			rep(i,12)rep(j,6){
				if(iscell(i,j)){
					rep(p,12)rep(q,6)done[p][q] = false;
					cnt = 0;
					search(i,j,data[i][j]);
					//cerr << cnt << endl;
					if(cnt>=4){
						del(i,j,data[i][j]);
					}
				}
			}
			down();
			//system("clear");rep(i,12){rep(j,6)cout << data[i][j];cout << endl;}usleep(1200000);
			if(prev == data){
				cout << O << endl;
				break;
			}
			prev = data;
		}
	}
}

Measured memory_bytes: 0
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;
#define int ll
signed main() {
    int H, W; cin >> H >> W;
    int m = min(H, W), M = max(H, W);
    int ans = 1;
    if (m == 1) {
        //means theres no inside
        int inside, edge, corner;
        if (M == 1) {
            ans = 1;
        }
        else {
            corner = 2;
            edge = M - 2;

            ans = edge;
        }
    }
    else {
        int inside, edge, corner;
        corner = 4;
        edge = 2 * (m + M - 4);
        inside = (m - 2) * (M - 2);

        ans = inside;
    }


    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  double half = N / 2;
  if (N % 2 == 1) {
    half += 1.0;
  }

  cout << half/N << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		double res = 0;
		while (res<=20000) {
			if(res * 0.08 >= A && res * 0.08 < A + 1 && res * 0.1 >= B && res * 0.1 < B + 1) {
				break;
			}
			res++;
		}
		if((int)res!=20001) {
			System.out.println((int)res);
		}else {
			System.out.println(-1);
		}
	}
}

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


pii mergeSegment(pii a,pii b){	//returns pii(1,-1) when two segments don't crossed.
	if(a.second<b.first || b.second<a.first)	return pii(1,-1);				//a∧b==∅
	if(a.first<=b.first && b.second<=a.second)	return b;						//b∈a
	if(b.first<=a.first && a.second<=b.second)	return a;						//a∈b
	if(a.first<b.first && a.second<b.second)	return pii(b.first,a.second);	//a b
	if(b.first<a.first && b.second<a.second)	return pii(a.first,b.second);	//b a
	
	return pii(1,-1);
}




ll solve(pii a,pii b){
	pii res = mergeSegment(a,b);
	if(res==pii(1,-1))return 0;
	return res.second-res.first+1;
}

const ll MOD = (1e9)+7;
int main(){
	int n;
	cin>>n;
	vector<int> t(n);
	vector<int> a(n);
	rep(i,n)cin>>t[i];
	rep(i,n)cin>>a[i];
	
	vector<pii> tt(n),aa(n);
	
	tt[0] = pii(t[0],t[0]);
	for(int i=1;i<n;i++){
		if(t[i]>t[i-1]){
			tt[i] = pii(t[i],t[i]);
		}
		else{
			tt[i] = pii(1,t[i]);
		}
	}
	
	
	aa[n-1] = pii(a[n-1],a[n-1]);
	for(int i=n-2;i>=0;i--){
		if(a[i]>a[i+1]){
			aa[i] = pii(a[i],a[i]);
		}
		else{
			aa[i] = pii(1,a[i]);
		}
	}
	
	
	ll ans = 1;
	rep(i,n){
		if(tt[i].second<aa[i].first || aa[i].second<tt[i].first){
			cout<<0<<endl;
			return 0;
		}
		pii x=tt[i],y=aa[i];
		ll  tmp = solve(x,y)%MOD;
		ans = (ans*tmp)%MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.swing.text.Segment;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final int N = sc.nextInt();
			final int M = sc.nextInt();
			
			final int time = 1900 * M + 100 * (N - M);
			
			final double EPS = 1e-5;
			
			double answer = -EPS;
			for(int i = 1; ; i++){
				final double pow = Math.pow(0.5, M);
				final double fst_part = Math.pow(1 - pow, i - 1);
				final double snd_part = pow;
				
				final double complete = fst_part * snd_part * i * time;
				if(complete < EPS){ break; }
					
				answer += complete;
				//System.out.println(answer + " " + complete);
			}
			
			System.out.println((long)(answer + 1));
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21332
a,b = gets.chomp.split(' ').map(&:to_i)
s = gets.chomp
if (s[a] != '-')
  puts 'No'
  exit
end

if (s[0...a].match?(/\d/) && s[(a+1)..-1].match?(/\d/))
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 14300
#include <iostream>
#include <vector>


using namespace std;

int main () {
    int N,X;
    cin >> N >> X;
    vector <int> L(N);
    for (int i = 0 ; i < N ; i++)
    {
        cin >> L[i];
    }
    int d = 0, ans = 1;
    for (int i = 0; i < N ; i++) {
        d += L[i];
        if(d > X)break;
        ans += 1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
	input!(a: usize);
	input!(b: usize);
	input!(x: usize);

	let t1 = if b == 0 {0+1} else {(b / x)+1};
	let t2 = if a == 0 {0} else {((a-1) / x)+1};
	//println!("t1={}, t2={}", t1, t2);
	println!("{}", t1 - t2);

}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int k,a,b;
    cin>>k>>a>>b;
    int flag=0;
    for(int i=a;i<=b;i++){
    	if(i%k==0){
    		flag=1;
    		break;
    	}
    }
    if(flag==1){
    	cout<<"OK"<<endl;
    }
    else{
    	cout<<"NG"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 1 << 58;

const int MOD = 1000000007;


int N, Q, K;
vector<int> ab[100010];
vector<int> c[100010];
long saitankyori[100010];
bool tootta[100010];

int kyori(int genzaichi, int maenogenzaichi){
    tootta[genzaichi] = true;
    while(!ab[genzaichi].empty()){
        int tuginogenzaichi = ab[genzaichi][0];
        long tuginogenzaichimadenokyori = c[genzaichi][0];
        ab[genzaichi].erase(ab[genzaichi].begin());
        c[genzaichi].erase(c[genzaichi].begin());
        if(tuginogenzaichi != maenogenzaichi){
            saitankyori[tuginogenzaichi] = saitankyori[genzaichi] + tuginogenzaichimadenokyori;
            kyori(tuginogenzaichi, genzaichi);
        }
    }
    return 0;
}
int transittreepath(){
    cin >> N;
    REP(i, N - 1){
        int a, b, c1;
        cin >> a >> b >> c1;
        ab[a].push_back(b);
        c[a].push_back(c1);
        ab[b].push_back(a);
        c[b].push_back(c1);
    }
    
    cin >> Q >> K;
    int x, y;
    long answers[100010];
    REP(i, N + 1){
        saitankyori[i] = INF;
        saitankyori[i] *= 256;
    }
    
    saitankyori[K] = 0;
    kyori(K, -1);
    
    REP(i, Q){
        cin >> x >> y;
        answers[i] = saitankyori[x] + saitankyori[y];
    }
    
    REP(i, Q){
        printf("%ld\n", answers[i]);
    }
    return 0;
}

/*
 vector<int> ab[100010];
 int konokazu[100100] = {0};
 ll dpf[100100] = {0};
 ll dpg[100100] = {0};
 bool tootta[100010] = {false};
 int N;
int kyori(int genzaichi){
    bool hasi = true;
    tootta[genzaichi] = true;
    while(!ab[genzaichi].empty()){
        int tuginogenzaichi = ab[genzaichi][0];
        ab[genzaichi].erase(ab[genzaichi].begin());
        if(!tootta[tuginogenzaichi]){
            kyori(tuginogenzaichi);
            dpf[genzaichi] = (dpg[tuginogenzaichi] * dpf[genzaichi]) % MOD;
            dpg[genzaichi] = (dpf[tuginogenzaichi] * dpg[genzaichi]) % MOD;
        }
    }
    dpf[genzaichi] += dpg[genzaichi];
    dpf[genzaichi] %= MOD;
    dpg[genzaichi] %= MOD;
    return 0;
}
int nurie(){
    //treeDP
    cin >> N;
    REP(i, N - 1){
        int a,b;
        cin >> a >> b;
        ab[a].push_back(b);
        ab[b].push_back(a);
    }
    REP(i, N + 1){
        dpf[i] = 1;
        dpg[i] = 1;
    }
    
    tootta[1] = true;
    kyori(1);
    
    return dpf[1];
}
*/

int main(){
    transittreepath();
}


Measured memory_bytes: 23808
s = input()
is1 = True
is2 = True
for i in range(2):
    if s[0] != s[i + 1]:
        is1 = False
for i in range(2):
    if s[1] != s[i + 2]:
        is2 = False
if is1 or is2:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);
 
typedef long long int ll;

int n, W, value[105], weight[105];
ll memo[105][100005];

ll dp(int idx, int remW) {
	if (idx == n || remW == 0) return 0;
	if (memo[idx][remW] != -1) return memo[idx][remW];
	if (remW < weight[idx])
		return memo[idx][remW] = dp(idx + 1, remW);
	return memo[idx][remW] = max(dp(idx + 1, remW), dp(idx + 1, remW - weight[idx]) + value[idx]);
}

int main() {
    optimizar_io
    
    cin >> n >> W;
    for (int i = 0; i < n; i++)
        cin >> weight[i] >> value[i];
    memset(memo, -1, sizeof(memo));
    cout << dp(0, W) << "\n";
    return 0;
}

Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  string s; cin >> s;
  bool  c= false, f = false;
  for(int i = 0; i < s.size(); ++i){
    if(!c && s[i]=='C')c = true;
    else if(c && !f  && s[i]== 'F')f = true;
  }
  string ans = "No";
  if(c && f )ans = "Yes";
  cout << ans << endl;
}


Measured memory_bytes: 3628
def main():
    a, b, c, d = map(int, input().split())

    if c % b == 0:
        e = c // b
    else:
        e = c // b + 1

    if a % d == 0:
        f = a // d
    else:
        f = a // d + 1

    if e > f:
        ans = "No"
    else:
        ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61476
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <cmath>
#include <iomanip>
#include <queue>
#include <deque>
#include <fstream>
#include <bitset>
#include <cassert>
using namespace std;
 
//#define int long long
#define double long double
#define mp make_pair
#define all(a) a.begin(), a.end()
#define pb push_back
#define debug(x) cerr << #x << ": " << x << '\n';
#define ppoint(p) cout << #p << ' ' << p.x << ' ' << p.y << '\n';
#define fi first
#define se second
#define FOR(i, n) for (int i = 0; i < n; ++i)
//typedef long long ll;
typedef pair<int, int> pii;
 
template<typename T1, typename T2> inline bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; };
template<typename T1, typename T2> inline bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; };
 
void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
}

const int N = 2e5 + 10;
int a[N];

signed main() {
	fast();
	cout << fixed << setprecision(10);
	int n, k;
	cin >> n >> k;
	double ans = 0;
	int s = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i >= k) s -= a[i - k];
		s += a[i];
		ans = max(ans, (s + k) / (double)2.);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
def resolve():
    '''
    code here
    '''
    import sys
    sys.setrecursionlimit(10000000)
    from decimal import Decimal
    N = int(input())
    T_list = [int(input()) for _ in range(N)]

    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a%b)

    def lcm(a,b):
        return int(a // gcd(a, b) * b)

    res = 1
    for i in T_list:
        res = lcm(res, i)
        # print(res, i)

    print(res)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 5844
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for i in range(n)]
count=0
for i in a:
    point=0
    for j in range(m):
        point+=i[j]*b[j]
    if point>-c:
        count+=1
print(count)


Measured memory_bytes: 38384
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
uint64_t gcd(uint64_t a, uint64_t b);
uint64_t lcm(uint64_t a, uint64_t b);

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

typedef struct {
  uint32_t x;
  bool y;
} States;

int main() {
  uint32_t N;
  cin >> N;
  vector<vector<States>> S(N);
  for (uint32_t i = 0; i < N; ++i) {
    uint32_t tmp;
    cin >> tmp;
    for (uint32_t j = 0; j < tmp; ++j) {
      States s;
      cin >> s.x >> s.y;
      s.x--;
      S[i].push_back(s);
    }
  }
  uint32_t res = 0;
  for (uint32_t i = 1; i < (0x01 << N); ++i) {
    bool flag = false;
    for (uint32_t j = 0; j < N; ++j) {
      if ((i >> j) & 0x01) {
        for (auto itr = S[j].begin(); itr != S[j].end(); ++itr) {
          if (((i >> itr->x) & 0x01) != itr->y) flag = true;
        }
      } else {
        continue;
      }
      if (flag) break;
    }
    if (flag)
      continue;
    else {
      uint32_t tmp = 0;
      for (uint32_t j = 0; j < N; ++j) {
        tmp += (i >> j) & 0x01;
      }
      if (res < tmp) res = tmp;
    }
  }
  cout << res << endl;
  return 0;
}

uint64_t gcd(uint64_t a, uint64_t b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

uint64_t lcm(uint64_t a, uint64_t b) { return a * b / gcd(a, b); }

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>

using namespace std;

int A[200005];

int main()
{
	int n,x;
	scanf("%d %d",&n,&x);
	if(x==1||x==2*n-1)
	{
		puts("No");
	}
	else
	{
		memset(A,-1,sizeof(A));
		A[n-2]=x-1;
		A[n-1]=x;
		A[n]=x+1;
		int now=1;
		for(int i=0;i<2*n-1;i++)
		{
			if(A[i]==-1)
			{
				while(abs(now-x)<=1) now++;
				A[i]=now++;
			}
		}
		puts("Yes");
		for(int i=0;i<2*n-1;i++) printf("%d\n",A[i]);
	}
	return 0;
}


Measured memory_bytes: 2176
N=int(input())
A = sorted(map(int, input().split()), reverse=True)
if N%2==1:
  print(sum(A[0:(N-1)//2])+sum(A[1:(N+1)//2]))
else:
  print(sum(A[0:N//2])+sum(A[1:N//2]))


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

typedef long long ll;

int main(int argc, char *argv[])
{
  long long n;
  cin >> n;
  ll ans = 1e18;
  for (ll i = 1; i * i <= n; ++i) {
    if(n%i != 0) continue;
    ll j = n/i;
    ans = min(ans, i + j - 2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main(){
    int s,w;
    cin >> s >> w;
    if(w >= s) cout << "unsafe" << endl;
    else
    {
        cout << "safe" << endl;
    }
    return 0;

}

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

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double x1, y1, x2, y2;
  x1 = a * cos((30*h + 0.5*m)*PI/180); y1 = a * sin((30*h + 0.5*m)*PI/180);
  x2 = b * cos(6*m*PI/180); y2 = b * sin(6*m*PI/180);
  cout << setprecision(15) << sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)) << endl;
  return 0;
}


Measured memory_bytes: 4100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(a>0 && c>0){
		c-=b;
		if(c<=0)break;
		a-=d;
	}	
	if(a>0)puts("Yes");
	else puts("No");
	return 0; 
}


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

template<unsigned mod=998244353>struct fp {
   unsigned v;
   static unsigned get_mod(){return mod;}
   unsigned inv() const{
      int tmp,a=v,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0){x+=mod;} return x;
   }
   fp():v(0){}
   fp(ll x):v(x>=0?x%mod:mod+(x%mod)){}
   fp operator-()const{return fp(-v);}
   fp pow(ll t){fp res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;} return res;}
   fp& operator+=(const fp& x){if((v+=x.v)>=mod)v-=mod; return *this;}
   fp& operator-=(const fp& x){if((v+=mod-x.v)>=mod)v-=mod; return *this;}
   fp& operator*=(const fp& x){v=ll(v)*x.v%mod; return *this;}
   fp& operator/=(const fp& x){v=ll(v)*x.inv()%mod; return *this;}
   fp operator+(const fp& x)const{return fp(*this)+=x;}
   fp operator-(const fp& x)const{return fp(*this)-=x;}
   fp operator*(const fp& x)const{return fp(*this)*=x;}
   fp operator/(const fp& x)const{return fp(*this)/=x;}
   bool operator==(const fp& x)const{return v==x.v;}
   bool operator!=(const fp& x)const{return v!=x.v;}
}; using Fp=fp<>;
template<typename T>struct factorial {
   vector<T> Fact,Finv,Inv;
   factorial(int maxx){
      Fact.resize(maxx); Finv.resize(maxx); Inv.resize(maxx);
      Fact[0]=Fact[1]=Finv[0]=Finv[1]=Inv[1]=1;
      rep(i,2,maxx){Fact[i]=Fact[i-1]*i;} Finv[maxx-1]=Fact[maxx-1].inv();
      for(int i=maxx-1;i>=2;i--){Finv[i-1]=Finv[i]*i; Inv[i]=Finv[i]*Fact[i-1];}
   }
   T fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
   T inv(int n){return Inv[n];}
   T nPr(int n,int r){if(n<0||n<r||r<0)return Fp(0);else return Fact[n]*Finv[n-r];}
   T nCr(int n,int r){if(n<0||n<r||r<0)return Fp(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};

factorial<Fp> fact(402000);

int main(){
   int n,m,k; cin>>n>>m>>k;
   Fp res;
   rep(i,0,k+1){
      Fp add=fact.nCr(n-1,n-1-i)*Fp(m)*Fp(m-1).pow(n-1-i);
      //cerr<<c<<add.v<<endl;
      res+=add;
   } cout<<res.v<<endl;
   return 0;
}

Measured memory_bytes: 7792
#include <stdio.h>

#define LIMIT 1000000

int main()
{
	int x, k;
	int low, high;
	int i;

	if(scanf("%d %d", &k, &x));

	low = x - k + 1;
	high = x + k - 1;

	if (low <= (-1 * LIMIT))
		low = -1 * LIMIT;

	if (high >= LIMIT)
		high = LIMIT;

	for (i = low; i <= high; i++)
		printf("%d ", i);
	printf("\n");

	return 0;
}


Measured memory_bytes: 128
#include<bits//stdc++.h>
using namespace std;
bool s[1000002];
int main(){
	fill(s,s+1000001,true);
	s[0]=false;
	s[1]=false;
	for(int i=0;i<=1000000;i++){
		if(s[i]){
			int j=2;
			while(i*j<=1000000){
				s[i*j]=false;
				j++;
			}
		}
	}
	int a,b,n;
	while(cin>>a>>b>>n&&a!=0&&b!=0&&n!=0){
		int c=a;
		int sum=0;
		while(sum<n){
			if(s[c]){
				sum++;
			}
			c+=b;
		}
		cout<<c-b<<endl;
	}
}

Measured memory_bytes: 4052