akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> >
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const ll INF = 1e18 + 0;
const ll mod = 1e9 + 7;
//const int mod = 998244353;

ll mul(ll a, ll b) {
  a += mod; b += mod;
  a %= mod; b %= mod; return ((a * b) % mod);
}
void solve(){
    ll n,k;
    cin>>n>>k;
    ll K=k;
    vector<ll>pos,neg,zero;
    vector<pair<ll,ll>>v(n);
    for(ll i=0;i<n;i++){
        ll d;
        cin>>d;
        if(d>0)pos.push_back(d);
        else if(d<0)neg.push_back(abs(d));
        else zero.push_back(d);
        ll s;
        if(d>=0)s=1;
        else s=-1;
        v[i]={abs(d),s};
    }
    sort(pos.begin(),pos.end(),greater<ll>());sort(neg.begin(),neg.end(),greater<ll>());sort(v.begin(),v.end());
    ll ans=1;
    ll pcur=0,ncur=0;
    if(k%2){
        if(pos.size()){
            ans=mul(ans,pos[pcur]);
            pcur++;
            k--;
        }
    }
    while(k && (pcur+1<(ll)pos.size() || ncur+1<(ll)neg.size())){
        ll val1=-INF,val2=-INF;
        if(pcur+1<(ll)pos.size()){
            val1=pos[pcur] * pos[pcur+1];
        }
        if(ncur+1<(ll)neg.size()){
            val2=neg[ncur] * neg[ncur+1];
        }
        if(val1>val2){
            ans=mul(ans,val1);
            pcur+=2;
        }
        else{
            ans=mul(ans,val2);
            ncur+=2;
        }
        k-=2;
    }
    if(k){
        if(!zero.empty()){
            ans=0;
        }
        else{
            ans=1;
            for(ll i=0;i<K;i++){
                ans=mul(ans,v[i].first * v[i].second);
            }
        }
    }
    cout<<ans<<endl;
    return;
}
signed main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
     solve();
  }
}



Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

vvi f(int n){
	if(n==0) return vvi(1,vi(1));
	vvi a(1<<n,vi(1<<n)),b=f(n-1);
	for(int i=0;i<1<<n;i++) for(int j=0;j<1<<n;j++){
		a[i][j]=b[i&((1<<n-1)-1)][j&((1<<n-1)-1)]^(i&1<<n-1&&j&1<<n-1);
	}
	return a;
}

int n,m;

int main(){
	cin>>n>>m;
	vvi a=f(10);
	for(int i=1;i<1<<n;i++){
		for(int j=1;j<1<<m;j++) cout<<(a[i][j]^a[i][j-1]^a[i-1][j]^a[i-1][j-1]);
		cout<<endl;
	}
}

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


int main(){
  vector<ll>lucas(90, 0);
  int n;
  cin >> n;
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  for(int i = 2; i <= n; i++){
    lucas.at(i) = lucas.at(i-1) + lucas.at(i-2);
  }

  cout << lucas.at(n) << endl;

  return 0;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#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>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#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>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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


ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }else{
        return gcd(b,a%b);
    }
}




void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll A,B; cin >> A >> B;
    
    cout << A*B/gcd(A,B) << endl;
    
    
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 256
x,y = map(int,input().split())
s = 0
if x == 1 and y == 1:
  s += 400000
for i in [x,y]:
  if i == 1:
    s += 300000
  elif i == 2:
    s += 200000
  elif i == 3:
    s += 100000
print(s)
  
  

Measured memory_bytes: 2940
w,h,n=gets.split.map &:to_i
pt=[nil,0,w,0,h]
n.times do
  a=gets.split.map &:to_i
  a[2]%2==1&&pt[a[2]]<a[a[2]/3]&&pt[a[2]]=a[a[2]/3]
  a[2]%2==0&&pt[a[2]]>a[a[2]/3]&&pt[a[2]]=a[a[2]/3]
end
x=pt[1]<pt[2] ? pt[2]-pt[1] : 0
y=pt[3]<pt[4] ? pt[4]-pt[3] : 0
puts x*y


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int n,r;
  while(true){
    cin >> n >> r;
    if(n==0) break;
    int p,c;
    int now[n+1],pre[n+1];
    for(int i=1;i<=n;i++) pre[i]=n-i+1;
    for(int i=0;i<r;i++){
      cin >> p >> c;
      for(int j=1;j<=c;j++) now[j]=pre[j+p-1];
      for(int j=c+1;j<=p+c-1;j++) now[j]=pre[j-c];
      for(int j=p+c;j<=n;j++) now[j]=pre[j];
      for(int j=1;j<=n;j++) pre[j]=now[j];
    }
    cout << now[1] << endl;
  }
}

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

using namespace std;

#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e16
#define PI acos(-1.0)
#define mk make_pair

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ABS(x) ((x)<0?-(x):(x))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())

#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);

int main()
{
    int n;
    cin >> n;
    int mx = 1e9;
    int ans = 0;
    for(int i = 1;i <= n;i++){
        int c;cin >> c;
        mx = min(mx,c);
        if(c == mx)ans++;
    }
    cout << ans << "\n";
}



Measured memory_bytes: 256
=begin
  1, s の先頭から p - 1 文字分を s 自身の後ろにくっつける(コード上ではindexのため -2)
  2, s　の中に p があるか判定して出力 
=end

s = gets.chomp
p = gets.chomp

s += s[0..p.length-2]

puts s.include?(p) ? "Yes" : "No"


Measured memory_bytes: 6876
n = gets.to_i
q = [["a", "a"]]
ans = []
until q.empty?
  s, c_max = q.shift
  if s.size < n
    "a".upto(c_max) do |c|
      q << [s + c, c_max]
    end
    q << [s + ((c_max).ord + 1).chr, ((c_max).ord + 1).chr]
  else
    ans << s
  end
end
puts ans


Measured memory_bytes: 21624
#include <iostream>
#include <vector>
using namespace std; 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define forin(i, n) for ( int i = 0; i < (int)n; ++i )
typedef long long ll;
const char nl = '\n';

vector<ll> nums;
int main()
{
    //IOS
    
    int n; cin >> n;
    ll resp = 1;
    nums.resize(n); bool cero = false;
    forin(i, n)
    {
        cin >> nums[i];
        if ( nums[i] == 0 ) cero = true;
    }

    if (cero) cout << '0' << nl;
    else
    {
        forin(i, n)
        {
            if ( resp <= ( 1000000000000000000 / nums[i] ) )
            {
                resp = resp * nums[i];
            }
            else
            {
                printf("-1");
                return 0;
            }
        }
        cout << resp << nl;
    }
    
    return 0;
}


Measured memory_bytes: 4028
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstdio>
#include<cmath>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007


int main(void){

  int n;
  cin >> n;
  double a,b,c,r,x,y;
  for(int i = 0;i < n;i++){

    
    double x1,y1,x2,y2,x3,y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

    x=(y1-y3)*(y1*y1-y2*y2+x1*x1-x2*x2)-(y1-y2)*(y1*y1-y3*y3+x1*x1-x3*x3);
    x/=(2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3));

    y=(x1-x3)*(x1*x1-x2*x2+y1*y1-y2*y2)-(x1-x2)*(x1*x1-x3*x3+y1*y1-y3*y3);
    y/=(2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3));

    a=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
    b=(x3-x2)*(x3-x2)+(y3-y2)*(y3-y2);
    c=(x1-x3)*(x1-x3)+(y1-y3)*(y1-y3);
    a=sqrt(a);
    b=sqrt(b);
    c=sqrt(c);
    r=a*b*c/sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));

    printf("%.3f %.3f %.3f\n",x,y,r);    

  }


  return 0;
}



Measured memory_bytes: 3072
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>

using namespace std;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || c > '9') break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

void ctsm(const int &tmp, long long int &sm, long long int &ct)
{
    // 正から負へ反転させる 正⇒負(-1)
    if ((0LL <= sm + tmp) && (0LL < sm))
    {
        ct += 1LL + sm + tmp;
        sm = -1LL;
    }
    // 負から正へ反転させる 負⇒正(1)
    else if ((sm + tmp <= 0LL) && (sm < 0LL))
    {
        ct += 1LL - sm - tmp;
        sm = 1LL;
    }
    // 反転させる必要がない
    else sm = sm + tmp;
}

int main()
{
    int n;
    gc(n);

    int tmp;

    gc(tmp);

    long long int sm = 0LL;
    long long int ct = 0LL;

    // 第1項目の符号の符号通りの場合
    sm = 0 == tmp ? 1LL : sm + tmp;
    ct = 0 == tmp ? 1LL : ct;

    // opposite 第1項目目の反対の符号
    tmp = (-1) * tmp;

    long long opsm = 0LL;
    long long opct = 0LL;

    // 第1項目の符号の正負逆の場合
    // 反転させたものが正なら元は負 負⇒正(1)
    // 反転させたものが負なら元は正 正⇒負(-1)
    opsm = 0 == tmp ? -1LL : 0 < tmp ? 1LL : -1LL;
    // 操作回数
    // 負⇒正(1)
    // 正⇒負(-1)
    opct += abs(tmp) + 1LL;

    for (int i = 1; i < n; i++)
    {
        gc(tmp);

        // count sum
        ctsm(tmp, sm, ct);
        // opposite count sum
        ctsm(tmp, opsm, opct);
    }

    printf("%lld\n", ct < opct ? ct : opct);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
    	Scanner s = new Scanner(System.in);
      	int inputNumber = s.nextInt();
      	int digits = String.valueOf(inputNumber).length();
      	int ans = 0;
      	int size = inputNumber;

		int cnt = 0;
      	for (int i = 0; i < size; i++) {
        	if (String.valueOf(inputNumber).length() % 2 == 1) {
            	ans++;
            }
          inputNumber--;
        }
      
		System.out.println(ans);
    }
}

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

int main(){
    while(1){
        int H,W;
        cin>>H>>W;
        if(H==0 && W==0) break;
        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<<".";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
	int n,k;
	cin >> n >> k;
	vector<int>a(n);
	for(int i=0;i<n;i++){
	    cin >> a.at(i);
	}
	sort(a.begin(),a.end());
	ll ans = 0;
	for(int i=0;i<k;i++){
	    ans+=a.at(i);
	}
	cout << ans <<endl;
}
    



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

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

    if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R'){
        cout << 3 << endl;
    }
    else if (s[0] == 'R' && s[1] == 'R'){
        cout << 2 << endl;
    }
    else if (s[1] == 'R' && s[2] == 'R'){
        cout << 2 << endl;
    }
    else if (s[0] == 'S' && s[1] == 'S' && s[2] == 'S'){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 3608
W = input()

w_list = {}

for w in W:
	if w in w_list:
		w_list[w] += 1
	else:
		w_list[w] = 1

ans = 'Yes'

for w in w_list:
	if(w_list[w] % 2 != 0):
		ans = 'No'
		break

print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<pii> a(n);
	rep(i,n) cin >> a.at(i).second >> a.at(i).first;
	sort(a.rbegin(),a.rend());
	map<int,bool> m;
	priority_queue<int,vector<int>,greater<int>> pq;
	ll sum=0,type=0;
	vector<ll> ans(n+1);
	rep(i,n){
		if(i<k){
			if(m[a.at(i).second]){
				sum+=a.at(i).first;
				pq.push(a.at(i).first);
				ans[type]=sum;
			}
			else{
				sum+=a.at(i).first-type*type;
				type++;
				sum+=type*type;
				m[a.at(i).second]=true;
				ans[type]=sum;
			}
		}
		else{
			if(!m[a.at(i).second] && !pq.empty()){
				sum-=pq.top()+type*type;
				type++;
				sum+=a.at(i).first+type*type;
				ans[type]=sum;
				pq.pop();
				m[a.at(i).second]=true;
			}
			else ans[type]=sum;
		}
	}
	ll res=0;
	rep(i,n+1) res=max(res,ans[i]);
	cout << res << endl;
}

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

int main() {
	string a,b;
    cin>>a>>b;
    if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0]){
        cout<<"YES";
    }
    else 
    cout<<"NO";
	return 0;
}

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

int N,c2n[40],nf[15],p,len[15];
char S[15][15],ch[15];

int s2i(char *s)
{
	int res=c2n[s[0]-'A'],i;
	if(strlen(s)>1&&res==0)return -1;
	for(i=1;s[i];i++)
	{
		res*=10;
		res+=c2n[s[i]-'A'];
	}
	return res;
}

int check()
{
	int p=len[N-1],i,j,c,t;
	char *a=S[N-1];
	if(len[N-1]!=0&&c2n[S[N-1][0]-'A']==0)return -1;
	for(i=c=0;p>=0&&c2n[a[p]-'A']!=-1;p--,i++)
	{
		for(j=t=0;j<N-1;j++)
			if(len[j]>=i)
			{
				if(len[j]!=0&&c2n[S[j][0]-'A']==0)return-1;
				if(c2n[S[j][len[j]-i]-'A']==-1)return 0;
				t+=c2n[S[j][len[j]-i]-'A'];
			}
		if((t+c)%10!=c2n[a[p]-'A'])
			return -1;
		c=(t+c)/10;
	}
	return p<0&&c==0?1:0;
}

int dfs(int d)
{
	int res=0,tmp;
	tmp=check();
	if(tmp==1)
	{
		return 1;
	}
	if(tmp==-1)
		return 0;
	int t=0;
	for(int i=0;i<10;i++)
	{
		if(nf[i]==0)
		{
			nf[i]=1;
			c2n[ch[d]-'A']=i;
			res+=dfs(d+1);
			c2n[ch[d]-'A']=-1;
			nf[i]=0;
		}
	}
	return res;
}

int main()
{
	int i,j,k;
	for(;scanf("%d\n",&N),N;)
	{
		p=0;
		memset(ch,0,sizeof(ch));
		memset(c2n,-1,sizeof(c2n));
		memset(nf,0,sizeof(nf));
		for(i=0;i<N;i++)
		{
			gets(S[i]);
			len[i]=strlen(S[i])-1;
		}
		for(i=0;i<N;i++)if(len[i]>len[N-1])break;
		if(i!=N)
		{
			puts("0");
			continue;
		}
		for(i=0;i<10;i++)
			for(j=0;j<N;j++)
			{
				if(len[j]>=i)
				{
					for(k=0;k<p;k++)
						if(ch[k]==S[j][len[j]-i])break;
					if(k==p)
						ch[p++]=S[j][len[j]-i];
				}
			}
			
		printf("%d\n",dfs(0));
	}
	return 0;
}

Measured memory_bytes: 1048
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]

ans = -float('inf')

for i in range(1, 2**10):
  c = [0] * N
  for j in range(10):
    if i>>j & 1:
      for k in range(N):
        c[k] += F[k][j]
  profit = sum([P[k][c[k]] for k in range(N)])
  ans = max(ans, profit)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+1;
const int INF=1e9+7;
int d[maxn];
int d2[maxn];
int par[maxn];
vector<int> g[maxn];
int dfs(int v,int p){
    int sum=1;
    for(int to:g[v]){
        if (to!=p){
            sum+=dfs(to,v);
        }
    }
    return sum;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=1; i<n; ++i){
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    set<pair<int,int>> s;
    for(int i=1; i<=n; ++i)
        d[i]=INF;
    d[1]=0;
    s.insert({d[1],1});
    while(!s.empty()){
        int v=s.begin()->second;
        s.erase(s.begin());
        for(int to:g[v]){
            if (d[to]>d[v]+1){
                s.erase({d[to],to});
                par[to]=v;
                d[to]=d[v]+1;
                s.insert({d[to],to});
            }
        }
    }
    for(int i=1; i<=n; ++i)
        d2[i]=INF;
    d2[n]=0;
    s.insert({d2[n],n});
    while(!s.empty()){
        int v=s.begin()->second;
        s.erase(s.begin());
        for(int to:g[v]){
            if (d2[to]>d2[v]+1){
                s.erase({d2[to],to});
                d2[to]=d2[v]+1;
                s.insert({d2[to],to});
            }
        }
    }
    vector<int> path;
    int v=par[n];
    path.push_back(n);
    while(v){
        path.push_back(v);
        v=par[v];
    }
    reverse(path.begin(),path.end());
    int ans1=0;
    int ans2=0;
    for(int to:g[1]){
        if (to!=path[1])
            ans1+=dfs(to,1);
    }
    for(int to:g[n]){
        if (to!=path[(int)path.size()-2])
            ans2+=dfs(to,n);
    }
    for(int i=1; i<(int)path.size()-1; ++i){
        int v=path[i];
        int v1=path[i-1];
        int v2=path[i+1];
        int sum=0;
        for(int to:g[v]){
            if (to!=v1 && to!=v2)
                sum+=dfs(to,v);
        }
        if (d[v]<=d2[v])
            ans1+=sum+1;
        else
            ans2+=sum+1;
    }
    if (ans1>ans2)
        cout<<"Fennec";
    else
        cout<<"Snuke";
}


Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
char s[10010];
int main(){   
    gets(s+1);
    for(int i=1;s[i]!='\0';i++){
        if(s[i]=='A'&&s[i+1]=='C'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int a = 2, n, p, h = 0, ans = 1;
	cin >> n >> p;
	if (n == 1) {
		cout << p << endl;
		return 0;
	}
	while (p >= a * a) {
		if (prime(a) == 0) {
			goto skip;
		}
		h = 0;
		while (p % a == 0) {
			p /= a;
			h++;
		}
		while (h >= n) {
			ans *= a;
			h -= n;
		}
	skip:
		a++;
	}
	cout << ans << endl;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long N, std::vector<long long> X){

    vector<lli> v(N);
    REP(i,0,N)v[i] = X[i];
    SORT(v);

    REP(i,0,N){
        
        lli center = ((N+1)/2-1);
        if(X[i]<=v[center])center++;
        cout<<v[center]<<endl;
    }

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
    }
    func(N, std::move(X));
    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdio.h>
#include <set>
#include <vector>
using namespace std;


int main(){
    int w, h, x, y;
    cin>>w>>h>>x>>y;

    if(2*x == w && 2*y == h){
        printf("%.10f 1", (double)w*h/2, 1);
    }

    else{
        printf("%.10f 0", (double)w*h/2, 0);
    }
    return 0;

}

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

int main() {
    int a, b, il_a = 1, il_b = 1, suma_a = 0, suma_b = 0;
    cin >> a >> b;
    for(int i=1; i<b; i++) {
        il_a *= 10;
    }
    for(int i=1; i<a; i++) {
        il_b *= 10;
    }
    for(int i=1; i<=b; i++) {
        suma_a += il_a*a;
        il_a /= 10;
    }
    for(int i=1; i<=a; i++) {
        suma_b += il_b*b;
        il_b /= 10;
    }
    if(suma_a > suma_b) {
        cout << suma_a;
    } else {
        cout << suma_b;
    }
    return 0;
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li a[5];

    li ans=0;

    f(i,0,4)
    {
        cin>>a[i];

        if(a[i]==0)
            ans=i+1;
    }

    cout<<ans;
}

int main()
{    
   

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

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int N;
vector<uint32_t> A;
int a;
int c = 0;
int main()
{
    scanf("%d", &N);
    while (N--) {
        scanf("%d", &a);
        A.push_back(a);
    }
    sort(A.begin(), A.end());
    uint32_t i = 1, prev = A[0], count = 1;
    A.push_back(0);
    while (i<A.size()) {
        if (A[i] != prev) {
            if (count % 2 == 1) {
                c++;
            }
            count = 1;
            prev = A[i];
        } else {
            count++;
        }
        i++;
    }
    cout << c << endl;
}


Measured memory_bytes: 892
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

#define rep(i, n) for (long long i = 0; i < n; i++)

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    ini(N);

    vll c(100001, 0);
    rep(i, N) {
        ini(A);
        c[A]++;
    } 

    rep(i, 100001) {
      if (c[i] <= 2)
        continue;

      if (c[i] % 2 == 1)
        c[i] = 1;
      else
        c[i] = 2;
    }

    ll ret = count_if(c.begin(), c.end(), [](auto x) { return x != 0; });
    if (count(c.begin(), c.end(), 2) % 2 == 1)
        out(ret - 1);
    else
        out(ret);
}


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

int main() {
  cout << setprecision(15);
  string s;
  cin >> s;
  ll ans = 0; 
  int max = pow(2, s.size() - 1);
  for (int i = 0; i < max; ++i) {
    int mask = 1;
    int prev_pos = 0;
    for (int j = 1; j <= s.size() - 1; j++) {
      if (i & mask) {
        ll num = stoll(s.substr(prev_pos, j - prev_pos)); 
        ans += num;
        prev_pos = j;    
      }
      mask <<= 1;
    }
    ll num = stoll(s.substr(prev_pos));
    ans += num;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"container/heap"
)

type State struct {
	Puzzle []int
	Zero int
	Prev int
	Turn int
	Dis int
	Cost int
}

type PriorityQueue []*State

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].Cost < pq[j].Cost
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *PriorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.(*State))
}

func (pq *PriorityQueue) Pop() interface{} {
	n := len(*pq)
	pop := (*pq)[n-1]
	*pq = (*pq)[0:n-1]
	return pop
}

func main() {
	n := 9
	puzzle := make([]int, n)
	var zero int
	for i := 0; i < n; i++ {
		fmt.Scan(&puzzle[i])
		if puzzle[i] == 0 {
			puzzle[i] = n
			zero = i
		}
	}

	turn := 0
	dis := dist(&puzzle)
	if dis == 0 {
		fmt.Println(turn)
		return
	}
	que := PriorityQueue{&State{puzzle, zero, -1, turn, dis, turn + dis}}
	heap.Init(&que)
	dir := []int{-3,-1,1,3}
	for que.Len() > 0 {
		pop := heap.Pop(&que).(*State)
		for i := 0; i < len(dir); i++ {
			next := (*pop).Zero + dir[i]
			if next == (*pop).Prev {
				continue
			}
			if next < 0 || n <= next {
				continue
			}
			if (next%3 - (*pop).Zero%3) * dir[i] < 0 {
				continue
			}
			
			p := make([]int, n)
			copy(p, (*pop).Puzzle)
			p[next], p[(*pop).Zero] = p[(*pop).Zero], p[next]
			turn = (*pop).Turn + 1
			dis = dist(&p)
			if dis == 0 {
				fmt.Println(turn)
				return
			}
			
			heap.Push(&que, &State{p, next, (*pop).Zero, turn, dis, turn + dis})
		}
	}
}

func dist(p *[]int) int {
	sum := 0
	n := len(*p)
	for i := 0; i < n; i++ {
		v := (*p)[i] - 1
		sum += abs(v/3 - i/3)
		sum += abs(v%3 - i%3)
	}
	return sum / 2
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}



Measured memory_bytes: 104160
#include <bits/stdc++.h>
using namespace std;
const int N =2e5+5;
int a[N];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=__gcd(ans,a[i]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


int main(){
    long long a,b,c; cin >> a >> b >> c;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) cout << 0 << endl;
    else cout << min(a*b, min(b*c, c*a)) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"

vector<long long int>sizes;
vector<vector<int>>edges;
int dfs(const int now) {
	long long int num = sizes[now];
	for (auto e : edges[now]) {
		num += dfs(e);
	}
	return sizes[now] = num;
}
long long int dfs2(const int now) {
	vector<long long >v;
	long long int ans = 0;
	for (auto e : edges[now]) {
		v.emplace_back(sizes[e]);
	}
	sort(v.begin(), v.end());
	int sum = 0;
	for (int i = 0; i < v.size(); ++i) {
		ans += sum;
		sum += v[i];
	}
	return ans;
}
int main() {
	int N; cin >> N;
	edges.resize(N);
	sizes.resize(N);
	vector<int>roots;
	vector<int>nums(N);
	vector<vector<int>>revedges(N);
	for (int i = 0; i < N; ++i) {
		int M, L; cin >> M >> L;
		sizes[i] = M;
		if (L != -1) {
			edges[L].push_back(i);
			revedges[i].push_back(L);
			nums[L]++;
		}
		else {
			roots.emplace_back(i);
		}
	}
	queue<int>que;
	for (int i = 0; i < nums.size(); ++i) {
		if (!nums[i])que.push(i);
	}
	while (!que.empty()) {
		const int now = que.front();
		que.pop();
		long long int num = sizes[now];
		for (auto e : edges[now]) {
			num += sizes[e];
		}
		for (auto re : revedges[now]) {
			nums[re]--;
			if (!nums[re])que.push(re);
		}
		sizes[now] = num;
	}
	long long int ans = 0;
	
	for (int i = 0; i < N;++i) {

		ans += dfs2(i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 123884
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();

            x -= a;
            out.println(x % b);
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
const int INF = 1e9;
const int MOD = 1000000007;

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;
        vector<int> s(n);
        rep(i,n) cin >> s[i];
        int mx = 0,mn = INF,sum = 0;
        rep(i,n){
            sum += s[i];
            mn = min(mn,s[i]);
            mx = max(mx,s[i]);
        }
        cout << (sum-mn-mx)/(n-2) << endl;
    }
    return 0;
}


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

bool is_all_even(vector<int> a)
{
    for (auto e : a)
    {
        if (e % 2 == 1)
            return false;
    }
    return true;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a.at(i);
    int answer = 0;
    while (is_all_even(a))
    {
        answer++;
        for (int i = 0; i < n; i++)
            a.at(i) /= 2;
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;

const int MAXN = 1e2+3; //AREGLAAAAAAAAR!!!!
int memo[MAXN][MAXN][MAXN];

int dp(int a,int b,int c){
	if(memo[a][b][c]!=-1) return memo[a][b][c]; 
	if(a==b && b==c) return 0;
	if(a>100 || b>100 || c>100) return 1e8;
	memo[a][b][c]=min(dp(a+1,b+1,c)+1,min(dp(a+1,b,c+1)+1,min(dp(a,b+1,c+1)+1,min(dp(a+2,b,c)+1,min(dp(a,b+2,c)+1,dp(a,b,c+2)+1)))));
	return memo[a][b][c];
}

int main(){
	int a,b,c;
	riii(a,b,c);
	ms(memo,-1);
	int ans=dp(a,b,c);
	printf("%d\n",ans);
}


Measured memory_bytes: 4480
import math
import fractions
from functools import reduce
 
n, m = map(int, input().split())
a = list(map(int, input().split()))
a=[t//2 for t in a] # リストの要素を全て2で割る
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
def lcm_list(numbers): # 最小公倍数を求める
    return reduce(lcm_base, numbers, 1)
 
def num_dev2(x): # 2で割り切れる回数をカウント
    return format(x, 'b')[::-1].find('1')
 
lcm = lcm_list(a)
q = m // lcm # mは最小公倍数で何回割れるか
 
count = 0
dev2 = num_dev2(a[0])
for i in range(1, n):
    if dev2 != num_dev2(a[i]): # リストの全ての要素の、2で割れる回数は等しいか？
        count += 1
        break
if count != 0:
    print(0)
else:
    print(math.ceil(q/2))

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r; cin>>r;
    cout<<setp(12);
    cout<<(double)r*2*M_PI<<endl;
    return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n;
    cin >> n;
    set<ll> m;
    ll sq = sqrt(n);

    repd(i, 2, sq + 1) {
        if (n % i == 0) {
            m.insert(i);
            m.insert(n / i);
        }
        if ((n - 1) % i == 0) {
            m.insert(i);
            m.insert((n - 1) / i);
        }
    }

    m.insert(n - 1);
    m.insert(n);
    ll ans = 0;
    for (auto iter = m.begin(); iter != m.end(); iter++) {
        ll num = *iter;
        if (num == 1) {
            continue;
        }
        ll temp = n;
        while (temp > 0) {
            if (temp % num == 0) {
                temp /= num;
            } else {
                temp %= num;
            }

            if (temp == 1) {
                ans++;
                break;
            } else if (temp < num) {
                if (temp < num) {
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <map>
//#include <set>
//#include <list>
//#include <cmath>
//#include <ctime>
//#include <deque>
//#include <queue>
//#include <stack>
//#include <string>
//#include <bitset>
//#include <cstdio>
//#include <limits>
//#include <vector>
//#include <climits>
//#include <cstring>
//#include <cstdlib>
//#include <fstream>
//#include <numeric>
//#include <sstream>
//#include <iomanip>
//#include <iostream>
//#include <algorithm>
//#include <unordered_map>

using namespace std;

#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.141592653589793238462643383279502884
#define MAX 200010
#define mod 1000000007
#define EPS 1E-9
#define int long long
#define endl "\n"

int fix(int cur, int m)
{
    return ((cur%m) + m) % m;
}

int fast_power(int x, int y,int m)
{
    if (y == 0)
        return 1;
    int temp = fast_power(x, y / 2, m) ;
    temp = (temp*temp)% m;
    if (y % 2 != 0)
        temp = (temp*x)% m;
    return temp;

}


int32_t main()
{
    //freopen("C:/Users/Joe/Desktop/tests/in11.txt", "r", stdin);
    //freopen("C:/Users/Joe/Desktop/tests/out11.txt", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.tie(0);

    int t=1;
    //cin >> t;
    while(t--)
    {
        int a,b;
        cin >> a >> b;
        int d=0,cnt=0;
        for(int i=0;i<a;i++)
        {
            int x;
            cin >> x;
            if(d<=b)
                cnt++;
            d=d+x;
        }
        if(d<=b)
            cnt++;
        cout << cnt << endl;

    }
    return 0;
}


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

int main() {
  int K, A, B; cin >> K >> A >> B;
  for (int i=A; i<=B; i++) {
    if (i%K==0) {
      cout << "OK" << endl;
      break;
    }
    if (i==B) cout << "NG" << endl;
  }
}

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

int main(){
    int N;
    cin >> N ;
    vector<char> color(N);
    for (int i = 0; i < N; i++){
        cin>>color.at(i);
    }
    bool flag=false ;
    for (int i = 0; i < N; i++){
    if(color.at(i)=='Y')
    flag = true;
    }
    
    if(flag)
    cout<<"Four"<<endl;
   
    else
    cout<<"Three"<<endl;
    
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a,b;
	b=n/2;
	if(n%2)
		a=(n/2)+1;
	else
		a=n/2;
	cout<<a*b;	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define repm(i, m, n) for (int i = (m); i < (n); i++)
#define rep_rev(i, n) for (int i = int (n); i >= 0; i--)
typedef long long int lli;
using namespace std;

int main() {
	string s;
	cin >> s;

	bool flag = false;
	for (int i = 0; i < s.size(); i += 2) {
		if (s[i] == 'L') { flag = true; break; }
	}
	for (int i = 1; i < s.size(); i += 2) {
		if (s[i] == 'R') { flag = true; break; }
	}
	if (flag)cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back

using namespace std;

int a,b;

int main()
{
    cin >> a >> b;
    if (a!=1&&b!=1)cout << 1 << endl;
    if (a!=2&&b!=2)cout << 2 << endl;
    if (a!=3&&b!=3)cout << 3 << endl;
}


Measured memory_bytes: 256
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int cnt[N];
const int M = 101;

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   f(i,1,M){
      f(j,1,M){
         f(k,1,M){
            int v = i*i+j*j+k*k+i*j+j*k+k*i;
            if(v <= n){
               cnt[v]++;
            }
         }
      }
   }
   f(i,1,n+1){
      cout << cnt[i] << '\n';
   }
   return 0;
} 


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

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

int i,j;

int main(void){
    
    int  n;
    cin >> n;
    vector<int> a;
    FOR(i,n){
        int o;
        cin>>o;
        a.push_back(o);
    }
    
    int nw=0,cnt=0;
    
    for(;;){
        
        if(nw==1){
            cout<<cnt;
            return 0;
        }
        if(cnt>n){
            cout<<-1;
            return 0;
        }
        cnt++;
        nw=a[nw]-1;
    }
    
    
    
    return 0;
    
}


Measured memory_bytes: 892