akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cstring>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

char in[200001];
int nxt[200001][26];
int mn[200002];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> in;
    int n = strlen(in);
    for (int i = 0; i < 26; ++i) nxt[n][i] = n;
    for (int i = n; i--; ) {
        for (int j = 0; j < 26; ++j) nxt[i][j] = nxt[i + 1][j];
        nxt[i][in[i] - 'a'] = i;
    }
    mn[n] = 1;
    for (int i = n; i--; ) {
        int mx = 0;
        for (int j = 0; j < 26; ++j) mx = max(mx, nxt[i][j]);
        mn[i] = mn[mx + 1] + 1;
    }
    for (int i = 0; i < n; ) {
        for (int j = 0; j < 26; ++j) if (mn[i] == mn[nxt[i][j] + 1] + 1) {
            printf("%c", 'a' + j);
            i = nxt[i][j] + 1;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 21504
def is_multiple_of_3?(array)
  sum = 0
  array.each do |line|
    sum += line.inject(:+)
  end
  sum % 3 == 0
end

def have_same_diffs?(array)
  diffs = []
  array.each do |line|
    diffs << [0, line[1] - line[0], line[2] - line[0]]
  end
  diffs[0] == diffs[1] && diffs[0] == diffs[2]
end

grid = []
3.times do
  grid << gets.split.map(&:to_i)
end

flag = true

# gridの9つの数字をすべて足し合わせると必ず3の倍数になっているはず。
flag = is_multiple_of_3?(grid) if flag

# 行ごとに見たとき、差分が3行とも一致しているはず
flag = have_same_diffs?(grid) if flag

# 列ごとに見たときも、差分が3行とも一致しているはず
flag = have_same_diffs?(grid.transpose) if flag

puts flag ? "Yes" : "No"


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
static auto x = []() {
    std::ios::sync_with_stdio(false); // turn off sync
    cin.tie(nullptr);                 // untie in/out streams
    return 0;
}();
int main()
{
    string s1, s2;
    cin >> s1 >> s2;
    cout << s2 << s1;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static int R, C;
    public static int[][] map;
    public static int[][] distMap;
    public static int[] iAdj = {-1,1,0,0};
    public static int[] jAdj = {0,0,-1,1};
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            C = sc.nextInt();
            R = sc.nextInt();
            if (R == 0 && C == 0) break;
            
            map = new int[R][C];
            distMap = new int[R][C];
            
            int startPosX = -1;
            int startPosY = -1;
            int endPosX = -1;
            int endPosY = -1;
            
            for (int i = 0; i < R; i++) {
                Arrays.fill(distMap[i], 999);
                for (int j = 0; j < C; j++) {
                    map[i][j] = sc.nextInt();
                    if (map[i][j] == 2) {
                        startPosX = j;
                        startPosY = i;
                    } else if (map[i][j] == 3) {
                        endPosX = j;
                        endPosY = i;
                    }
                }
            }
            
            flood(startPosY, startPosX, 6, 0);
            
            if (distMap[endPosY][endPosX] == 999)
                System.out.println(-1);
            else
                System.out.println(distMap[endPosY][endPosX]);
        }
    }
    
    public static void flood(int i, int j, int energy, int t) {
        if (energy <= 0) return;
        if (i < 0 || i >= R || j < 0 || j >= C) return;
        if (map[i][j] == 0) return;
        
        if (t < distMap[i][j]) {
            distMap[i][j] = t;
            if (map[i][j] == 4) {
                energy = 6;
            }
        }
        
        for (int x = 0; x < 4; x++) {
            flood(i + iAdj[x], j + jAdj[x], energy - 1, t + 1);
        }
    }
}




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

using namespace std;
using ll = long long;
map<ll, ll> mods;

long long mod(ll a, ll b, ll k) {
  //return (a^b)%k
  if(b==0) return 1;
  ll res = mod(a, b/2, k);
  res *= res;
  res %= k;
  if(b & 1) {
    res *= a;
    res %= k;
  }
  return res;
}

int main() {
  long long k;
  scanf("%lld", &k);
  if(k==1 || k==7) {
    printf("1\n");
    return 0;
  }
  if(k%7==0) k /= 7;
  k *= 9;
  set<ll> check;
  ll ans = 1;
  while(1) {
    ll now = mod(10LL, ans, k);
    if(now == 1) {
      printf("%lld\n", ans);
      return 0;
    }
    if(check.find(now) == check.end()) {
      check.insert(now);
    } else {
      printf("-1\n");
      return 0;
    }
    ans++;
  }
}


Measured memory_bytes: 50536
X = int(input())


def is_prime_number(number):
    result = True
    for divider in range(2, number):
        is_dividable = number % divider == 0
        if is_dividable:
            result = False
            break

    return result


answer = X
while True:
    if is_prime_number(answer): break
    answer += 1

print(answer)


Measured memory_bytes: 2940
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;
const int Maxn=100000+10;
vector <int> e[Maxn];
int a[Maxn];
int n,m,ans;
bool check(int x)
{
	for(int i=0;i<e[x].size();++i)
	{
		int y=e[x][i];
		if(a[y]>=a[x])return 0;
	}
	return 1;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
	scanf("%d",a+i);
	while(m--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	for(int i=1;i<=n;++i)
	if(check(i))++ans;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 9276
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;

int main(){
  string S,buf;
  cin>>S;
  int sum=0;
  for(int i=0;i<S.size();i++){
    buf=S[i];
    sum+=stoi(buf);
  }
  if(sum%9==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
    return 0;
}


Measured memory_bytes: 3744
NMX = list(map(int, input().split()))
A = list(map(int, input().split()))
masu = {}
for i in range(NMX[0]+1):
	if(i in A):
		masu[i] = 1
	else:
		masu[i] = 0
right=0
for i in reversed(range(0,NMX[2]+1)):
	right+=masu[i]
left=0
for i in reversed(range(NMX[2]+1,NMX[0]+1)):
	left+=masu[i]
if(right>left):
	print(left)
else:
	print(right)

Measured memory_bytes: 3064
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::cmp::{max, min};

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        n: usize,
        s:[chars; n],
    }
    let mut d = vec![0_usize; 5];
    for s in s.iter() {
        if s[0] == 'M' {d[0]+=1;}
        if s[0] == 'A' {d[1]+=1;}
        if s[0] == 'R' {d[2]+=1;}
        if s[0] == 'C' {d[3]+=1;}
        if s[0] == 'H' {d[4]+=1;}
    }
    let mut res = 0;
    for first in 0..3 {
        for second in first+1..4 {
            for third in second+1..5 {
                res += d[first] * d[second] * d[third];
            }
        }
    }
    println!("{}", res);
}

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

int N;
const int MAX_N = 100 + 10;
int a[MAX_N];

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

    sort(a, a+N);

    cout << a[N-1] - a[0] << endl;
    
    return 0;
}


Measured memory_bytes: 256
# 42
N,M = map(int,input().split())
a = [0 for i in range(31)]
for i in range(N):
    l = list(map(int,input().split()))
    for i in range(1,31):
        for j in l[1:]:
            if i == j:
                a[i] +=1


cou = 0
for i in a:
    if i == N:
        cou+=1
    
print(cou)

        
        

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

using namespace std;

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, a, b) for (int i = a; i < b; i++)

int H, W;

int cost[10][10];
int num[10];

int main()
{
	cin >> H >> W;
	rep(i, 10) rep(j, 10) {
		cin >> cost[i][j];
	}
	rep(i, H) rep(j, W) {
		int t;
		cin >> t;
		if (t != -1) num[t]++;
	}
	rep(k, 10) rep(i, 10) rep(j, 10) {
		cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]);
	}
	int res = 0;
	rep(i, 10) {
		res += cost[i][1] * num[i];
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    string s;

    cin >> s;

    for (char c = 'a'; c <= 'z'; c++) {
        bool flag = false;
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == c) flag = true;
        }
        if (flag != true) {
            cout << c << endl;
            return 0;
        }
    }

    cout << "None" << endl;
    return 0;
}

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

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

    vector<int> a(n);
    rep(i, n) cin >> a.at(i);

    set<int> s;
    rep(i, n)
    {
        if (s.find(a.at(i)) == s.end())
        {
            s.insert(a.at(i));
        }
        else
        {
            s.erase(a.at(i));
        }
    }

    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 8120
a,b = map(int, input().split())
import fractions
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
myset={1}
mygcd=fractions.gcd(a,b)
myset=myset | set(prime_factorize(mygcd))
print(len(myset))

Measured memory_bytes: 5176
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  int ans = b % a == 0 ? a + b : b - a;
  cout << ans << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

m = 10 ** 9 + 7
d = Array.new(k+1, 0)
d[0] = 1
u = Array.new(k+1)

a.each do |e|
    (k+1).times do |i|
        d[i+1] += d[i] if i < k
        u[i] = d[i]
        u[i] -= d[i-e-1] if i > e
        u[i] %= m
    end
    
    d, u = u, d
end

p d[k]

Measured memory_bytes: 15812
#include <iostream>
#include <map>
#include <set>
#include <string>
#include<string.h>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;

vector<long long> xray,yray;
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    vector<long long> x(n),y(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        xray.push_back(x[i]);
        yray.push_back(y[i]);
    }
    sort(xray.begin(),xray.end());
    sort(yray.begin(),yray.end());

    ll ans=1LL*(xray[n-1]-xray[0])*(yray[n-1]-yray[0]);

    for(int x1=0;x1<n;x1++){
        for(int x2=x1+1;x2<n;x2++){
            for(int y1=0;y1<n;y1++){
                for(int y2=y1+1;y2<n;y2++){
                    ll lx=xray[x1],rx=xray[x2];
                    ll uy=yray[y2],dy=yray[y1];
                    int num=0;
                    for(int i=0;i<n;i++){
                        if(x[i]>=lx and x[i]<=rx&&y[i]<=uy&&y[i]>=dy){
                            num++;
                        }
                    }
                    if(num>=k) ans=min(ans,1LL*(rx-lx)*(uy-dy));
                }
            }
        }
    }
   // printf("%I64d\n",ans);
   cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int x[301000],t[301000],L,n,ans;
int main(){
	read(n);read(L);
	for(int i=1;i<=n;i++) read(x[i]);
	for(int i=1;i<=n;i++) read(t[i]);
	int pos=1;
	for(int i=1;i<=n;i++)
		if(x[i]<=L-x[i]) pos=i;
	for(int i=1;i<=n;i++){
		ans+=t[i]/(2*L);t[i]%=2*L;
		if(t[i]>2*max(x[i],L-x[i])) ans++,t[i]=0;
	}
	int sl=0,m=0,sr=0,fl=0,fr=0,fm=0;
	for(int i=pos;i;i--){
		if(!t[i]) continue;
		if(t[i]<=2*x[i]){
			if(!sl) m++;
			else sl--,ans++,fl|=sl==0;
		}
		else sl++;
	}
	for(int i=pos+1;i<=n;i++){
		if(!t[i]) continue;
		if(t[i]<=2*(L-x[i])){
			if(!sr) m++,fr=0;
			else sr--,ans++,fr=1;
		}
		else sr++;
	}
	//cerr<<ans<<' '<<sl<<' '<<m<<' '<<sr<<'\n';
	ans+=m/2;
	fm=m>1;m&=1;
	ans+=sl+m+sr;
	if(sr||t[n]==0||fr||!m&&(fl||fm)) ans++;
	cout<<2ll*L*ans<<'\n';
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  string s;
  cin>>s;
  ll c=0,d=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='B') c++;
    else d+=c;
  }
  cout<<d;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int i = 1, ans = 0;
  for (i = 1; i <= n; i++) {
    ans = i * (i + 1) / 2;
    if (ans >= n) break;
  }
  for (int j = 1; j <= i; j++) {
    if (ans - n == j) continue;
    cout << j << endl;
  }

  return 0;
}

Measured memory_bytes: 256
def resolve():
    n, m, x = map(int, input().split())
    c = [list(map(int, input().split())) for _ in range(n)]
    ans = 10**8
    for i in range(2**n):
        book = [0] * n
        cost = 0
        lan = [0] * m
        for j in range(n):
            if (i >> j & 1):
                cost += c[j][0]
                for k in range(m):
                    lan[k] += c[j][k+1]
        ok = True
        for k in range(m):
            if lan[k] < x:
                ok = False
        if ok:
            ans = min(ans, cost)

    if ans == 10**8:
        print("-1")
    else:
        print(ans)

resolve()

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 105;
vector<ii> adj[MAX];
int L;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> L;
    int b = 31 - __builtin_clz(L);
    b++;
    int cnt = 1;
    int cur_b = b - 2;
    fori(i, 1, b) {
        adj[cnt].emplace_back(cnt + 1, 0);
        adj[cnt].emplace_back(cnt + 1, 1 << cur_b);
        cnt++;
        cur_b--;
    }
    int p = 1 << (b - 1);
    ford(i, b - 2, 0) {
        if(L & (1 << i)) {
            int left = i;
            adj[1].emplace_back(cnt - left, p);
            p |= (1 << i);
        }
    }
    int edges = 0;
    fori(i, 1, b + 1) {
        edges += adj[i].size();
    }
    cout << b << " " << edges << '\n';
    fori(i, 1, b + 1) {
        for(auto &each : adj[i]) {
            cout << i << " " << each.first << " " << each.second << '\n';
        }
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[]) {
  ull K;
  ull N = 50;
    
  cin >> K;
  cout << N << endl;

  FOR(i, K % N)
  cout << 49ULL + K / N + N - K % N + 1 << " ";

  FOR1(i, K % N, N)
  cout << 49ULL + K / N - K % N << " ";

  cout << endl;

  return 0;
}


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

#define count_ones __builtin_popcountl
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);

    map<string, int> days = {{"SUN", 1},
                             {"MON", 2},
                             {"TUE", 3},
                             {"WED", 4},
                             {"THU", 5},
                             {"FRI", 6},
                             {"SAT", 7}};

    string d;
    cin >> d;
    int ind = days[d];
    cout << 7 - (ind - 1);

    return 0;
}

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

#define FOR(a,b,c) for(int a=(b),a##_end__=(c);a<a##_end__;a++)
#define DOR(a,b,c) for(int a=(b)-1,a##_end__=(c);a>=a##_end__;a--)
#define ll long long
const int M=100005;
int A[M];
int n;
int main(){
    scanf("%d",&n);
    FOR(i,0,n) scanf("%d",&A[i]);
    if(A[n-1]!=2){puts("-1");return 0;}
    ll x=2,y=3;
    DOR(i,n-1,0){
        x=(x+A[i]-1)/A[i]*A[i];
        y=y/A[i]*A[i]+A[i]-1;
        if(x>y){puts("-1");return 0;}
    }
    printf("%lld %lld\n",x,y);
    return 0;
}

Measured memory_bytes: 640
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def simulation(words, x, y):
    N = 200_000
    Q = 200_000
    assert len(words) <= Q
    
    A = [0] * N
    A[0], A[1] = x, y
    for w in words:
        if w.startswith('+'):
            i, j, k = map(int, w[2:].split())
            assert 0 <= i < N
            assert 0 <= j < N
            assert 0 <= k < N
            A[k] = A[i] + A[j]
        elif w.startswith('<'):
            i, j, k = map(int, w[2:].split())
            assert 0 <= i < N
            assert 0 <= j < N
            assert 0 <= k < N
            A[k] = 1 * (A[i] < A[j])
        else:
            raise ValueError
    return A

def main():
    S = []

    def ADD(i, j, k):
        S.append(f'+ {i} {j} {k}')

    def LT(i, j, k):
        S.append(f'< {i} {j} {k}')

    # A[0] = 0 のときはとりあえずあまり考えない
    ONE = 100
    LT(2, 0, ONE)

    POW = 200
    # A[POW + i] に 2^i を入れる
    ADD(2, ONE, POW)
    for n in range(1, 62):
        ADD(POW + n - 1, POW + n - 1, POW + n)

    TMP = 19000

    # binary_expression
    def binary_expression(pos, i):
        x_pos = TMP  # A[i] 以下の今まで見た 2 べきの和を管理する
        y_pos = TMP + 1  # x + 2^k
        a_plus_one = TMP + 2
        # z_pos = TMP + 2  # 2べきを育てるフリースペース
        # 0 初期化
        ADD(2, 2, x_pos)
        ADD(2, 2, y_pos)
        ADD(i, ONE, a_plus_one)
        for k in range(30, -1, -1):
            # x + 2^k <= A[i] ならば、pos + k に 1 を入れる
            ADD(x_pos, POW + k, y_pos)
            LT(y_pos, a_plus_one, pos + k)
            # x の値を更新する。
            # 2^k or 0 を z につくったあと、x に加算
            z_pos = TMP + 3
            ADD(pos + k, 2, z_pos)  # 1 or 0
            for i in range(k):
                ADD(z_pos, z_pos, z_pos)
            ADD(x_pos, z_pos, x_pos)

    A_BIN = 500
    B_BIN = 600
    binary_expression(A_BIN, 0)
    binary_expression(B_BIN, 1)
    for i in range(30):
        for j in range(30):
            # 初期化
            ADD(3, 3, TMP)
            # 2^i, 2^j が両方存在するときに 1 を作る
            x_pos = TMP
            ADD(A_BIN + i, B_BIN + j, TMP + 1)  # 両立するときにのみ 2
            LT(ONE, TMP + 1, x_pos)
            # 2^{i+j} をかける
            for _ in range(i + j):
                ADD(x_pos, x_pos, x_pos)
            # 2^{i+j} ができた
            ADD(x_pos, 2, 2)
    return S

S = main()

"""
for a in range(11):
    for b in range(11):
        assert a * b == simulation(S, a, b)[2]
"""

print(len(S))
print('\n'.join(S))

Measured memory_bytes: 12552
#include<iostream>
#include<stack>
#include<vector>
#include <map>
#include <queue>
#include<string.h>
using namespace std;
typedef pair<int,int> P;
int node[200][200];
int main()
{
  int n;
  cin>>n;
  memset(node,-1,sizeof(node));
  for(int x=0;x<n;x++)
    {
      int k,t;
      cin>>k>>t;
      for(int i=0;i<t;i++)
	{
	  int tmp;
	  cin>>tmp;
	  node[k][tmp]=1;
	}
    }
  int p;
  cin>>p;
  for(int x=0;x<p;x++)
    {
      int s,d,v;
      cin>>s>>d>>v;
      int ans=-1;
      
      queue<P> qu;
      int c[200];
      memset(c,-1,sizeof(c));
      for(int i=0;i<200;i++)
	{
	  if(v-1>0)
	    if(node[s][i]==1)
	      qu.push(P(i,2));
	}
      while(!qu.empty())
	{
	  P a = qu.front();
	  qu.pop();
	  //      cout<<a.first<<" "<<a.second<<endl;
	  if(a.first==d)
	    {
	      ans=a.second;
	      break;
	    }
	  for(int i=0;i<200;i++)
	    {
	      if(node[a.first][i]==1)
		{
		  if(a.second+1<=v)
		    {
		      if(c[i]==-1)
			{
			  c[i]=1;
			  qu.push(P(i,a.second+1));	    
			}
		    }
		}
	    } 
	}
      
      
      if(ans==-1)
	cout<<"NA"<<endl;
      else
	cout<<ans<<endl;
      
    }
  
}

Measured memory_bytes: 1364
/****************### With The name of ALLAH, most Gracious, most Compassionate ###****************/

/**============================================================================**\
|   Author      : Md Jubayer Hossen Jame
|   Study       : CSE, BRUR
|   Today       : 03 September, 2k20
|   Source      : AtCoder Online Judge
|   Problem link: https://atcoder.jp/contests/abc177/tasks/abc177_a
|   Algorithm   :
|
\**============================================================================**/

#include "bits/stdc++.h"
using namespace std;

#define FI                    freopen("input.txt", "r", stdin)
#define FO                    freopen("output.txt", "w", stdout)
#define FasterIO              ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

typedef long long             ll;
typedef unsigned long long    ull;
typedef unsigned int          ui;

#define mem(x,y)              memset(x,y,sizeof(x));
#define pii                   pair<int,int>
#define mk                    make_pair
#define ff                    first
#define ss                    second
#define pb                    push_back
#define ppb                   pop_back
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define for0(i, n)            for (int i = 0; i < (int)(n); ++i)
#define endl                  '\n'

const double PI = acos(-1.0);

#define gcd(a,b)              __gcd(a,b)
#define lcm(a,b)              (a*(b/gcd(a,b)))

///Direction Array
// 4 Direction - DOWN, UP, RIGHT, LEFT
int dx4[]= {+1, -1, +0, +0};
int dy4[]= {+0, +0, +1, -1};
#define isValid(a, b, R, C)   (0 <= a && a < R) && (0 <= b && b < C)
int dx8[]= {+0, +0, +1, -1, -1, +1, -1, +1};
int dy8[]= {-1, +1, +0, +0, +1, +1, -1, -1};

///Knight Moves
int dr[] = {-1, 1, -2, -2, -1, 1, 2, 2};
int dc[] = {-2, -2, -1, 1, 2, 2, 1, -1};
/**************************************************************************************************/

void test_case()
{
    int dis, time, speed;
    cin >> dis >> time >> speed;

    string ans = "No";
    if(dis <= time * speed)ans = "Yes";
    cout << ans << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    //FI;
    //FO;
#endif // ONLINE_JUDGE
    //FasterIO

    int T = 1;
    //cin >> T;
    for(int tc = 1; tc <= T; ++tc)
    {
        //cout << "Case #" << tc << ":" << endl;
        test_case();
    }
    return 0;
}


Measured memory_bytes: 3608
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    x, a = rli()
    if x < a:
        print(0)
    else:
        print(10)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
	while(1){
	int a,t=0;
	scanf("%d",&a);
		if(a==0){
			return 0;
		}
	a=1000-a;
	if(a>=500){
		a=a-500;
		t++;
	}
	while(1){
		if(a<100){
			break;
		}
		a=a-100;
		t++;
	}
	if(a>=50){
		a=a-50;
		t++;
	}
	while(1){
		if(a<10){
			break;
		}
		a=a-10;
		t++;
	}
	if(a>=5){
		a=a-5;
		t++;
	}
	while(1){
		if(a<1){
			break;
		}
		a=a-1;
		t++;
	}
	printf("%d\n",t);
	}
}

Measured memory_bytes: 596
N = int(input())
ls = [None]*N
ind = None
for i in range(N):
    ls[i] = tuple(map(int,input().split()))
    if ls[i][2] > 0:
        ind = i
for cx in range(101):
    for cy in range(101):
        flag = True
        x,y,h = ls[ind]
        H = h+abs(x-cx)+abs(y-cy)
        for i in range(N):
            x,y,h = ls[i]
            if h != max(0,H-abs(x-cx)-abs(y-cy)):
                flag = False
                break
        if flag:
            print(cx,cy,H)
            exit(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define lli long long int   
#define endl "\n"

int countDigit(long long n) { 
    int count = 0; 
    while (n != 0) { 
        n = n / 10; 
        ++count; 
    } 
    return count; 
} 

int main(){
	lli n;
    cin>>n;
    lli counta=0;
    for(int i=0;i<=n;i++){
        if(countDigit(i)%2!=0){
            counta++;
        }
    }
    cout<<counta<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;
const double EPS = 1e-9;
bool equals(double a, double b){
	return fabs(a-b)<EPS;
}
int main(){
	ios::sync_with_stdio(0);
	double w, h, x, y;
	cin >> w >> h >> x >> y;
	double area = (w*h)/2.0;
	int mp = 0;
	if(equals(x, w/2.0) and equals(y, h/2.0))
		mp = 1;
	cout << fixed << setprecision(20) << area << " " << mp << endl;
}


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

int main()
{
    int a, b;
    int ac[5], bc[5];
    int x, y;
    int o, p, q, r;
    int ans = 0;
    int i;
    
    cin >> a >> b;
    
    x = a; y = b;
    
    
    for(i = 0; i < 5; i++) {
        ac[4-i] = x % 10;
        bc[4-i] = y % 10;
        x /= 10; y /= 10;
    }
    
    o = 10 * ac[1] + ac[0];
    p = 10 * ac[3] + ac[4];
    q = 10 * bc[1] + bc[0];
    r = 10 * bc[3] + bc[4];
    
    ans = (10 * (bc[0] - ac[0]) + (bc[1] - ac[1]) - 1) * 10;
    
    if(o < p) {
        ans += 9 - ac[2];
    } else {
        ans += 10 - ac[2];
    }
    
    if(q > r) {
        ans += bc[2];
    } else {
        ans += bc[2] + 1;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mn(a, b) (a < b ? a : b)
#define mx(a, b) (a > b ? a : b)
#define f first
#define s second
#define all(v) (v).begin(), (v).end()
#define base 331

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ll dp[(1 << 16) + 2];
ll cost[17][17];
ll subm[(1 << 16) + 2];

int main(){

    //freopen(".in","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin>>cost[i][j];
        }
    }
    for(int mask = 1; mask < (1 << n); mask++){
        dp[mask] = -(1e17);
        for(int i = 0; i < n; i++){
            if(mask & (1 << i)){
                for(int j = i + 1; j < n; j++){
                    if(mask & (1 << j)){
                        subm[mask] += cost[i + 1][j + 1];
                    }
                }
            }
        }
    }
    int aux = (1 << n) - 1;
    for(int mask = 0; mask < (1 << n); mask++){
        int exp = aux ^ mask;
        for(int x = exp; x > 0; x = ((x - 1) & exp))
            dp[x ^ mask] = mx(dp[x ^ mask], dp[mask] + subm[x]);
    }
    cout<<dp[aux];
    return 0;
}


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

using namespace std;

using ll=long long ;

void solve() {
    int n; ll C;
    cin >> n >> C;
    vector<ll> d(n), v(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i] >> v[i];
    }
    auto rd = d;
    vector<ll> L(n),R(n),lx(n),rx(n);
    ll sum = 0, mx = 0;
    for (int i = 0; i < n; i++) {
        sum += v[i];
        R[i] = sum - rd[i];
        rx[i] = mx = max(mx, R[i]);
    }
    auto ld = d;
    for (auto& x: ld) {
        x = C-x;
    }
    sum = 0, mx = 0;
    for (int i = n-1; i >= 0; i--) {
        sum += v[i];
        L[i] = sum - ld[i];
        lx[i] = mx = max(mx, L[i]);
    }
    ll res = max(lx[0], rx[n-1]);
    for (int i = 0; i < n-1; i++) {
        ll tmp = R[i] - rd[i];
        tmp += lx[i+1];
        res = max(res, tmp);

        tmp = L[i+1] - ld[i+1];
        tmp += rx[i];
        res = max(res, tmp);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <functional>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) (v).erase( unique(all(v), (v).end() );
#define SZ(x) ((ll)(x).size()) // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define INF 1000000000000
#define MOD 1000000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ll = long long;
using ull = unsigned long long;

template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return true;}return false;}

const char newl = '\n';

ll qp(ll a,ull b){ll ans=1;do{if(b&1u)ans*=a;a*=a;}while(b>>=1u);return ans;}
ll qp(ll a,ull b,ll mod){ll ans=1;do{if(b&1u)ans=ans*a%mod;a=a*a%mod;}while(b>>=1u);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


ll llmin(ll a, ll b) {
    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int main() {
    ll n;
    cin >> n;
    vector<ll> vec;
    rep(i, n+1) {
        ll x;
        cin >> x;
        vec.push_back(x);
    }

    vector<ll> uppers;
    ll upper = 1;
    for (cauto a : vec) {
        uppers.push_back(upper);
        upper = 2 * llmin(upper - a, LONG_MAX / 2);
        if (upper < 0) {
            cout << -1;
            return 0;
        }
    }
    
    // upper >= 0

    ll total = 0;
    ll state = 0;
    for (int i = n; i >= 0; i--) {
        ll a = vec[i];
        ll u = uppers[i];
        state = min(state + a, u);
        total += state;
    }

    cout << total;

    return 0;
}


Measured memory_bytes: 5156
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  cout << (s[0] == s[1] || s[1] == s[2] || s[2] == s[3] ? "Bad\n" : "Good\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())



void init() {

}

void input() {

}

void solve() {
  int n, m;
  cin >>  n >> m;
  int a[100];
  REP(i, 100) a[i] = 0;
  REP(i, n) {
    int k;
    cin >> k;
    REP(j, k) {
      int p;
      cin >> p;
      a[p]++;
    }
  }
  int res = 0;
  REP(i, 100) if(a[i] == n) res++;
  cout << res << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;

const char cs[] = "xo";
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 };
const int dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };

inline bool valid(int x, int y){
    return 0 <= x && x < 8 && 0 <= y && y < 8;
}

struct state {
    vi score;
    vs g;
    state(){}
};

state flip(const int x, const int y, state s, bool turn){
    bool update = false;
    for (size_t i = 0; i < 8; i++){
        int cx = x + dx[i];
        int cy = y + dy[i];
        if (!valid(cx, cy) || s.g[cy][cx] == cs[turn]) continue;
        while (valid(cx, cy) && s.g[cy][cx] == cs[!turn]){
            cx += dx[i];
            cy += dy[i];
        }
        if (valid(cx, cy) && s.g[cy][cx] == cs[turn]){
            update = true;
            for (int ix = x + dx[i], iy = y + dy[i];
                !(ix == cx && iy == cy);
                ix += dx[i], iy += dy[i]){
                s.g[iy][ix] = cs[turn];
                s.score[turn]++;
                s.score[!turn]--;
            }
        }
    }
    if (update){
        s.g[y][x] = cs[turn];
        s.score[turn]++;
        s.score[1 - turn]--;
    }
    return s;
}

int main(){
    state cur;
    cur.score = vector < int > {0, 0};
    for (size_t i = 0; i < 8; i++){
        string s; cin >> s;
        cur.g.push_back(s);
        cur.score[0] += count(s.begin(), s.end(), 'x');
        cur.score[1] += count(s.begin(), s.end(), 'o');
    }

    for (size_t turn = 1; turn <= 128; turn++){
        bool ok = false;
        state next = cur;
        for (size_t y = 0; y < 8; y++){
            for (size_t x = 0; x < 8; x++){
                if (cur.g[y][x] == '.'){
                    state cand = flip(x, y, cur, turn & 1);
                    if (((turn & 1) == 1 && next.score[1] < cand.score[1]) ||
                        ((turn & 1) == 0 && next.score[0] <= cand.score[0])){
                        ok = true;
                        next = cand;
                    }
                }
            }
        }

        cur = next;
        //for (size_t i = 0; i < 8; i++){
        //    cout << cur.g[i] << endl;
        //}
    }

    for (size_t i = 0; i < 8; i++){
        cout << cur.g[i] << endl;
    }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
int INF = 10000000;
int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<char>> d(m, vector<char>(n));
  for (int i = 0; i < m; i++){
    for (int j = 0; j < n; j++){
      cin >> d[i][j];
    }
  }
  vector<int> L(n + 1, 0);
  for (int i = 0; i < n; i++){
    L[i + 1] = L[i];
    for (int j = 0; j < m; j++){
      if (d[j][i] == 'E'){
        L[i + 1]++;
      }
    }
  }
  vector<int> R(n + 1, 0);
  for (int i = n - 1; i >= 0; i--){
    R[i] = R[i + 1];
    for (int j = 0; j < m; j++){
      if (d[j][i] == 'W'){
        R[i]++;
      }
    }
  }
  int ans = INF;
  int pos = -1;
  for (int i = 0; i <= n; i++){
    if (L[i] + R[i] < ans){
      ans = L[i] + R[i];
      pos = i;
    }
  }
  cout << pos << ' ' << pos + 1 << endl;
}


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

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

int main(){
	int H,W;
	cin >> H >> W;
	
	char field[55][55];
	int dist[55][55];
	rep(i,H){
		rep(j,W){
			cin >> field[i][j];
		}
	}
	
	rep(i,H){
		rep(j,W){
			dist[i][j] = -1;
		}
	}
	
	int white = 0;
	rep(i,H){
		rep(j,W){
			if (i == 0 && j == 0) continue;
			if(i == H-1 && j == W-1) continue;
			if(field[i][j] == '.') white++;
		}
	}
	
	queue<pair<int,int>> que;
	que.push(make_pair(0,0));
	dist[0][0] = 0;
	
	while(!que.empty()){
		auto p = que.front();
		que.pop();
		rep(i,4){
			int ny = p.first + dy[i];
			int nx = p.second + dx[i];
			if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
			if(dist[ny][nx] != -1) continue;
			if(field[ny][nx] == '.'){
				que.push(make_pair(ny,nx));
				dist[ny][nx] = dist[p.first][p.second] + 1;
			}
		}
	}
	
	if(dist[H-1][W-1] == -1){
		cout << -1 << endl;
	}else{
		cout << white - dist[H-1][W-1] + 1 << endl;
	}
	
    return 0;
}



Measured memory_bytes: 256
//Traveling Salesman around Lake

#include<iostream>
#include <vector>
using namespace std;

int main (){
    int K, N, st =0, stt = 0,ans;
    cin >> K >> N;
    int A[N];
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        if(i > 0){
            st = A[i] - A[i-1];
            if(st > stt){
                stt = st;
            }
        }
    }
    st = A[0] + K - A[N-1];
    if(st>stt){
        stt = st;
    }
    ans = K - stt;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    double a[n],x=0;
    for(int i=0; i<n; i++){
        scanf("%lf",&a[i]);
        a[i]=1/a[i];
        x+=a[i];
    }
    printf("%f",1/x);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define ll long long
typedef pair<ll, ll> P;
//const ll INF = 1LL << 60;
//using mint = modint1000000007;
using mint = modint998244353;
//const int MOD = 1000000007;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main(){
  int n;
  cin>>n;
  string s="ACL";
  rep(i,n){
    cout<<s;
  }
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    size_t n;
    cin >> n;
    vector<int> a(n);
    for (auto &&i : a) {
        cin >> i;
    }
    sort(rbegin(a), rend(a));

    int x = 0;
    int y = 0;
    for (size_t i = 0; i < n; i += 2) {
        x += a[i];
        if (i + 1 < n) {
            y += a[i + 1];
        }
    }
    cout << x - y << endl;

    return 0;
}


Measured memory_bytes: 256
s = input()
t = input()

sorted_s = sorted(s)
sorted_t = sorted(t,reverse=True)

import sys
N = min(len(sorted_s),len(sorted_t))

for i in range(N):
    if ord(sorted_s[i]) < ord(sorted_t[i]):
        print('Yes')
        sys.exit()
    elif ord(sorted_s[i]) > ord(sorted_t[i]):
        print('No')
        sys.exit()

if len(sorted_s) < len(sorted_t):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int N;

ll merge_sort(vector<int> &A){
  int n = A.size();
  if (n == 1) return 0;
  int n2 = n/2;
  vector<int> B(n2); rep(i, n2) B[i] = A[i];
  vector<int> C(n-n2); rep(i, n-n2) C[i] = A[n2+i];
  ll res = merge_sort(B);
  res += merge_sort(C);

  int bi = 0, ci = 0;
  for (int i=0; i<n; i++){
    if (bi < n2 && (ci == n-n2 || B[bi] < C[ci])) A[i] = B[bi++];
    else{
      res += n2 - bi;
      A[i] = C[ci++];
    }
  }
  return res;
}

int main() {
  cin >>N;
  vector<int> A(N); rep(i, N) cin >>A[i];
  ll res = merge_sort(A);
  cout <<res <<endl;
}



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

int main(){
	int N, M;
  	cin >> N >> M;
  	
  	const int NMMAX = 60;
  	int A[NMMAX], B[NMMAX];
  
  	for(int i = 0; i < M; i++){
    	cin >> A[i] >> B[i];
    }
  
  	int road[NMMAX];
  	for(int i = 0; i < N; i++){
    	road[i] = 0;
    }
  
  	for(int i = 0; i < M; i++){
    	road[A[i] - 1] += 1;
      	road[B[i] - 1] += 1;
    }
  
  	for(int i = 0; i < N; i++){
    	cout << road[i] << endl;
    }
  	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void kurai(int a[], int n){
  int i = 0;
  while(n > 0){
    a[i] = n % 10;
    n /= 10;
    i++;
  }
}

int main(void){
  int n;
  scanf("%d", &n);
  int a[3];
  kurai(a, n);
  if(a[2] < a[0] || a[2] < a[1]){
    printf("%d%d%d\n", a[2] + 1, a[2] + 1, a[2] + 1);
  }else{
    printf("%d%d%d\n", a[2], a[2], a[2]);
  }
  return 0;
}

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

import sys
import codecs

for line in sys.stdin:
    for i in range(0, 26):
        ans = ""
        for j in range(len(line)):
            a = ord(line[j])
            if ord('a') <= a <= ord('z'):
                if a-i >= ord('a'):
                    ans = ans + chr(a-i)
                else:
                    ans = ans + chr(a-i+26)
            else:
                ans = ans + line[j]
        if "the" in ans or "this" in ans or "that" in ans:
            break
    sys.stdout.write(ans)

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

int main() {

	string a, b; cin >> a >> b;
	if (b.size() < a.size()) {
		cout << "GREATER" << endl;
		return 0;
	}
	else if (a.size() < b.size()) {
		cout << "LESS" << endl;
		return 0;
	}
	int cnt = a.size();
	string ans = "EQUAL";
	while (cnt--) {
		int index = a.size() - (cnt + 1);
		int a_int = a[index] - '0';
		int b_int = b[index] - '0';
		if (a_int == b_int) {}
		else if (b_int < a_int) {
			ans = "GREATER";
			break;
		}
		else if (a_int < b_int) {
			ans = "LESS";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3588
package main

import (
  "fmt"
  "time"
)

func main () {
  var h1, m1, h2, m2, k, dist int
  fmt.Scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k)
  
  wakeupTime := time.Date(2020, time.May, 30, h1, m1, 0, 0, time.UTC)
  sleepTime := time.Date(2020, time.May, 30, h2, m2, 0, 0, time.UTC)
  
  //sleepTime := time.Now()
  //sleepTime.hour = h2
  //sleepTime.min = m2
  
  wakeTime := sleepTime.Sub(wakeupTime)
  
  dist = int(wakeTime.Minutes()) - k
  
  fmt.Printf("%d\n", dist)
}

Measured memory_bytes: 1820
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<int,int> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int x,y,n,m,tmp;
	cin>>n>>m>>x>>y;
	vector<int> a;
  	vector<int> b;
	for(int i=0;i<n;i++){
		cin>>tmp;
      	a.push_back(tmp);
	}
	for(int i=0;i<m;i++){
		cin>>tmp;
      b.push_back(tmp);
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	if(x<y && x<b[0] && a[n-1]<y){
		if(a[n-1]<b[0]){
			cout<<"No War"<<endl;
			return 0;
		}
	}
	cout<<"War"<<endl;
	return 0;
}

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

namespace _20170409_AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            int[] iArr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            StringBuilder sb = new StringBuilder();
            foreach( var v in iArr.Reverse())
            {
                sb.Append(v);
                sb.Append(' ');
            }
            Console.WriteLine(sb.ToString().TrimEnd(' '));

            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9580
n = int(input())
l = n
if not n % 2:
  l += 1
print(n * (n - 1) // 2 - n // 2 )
for i in range(1, n+1):
  for j in range(i+1, n+1):
    if i + j == l:
      continue
    print(i, j)

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

int main() {
  while(true){
    int h,w;
    cin >> h >> w;
    if(h == 0&&w == 0) return 0;
    for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
        if((i != 0 && i != h-1)&&(j != 0 && j!= w-1)) cout << '.';
        else cout << '#';
        if(j == w-1) cout << "" << endl;
      }
    }
    cout << "" << endl;
  }
}



Measured memory_bytes: 3092