akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main(){
//    int64_t a,x;
//    long double b;
//    cin >> a >> b;
//    x=a*b;
//    printf("%ld\n",x);
//    return 0;
 ll a;
 double b;
 cin>>a>>b;
 double c=100*b+0.5;
 ll d=c;
 a*=d;
 a/=100;
 printf("%lld",a);
 return 0;
}


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

using namespace std;

int a[100000];

int main()
{
	for(int n,k;scanf("%d%d",&n,&k),n;){
		for(int i=0;i<k;i++)	scanf("%d",a+i);

		sort(a,a+k);
		int white=(a[0]?0:1);

		int maxlen=0;
		int len[2]={},bf[2]={-100,-100};
		for(int i=1,j=white;i<=n&&j<k;i++){
			if(a[j]==i){
				for(int m=0;m<=white;m++){
					if(a[j]==bf[m]+1)	len[m]++;
					else	len[m]=1;
					bf[m]=a[j];
				}
				j++;
			}
			else{
				if(white){
					len[1]=len[0]+1;
					bf[1]=i;
				}
				len[0]=0;
			}
			maxlen=max(maxlen,max(len[0],len[1]));
		}

		printf("%d\n",maxlen);
	}

	return 0;
}

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

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d;
  
  e = a + b - c - d;
  
  if (e > 0){
    cout << "Left" << endl;
  }
  else if (e == 0){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
a,b,c,x,y = map(int, input().split())
if (a+b <= c*2):
    print(a*x+b*y)
else:
    if (x>=y):
        print(min(y*c*2+(x-y)*a,x*c*2))
    else:
        print(min(x*c*2+(y-x)*b,y*c*2))

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string> 
#include<map>
#include<set>
#include<vector>
#include<string.h> 
#include<math.h>
#include<stdio.h> 
#include<queue>
using namespace std;
int main()
{int a,b,c;cin>>a>>b>>c;
if(c*2>=b-a+1){
	for(int i=a;i<=b;i++)cout<<i<<endl;return 0;
}
for(int i=0;i<c;i++)cout<<a+i<<endl;
for(int i=c-1;i+1;i--)cout<<b-i<<endl;
system("pause");
return 0;
}

Measured memory_bytes: 504
def solve():
    N, M = map(int, input().split())
    n_ball = [1] * N
    could_exist = [False] * N
    could_exist[0] = True

    for _ in range(M):
        frm, to = map(lambda elem:int(elem)-1, input().split())
        if could_exist[frm] and n_ball[frm] > 0:
            could_exist[to] = True
        if could_exist[frm] and n_ball[frm] == 1:
            could_exist[frm] = False
        n_ball[frm] -= 1
        n_ball[to] += 1
    
    print(sum(could_exist))
    
if __name__ == '__main__':
    solve()

Measured memory_bytes: 48344
#include <iostream>
#include <list>
#include <iterator>

using namespace std;

int main(int argc, const char * argv[]) {
    list<int> ls;
    
    int N;
    cin>>N;
    
    
    list<int>::iterator it=ls.end();
    for(int i=0;i!=N;++i){
        int q;
        cin>>q;
        
        switch(q){
                
            case 0:
                int x;
                cin>>x;
                it=ls.insert(it,x);
                break;
            case 1:
                int d;
                cin>>d;
                advance(it,d);
                break;
            case 2:
                it=ls.erase(it);
                break;
            
        }
        
    }
    
    for(list<int>::iterator it=ls.begin();it!=ls.end();++it){
        cout<<*it<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 18596
{-# LANGUAGE BangPatterns #-}
import Data.Int
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM

solve :: Int -> Int -> V.Vector (Int,Int) -> V.Vector Int64
solve n m edges = V.create $ do
  -- m 番目の島から順番に島同士が「繋がっていく」と考える

  -- j = assocs ! i : i 番目の島の親が j
  assocs <- VM.new n
  forM_ [0..n-1] $ \i -> VM.write assocs i i

  -- numberOfElements ! i : i番目の島と同じ連結成分に属する島の個数
  numberOfElements <- VM.replicate n 1

  let getRoot i xs = do
        j <- VM.read assocs i
        if i == j
          then return (i, xs)
          else getRoot j (i:xs)
      unify i j = do
        (i',xs) <- getRoot i []
        (j',ys) <- getRoot j []
        let !k = min i' j'
        forM_ (i':xs) (\l -> VM.write assocs l k)
        forM_ (j':ys) (\l -> VM.write assocs l k)
        if i' == j'
          then return 0
          else do
          n1 <- VM.read numberOfElements i'
          n2 <- VM.read numberOfElements j'
          VM.write numberOfElements k (n1 + n2)
          return (n1 * n2)
  result <- VM.new m
  VM.write result (m-1) $ fromIntegral n * (fromIntegral n - 1) `quot` 2
  forM_ [m-1,m-2..1] $ \i -> do
    let (a,b) = edges V.! i
    convenience <- unify a b
    prevInconveniences <- VM.read result i
    VM.write result (i-1) (prevInconveniences - convenience)
  return result

main = do
  [n,m] <- map read . words <$> getLine -- 2 <= n <= 10^5, 1 <= m <= 10^5
  edges <- V.replicateM m $ do
    [a,b] <- map read . words <$> getLine
    return (a-1, b-1)
  -- maxIncovenience < n * (n - 1) / 2 < 10^10 (2^32 < 10^10)
  let result = solve n m edges
  V.forM_ result print


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

int main() {
    long double a, b;
    int h, m;
    cin >> a >> b >> h >> m;
    long double pi = 3.14159265358979;

    long double s1 = (pi * h / 6) + pi * m / 360;
    long double s2 = (pi * m / 30);

    while (s1 > 2 * pi) {
        s1 -= 2 * pi;
    }
    while (s2 > 2 * pi) {
        s2 -= 2 * pi;
    }

    double c = sqrt(a * a + b * b - 2 * a * b * cos(s2 - s1));

    printf("%.12lf", c);
}


Measured memory_bytes: 4136
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<stack>
#include<set>
#include<deque>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
const ll m = (1e+9) + 7;

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

Measured memory_bytes: 1024
//#include "stdafx.h"
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define e "\n"
#define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#define fix(n) cout << fixed << setprecision(n);
using namespace std;
int main()
{
	MaRiaMa;
	double x;
	int n;
	cin >> n;
	while(n!=0)
	{
		x = sqrt(n);
		if (x != int(sqrt(n)))
		{
			n--;
                        x=0;
		}
		else
		{
			cout << n;
			return 0;
		}
	}
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n=0 , k=0 ,sum =0,i=0;
cin>>n>>k;
int arr [n];
for( int m =0 ; m<n ; m++){cin>>arr[m];}
sort(arr,arr+n);
while (i<k)
{
 sum+=arr[i]; i++;   
}
cout<<sum;
}

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

ll gcd(ll a, ll b){
  if (a < b) gcd(b,a);
  ll r;
  while((r = a % b)){
    a = b;
    b = r;
  }
  return b;
}

int main(){
  int N;
  cin >> N;
  ll ans = 1;
  for (int i = 0; i < N; i++){
    ll t;
    cin >> t;
    ans *= t / gcd (ans, t);
  }
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9 + 10)
#define PI (acos(-1))
#define MOD (1000000007)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
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; }

int main() {
    int N,M;
    cin >> N;cin >> M;
    vector<vector<int>> G;
    G.assign(N, vector<int>());
    REP(i, M) {
        int x, y;
        cin >> x;cin >> y;
        G[x-1].push_back(y-1);
        G[y-1].push_back(x-1);
    }
    deque<int> ans;
    int first = -1;
    REP(i, N) {
        if (G[i].size() >= 2) {
            first = i;
            break;
        }
    }
    if (first == -1) {
        cout << "2" << endl << "1 2" << endl;
        return 0;
    }
    int start = G[first][0];
    int end = G[first][1];
    for (int i: G[first]){
        G[i].erase( find(ALL(G[i]), first) );
    }
    ans.push_back(first);
    while (true){
        ans.push_back(end);
        if (!G[end].empty()){
            for (int i: G[end]){
                G[i].erase( find(ALL(G[i]), end) );
            }
            if (G[end][0] == start && G[end].size() == 1){
                break;
            } else if(G[end][0] == start) {
                end = G[end][1];
            } else {
                end = G[end][0];
            }
        } else break;
    }
    while (true){
        ans.push_front(start);
        if (!G[start].empty()){
            for (int i: G[start]){
                G[i].erase( find(ALL(G[i]), start) );
            }
            start = G[start][0];
        } else break;
    }
    cout << ans.size() << endl;
    for (int i :ans){
        cout << i+1 << " ";
    }
    cout << endl;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll a,b,h;
	cin >> a >> b >> h;
	cout << (a+b)*h/2 << endl;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ST = Io.ReadList();
            var S = ST[0];
            var T = ST[1];

            var output = T + S;
            Io.Write(output);
        }

        static int NumberOfDigits(long x)
        {
            if (x < 10) return 1;

            var result = 0;
            while (x > 0)
            {
                result++;
                x /= 10;
            }

            return result;
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }

        class Io
        {
            public static string Read()
            {
                return Console.ReadLine();
            }

            public static IEnumerable<string> ReadRepeat(int count)
            {
                return Enumerable.Range(0, count).Select(_ => Read());
            }

            public static T Read<T>()
            {
                return (T)Convert.ChangeType(Read(), typeof(T));
            }

            public static IEnumerable<T> ReadRepeat<T>(int count)
            {
                return Enumerable.Range(0, count).Select(_ => Read<T>());
            }

            public static string[] ReadList(char devide = ' ')
            {
                return Read().Split(devide);
            }

            public static T[] ReadList<T>(char devide = ' ')
            {
                return ReadList(devide)
                    .Select(s => (T)Convert.ChangeType(s, typeof(T)))
                    .ToArray();
            }

            public static IEnumerable<T[]> ReadListRepeat<T>(int count, char devide = ' ')
            {
                return Enumerable.Range(0, count).Select(_ => ReadList<T>(devide));
            }

            public static void Write(string value)
            {
                Console.WriteLine(value);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

#define rep(i,a,b) for(int i=a; i<=b; i++)
#define per(i,a,b) for(int i=a; i>=b; i--)
void print(char name[], int val) {fprintf(stderr,"%s : %d\n", name, val);}
int intscan(char name[]) {fprintf(stderr,"%s>>",name); int val; scanf("%d",&val); return val;}

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

    int fib[n];
    fib[0] = 1;
    fib[1] = 1;

    rep(i,2,n) {
        fib[i] = fib[i-1] + fib[i-2];
    }
    printf("%d\n", fib[n]);

    return 0;
}



Measured memory_bytes: 2144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        string s = sc.Next();
        bool[] stones = new bool[n];
        for (int i = 0; i < n; i++)
        {
            stones[i] = s[i] == 'R';
        }

        long left = 0;
        long right = n - 1;

        long answer = 0;
        while (true)
        {
            while (stones[left])
            {
                left++;
                if (left >= n)
                {
                    break;
                }
            }
            while (!stones[right])
            {
                right--;
                if (right < 0)
                {
                    break;
                }
            }
            if (left >= n)
            {
                break;
            }
            if (right < 0)
            {
                break;
            }
            if (left < right)
            {
                answer++;
                left++;
                right--;
            }
            else
            {
                break;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28372
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//入力
		Scanner sc = new Scanner(System.in);

		//図形作成繰り返し
		for (int h = 0;; h++) {

			//縦の長さ
			int H = sc.nextInt();

			//横の長さ
			int W = sc.nextInt();

			//どちらも0の時は終了
			if (H == 0 && W == 0) {
				break;

			}
			//繰り返しH(縦)
			for (int i = 0; i < H; i++) {

				//繰り返しW(横)
				for (int j = 0; j < W; j++) {

					if (i % 2 == 0) { //奇数行
						if (j % 2 == 0) {//奇数列
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					} else { //偶数行
						if (j % 2 == 0) {//奇数列
							System.out.print(".");
						} else {
							System.out.print("#");//偶数列
						}
					}
				}
				System.out.println();//縦を次の行に
			}
			System.out.println();//最後の改行
		}

	}

}


Measured memory_bytes: 33416
#include <stdio.h>
#include <string.h>
int main() {
	char s[51];
	char okStr[16][10] = {"KIHBR",	 "KIHBRA",	 "KIHBAR",	 "KIHBARA",
						  "KIHABR",	 "KIHABRA",	 "KIHABAR",	 "KIHABARA",
						  "AKIHBR",	 "AKIHBRA",	 "AKIHBAR",	 "AKIHBARA",
						  "AKIHABR", "AKIHABRA", "AKIHABAR", "AKIHABARA"};
	scanf("%s", s);
	for (int i = 0; i < 16; i++) {
		if (strcmp(s, okStr[i]) == 0) {
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
inf = 10**18
mod = 10**9+7

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = map(int, input().split())
p = list(map(int, input().split()))
uf = UnionFind(n)
for i in range(m):
    x,y = map(int, input().split())
    uf.union(x-1, y-1)
ans=0
for i,num in enumerate(p):
    if uf.same(i,num-1):
        ans+=1
print(ans)

Measured memory_bytes: 89196
#include<stdio.h>
#include<string.h>

#define N 1000

int main(){
  char T[N];
  char P[N];
  int i,j,k;
  int flag=0;
  scanf("%s",T);
  scanf("%s",P);

  for(i=0;i<strlen(T);i++){
    flag=0;
    for(j=0,k=i; j<strlen(P); j++,k++){
      if(T[k]!=P[j]){
	flag=1;
      }
    }
    if(flag==0) printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 540
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s = iterator.next().unwrap();

    if s.replace("hi", "").len() == 0 {
        "Yes".to_string()
    } else {
        "No".to_string()
    }
}


Measured memory_bytes: 2136
#include <iostream>
#include <vector>
int main(){
  int a,b,c,x;
  std::cin >> a >> b >> c >> x;
  
  int count =0;
  for(int ac = 0; ac <= a;ac++){
  for(int bc = 0; bc <= b;bc++){
  for(int cc = 0; cc <= c;cc++){
    if(ac * 500 + bc * 100 + cc * 50 == x){
      count++;
    }
  }
  }
  }
  
  std::cout << count << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
const int maxn=5000010;
bitset<maxn>bs;
int a[2010];
int n,sum;
int main(){
	cin>>n;
	bs[0]=1;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
		bs|=(bs<<a[i]);
	}
	do sum++;while(!bs[sum/2]);
	// while(!bs[sum/2])sum++;
	cout<<sum/2<<endl;
}


Measured memory_bytes: 4388
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    for(int i = 0; i < h; i ++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
    vector<bool> allh(h, false), allw(w, false);
    for(int i = 0; i < h; i ++){
        for(int j = 0; j < w; j++){
            if(j == w-1 && a[i][j] == '.') allh[i] = true;
            if(a[i][j] == '.') continue;
            else break;
        }
    }

    for(int i = 0; i < w; i ++){
        for(int j = 0; j < h; j++){
            if(j == h-1 && a[j][i] == '.') allw[i] = true;
            if(a[j][i] == '.') continue;
            else break;
        }
    }

    for(int i = 0; i < h; i++){
        if(allh[i]) continue;
        for(int j = 0; j < w; j++){
            if(allw[j]) continue;
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

class Main {

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

		int n = sc.nextInt();
		int[] a = new int[n];
		
		int cnt=0;
		boolean flg=false; 
		
		for(int i=0; i<n; i++){
			a[i] = sc.nextInt();
			if(a[i]==i+1){
				if(flg){
					flg=false;
				}else{
					flg=true;
					cnt++;
				}
			}else{
				flg=false;
			}
		}
		
		System.out.print(cnt);

	}

}


Measured memory_bytes: 50648
import java.util.Scanner;

public class Main {

    static Scanner in = new Scanner(System.in);

    void solve() {
		int n = in.nextInt(), k = in.nextInt();
		int ans = 1;
		for(int i = 0; i < n; i++){
			if(ans > k){
				ans += k;
			}else{
				ans *= 2;
			}
		}
		System.out.println(ans);
	}
	
    public static void main(String[] args) {
		new Main().solve();
    }
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl

typedef long long LL;

int k;
string s;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> k >> s;
    int l = s.length();

    if(l <= k) {
        cout << s << '\n';
    } else {
        cout << s.substr(0, k) << "..." << '\n';
    }
    
    return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

struct Edge { int v, f; };

int n, m, f[110][110];

int getCost(vector< int > X) {
	if (X.size() == 1) return 0;
	int ret = 0;
	for (int v : X) {
		int add = 1L << 30;
		for (int u : X) if (u != v) add = min(add, f[u][v]);
		ret += add;
	}
	return ret;
}

int main() {
	cin >> n >> m;
	
	vector< vector< int > > adj(n, vector< int >());
	for_(i,0,m) {
		int u, v, c;
		cin >> u >> v >> c;
		--u; --v;
		adj[u].push_back(v);
		adj[v].push_back(u);
		f[u][v] = f[v][u] = c;
	}
	
	vector< int > order(n);
	iota(order.begin(), order.end(), 0);
	
	sort(order.begin(), order.end(), [&](int i, int j) { return adj[i].size() < adj[j].size(); });
	
	int ans = 0;
	for_(v,0,n) {
		int k = adj[v].size();
		for_(S,0,(1<<k)) {
			vector< int > X = {v};
			for_(i,0,k) if (S >> i & 1) X.push_back(adj[v][i]);
			ans = max(ans, getCost(X));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3212
auto solve(long target, in int[] cards)
{
    import std.algorithm, std.range;
    immutable
        n = cards.length,
        m = cards.sum;
    auto dp = new long[][](n+1, m+1);
    dp[0][0] = 1;
    foreach (card; cards)
        foreach_reverse (usedCards; 0..n)
            foreach (currentSum; 0..m+1-card)
                dp[usedCards+1][currentSum+card] += dp[usedCards][currentSum];
    return 1.iota(n+1).map!(i => (i*target <= m) ? dp[i][cast(size_t)(i*target)] : 0).sum;
}

unittest
{
    import std.range, std.array;
    assert (8.solve([7, 9, 8, 9]) == 5);
    assert (8.solve([6, 6, 9]) == 0);
    assert (5.solve([3, 6, 2, 8, 7, 6, 5, 9]) == 19);
    assert (3.solve(3.repeat.take(33).array) == 8589934591);
}

void main()
{
    import std.stdio, std.string, std.array, std.conv;
    immutable
        target = readln.chomp.split[1].to!long,
        cards = readln.chomp.split.to!(int[]);
    target.solve(cards).writeln;
}


Measured memory_bytes: 1276
import java.util.*;
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
        int nam[] = new int[n];
        int flag = 0;
      
      for(int i = 0; i < n ;i++){
      	nam[i] = in.nextInt();
      }
      
      int bh = -999;
      for(int i = 0;i < n ; i++){
      if(bh<=nam[i]-1){
       	nam[i] -= 1 ;
      }else if(bh<=nam[i]){
       	nam[i] = nam[i];
      }else{
      	flag = 1;
        break;
      }
        bh = nam[i];
    }

	if(flag==1){
     	System.out.print("No"); 
    }else{
     	System.out.print("Yes"); 
    }
      
	}
}


Measured memory_bytes: 49868
#include<stdio.h>

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
	return;
}

int main()
{
	int a[3], i;
	for (i = 0; i < 3; i++)
		scanf("%d", a + i);
	if (a[0] > a[1])
		swap(a, a + 1);
	if (a[1] > a[2])
		swap(a + 1, a + 2);
	if (a[0] > a[1])
		swap(a, a + 1);

	printf("%d\n", a[2] - a[0]);

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main() {

	int n, l[101], i, j, k, count = 0;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &l[i]);
	}

	for (i = 0; i < n-2; i++) {
		for (j = i + 1; j < n-1; j++) {
			for (k = j + 1; k < n; k++) {
				if (l[i] != l[j] && l[j] != l[k]&&l[i]!=l[k]) {
					if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]) {
						count++;
					}
				}
			}
		}
	}

	printf("%d", count);

	return 0;
}

Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll A[200005];
int main() {
    ll N;
    ll ans = 1LL;
    cin >> N;
    
    
    
    rep(i, N){
        cin >> A[i];
        if (A[i] == 0){
            cout << 0;
            return 0;
        }
    }
    rep(i, N){
        if (ans > (ll)1e18/A[i]){
            cout << -1;
            return 0;
        }
        ans *= A[i];
        if (ans > (ll)1e18){
            cout << -1;
            return 0;
        }
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 4416
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N;
    cin >> N;

    vector<int> a,b,c;
    vector<llint> cb(N, 0), cc(N, 0);

    REP(i, N){
        int x;
        cin >> x;
        a.pb(x);
    }    
    REP(i, N){
        int x;
        cin >> x;
        b.pb(x);
    }    
    REP(i, N){
        int x;
        cin >> x;
        c.pb(x);
    }

    sort(All(a));
    sort(All(b));
    sort(All(c));
    
    int j = 0;
    REP(i, N){
        while(a[i] >= b[j] && j < N) j++;
        if(j == N) break;
        cb[j]++;
    }
    REP(i, N-1){
        cb[i+1] += cb[i];
    }

    j = 0;
    REP(i, N){
        while(b[i] >= c[j] && j < N) j++;
        if(j == N) break;
        cc[j] += cb[i];
    }
    REP(i, N-1){
        cc[i+1] += cc[i];
    }
    llint ans = 0;
    REP(i, N){
        ans += cc[i];
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3448
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  string s;
  cin>>s;
  if(len(s)==1){
    cout<<"YES"<<endl;
    return 0;
  }
  if(len(s)==2){
    if(s[0]==s[1]){
      cout<<"NO"<<endl;
      return 0;
    }
    if(s[0]!=s[1]){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  vi t(3);
  rep(i,len(s)){
    if(s[i]=='a'){
      t[0]++;
    }
    if(s[i]=='b'){
      t[1]++;
    }
    if(s[i]=='c'){
      t[2]++;
    }
  }
  int a=len(s)/3;
  bool ja=true;
  for(auto x:t){
    if(x<a) ja=false;
    if(x>a+1) ja=false;
  }
  if(ja){
    cout<<"YES"<<endl;
    return 0;
  }
  cout<<"NO"<<endl;
}

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

using namespace std;
char mapa[3000][3000];
int linha[3000][3000];
int coluna[3000][3000];
int main() {
    int n,m;
    scanf("%d %d",&n,&m);

    for(int i=0;i<n;i++){
        int curr = 0;
        for(int j=0;j<m;j++){
            scanf(" %c",&mapa[i][j]);
            
            if(mapa[i][j]!='#') linha[i][j] = ++curr;
            if((mapa[i][j]=='#') || (j==m-1)){
                for(int w = j-1;w>=0;w--) {
                    if(mapa[i][w]=='#') break;
                    linha[i][w] = curr; 
                }
                curr = 0;
            } 
        }
    }
    for(int i=0;i<m;i++){
        int curr = 0;
        for(int j=0;j<n;j++){
            
            if(mapa[j][i]!='#') coluna[j][i] = ++curr;
            if((mapa[j][i]=='#') || (j == n-1)){
                for(int w = j-1;w>=0;w--) {
                    if(mapa[w][i]=='#') break;
                    coluna[w][i] = curr; 
                }
                curr = 0;
            }
        } 
            
    }

    int maior = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            maior = max(linha[i][j]+coluna[i][j] - 1, maior);
        }
    }
    printf("%d\n",maior);
}

Measured memory_bytes: 57600
S = input()

N = len(S)

count = 0

for n in range(N-1):
	if S[n] == S[n+1]:
		count += 1
		if S[n+1] == "0":
			S = S[:n+1] + "1" + S[n+2:]
		else:
			S = S[:n+1] + "0" + S[n+2:]

ccount = N - count

print(min(count, ccount))




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

using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = v;
            que.push(nv);
        }
    }

    cout << "Yes" << endl;
    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    for (int v = 1; v < N; ++v) cout << dist[v]+1 << endl;
}


Measured memory_bytes: 10260
#include<stdio.h>
#include<math.h>
int main(){
     
    double x1,x2,y1,y2;
    double kyori;
     
    scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
     
    kyori=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
     
    printf("%.8f\n",kyori);
    return 0;
}

Measured memory_bytes: 656
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using llu=unsigned long long;
#define mod 1000000007
#define mode 998244353
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mms(x,y) memset(x,y,sizeof(x))
#define pqm priority_queue<ll,vector<ll>,greater<ll>>
#define pb push_back
#define um unordered_map
#define pr pair
#define mm multimap
#define ms multiset
#define mp make_pair
#define vr vector
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define inf INT_MAX
#define ninf INT_MIN
#define ff first
#define ss second
#define gcd __gcd
int main()
{
    fast;
    ll t,n,m,i,j,k;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++)cin>>a[i];
    bool dp[k+1]={false};
    for(i=1;i<=k;i++)
    {
        for(j=0;j<n;j++)
        {
            if(i>=a[j] && !dp[i-a[j]])dp[i]=true;
        }
    }
    if(dp[k])cout<<"First";
    else cout<<"Second";
}


Measured memory_bytes: 384
n,m = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

MOD = 10**9+7

X_sum = 0
for i in range(n):
    X_sum += (2*i-n+1)*X[i]
    X_sum = X_sum % MOD
    
Y_sum = 0
for j in range(m):
    Y_sum += (2*j-m+1)*Y[j]
    Y_sum = Y_sum % MOD
    
print(X_sum * Y_sum % MOD)

Measured memory_bytes: 18556
#!/usr/bin/python3

k = int(input())

c = [ 0 for i in range(k + 1) ]

for i in range(k, 0, -1):
    c[i] = (k // i) ** 3
    for j in range(2, k + 1):
        if i * j > k:
            break
        else:
            c[i] -= c[i * j]

s = 0
for i in range(1, k + 1):
    s += i * c[i]

print(s)
    


Measured memory_bytes: 62364
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
long long N,X,x,D,d[100010]={};

long long gcd(long long a,long long b){
  if(a<b){
    swap(a,b);
  }
  long long r;
    r=a%b;
    if(r==0) return b;
    else return gcd(b,r);
  }


int main(){
  cin >> N >> X;
  for(long long i=0;i<N;i++){
    cin >> x;
    d[i]=abs(X-x);
  }
  D=d[0];
  for(long long i=0;i<N;i++){
    D=gcd(d[i],D);
  }
  cout << D << endl;
  return 0;
}


Measured memory_bytes: 1024
# Your code here!
def pin(type=int):
    return map(type,input().split())


N, =(pin())
s, =pin(str)

counter =0
for i in range(N):
    if s[i] == "R":
        counter +=1
        
if (counter > N-counter):
    print("Yes")
else:
    print("No")

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

//全部整数なら割れる。ひとつでも、奇数なら破れない。。

int n;
int a[210];

int main()
{

    cin >> n;

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

    int ans = 0;
    bool exists_odd = false;
    while (!exists_odd)
    {
        for (int i = 0; i < n; i++)
        {
            if (a[i] % 2 == 1) exists_odd = true;
        }

        if(exists_odd) break;
        for (int i = 0; i < n; i++)
        {
            a[i] /= 2;
        }
        
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    
    for(int i = 0; i <= a; i++) {
        for(int j = 0; j <= b; j++) {
            for(int k = 0; k <= c; k++) {
                int total = 500*i + 100*j + 50*k;
                if(total == x) { ans++; }
            }
        }
    }
 
    cout << ans;
    
    cout << endl;
    return 0;
}

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

int main() {
	int n, k; cin >> n >> k;
	vector<int>d(k); for (auto&& x : d)cin >> x;
	
	int ans = n;
	while (1) {
		bool ok = true;
		string s = to_string(ans);
		for (int i = 0; i < s.size(); i++) {
			if (count(d.begin(), d.end(), s[i] - '0') > 0) { ok = false; ans++; break; }
		}
		if (ok) { cout << ans << endl; return 0; }
	}

	return 0;
}

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

int main()
{
  long N, P;
  cin >> N >> P;

  if( N == 1 ){
    cout << P << endl;
    return 0;
  }
  long PN = long(sqrt(P));
  vl sieve(PN+1);
  vl prim;

  for( long i=0; i<PN+1; i++ ){
    sieve[i] = i;
  }
  for( long i=2; i<PN+1; i++ ){
    if( sieve[i] == 0 ) continue;
    for( long j=2; i*j < PN+1; j++ ){
      sieve[i*j] = 0;
    }
  }
  for( long i=2; i<PN+1; i++ ){
    if( sieve[i] == 0 ) continue;
    prim.pb(i);
  }

  long ret = 1;
  for( auto &val : prim ){
    long cnt;
    for( cnt=0; P%val == 0; cnt++ ){
      P /= val;
    }
    for( ; cnt >= N; cnt -= N ){
      ret *= val;
    }
  }

  cout << ret << endl;

  return 0;
}



Measured memory_bytes: 9208
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<char> s(n);
    REP(i, n){
        cin >> s[i];
    }
    bool hasYellow = false;
    REP(i, n){
        if(s[i] == 'Y'){
            hasYellow = true;
        }
    }
    cout << ((hasYellow) ? "Four" : "Three") << endl;
    return 0;
}

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

using namespace std;

int main (void){
    vector <int> x,y;
    int Round_Count=0;
    for (;true;)
    {
        int x_ex,y_ex;
        cin >> x_ex >> y_ex;
        if (x_ex == 0 && y_ex == 0) break;
        Round_Count++;
        if (x_ex > y_ex){
            x.push_back(y_ex); y.push_back(x_ex);
            continue;
        }else{
            x.push_back(x_ex); y.push_back(y_ex);
        continue;
        }
    }
    for (int i = 0; i < Round_Count; i++)
    {
        cout << x[i] << " " << y[i] << endl;
    }
}


Measured memory_bytes: 3072
sub f{my($u,$p)=@_;push@{--$|?b:c},$u;$_-$p&&f($_,$u)for@$u;--$|}$n=<>;map{push@$_,$u-$_+$;for($u,$;)=split}<>;f 1;$y=2*--$x;@a=($,=$",(0)x$n);@b>$n/3&@c>$n/3?(map$a[$_]=$x+=3,@b)+map$a[$_]=$y+=3,@c:map$a[$_]=$x+=$x%3,@b>@c?@b:@c;print map$_<=$n&&$_||3*++$z,@a

Measured memory_bytes: 254208
#include<cstdio>

int main(){
	int N, K;
	scanf("%d %d", &N, &K);
	bool has_candy[N];
	for (int i = 0; i < N; ++i){
		has_candy[i] = false;
	}
	int ans = N;
	for (int i = 0; i < K; ++i){
		int d;
		scanf("%d", &d);
		for (int j = 0; j < d; ++j){
			int a;
			scanf("%d", &a);
			a--;
			if(!has_candy[a]){
				has_candy[a] = true;
				ans--;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1732
//00
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int h,w,n;
  cin>>h>>w>>n;
  char g[30][31];
  for(int i=0;i<h;i++){
    cin>>g[i];
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w-1;j++){
      char c[30][31];
      copy(g[0],g[h],c[0]);
      swap(c[i][j],c[i][j+1]);
      for(;;){
	for(int k=0;k<w;k++){
	  for(int l=h-1;l>=0;l--){
	    if(c[l][k]=='.'){
	      int m;
	      for(m=l-1;m>=0&&c[m][k]=='.';m--);
	      if(m>=0){
		swap(c[l][k],c[m][k]);
	      }
	    }
	  }
	}
	bool u=false;
	bool v[30][30]={};
	for(int k=0;k<h;k++){
	  for(int l=0;l<w;){
	    if(c[k][l]!='.'){
	      int m;
	      for(m=l+1;m<w&&c[k][l]==c[k][m];m++);
	      if(m-l>=n){
		for(int o=l;o<m;o++){
		  v[k][o]=true;
		}
	      }
	      l=m;
	    }else{
	      l++;
	    }
	  }
	}
	for(int k=0;k<w;k++){
	  for(int l=0;l<h;){
	    if(c[l][k]!='.'){
	      int m;
	      for(m=l+1;m<h&&c[l][k]==c[m][k];m++);
	      if(m-l>=n){
		for(int o=l;o<m;o++){
		  v[o][k]=true;
		}
	      }
	      l=m;
	    }else{
	      l++;
	    }
	  }
	}
	for(int k=0;k<h;k++){
	  for(int l=0;l<w;l++){
	    if(v[k][l]){
	      u=true;
	      c[k][l]='.';
	    }
	  }
	}
	if(!u)break;
      }
      bool a=false;
      for(int k=0;k<h;k++){
	for(int l=0;l<w;l++){
	  a|=c[k][l]!='.';
	}
      }
      if(!a){
	cout<<"YES"<<endl;
	return 0;
      }
    }
  }
  cout<<"NO"<<endl;
  return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef pair<ll,int> p;

const ll INF=3003003003003003003LL;

int main()
{
    int n,q;
    ll t;
    cin >>n >>t >>q;

    vector<p> a(n);
    rep(i,n) cin >>a[i].fi >>a[i].se;

    vector<ll> ans(n,INF);

    //?\???????????¶???????
    int st=0;
    while(st<n && a[st].se==2)
    {
        ans[st]=a[st].fi-t;
        ++st;
    }

    //??±??????????¶???????
    int ed=n-1;
    while(ed>=0 && a[ed].se==1)
    {
        ans[ed]=a[ed].fi+t;
        --ed;
    }

    while(st<ed)
    {
        int x=st;
        while(x+1<n && a[x+1].se==1) ++x;
        int y=x;
        while(y+1<n && a[y+1].se==2) ++y;
        //printf(" %d %d %d\n", st,x,y);

        //??????x??¨x+1????????????????????????????????????
        bool meet=(a[x+1].fi-t < a[x].fi+t);
        if(meet)
        {
            ll point=a[x].fi+(a[x+1].fi-a[x].fi)/2;
            for(int i=st; i<=x; ++i) ans[i]=min(point,a[i].fi+t);
            for(int i=x+1; i<=y; ++i) ans[i]=max(point,a[i].fi-t);
        }
        else
        {
            for(int i=st; i<=y; ++i)
            {
                if(a[i].se==1) ans[i]=a[i].fi+t;
                else ans[i]=a[i].fi-t;
            }
        }

        st=y+1;
    }

    //answer
    rep(i,q)
    {
        int x;
        cin >>x;
        cout << ans[x-1] << endl;
    }

    return 0;
}

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

using ll=long long;

int main(){
  int n,q;cin>>n>>q;
  vector<ll> v;
  v.push_back(n);
  while(q--){
    ll a;cin>>a;
    while(v.size()&&v.back()>=a)v.pop_back();
    v.push_back(a);
  }
  int L=v.size();
  vector<ll> t(L,0),ans(n+1,0);
  t[L-1]=1;
  for(int i=L-1;i>=0;i--){
    ll k=v[i];
    int j=i;
    while(j){
      if(v[0]>k)break;
      int l=0,r=j;
      while(r-l>1){
        int mid=(r+l)>>1;
        (v[mid]>k?r:l)=mid;
      }
      t[l]+=t[i]*(k/v[l]);
      k%=v[l];
      j=l;
    }
    ans[0]+=t[i];
    ans[k]-=t[i];
  }
  for(int i=0;i<n;i++){
    cout<<ans[i]<<endl;
    ans[i+1]+=ans[i];
  }
}


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[1001];
int main(){
    int n,m;
    cin>>n>>m;
    int r=n/__gcd(n,m)*m;
    rep(i,n) cin>>a[i];
    int i=0;
    ll sum=0;
    while(i!=r){
        int mn=1000,mx=0;
        rep(j,m) mn=min(mn,a[(i+j)%n]),mx=max(mx,a[(i+j)%n]);
        sum+=mx-mn;
        i+=m;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3096
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
bool sortbysecdesc(const pair<string,ll> &a,const pair<string,ll> &b)
{
       return a.second>b.second;
}
int main() {
	int n,m,p=0,a=0;cin>>n>>m;
	bool ac[n+1]={};
	int cnt[n+1]={};
	loop(m,i,0){
		string pe;
		int num;cin>>num>>pe;
		if(!ac[num]&&pe=="WA")cnt[num]++;
		else if(!ac[num]&&pe=="AC")a++,ac[num]=1,p+=cnt[num];
	}
	cout<<a<<' '<<p<<endl;
}
/*
 0 2 1

 */


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

const int MAX_N = 200000;
int N;

typedef struct {
	int index;
	long val;
} pair;

int main() {
	pair p[MAX_N];
	long val[MAX_N] = {0};
	int i;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%ld", &p[i].val);
		p[i].index = i;
	}
	int index = N / 2;
	std::sort(p, p+N, [](const pair t, const pair p){return t.val < p.val;});
	for (i = 0; i < N; i++) {
		if (i < index)
			val[p[i].index] = p[index].val;
		else
			val[p[i].index] = p[index-1].val;
	}
	for (i = 0; i < N; i++)
		printf("%ld\n", val[i]);
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
struct node {
	int to,next,v;
} a[2000001];
int head[1000001],cnt,f[100001];
void add(int x,int y,int v) {
	a[++cnt].to=y;
	a[cnt].next=head[x];
	a[cnt].v=v;
	head[x]=cnt;
}
void dfs(int x,int fa,int ans) {
	if(ans&1) f[x]=1;
	for(int i=head[x]; i; i=a[i].next) {
		int v=a[i].to;
		if(v==fa) continue;
		dfs(v,x,ans+a[i].v);
	}
}
main() {
	int n=read(),x,y,z;
	for(int i=1; i<n; i++)
		x=read(),y=read(),z=read(),add(x,y,z),add(y,x,z);
	dfs(1,0,0);
	for(int i=1; i<=n; i++)
		cout<<f[i]<<endl;
}


Measured memory_bytes: 7552