akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[100000];
  for(int i=0;i<N;i=i+1){
    cin>>a[i];
  }
  int judge=0;
  for(int i=0;i<N;i=i+1){
    if(a[i]%2==0){
      judge=judge+1;
    }
  }
  if(judge==N){
    cout<<"second"<<endl;
  }
  else{
    cout<<"first"<<endl;
  }
}

Measured memory_bytes: 640
s=sorted(list(input()))
t=sorted(list(input()))
if s[0]<t[len(t)-1]:
  print('Yes')
elif s[0]>t[len(t)-1]:
  print('No')
else:
  if s[len(s)-1]==t[0] and len(s)<len(t):
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, f, n) for (ll i = (f); i < (ll)(n); i++)
#define repe(i, f, n) for (ll i = (f); i <= (ll)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const ll mod = 1e9 + 7;

int main() {
  int n, a;
  cin >> n;
  vector<int> num(n, 0);
  rep(i, 0, n) {
    cin >> a;
    num[a]++;
  }

  ll ans = 1;

  // 奇数個
  if (n % 2 == 1) {
    if (num[0] != 1) {
      cout << 0 << endl;
      return 0;
    }

    for (int i = 2; i < n; i += 2) {
      if (num[i] != 2) {
        cout << 0 << endl;
        return 0;
      }
      ans *= 2;
      ans %= mod;
    }
    cout << ans << endl;
    return 0;
  }

  // 偶数個
  if (n % 2 == 0) {
    for (int i = 1; i < n; i += 2) {
      if (num[i] != 2) {
        cout << 0 << endl;
        return 0;
      }
      ans *= 2;
      ans %= mod;
    }
    cout << ans << endl;
    return 0;
  }

  return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define X first
#define Y second
#define mod 1e9+7
#define pb push_back
#define mp make_pair
#define abs(x) ((x)>0?(x):(-(x)))
#define F(n) Fi(i,n)
#define Fi(i,n) Fl(i,0,n)
#define Fl(i,l,n) for(int i=l;i<n;i++)
#define memres(a) memset(a,0,sizeof(a))
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	for(int i=n;;i++){
		bool ch=true;
		for(int j=2;j*j<=n;j++){
			if(i%j==0){
				ch=false;
				break;
			}
		}
		if(ch){
			cout<<i<<endl;
			break;
		}
	}
return 0;
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x % y)


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    num = 1
    for ai in a:
        if ai == num:
            num += 1
        else:
            ans += 1
    if num == 1:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

#define rep(i,n) for(long 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 foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

long N;
int A[3];
int B[3];

long dp[6000];

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

  cin >> N;
  cin >> A[0] >> A[1] >> A[2];
  cin >> B[0] >> B[1] >> B[2];

  vi Av;
  vi Bv;
  rep(i,3) {
    if (A[i] < B[i]) Av.pb(i);
    else if (A[i] > B[i]) Bv.pb(i);
  }

  long ans = N;

  if (Av.size()==0) {
  } else if (Av.size()==1) {
    long cnt = ans / A[Av[0]];
    ans = ans + cnt * (B[Av[0]] - A[Av[0]]);
  } else if (Av.size()==2) {
    long ans2 = ans;
    long cnt0ma = ans / A[Av[0]];
    rep(cnt0, cnt0ma+1) {
      long rem = ans - cnt0 * A[Av[0]];
      long cnt1 = rem / A[Av[1]];
      long ans3 = ans + cnt0 * (B[Av[0]] - A[Av[0]]) + cnt1 * (B[Av[1]] - A[Av[1]]);
      ans2 = max(ans2, ans3);
    }
    ans = ans2;
  } else {
    rep(i, ans+1) dp[i] = 0;
    for (auto Ai : Av) {
      rep(i, ans+1) {
        rep(j,i+1) {
          dp[i] = max(dp[i], dp[j] + (i-j) / A[Ai] * (B[Ai] - A[Ai]));
        }
      }
    }
    ans = ans + dp[ans];
  }

  if (Bv.size()==0) {
  } else if (Bv.size()==1) {
    long cnt = ans / B[Bv[0]];
    ans = ans + cnt * (A[Bv[0]] - B[Bv[0]]);
  } else if (Bv.size()==2) {
    long ans2 = ans;
    long cnt0ma = ans / B[Bv[0]];
    rep(cnt0, cnt0ma+1) {
      long rem = ans - cnt0 * B[Bv[0]];
      long cnt1 = rem / B[Bv[1]];
      long ans3 = ans + cnt0 * (A[Bv[0]] - B[Bv[0]]) + cnt1 * (A[Bv[1]] - B[Bv[1]]);
      ans2 = max(ans2, ans3);
    }
    ans = ans2;
  } else {
    rep(i, ans+1) dp[i] = 0;
    for (auto Bi : Bv) {
      rep(i, ans+1) {
        rep(j,i+1) {
          dp[i] = max(dp[i], dp[j] + (i-j) / B[Bi] * (A[Bi] - B[Bi]));
        }
      }
    }
    ans = ans + dp[ans];
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin >> N;
    ll Mod = 1000000007;
    vll A(N);

    REP(i,N){
      ll d =0;
      cin >> d;
      d %= Mod;
      A[i]=d;
    }

    //本文
    ll ans = 0;
    ll sum = 0;
    for(int i =0;i<N;i++){
      sum += A[i];
      sum %= Mod;
    }
    vll a(N-1);
    ll current = 0;
    for(int i =0;i<N-1;i++){
      current += A[i];
      current %= Mod;
      a[i]= sum - current;
      if(a[i]<0) a[i]+= Mod;
      a[i] %= Mod;
    }
    for(int i=0;i<N-1;i++){
        ll e = A[i]*a[i];
        e %= Mod;
        ans += e;
        ans %= Mod;
    }
    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

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

namespace AtCoder
{
    class Abc168E
    {
        static long mod = 1000000007;

        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var count = new Dictionary<(long, long), int[]>();
            var zeroN = 0;
            for (int i = 0; i < n; i++)
            {
                var ab = Console.ReadLine().Split(' ').Select(j => long.Parse(j)).ToArray();
                var a = ab[0];
                var b = ab[1];
                if (a == 0 && b == 0)
                {
                    zeroN++;
                    continue;
                }
                else if (a == 0)
                    b = 1;
                else if (b == 0)
                    a = -1;
                else
                {
                    if (b < 0)
                    {
                        a = -a;
                        b = -b;
                    }
                    var r = Gcd(Math.Abs(a), b);
                    a /= r;
                    b /= r;
                }

                bool reverse = a < 0;
                (long, long) key = reverse ? (b, -a) : (a, b);

                if (count.TryGetValue(key, out var v))
                    v[reverse ? 1 : 0]++;
                else
                    count.Add(key, reverse ? new[] { 0, 1 } : new[] { 1, 0 });
            }

            long ans = 1;
            foreach (var item in count.Values)
                ans = ans * (ModPower(2, item[0]) + ModPower(2, item[1]) - 1) % mod;
            Console.WriteLine((ans + zeroN - 1 + mod) % mod);
        }

        static long Gcd(long a, long b)
        {
            if (a < b)
                return Gcd(b, a);
            while (b > 0)
            {
                var r = a % b;
                a = b;
                b = r;
            }
            return a;
        }

        static long ModPower(long a, long n)
        {
            long ret = 1;
            while (n > 0)
            {
                if (n % 2 == 1)
                    ret = ret * a % mod;
                a = a * a % mod;
                n /= 2;
            }
            return ret;
        }
    }
}


Measured memory_bytes: 62820
#include <stdio.h>
int main(void){
	int H = 0, W = 0;
	while (1){
		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0){
			break;
		}

		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				printf("#");
			}
			printf("\n");
		}
                printf("\n");
	}
}

Measured memory_bytes: 2572
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


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


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


def solve():
    return


def main():
    S = input()
    d = {"SUN":7 ,"MON": 6,"TUE": 5,"WED": 4,"THU": 3,"FRI": 2,"SAT": 1}
    print(d[S])

if __name__ == '__main__':
    main()


Measured memory_bytes: 4208
/************************************
 TEMPLATE FOR PROGRAM COMPETITION
 ***********************************/
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
using namespace std;

int main(){
  
  /* read input */
  std::string S;
  std::cin >> S;
  int n = S.length();
  
  /* solve problem */
  
  // check possibility
  int possible = 1;
  if(S[0] == '0' || S[n-2] == '0' || S[n-1] == '1'){
    possible = 0;
  }
  for(int i = 1; i < n/2; i++){
    if(S[i] != S[n-i-2]){
      possible = 0;
    }
  }
  
  if(possible == 0){
    std::cout << "-1\n";
    return 0;
  }
  
  // if possible print answer
  int node = 0;
  int node_new;
  
  while(node < n/2){
    node_new = node+1;
    while(S[node_new] == '0'){
      node_new++;
    }
    for(int i = node; i < node_new; i++){
      printf("%d %d\n", i+1, node_new+1);
    }
    node = node_new;
  }
  for(int i = node+1; i < n; i++){
    printf("%d %d\n", node+1, i+1);
  }
  return 0;
}


Measured memory_bytes: 1664
import sys

ans = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]

lst = []

N = int(input())
for i in sys.stdin.readlines():
    row = i.rstrip().split()
    b = int(row[0])
    f = int(row[1])
    r = int(row[2])
    v = int(row[3])
    
    ans[b-1][f-1][r-1] += v
    
for i,j in enumerate(ans,start=1):
    if i != 4:
        for k in j:
            print(' ', end='')
            print(*k)
        print('#'*20)
    else:
        for k in j:
            print(' ', end='')
            print(*k)

        


Measured memory_bytes: 5628
from math import ceil
import sys
input=sys.stdin.readline
n, h = map(int, input().split())
a = []
b = []
for i in range(n):
  p, q = map(int, input().split())
  a.append(p)
  b.append(q)
b.sort(reverse=1)
ans=0
m=max(a)
while(h>0 and len(b) != 0):
  if b[0] < m:
    break
  h-=b[0]
  b.pop(0)
  ans+=1
if h>0:
  ans+=ceil(h/m)
print(ans)


Measured memory_bytes: 11264
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define SF scanf
#define PF printf
#define MAXN 200010
#define MOD 1000000007
using namespace std;
typedef long long ll;
int n;
int a[MAXN],b[MAXN],st,ed,cnt1,cnt2;
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&a[i]);
	for(int i=1;i<=n;i++)
		SF("%d",&b[i]);
	reverse(b+1,b+1+n);
	for(int i=1;i<=n;i++)
		if(a[i]==b[i]){
			st=i;
			break;
		}
	for(int i=n;i>=1;i--)
		if(a[i]==b[i]){
			ed=i;
			break;	
		}
	if(st==0){
		PF("Yes\n");
		for(int i=1;i<=n;i++)
			PF("%d ",b[i]);
		return 0;
	}
	int maxv=a[st];
	for(int i=1;i<=n;i++){
		if(a[i]==maxv)
			cnt1++;
		if(b[i]==maxv)
			cnt2++;
	}
	int j=1;
	for(int i=st;i<=ed;i++){
		for(;j<=n;j++)
			if(b[i]!=a[j]&&a[i]!=b[j]){
				swap(b[i],b[j]);
				j++;
				break;
			}
	}
	for(int i=1;i<=n;i++)
		if(a[i]==b[i]){
			PF("No");
			return 0;	
		}
	PF("Yes\n");
	for(int i=1;i<=n;i++)
		PF("%d ",b[i]);
}

Measured memory_bytes: 3292
#include <bits/stdc++.h>
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) x.begin(),x.end()
using namespace std;
const int MOD = 1000000007;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


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

    int n;
    cin >> n;
    ll ans= (modpow(10, n, MOD) - modpow(9, n, MOD) - modpow(9, n, MOD) + modpow(8, n, MOD)) % MOD;
    ans = (ans+MOD) % MOD;
    cout << ans << endl;
    return 0;
}

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

int main()
{
	string s1,s2;
	cin >> s1 >> s2;
	int ans = 0;
	for(int i=0;i<3;i++)
		if(s1[i] == s2[i])
			ans ++;
	cout << ans << endl;
}

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

using namespace std;

const int maxn=1e5+500;

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

int main()
{
	long long n,m;
	cin>>n>>m;
	string s,t;
	cin>>s>>t;
	long long l=n/gcd(n,m)*m;
	int flag=1;
	long long time1=l/m,time2=l/n;
	for(int i=0;i<(int)max(n,m);i++)
    {
		if(s[time1*i%n]!=t[time2*i%m])
		{
			flag=0;
			break;
		}
	}
	cout<<(flag?l:-1);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
  int n,q;
  cin>>n>>q;
  n *= 2;
  vector<int> a(n),b(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];

  vector<int> d(n);
  rep(i,n) d[i] = b[i]-a[i];

  long acc = accumulate(all(a), 0L);
  long plus_sum = 0;

  multiset<int> plus, minus;
  rep(i,1,n-1){
    if(d[i]>=0) plus.insert(d[i]);
    else minus.insert(d[i]);
  }

  for(auto x : plus) plus_sum += x;

  rep(i,q){
    int p,x,y;
    cin>>p>>x>>y;
    p--;

    if(p==0 || p == n-1){
      acc -= a[p];
      a[p] = x;
      b[p] = y;
      acc += a[p];
    }

    else {
      acc -= a[p];
      int old_d = b[p] - a[p];
      if(old_d >= 0){
        plus.erase(plus.lower_bound(old_d));
        plus_sum -= old_d;
      }
      else minus.erase(minus.lower_bound(old_d));

      a[p] = x;
      b[p] = y;
      acc += a[p];
      int new_d = b[p] - a[p];
      if(new_d >= 0){
        plus.insert(new_d);
        plus_sum += new_d;
      }
      else minus.insert(new_d);
    }

    if(plus.size()%2==0) cout << acc + plus_sum << "\n";
    else {
      // 奇数なのでどっちも1以上ある
      long c1 = acc + plus_sum - *plus.begin();
      long c2 = acc + plus_sum + *minus.rbegin();

      cout << max(c1, c2) << "\n";
    }
    // dbg(vector<int>(all(plus)));
    // dbg(vector<int>(all(minus)));
  }

  return 0;
}


Measured memory_bytes: 13440
// <BBQ.cpp> - Sat Mar 25 11:43:04 2017
// This file is created by XuYike's black technology automatically.
// Copyright (C) 2015 ChangJun High School, Inc.
// I don't know what this program is.

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long lol;
#define next NEXT
template<typename T>
inline void gg(T &res){
    res=0;T fh=1;char ch=getchar();
    while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
    if(ch=='-')fh=-1,ch=getchar();
    while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
    res*=fh;
}
inline int gi(){int x;gg(x);return x;}
inline lol gl(){lol x;gg(x);return x;}
const int MAXN=200010;
const int K=2001;
const int N=4002;
const int INF=1e9;
const int MOD=1e9+7;
int qpow(int x,int y){
    int res=1;
    while(y){
        if(y&1)res=1ll*res*x%MOD;
        x=1ll*x*x%MOD;
        y>>=1;
    }
    return res;
}
int jc[N<<1],nj[N<<1],f[N][N];
inline int C(int n,int m){return 1ll*jc[n]*nj[m]%MOD*nj[n-m]%MOD;}
int a[MAXN],b[MAXN];
int main(){
    jc[0]=1;for(int i=1;i<=8000;i++)jc[i]=1ll*jc[i-1]*i%MOD;
    nj[8000]=qpow(jc[8000],MOD-2);for(int i=8000;i;i--)nj[i-1]=1ll*nj[i]*i%MOD;
    int n=gi(),ans=0;
    for(int i=1;i<=n;i++){
        a[i]=gi(),b[i]=gi();
        f[K-a[i]][K-b[i]]++;
        ans=(ans-C(a[i]+b[i]<<1,a[i]<<1)+MOD)%MOD;
    }
    for(int i=1;i<N;i++)
        for(int j=1;j<N;j++)f[i][j]=(0ll+f[i][j]+f[i-1][j]+f[i][j-1])%MOD;
    for(int i=1;i<=n;i++)ans=(ans+f[a[i]+K][b[i]+K])%MOD;
    printf("%d",1ll*ans*qpow(2,MOD-2)%MOD);
    return 0;
}

Measured memory_bytes: 64384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

struct Prime { // Wheel factorization
    static constexpr int wheel[] = {4, 2, 4, 2, 4, 6, 2, 6},
            wheel2[] = {7, 11, 13, 17, 19, 23, 29, 31},
            wheel_sum[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7};
    static inline int f(int n){ return (n-1)/30*8 + wheel_sum[(n-1)%30]; }
    static inline int g(int n){ return ((n-1) >> 3)*30 + wheel2[(n-1)&7]; }
    vector<int> primes;

    Prime(int M) {
        primes = {2, 3, 5};
        if(M < 7){
            while(!primes.empty() && M < primes.back()) primes.pop_back();
            return;
        }
        int n = f(M), m = g(n), k = f(int(floor(sqrt(M))));
        primes.reserve(3+max(0, (int)(n/(log(n)-1.12))));
        vector<bool> sieve(n+1, true);
        for (int i = 1; i <= k; ++i) {
            if(sieve[i]){
                ll p = g(i), q = p*p;
                int j = (i-1)&7;
                while(q <= m){
                    sieve[f(q)] = false;
                    q += wheel[j] * p;
                    j = (j+1)&7;
                }
            }
        }
        for (int i = 1; i <= n; ++i) {
            if(sieve[i]) primes.emplace_back(g(i));
        }
    }
};
constexpr int Prime::wheel[], Prime::wheel2[], Prime::wheel_sum[];


int main() {
    Prime x(10000001);
    vector<int> val;
    for (int i = 0; i+3 < x.primes.size(); ++i) {
        if(x.primes[i]+2 == x.primes[i+1]
        && x.primes[i+1]+4 == x.primes[i+2]
        && x.primes[i+2]+2 == x.primes[i+3]){
            val.emplace_back(x.primes[i+3]);
        }
    }
    int n;
    while(cin >> n, n){
        printf("%d\n", *--upper_bound(val.begin(),val.end(), n));
    }
    return 0;
}


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

lst = [ [a,b], [c,d] ]
mx = a*c
for i in range(2):
  x = lst[0][i]*lst[1][0]
  if x >= mx:
    mx = x
  x = lst[0][i]*lst[1][1]
  if x >= mx:
    mx = x
print(mx)

Measured memory_bytes: 8972
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100007;
int X;
int pw(int x)
{
    return x*x*x*x*x;
}
void check(int t)
{
    for(int B=-200;B<=200;++B) if(pw(B+t)-pw(B)==X) printf("%lld %lld",B+t,B),exit(0);
}
signed main()
{
    cin>>X;
    for(int i=1;i*i<=X;++i) if(!(X%i)) check(i),check(X/i);
}



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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

void solve()
{
    int N; cin >> N;
    vb use(101, false);
    REP(i, N)
    {
        int d; cin >> d;
        use[d] = true;
    }
    int ans = 0;
    REP1(i, 100) if(use[i]) ans++;
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

int dp[2001][3001];
int main(){
  while(1){
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    int n, m, s, i, j, k, ans = 0;
    scanf("%d%d%d", &n, &m, &s);
    if(n == 0 && m == 0 && s == 0)return 0;
    n *= n;
    for(i = 1;i <= m;i++){
      for(j = n;j > 0;j--){
	for(k = i;k <= s;k++){
	  dp[j][k] += dp[j - 1][k - i];
	  dp[j][k] %= 100000;
	}
      }
    }
    printf("%d\n", dp[n][s]);
  }
}

Measured memory_bytes: 24064
import numpy as np


def solve(n, k):
    if k % 2 == 1:
        return 0
    k //= 2

    MOD = 10 ** 9 + 7

    dp = np.zeros((1, k + 1), dtype=np.int64)
    dp[0, 0] = 1
    for i in range(1, n + 1):
        max_d = min(i + 1, n - i + 1, k + 1)
        ndp = np.zeros((max_d, k + 1), dtype=np.int64)
        for d, ks in enumerate(dp):
            base = ks[:k - d + 1]
            if d > 0:
                ndp[d - 1, d:] += base * d ** 2
            if max_d > d:
                ndp[d, d:] += base * (2 * d + 1)
            if max_d > d + 1:
                ndp[d + 1, d:] += base
        dp = ndp % MOD

    return dp[0, k]


n, k = map(int, input().split())
print(solve(n, k))


Measured memory_bytes: 21496
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            #print(i,j,k)
            if 500*(i)+100*(j)+50*(k) == x:
                ans += 1
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int rect = 0;
		int dia = 0;
		while(scan.hasNext()){
			String[] str = (scan.nextLine()).split(",");
			int[] a = new int[3];
			for(int i = 0;i < 3;i++){
				a[i] = Integer.parseInt(str[i]);
			}
			if(a[0] == a[1]){
				dia++;
			}
			if(a[0]*a[0]+a[1]*a[1] == a[2]*a[2]){
				rect++;
			}
		}
		System.out.println(rect + "\n" + dia);
	}
}

Measured memory_bytes: 12000
program ABC169D
    implicit none
    integer(8)::N,c,Ns,i,m,d,ans,j
    integer(8),allocatable,dimension(:)::L
    read*,N
    Ns=int(sqrt(real(N)))
    c=1
    m=N
    ans=0
    allocate(L(Ns+10))
    do i=2,Ns
        if(mod(m,i)==0)then
            d=0
            do
                m=m/i
                d=d+1
                if(mod(m,i)/=0)exit
            end do
            !print'(i0,1x,i0)',i,d
            L(c)=d
            c=c+1
        end if
    end do

    if(m>1)then
        !print'(i0,1x,i0)',m,1
        L(c)=1
    else
        c=c-1
    end if
    !print'(i0)',c
    if(c==0)then
        print'(i0)',0
    else
        do i=1,c
            do j=1,10
                if(2*L(i)<j*(j+1))then
                    ans=ans+j-1
                    exit
                end if
            end do
        end do
        print'(i0)',ans
    end if
end program ABC169D

Measured memory_bytes: 2928
#include <iostream>
#include <map>
#include <cctype>
#include <cstdlib>
using namespace std;

int idx,len;
string s;
map<int,int> val[128];
int size[128];

int number(){
	string tmp = "";
	while(isdigit(s[idx])){
		tmp += s[idx];
		idx++;
	}
	return atoi(&tmp[0]);
}

int expression(){
	if(isdigit(s[idx])){
		return number();
	}

	char name = s[idx++];
	if(size[name] == -1) return -1;

	idx++;
	int exp = expression();
	idx++;
	if(exp==-1 || exp>=size[name] || val[name].find(exp)==val[name].end()) return -1;

	return val[name][exp];
}

bool assignment(){
	char name = s[idx++];
	if(size[name] == -1) return false;

	idx++;
	int exp = expression();
	idx++;
	if(exp==-1 || exp>=size[name]) return false;

	idx++;
	int exp2 = expression();
	if(exp2==-1) return false;

	val[name][exp] = exp2;

	return true;
}

bool declaration(){
	char name = s[idx++];

	idx++;
	int num = number();
	idx++;

	size[name] = num;

	return true;
}

bool program(){
	idx = 0;
	len = s.length();

	bool flg = false;
	for(int i=0;i<len;i++){
		if(s[i] == '='){
			flg = true;
			break;
		}
	}

	if(flg) return assignment();
	return declaration();
}

int main(void){
	while(1){
		bool bugFlg = false;

		for(int i=0;i<128;i++){
			val[i].clear();
			size[i] = -1;
		}

		for(int set=1;;set++){
			cin>>s;
			if(s == "."){
				if(set == 1) return 0;
				if(!bugFlg) cout<<0<<endl;
				break;
			}

			if(!bugFlg){
				if(!program()){
					bugFlg = true;
					cout<<set<<endl;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.*;

/**
 * Created by Seiya on 2016/10/16.
 */
public class Main {

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

        int[] a = new int[100];
        int[][] b = new int[100][2];
        int N, M;
        N = scanner.nextInt();
        int  sum = 0;
        for (int i = 0; i < N; i++) {
            a[i] = scanner.nextInt();
            sum += a[i];
        }
        M = scanner.nextInt();
        for (int i = 0; i < M; i++) {
            b[i][0] = scanner.nextInt();
            b[i][1] = scanner.nextInt();
            //System.out.println("de = " + a[b[i][0] - 1 ]);
            System.out.println(sum - (a[b[i][0] - 1] - b[i][1]));
        }

    }





}




Measured memory_bytes: 10320
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

typedef long long ll;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    int N, res=0;
    std::cin >> N;
    vi A(N, 0);

    floop(N)
    {
        std::cin >> A[i];
        if((i+1)%2 == 1 && A[i] % 2 == 1)
            res++;
    }
    
    print(res);
    return 0;
}

Measured memory_bytes: 3628
from math import cos,radians,sqrt
a,b,h,m=map(int,input().split())
hangle= 30*h + 0.5*m
mangle= 6*m
angle=abs(hangle-mangle)
angle=min(360-angle,angle)
ans= (a**2 + b**2 - (2*a*b*cos(radians(angle))))
print(sqrt(ans))


Measured memory_bytes: 62644
N, M  = map(int, input().split())
AB = [None] * N
for i in range(N):
    a, b = map(int, input().split())
    AB[i] = (a, b)
    
days_limit = M

jobs = AB[:]
from collections import defaultdict
jobs_dict = defaultdict(lambda: [])
for d, r in jobs:
    jobs_dict[d].append(r)
#print(jobs_dict)

import heapq
hq = []

ans = 0
for d in range(1, M+1):
    for r in jobs_dict[d]:
        heapq.heappush(hq,-r)
    if hq:
        ans += -1 * heapq.heappop(hq)
print(ans)

    

Measured memory_bytes: 85336
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  ll N;
  cin >> N;
  ll sum = 0;
  ll NG;
  ll last;
  repp(i, 1, N) {
    sum += i;
    if (sum >= N) {
      last = i;
      NG = sum - N;
      break;
    }
  }

  repp(i, 1, last) {
    if (i == NG)
      continue;
    cout << i << endl;
  }
}

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

namespace atcorder1
{
    class MainClass
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }
        public static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var r = Read();
            Console.WriteLine(r * r);
               
            Console.Out.Flush();
        }
    }
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

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

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    sort(all(a));

    LL ans1 = 0, ans2 = 0;
    vector<int> keisuu1(n), keisuu2(n);
    REP(i, n) {
        if (i % 2 == 0) keisuu1[i] = 1, keisuu2[i] = -1;
        else keisuu1[i] = -1, keisuu2[i] = 1;

        if (i != 0 && i != n - 1) keisuu1[i] *= 2, keisuu2[i] *= 2;
    }

    sort(all(keisuu1)); sort(all(keisuu2));

    REP(i, n) ans1 += keisuu1[i] * a[i];
    REP(i, n) ans2 += keisuu2[i] * a[i];

    cout << max(ans1, ans2) << endl;
}

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

#include <algorithm>
#include <array>
#include <chrono>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>
#define FOR(i, n, m) for (ll i = n; i < (ll)m; i++)
#define FORr(i, m, n) for (ll i = n; i >= (ll)m; i--)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define sortAl(v) sort(v.begin(), v.end())
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())
#define cout(n) cout << fixed << setprecision(n)

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

  vector<ll> A(3);
  cin >> A[0] >> A[1] >> A[2];

  sort(A.begin(), A.end());

  ll sum = 0;
  for (int i = 1; i < A.size(); i++) {
    sum += A[i] - A[i - 1];
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <math.h>

typedef unsigned long long int uint64;
typedef long long int          int64;

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))

#define SIZE (200000)


void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;

tmp_t A[SIZE];
tmp_t B[SIZE];

int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return -1;
  if (x->a < y->a) return 1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

int main()
{
  int cnt;
  int i;
  int64 N;

  get_N(&N);

  for(i=0; i<N; i++) {
    cnt = scanf("%lld", &A[i].a);
    B[i].a = A[i].a;
  }

  qsort_a (B, N);

  for(i=0; i<N; i++) {
//    printf("A=%d B=%d\n", A[i].a, B[i].a);
    if (A[i].a == B[0].a) {
      printf("%d\n", B[1].a);
    }else{
      printf("%d\n", B[0].a);
    }
  }
  
  return 0;
}



Measured memory_bytes: 9596
n = int(input())
a = list(int(input()) for _ in range(n))

aa = sorted(a)
a_max = aa[-1]
a_max_ind = [x == a_max for x in a]

if aa[-2] == aa[-1]:
    for i in range(n):
        print(a_max)
else:
    for i in range(n):
        if a_max_ind[i]:
            print(aa[-2])
        else:
            print(aa[-1])


Measured memory_bytes: 72968
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define inf 2000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;			
	   
int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			// #endif
			
			ll r,g,b,k;
			cin>>r>>g>>b>>k;

			if(g<=r)
			{
				while(g<=r)
				{
					g*=2;
					k-=1;
				}
				if(k<0)
				{
					cout<<"No"<<endl;
					return 0;
				}
			}
			if(b<=g)
			{
				while(b<=g)
				{
					b*=2;
					k-=1;
				}
				if(k<0)
				{
					cout<<"No"<<endl;
					return 0;
				}
			}		
			// cout<<b<<" "<<g<<" "<<r<<endl;
			cout<<"Yes"<<endl;	


		
			
			return 0;
		 }	




Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const int nax = 10123;
char k[nax];

void add_self(int &a, int b){
    a+=b;
    if(a>=mod){
        a-=mod;
    }
}

int main(){
    int d;
    scanf("%s", k);
    cin >> d;
    int len = strlen(k);
    vector<vector<int>>dp(d, vector<int>(2));
     dp[0][0] = 1;
    for(int i=0; i<len; i++){
        vector<vector<int>>new_dp(d, vector<int>(2));
        for(int j=0; j<d; j++){
            for(bool f: {false, true}){
                for(int a=0; a<10; a++){
                    if(a > k[i]-'0' && !f)
                    {
                        break;
                    }
                        
                    add_self(new_dp[(j+a)% d][f || (a<k[i]-'0')], dp[j][f]);
                }
            }
        }
        dp = new_dp;
    }
    int ans = (dp[0][true] + dp[0][false])%mod;
    --ans;
    if(ans == -1){
        ans = mod-1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    FOR(x, 1, N + 1) {
        if (x + 8 * x / 100 == N) {
            cout << x << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
    return 0;
};

Measured memory_bytes: 256
#include<iostream>
using namespace std;
class dice
{
  private:
  int status[6];
  public:
  dice();
  int showfront(void);
  bool is(int,int);
  bool isfront(int);
  void rotate(char);
  bool rtfront(int);
  bool operator==(dice);
  bool eqv(dice);
};

bool dice::eqv(dice di2)
{
  if(!di2.rtfront((*this).showfront()))
    return false;
  else
  {
    int i;
    for(i=0;i<4;i++)
    {
      if ((*this)==di2)
      {
        return true;
      }
      di2.rotate('E');
    }
    if(i==4) return false;
  }
}



bool dice::rtfront(int a)
{
  int j;
  for(j=0;j<=3;j++)
  {
    if((*this).isfront(a)) break;
    (*this).rotate('N');
  }
  if(j==4)
  {
    (*this).rotate('E');
    (*this).rotate('S');
  }
  if(!(*this).isfront(a))
  {
    (*this).rotate('N');
    (*this).rotate('N');
  }
  if(!(*this).isfront(a))
    return false;
  else
    return true;
}

bool dice::operator==(dice d)
{
  int i=0;
  for(i=0;i<6;i++)
    if((*this).status[i]!=d.status[i]) break;
  if(i==6) return true;
  else return false;
}

dice::dice()
{
  for(int i=0;i<6;i++)
    cin>>status[i];
}

bool dice::isfront(int a)
{
  if(status[1]==a) return true;
  else return false;
}

bool dice::is(int a,int b)
{
  if((status[0]==a)&&(status[1]==b)) return true;
  else return false;
}

int dice::showfront()
{
  return status[1];
}

void dice::rotate(char s)
{
  switch(s)
  {
    int tmp;
    case 'N':
      tmp=status[0];
      status[0]=status[1];
      status[1]=status[5];
      status[5]=status[4];
      status[4]=tmp;
      break;
    case 'E':
      tmp=status[0];
      status[0]=status[3];
      status[3]=status[5];
      status[5]=status[2];
      status[2]=tmp;
      break;
    case 'W':
      tmp=status[0];
      status[0]=status[2];
      status[2]=status[5];
      status[5]=status[3];
      status[3]=tmp;
      break;
    case 'S':
      tmp=status[0];
      status[0]=status[4];
      status[4]=status[5];
      status[5]=status[1];
      status[1]=tmp;
      break;
  }
}

int main()
{
  int n;
  cin>>n;
  dice di[n];
  bool ans=true;
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
      if(di[i].eqv(di[j]))
      {
        ans=false;
        break;
      }
  if(ans==true)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

}

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

int main() {
  int n,m,c;
  cin >> n >> m >> c;
  vector<int> b(m,0);
  for(int i = 0; i<m; i++){
    cin >> b.at(i);
  }
  vector<vector<int>> a(n,vector<int>(m,0));
  for(int i = 0; i<n; i++){
    for(int j = 0; j<m; j++){
      cin >> a.at(i).at(j);
    }
  }
  
  int count = 0;
  for(int i = 0; i<n; i++){
    int p = 0;
    for(int j = 0; j<m; j++){
      p +=b.at(j)*a.at(i).at(j);
    }
    p += c;
    if(p>0){
      count++;
    }
  }
  cout << count << endl;
  
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

int main() {
    int N, K, C;
    string S;
    cin >> N >> K >> C >> S;
    vector<int> L(K);
    vector<int> R(K);
    int ind = 0;
    int wsum = 0;
    while(ind < N) {
        if(wsum >= K) {
            break;
        }
        if(S[ind] == 'x') {
            ind++;
        } else {
            L[wsum] = ind;
            wsum++;
            ind += 1 + C;
        }
    }
    ind = N - 1;
    wsum = 0;
    while(ind >= 0) {
        if(wsum >= K) {
            break;
        }
        if(S[ind] == 'x') {
            ind--;
        } else {
            R[K - 1 - wsum] = ind;
            wsum++;
            ind -= 1 + C;
        }
    }

    rep(i, 0, K) {
         //cout << "L:" << L[i] << ",R:" << R[i] << endl;
        if(L[i] == R[i]) {
            cout << L[i]+1 << endl;
        }
    }
}


Measured memory_bytes: 3332
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
  int n, T;
  cin >> n >> T;
  int ans = 1e9;
  while (n--) {
    int c, t;
    cin >> c >> t;
    if (t <= T) {
      ans = min(ans, c);
    }
  }
  if (ans == 1e9) {
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;
  }
}



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

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const int MOD = 1000000007;
const int MAX_N = 100010;

signed main() {
    IOS;

    int N, K;
    V<> P;
    cin >> N >> K;
    P.resize(N);
    REP(i, N) {
        cin >> P[i];
    }
    SORT(P);
    int ans = 0;
    REP(i, K) {
        ans += P[i];
    }
    print(ans);

    return 0;
}


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

int N, M, Q;
int A[10];
int a[51], b[51], c[51], d[51];
int ans;

void makeA(int level, int prev) {
    if (level == N) {
        int score = 0;
        rep(i, Q) if (A[b[i]] - A[a[i]] == c[i]) score += d[i];
        ans = max(ans, score);        
    }
    else {
        for (int now=prev; now <= M; now++) {
            A[level] = now;
            makeA(level+1, now);
        }
    }
}

int main() {
    cin >> N >> M >> Q;

    int ai, bi, ci, di;
    rep(i, Q) {
        cin >> ai >> bi >> ci >> di;
        ai--, bi--;
        a[i] = ai, b[i] = bi, c[i] = ci, d[i] = di;
    }

    ans = 0;
    makeA(0, 1);

    cout << ans << endl;

    return 0;
}



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

int main(){
  	string S, T;
  	cin >> S >> T;
  	if(S.length()+1==T.length()){
    	for(int i=0; i<S.length(); i++){
        	if(S[i]==T[i]){
              
            }else{
            	cout << "No" << endl;
              	return 0;
            }
        }
    }
  	cout << "Yes" << endl;
	return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int F[mx2][15], P[mx2][15];

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

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

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

    int ans = INT_MIN;
    for(int N = 1; N < 1024; N++){

        int res = 0;
        for(int i = 1; i <= n; i++){
            int cnt = 0;
            for(int j = 0; j < 10; j++)
                cnt += (N >> j) & F[i][j + 1];
            res += P[i][cnt];
        }
        ans = max(ans, res);
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3608
N,A=map(int,input().split())
X=list(map(int,input().split()))
X=[X[i]-A for i in range(0,N)]
dp=[[0 for i in range(0,5000)] for i in range(0,N+1)]#i枚で和がj-2500のもの
dp[0][2500]=1
for i in range(1,N+1):
    for j in range(0,5000):
        if j>=X[i-1] and 4999>=j-X[i-1]:
            dp[i][j]=dp[i-1][j]+dp[i-1][j-X[i-1]]
        else:
            dp[i][j]=dp[i-1][j]
print(dp[N][2500]-1)

Measured memory_bytes: 42716
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  ll res = (b / x) - (a / x);
  if (a % x == 0) {
    res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256