akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<math.h>
long long int a,s,d[1000001],f,g[10000001],h[1000001];
int main(void)
{
	int j,i,k;
	for(i=0;i<1000001;i++){
		h[i]=0;
		g[i]=0;
	}
	for(i=2;i*i<=1000000;i++){
		if(h[i]==0){
			for(j=2;j<=500000;j++){
				if(i*j>1000000) break;
				h[i*j]=1;
			}
		}
	}
	while(1){
		scanf("%d %d",&a,&s);
		f=0;
		if(a==0&&s==0) break;
		for(i=0;i<1000001;i++) g[i]=0;
		for(i=0;i<a;i++){
			scanf("%d",&d[i]);
			g[d[i]]=1;
		}
		for(i=0;i<=s;i++){
			if(g[i]==1){
				for(j=0;j<a;j++){
					if(i+d[j]<=s) g[i+d[j]]=1;
				}
			}
		}
		for(i=s;i>1;i--){
			if(h[i]==0&&g[i]==1){
				f=i;
				break;
			}
		}
		if(f==0) printf("NA\n");
		else printf("%d\n",f);
	}
	return 0;
}

Measured memory_bytes: 18280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n;
  ll a[200001]={};
  ll ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  if(a[0]!=0){
    cout<<-1<<endl;
    return 0;
  }
  for(int i=1;i<n;i++){
    if(a[i-1]+1<a[i]){
      ans=-1;break;
    }
    if(a[i-1]+1==a[i]){
      ans+=1;
    }
    else{
      ans+=a[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
n = input()

if len(n) == 1:
    print(n)
elif len(n) == 2:
    print(9)
elif len(n) == 3:
    print(int(n)+10-100)
elif len(n) == 4:
    print(909)
elif len(n) == 5:
    print(int(n)+910-10000)
elif len(n) == 6:
    print(90909)


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B;
  cin >> A >> B;
  cout << (A <= 8 && B <= 8 ? "Yay!" : ":(") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum,t;

char s[N];

int main()
{
	fast;
	cin>>n;
	cin>>s+1;
	if(n%2==1)
		return cout<<"No",0;
	fo(i,1,n/2)
	if(s[i]!=s[i+n/2])
		return cout<<"No",0;
	cout<<"Yes";
}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 256
#include <stdio.h>
#define N 500000
#define inf 2000000000

int cnt;
int L[N/2+2],R[N/2+2];

void merge(int A[],int n,int left,int mid,int right)
{
  int i,j,k,n1, n2;
  n1 = mid - left ;
  n2 = right - mid;
  for(i=0;i<n1;i++)
    L[i] = A[left + i];
  for(i=0;i<n2;i++)
    R[i] = A[mid + i];
  L[n1] = inf;
  R[n2] = inf;
  i = 0;
  j = 0;
  for(k=left;k<right;k++)
    {
      cnt++;
      if(L[i] <= R[j])
        {
          A[k] = L[i++];
        }
      else
        {
          A[k] = R[j++];
        }
    }
}
void mergeSort(int A[],int n,int left,int right)
{
  int mid;
  if(left+1 < right)
  {
    mid = (left + right)/2;
     mergeSort(A,n,left,mid);
     mergeSort(A,n,mid,right);
     merge(A,n,left,mid,right);
  }
}

int main()
{
  int n,A[N],i;
  cnt = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%d",&A[i]);
  }
  mergeSort(A,n,0,n);
  for(i=0;i<n;i++)
  {
    if(i)
    {
      printf(" ");
    }
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 5632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] str = br.readLine().split(" ");
		long a = Long.parseLong(str[0]);
		long b = Long.parseLong(str[1]);
		long c = Long.parseLong(str[2]);
		if(a%2==0 || b%2==0 || c%2==0){
			sb.append(0);
			System.out.println(sb);
			return;
		}
		long min1 = Math.min(a,b);
		long min2 = Math.min(c,Math.max(a,b));
		sb.append(min1*min2);
		System.out.println(sb);
	}
}

Measured memory_bytes: 8020
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
  int n,m;
  cin >> n >> m;
  VI a(n);
  int p = 0;
  rep(i,n) {
    cin >> a[i];
    p += a[i];
  }
  int cnt = 0;
  rep(i,n) {
    if(a[i] >= p*1.0/(4.0*m)) cnt++;
    // cout << 1.0/(4.0*m) << endl;
  }
  if(cnt>=m) cout << "Yes" << endl;
  else cout << "No" <<endl;

    
}


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

using namespace std;

#define int long long

signed main()
{
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    vector<pair<int, int>> b;
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i];
        b.push_back(make_pair(k - a[i], i));
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    vector<int> c(n);
    vector<int> ind(n);
    for(int i = 0; i < n; ++i)
    {
        ind[b[i].second] = i;
        c[i] = b[i].first;
    }
    int ans = 1e9;
    for(int i = 0; i < n; ++i)
    {
        int curr = 0;
        int x = 0;
        if (i != 0)
        {
            x = a[i - 1] - a[0];
        }
        int y = 0;
        curr = a[n - 1] - a[i] + (k - a[n - 1] + a[0]) * (i != 0) + x;
        int j = ind[i];
        if (j != 0)
        {
            y = + c[j - 1] - c[0];
        }
        curr = min(curr, c[n - 1] - c[j] + ((k - c[n - 1]) + c[0]) * (j != 0) + y);
        ans = min(ans, curr);
    }
    cout << ans;
}

Measured memory_bytes: 9068
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        int a = 0;
        int count = 0;
        for(int i = 0; i < n; i++){
            a = scan.nextInt();
            if(a >= k){count++;}
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 48920
from collections import Counter

n=int(input())
v=list(map(int,input().split()))

v1=[]
v2=[]

for i in range(n):
  if i%2==0:
    v1.append(v[i])
  else:
    v2.append(v[i])

v1c = Counter(v1).most_common()
v2c = Counter(v2).most_common()

ans2=float("inf")
ans3=float("inf")
ans4=float("inf")


if v1c[0][0]!=v2c[0][0]:
  ans=len(v1)-v1c[0][1]+len(v2)-v2c[0][1]
  print(ans)

else:
  if len(v1c) !=1:
    ans2=len(v1)-v1c[1][1]+len(v2)-v2c[0][1]
  if len(v2c) !=1:
    ans3=len(v1)-v1c[0][1]+len(v2)-v2c[1][1]
  else:
    ans4=min(len(v1),len(v2))
  print(min(ans2,ans3,ans4))
 
  

Measured memory_bytes: 21212
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;}
  else{
    cout << "consonant" << endl;}
}

Measured memory_bytes: 256
// eddy1021
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009ll
#define mod7 1000000007ll
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline ll getint(){
  ll _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline ll add( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x + _y;
  if( _ >= _mod ) _ -= _mod;
  return _;
}
inline ll sub( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x - _y;
  if( _ < 0 ) _ += _mod;
  return _;
}
inline ll mul( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x * _y;
  if( _ >= _mod ) _ %= _mod;
  return _;
}
ll mypow( ll _a , ll _x , ll _mod ){
  if( _x == 0 ) return 1ll;
  ll _tmp = mypow( _a , _x / 2 , _mod );
  _tmp = mul( _tmp , _tmp , _mod );
  if( _x & 1 ) _tmp = mul( _tmp , _a , _mod );
  return _tmp;
}
ll mymul( ll _a , ll _x , ll _mod ){
  if( _x == 0 ) return 0ll;
  ll _tmp = mymul( _a , _x / 2 , _mod );
  _tmp = add( _tmp , _tmp , _mod );
  if( _x & 1 ) _tmp = add( _tmp , _a , _mod );
  return _tmp;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
int __ = 1 , _cs;
/*********default*********/
#define N 404040
void build(){

}
int n , m , mcnt;
map< int , int > M[ N ];
vector< int > v[ N ];
void add_edge( int ui , int vi , int ci ){
  if( M[ ui ].count( ci ) == 0 )
    M[ ui ][ ci ] = mcnt ++;
  v[ M[ ui ][ ci ] ].push_back( vi );
}
void init(){
  n = getint();
  m = getint();
  while( m -- ){
    int pi = getint();
    int qi = getint();
    int ci = getint();
    add_edge( pi , qi , ci );
    add_edge( qi , pi , ci );
  }
}
queue< int > Q;
int dst[ N ] , vst[ N ] , stmp;
bool got[ N ];
vector< int > cand;
void go( int now , int clr ){
  cand.push_back( now );
  vst[ now ] = stmp;
  int id = M[ now ][ clr ];
  for( int nxt : v[ id ] )
    if( vst[ nxt ] != stmp )
      go( nxt , clr );
}
inline void expand( int tn ){
  for( auto it = M[ tn ].begin() ; it != M[ tn ].end() ; it ++ ){
    ++ stmp;
    cand.clear();
    go( tn , it->first );
    for( int i : cand ){
      if( i == tn ) continue;
      if( !got[ i ] ){
        Q.push( i );
        got[ i ] = true;
        dst[ i ] = dst[ tn ] + 1;
      }
      M[ i ].erase( it->first );
    }
  }
}
void solve(){
  Q.push( n );
  dst[ n ] = 0;
  got[ n ] = true;
  while( Q.size() ){
    int tn = Q.front(); Q.pop();
    expand( tn );
  }
  printf( "%d\n" , got[ 1 ] ? dst[ 1 ] : -1 );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 60928
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Sun Jan 20 21:00:50 2019
//
package main

import "fmt"

func makeArr(s int) []int {
	arr := []int{s}
	for s != 1 {
		if s%2 == 0 {
			s /= 2
		} else {
			s = 3*s + 1
		}
		arr = append(arr, s)
	}

	arr = append(arr, 4)
	return arr
}

func main() {
	var s int
	fmt.Scan(&s)

	if s == 1 {
		fmt.Println(4)
		return
	} else if s == 2 {
		fmt.Println(4)
	}

	arr := makeArr(s)
	for i := range arr {
		for j := i + 1; j < len(arr); j++ {
			if arr[i] == arr[j] {
				fmt.Println(j + 1)
				return
			}
		}
	}
}


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

// using mint = modint1000000007;
// using mint = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    Int k;
    cin >> k;
    for (Int i = 0; i < k; i++) {
        cout << "ACL";
    } cout << endl;
}

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


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front

// #define fisier 1

using namespace std;

typedef long long ll;

const int mod = 1000000007;
const double dancila = 3.14159265359; // PI 
const double eps = 1e-9;

ll dp[2][2020];
int rst[2000002];
int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

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

	string s;
	cin >> s;
	for(int i = 1; i <= 100000; ++i)
		rst[i] = i % 2019;
	dp[0][(s[0] - '0')] = 1;
	ll ans = 0;
	int n = s.size();
	for(int i = 1; i < n; ++i)
	{
		for(int j = 0; j <= 2018; ++j)
		{
			int nxt = rst[j * 10 + (s[i] - '0')];
			dp[1][nxt] += dp[0][j];
		}
		ans += dp[1][0];
		memcpy(dp[0], dp[1], sizeof(dp[1]));
		dp[0][(s[i] - '0')]++;
		memset(dp[1], 0, sizeof(dp[1]));
	}
	cout << ans;
    return 0;
}


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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = (int) 1e5 + 10;
int n;
vector<int> adj[MAXN];

int DFS(int u, int T, int par = -1) {
    vector<int> a;
    for (int i = 0; i < (int) adj[u].size(); ++i) {
        int v = adj[u][i];
        if (v != par) a.push_back(DFS(v, T, u));
    }
    if ((int) a.size() % 2 == 0 && par != -1) a.push_back(0);
    sort(a.begin(), a.end());

    if ((int) a.size() % 2 == 0) {
        for (int i = 0; i < (int) a.size(); ++i)
            if (a[i] + a[(int) a.size() - i - 1] > T) return T + 3;
        return 0;
    }

    int l = 0, r = (int) a.size() - 1, f = -1;
    while (l <= r) {
        int mid = (l + r) >> 1;
        vector<int> b;
        for (int i = 0; i < (int) a.size(); ++i)
            if (i != mid) b.push_back(a[i]);
        bool check = true;
        for (int i = 0; i < (int) b.size() / 2; ++i) {
            if (b[i] + b[(int) b.size() - i - 1] > T) {
                check = false;
                break;
            }
        }
        if (check) {
            f = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    if (f == -1) {
        // printf("#%d: %d\n", u, T + 3);
        return T + 3;
    }
    // printf("#%d: %d\n", u, a[f] + 1);
    return a[f] + 1;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n - 1; ++i) {
        int u, v; scanf("%d%d", &u, &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    int l = 1, r = n, f = -1;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (DFS(1, mid) <= mid + 1) {
            f = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }

    int cnt = 0;
    for (int i = 1; i <= n; ++i) cnt += (int) adj[i].size() % 2;

    printf("%d %d\n", cnt / 2, f);
    return 0;
}

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

unordered_map<ll, ll> minvmap;
ll minv(ll a, ll m) {
  auto k = a; auto p = minvmap[a]; if (p != 0) return p;
  ll b = m, u = 1, v = 0;
  while (b) { ll t = a/b; swap(a -= t*b, b); swap(u -= t*v, v); }
  p = (u%m+m)%m; minvmap[k] = p; return p;
}
struct mint {
    ll x;
    mint():x(0){}
    mint(ll x):x((x%mod+mod)%mod){}
    mint& fix() { x = (x%mod+mod)%mod; return *this;}
    mint operator-() const { return mint(0) - *this;}
    mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
    mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
    mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
    mint& operator/=(const mint& a){ (x*=minv(a.x, mod))%=mod; return *this; }
    mint operator+(const mint& a)const{ return mint(*this) += a;}
    mint operator-(const mint& a)const{ return mint(*this) -= a;}
    mint operator*(const mint& a)const{ return mint(*this) *= a;}
    mint operator/(const mint& a)const{ return mint(*this) /= a;}
    bool operator<(const mint& a)const{ return x < a.x;}
    bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}

mint mod_pow(mint a, long long x) {
  mint res = 1;
  while(x > 0) {
    if (x & 1) res *= a;
    a *= a; x >>= 1;
  }
  return res;
}

int MAXN = 200000;
vector<mint> fact(MAXN+1);

void init() {
  fact[0] = 1;
  for(int i=1; i<=MAXN; i++) fact[i] = fact[i-1]*3;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string s; cin >> s;
  int n = s.size();
  init();

  mint ans = 0;
  mint now = 1;
  rep(i, n) {
    if (s[i] == '1') {
      ans += now*fact[n-i-1];
      now *= 2;
    } else {
    }
  }
  ans += now;
  cout << ans << endl;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int solve(vi &a, int n, int k)
{
	int dp[n + 1] ={0}; 

	dp[0] = 0;
	dp[1] = 0;
	for(int i=2; i<=n; ++i)
	{
		dp[i] = inf;
		for(int j = 1; j<=k; ++j)
		{
			if(i > j)
			{
				int op = abs(a[i] - a[i - j]) + dp[i - j];
				dp[i] = min(dp[i], op);
			}
		}
	}

	return dp[n];
}
int32_t main()
{
	FIO;
	int n, k; cin >> n >> k;

	vi a(n + 1);
	for(int i=1; i<=n; ++i)
		cin >> a[i];

	cout << solve(a, n, k) << '\n';
	return 0;
}

Measured memory_bytes: 4812
#include <iostream>

using namespace std;

#define N 100000
#define Q 50000
#define NF 0

int s[N], t[Q];

int binarySearch(int key, int n)
{
  int left = 0;
  int right = n;

  while(left < right) {
    int mid = (left+right) / 2;
    if(s[mid] == key) return 1; 
    else if(key < s[mid]) right = mid;
    else left = mid + 1;
  } 

  return NF;
}

int main(void)
{
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> s[i];

  int q;
  cin >> q;
  for(int i = 0; i < q; i++) cin >> t[i];

  int count = 0;
  for(int i = 0; i < q; i++) count += binarySearch(t[i], n);

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>

using namespace std;
typedef long long LL;
const int MAXN = 1e2 + 8;

int ans[MAXN][MAXN], a[MAXN*MAXN];

int main()
{
    #ifdef LOCAL
    freopen("b.txt", "r", stdin);
    //freopen("b.out", "w", stdout);
    int T = 4;
    while(T--){
    #endif // LOCAL
    ios::sync_with_stdio(false); cin.tie(0);

    int r, c, n, i, j, ptr = 1, x = 0, y = 0;
    cin >> r >> c >> n;
    for(i = 1; i <= n; i++){
         cin >> a[i];
    }
    for(i = 1; i <= n; i++){
        while(a[i]--){
            ans[x][y] = ptr;
            if(x&1){
                if(y - 1 >= 0){
                    y--;
                }
                else{
                    x++;
                }
            }
            else{
                if(y + 1 < c){
                    y++;
                }
                else{
                    x++;
                }
            }
        }
        ptr++;
    }

    for(i = 0; i < r; i++){
        for(j = 0; j < c; j++){
            if(j) cout << " ";
            cout << ans[i][j];
        }
        cout << "\n";
    }



    #ifdef LOCAL
    cout << endl;
    }
    #endif // LOCAL
    return 0;
}



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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define repl(n) for (int l = 0; l < (n); l++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

int main() {
  string s, t;
  cin >> s >> t;
  int sc[26] = {}, tc[26] = {};
  repv(s) sc[v - 'a']++;
  repv(t) tc[v - 'a']++;
  sort(sc, sc + 26);
  sort(tc, tc + 26);
  repi(26){
    if(sc[i]!=tc[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 776
K=gets.to_i
K<2&&(p 1,1;exit)
p N=(K+3)/4*2
N.times{|i|
	N.times{|j|
		print (i+j)%N+1 + (i%2<1||(i+j)%N+N>=K ? 0 : N)
		print j<N-1 ? " " : "\n"
	}
}

Measured memory_bytes: 2812
#include <stdio.h>

int main(void)
{
  int r, c;

  scanf("%d %d", &r, &c);

  while( !(r == 0 && c == 0) ) {
    if ( r*c % 2 == 0)
      printf("yes\n");
    else 
      printf("no\n");
    scanf("%d %d", &r, &c);

  }

  return 0;

}

Measured memory_bytes: 584
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	/*int a, b;
	cin >> a >> b;
	cout << max({ a + b, a - b, a * b });*/


	int k, x;
	cin >> k >> x;
	rep(i, 2 * k - 1) {
		int ans = x - k + 1 + i;
		if (ans >= -1000000 && ans <= 1000000)cout << ans << " ";
	}

	return 0;
}

Measured memory_bytes: 256
/* ALDS1_2_B: Selection Sort */

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#define N 100

int selectionSrot(int *A, int n);
void swap(int *A, int x, int y);

int main(void){
	int i = 0, j, n, A[N] = {0}, sw;

	scanf("%d", &n);
	while(i < n) scanf("%d", &A[i++]); 
	
	sw = selectionSrot(A, n);

	printf("%d", A[0]);
	for(i = 1; i < n; i++){
		printf(" %d", A[i]);
	}

	printf("\n%d\n", sw);

	return 0;
}

int selectionSrot(int *A, int n){
	int min_id, i, j, sw = 0;

	for(i = 0; i < n - 1; i++){
		min_id = i;
		for(j = i+1; j < n; j++){
			if(A[j] < A[min_id]){
				min_id = j;
			}
		}

		if(min_id != i){
			swap(A, i, min_id);
			sw++;
		}
	}

	return sw;
}

void swap(int *A, int x, int y){
	int temp;
	 
	temp = A[x];
	A[x] =  A[y];
	A[y] = temp;
}


Measured memory_bytes: 1956
n, a, b = map(int, input().split())
hlist = [int(input()) for _ in range(n)]
maxn = (max(hlist) + b - 1) // b

def enough(t):
  c = 0
  for h in hlist:
    if h - b * t > 0:
      c += (h - b * t + a - b - 1) // (a - b)
  return c <= t

l, r = 0, maxn
while l != r:
  mid = (l + r) // 2
  if enough(mid):
    r = mid
  else:
    l = mid + 1
print(l)


Measured memory_bytes: 7072
#include <bits/stdc++.h>
#define pb push_back
#define inf 10e9
#define ll long long
using namespace std;
struct act{
    ll val,w;
};
ll dp[101][100005];
ll solve(vector<act> arr,int n,int weight)
{
    if(weight<0)
    	return INT_MIN;
    	
    if(n==0)
        return 0;
        
    if(dp[n][weight]!=-1)
    	return dp[n][weight];
    	
    dp[n][weight]=max((arr[n].val+solve(arr,n-1,weight-arr[n].w)),solve(arr,n-1,weight));
    
	return dp[n][weight];
}
int main() {
    int n,weight;
    cin>>n>>weight;
    vector<act> arr(n+1);
    for(int i=1;i<=n;i++)
    {
        ll x,y;
        cin>>x>>y;
        
        arr[i].w=x;
        arr[i].val=y;

    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=weight;j++)
        dp[i][j]=-1;
    }
    cout<<solve(arr,n,weight);
}


Measured memory_bytes: 81868
# coding: utf-8

a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())

print(a[K-1])


Measured memory_bytes: 2940
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

class Dinic:
    def __init__(self, v, inf =10**10):
        self.v = v
        self.inf = inf
        self.G = [[] for _ in range(v)]
        self.level = [-1]*v  # 深さ
        self.ite = [0]*v  # DFSでの探索が済んでいるか
    def add_edge(self, fr, to, cap):
        self.G[fr].append([to, cap, len(self.G[to])])
        self.G[to].append([fr, 0, len(self.G[fr])-1])
    def bfs(self, s):  # BFSで深さ決定,sがstart
        self.level = [-1]*self.v  # 必要
        self.level[s] = 0
        Q = deque()
        Q.append(s)
        while Q:
            v = Q.popleft()
            for i in range(len(self.G[v])):
                e = self.G[v][i]
                if e[1]>0 and self.level[e[0]]<0: ###capacity>0かつtoの深さ未定
                    self.level[e[0]] = self.level[v]+1
                    Q.append(e[0])
    def dfs(self, v, t, f):  # DFSで増加パス探索,v開始、t終点、総フローf
        if v==t:
            return f
        for i in range(self.ite[v],len(self.G[v])):
            self.ite[v] = i
            e = self.G[v][i]
            if e[1]>0 and self.level[v]<self.level[e[0]]:
                d = self.dfs(e[0], t, min(f, e[1]))
                if d>0:
                    e[1] -= d  # cap減少
                    self.G[e[0]][e[2]][1] += d  # 逆辺のcap増加
                    return d
        return 0
    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t]<0:
                return flow
            self.ite = [0]*self.v  # DFSでの探索が済んでいるか否か
            f =self.dfs(s,t,self.inf)
            while f>0:
                flow+= f
                f = self.dfs(s,t,self.inf)

H, W = MAP()
a = [list(input()) for _ in range(H)]
D = Dinic(H+W+2)

for i in range(H):
    for j in range(W):
        if a[i][j] == "S":
            sy, sx = i, j
            D.add_edge(0, i+1, INF)
            D.add_edge(0, H+j+1, INF)
        elif a[i][j] == "T":
            gy, gx = i, j
            D.add_edge(i+1, H+W+1, INF)
            D.add_edge(H+j+1, H+W+1, INF)
        elif a[i][j] == "o":
            D.add_edge(i+1, H+j+1, 1)
            D.add_edge(H+j+1, i+1, 1)

if sy == gy or sx == gx:
	print(-1)
	exit()

print(D.max_flow(0, H+W+1))


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

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

using namespace std;

const int MOD=1000000007;

int dp[4][4][4][1000];

int dfs(int i,int j,int k,int n){
	if((i==0 && j==1 && k==2)
	|| (i==0 && j==2 && k==1)
	|| (i==2 && j==0 && k==1)) return 0;

	if(n==0) return 1;

	if(~dp[i][j][k][n]) return dp[i][j][k][n];

	int res=0;
	(res+=dfs(j,k,0,n-1))%=MOD;
	(res+=dfs(j,k,2,n-1))%=MOD;
	(res+=dfs(j,k,3,n-1))%=MOD;
	if(!(i==0 && j==2)
	&& !(i==0 && k==2)) (res+=dfs(j,k,1,n-1))%=MOD;
	return dp[i][j][k][n]=res;
}

int main(){
	memset(dp,-1,sizeof dp);

	int n; cin>>n;

	int ans=0;
	rep(i,4) rep(j,4) rep(k,4) (ans+=dfs(i,j,k,n-3))%=MOD;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 640
using namespace std;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int n, y;
    cin >> n >> y;

    int res1 = -1, res2 = -1, res3 = -1;
    for (int i = 0; i <= n; i++){
        for (int k = 0; k <= n - i; k++){
            int c = n - i - k;
            if (i * 10000 + k * 5000 + 1000 * c == y){
                res1 = i;
                res2 = k;
                res3 = c;
            }
        }
    }
    cout << res1 << ' ' << res2 << ' ' << res3 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
#include<functional>
using namespace std;
int n,k;
string s;
int a[100005];
int sum1[100005],sum2[100005];
vector<int> v;
int ans;
int st1,st2;
int main()
{
	cin>>n>>k;
	cin>>s;
	for(int i=0;i<n;i++)
		a[i]=s[i]-'0';
	int i=0;
	if(a[0]==0)
		v.push_back(0);
	while(i<n)
	{
		int j=0;
		while(a[i]==0&&i<n)
		{
			i++;
			j++;
		}
		if(j!=0)
			v.push_back(j);
		j=0;
		while(a[i]==1&&i<n)
		{
			i++;
			j++;
		}
		if(j!=0)
			v.push_back(j);	
	}
	if(a[n-1]==0)
		v.push_back(0);
	for(int i=1;i<=v.size();i++)
		sum1[i]=sum1[i-1]+v[i-1];
	for(int i=v.size();i>=1;i--)
		sum2[i]=sum2[i+1]+v[i-1];
	int m=v.size();
	int t=min(2*k+1,m);
	for(int i=1;i<=m-t+1;i+=2)
		ans=max(ans,sum1[i+t-1]-sum1[i-1]);
	for(int i=m-t+1;i>=1;i-=2)
		ans=max(ans,sum2[i]-sum2[i+t]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 2040
#include<iostream>
#include <vector>
#include<algorithm>
using namespace std;
#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
LL N, ans;
vector<vector<LL>> abc;
int main() {
	cin >> N;
	REP(i, 3) { abc.push_back(vector<LL>()); REP(j, N) { LL tmp; cin >> tmp; abc[i].push_back(tmp); }sort(abc[i].begin(), abc[i].end()); }
	REP(i, N) ans += (lower_bound(abc[0].begin(), abc[0].end(), abc[1][i]) - abc[0].begin())*(N - (upper_bound(abc[2].begin(), abc[2].end(), abc[1][i]) - abc[2].begin()));
	cout << ans << endl;
	return 0;
}

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

const int NMAX = 1e6 + 5;
int a[NMAX], res, n, freq[NMAX], x;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        x = a[i];
        for(int j = 2; j * j <= x; j++) {
            if(x % j == 0) {
                freq[j]++;
                while(x % j == 0) {
                    x /= j;
                }
            }
        }
        if(x > 1) {
            freq[x]++;
        }
    }
    res = a[1];
    for(int i = 2; i <= n; i++) {
        res = __gcd(res, a[i]);
    }
    if(res > 1) {
        cout << "not coprime\n";
    } else {
        for(int i = 1; i <= 1000000; i++) {
            if(freq[i] > 1) {
                cout << "setwise coprime\n";
                return 0;
            }
        }
        cout << "pairwise coprime\n";
    }
    return 0;
}

Measured memory_bytes: 11336
#include <map>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define mo 1000000007
#define num(x) (x>='0' && x<='9')
typedef unsigned long long ull;
typedef long long ll;
using namespace std::tr1;
using namespace std;
int read(){
    int p=0, q=1;
    char ch=getchar();
    while (!num(ch))
        (ch=='-'?q=-1:0),
        ch=getchar();
    while (num(ch)) p=p*10+ch-'0', ch=getchar();
    return p*q;
}
int power(ll a, int b){
	ll c=1;
	while (b){
		if (b&1) c=c*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return c;
}
#define N 200005
int n, ans;
char s[N];
int main(){
	n=read();
	scanf("%s", s);
	for (int i=0, j=n-1;i<j;){
		while (i<j && s[i]=='R') i++;
		while (i<j && s[j]=='W') j--;
		if (i<j) ans++, i++, j--;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3948
N,M=map(int,input().split())
box=[1]*N
P=[1]+[0]*(N-1)
for i in range(M):
  x,y=map(int,input().split())
  x,y=x-1,y-1
  box[x]-=1
  box[y]+=1
  if P[x]==1:
    P[y]=1
    if box[x]==0:
      P[x]=0
print(sum(P))

Measured memory_bytes: 5364
H, W = map(int,input().split())
mapli = []
for i in range(H):
    tmp = []
    s = str(input())
    for j in range(W):
        tmp.append(s[j])
    mapli.append(tmp)

tmp = []

for i in range(H):
    count = 0
    for j in range(W):
        if mapli[i][j] == ".":
            count += 1
    if count == W:
        tmp.append(i)
tmp.sort(reverse=True)

for i in range(len(tmp)):
    del mapli[tmp[i]]

tmp = []

for i in range(W):
    count = 0 
    if mapli[0][i] == ".": 
        for j in range(len(mapli)):
            if mapli[j][i] != ".":
                break
            count += 1
    if count == len(mapli):
        tmp.append(i)
tmp.sort(reverse=True)

for i in range(len(tmp)):
    for k in range(len(mapli)):
        del mapli[k][tmp[i]]

for i in range(len(mapli)):
    print(''.join(map(str, mapli[i])))


Measured memory_bytes: 3188
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func main() {
	var A, B, C int
	fmt.Scanf("%d %d %d\n", &A, &B, &C)
	remain := A - B
	if remain > C {
		fmt.Println(0)
	} else {
		fmt.Println(C - remain)
	}

}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(){
  int n;
  scanf("%d%*d",&n);
  char s[n][101];
  for(int i=0;i<n;i++)scanf("%s",&s[i]);
  qsort(s,n,sizeof(s[0]),strcmp); 
  for(int i=0;i<n;i++)printf("%s",s[i]);
  return 0;
}


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

        int main() {
          char S;
          cin>> S; 
          if(S=='A') cout<< "T" << endl; 
          if(S=='T') cout<< "A" << endl; 
          if(S=='C') cout<< "G" << endl;
          if(S=='G') cout<< "C" << endl; 

        }

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int K, X;  cin >> K >> X;
	if(X <= K * 500)  cout << "Yes" << endl;
	else              cout << "No"  << endl;

	return 0;
}


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

using namespace std;

int main()
{
  int n;
  scanf("%d", &n);
  int a[n+1];
  int fo[100001],fe[100001];
  memset(fo, 0, sizeof(fo));
  memset(fe, 0, sizeof(fe));
  for(int i=1;i<=n;i++)
  {
    scanf("%d", &a[i]);
    if(i%2)
      fo[a[i]]++;
    else
      fe[a[i]]++;
  }
  int max1o=0,max2o=0,max1e=0,max2e=0,indexmaxo=-1,indexmaxe=-1;
  for(int i=1;i<=100000;i++)
  {
    if(max1o < fo[i])
    {
      max1o = fo[i];
      indexmaxo = i;
    }
    if(max1e < fe[i])
    {
      max1e = fe[i];
      indexmaxe = i;
    }
  }
  for(int i=1;i<=100000;i++)
  {
    if(max2o < fo[i] && i!= indexmaxo)
    {
      max2o = fo[i];
    }
    if(max2e < fe[i] && i != indexmaxe)
    {
      max2e = fe[i];
    }
  }
  if(indexmaxo != indexmaxe)
  {
    printf("%d\n", n - max1o - max1e);
  }
  else
  {
    if(max1e == max1o)
    {
      if(max2e > max2o)
        printf("%d\n", n - max2e - max1e);
      else
        printf("%d\n", n - max2o - max1e);
    }
    else
      {
        if(max1e > max1o)
        {
          printf("%d\n", n - max1e - max2o);
        }
        else
          printf("%d\n", n - max1o - max2e);
      }
  }

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

LL gcd(LL a, LL b){
    LL tmp; 
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    tmp = a%b;
    while(tmp!=0){
        a = b;
        b = tmp;
        tmp = a%b;
    }

    return b;
}

int main() {
    LL k;
    LL ans=0;
    LL tmp;

    cin >> k;

    for(int i=1; i<=k; i++){
        for(int j=1; j<=k; j++){
            tmp = gcd(i, j);
            for(int l=1; l<=k; l++){
                ans = ans + gcd(tmp, l);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
n,k = map(int,input().split())
if n <= k:
    k = n
H = list(map(int,input().split()))
dp = [float('inf') for _ in range(n+1)]
for i in range(k):
    dp[i] = abs(H[i] - H[0])
for i in range(k,n):
    for j in range(k+1):
        dp[i] = min(dp[i],dp[i-j] + abs(H[i] - H[i-j]))
print(dp[-2])

Measured memory_bytes: 83368
using System;

class program
{
    public static void Main()
    {
        int length = int.Parse(Console.ReadLine());
        var str = Console.ReadLine().Split(' ');

        long min = long.Parse(str[0]), max = long.Parse(str[0]), sum = long.Parse(str[0]);

        for (int i = 1; i < length; i++)
        {
            min = min > int.Parse(str[i]) ? int.Parse(str[i]) : min;
            max = max < int.Parse(str[i]) ? int.Parse(str[i]) : max;
            sum += int.Parse(str[i]);
        }

        Console.WriteLine("{0} {1} {2}", min, max, sum);
    }
}

Measured memory_bytes: 19952
package main

import (
	"fmt"
)

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

	dishes := [5]int{a,b,c,d,e}

	// find dish which should be ordered last
	var lastOrder = 0
	var largestGap = 0
	for i := 0; i < len(dishes); i++ {
			gap := 10 - dishes[i] % 10
			if gap == 10 {
				continue
			}
			if largestGap < gap {
				largestGap = gap
				lastOrder = i
			}
	}

	// calculate total time to order every dishes
	var totalTime = 0
	for i := 0; i < len(dishes); i++ {
		totalTime	+= dishes[i]
		gap := 10 - (dishes[i] % 10)

		if i == lastOrder {
			continue
		}
		if gap == 10 {
			continue
		}

		totalTime	+= gap
	}

	fmt.Println(totalTime)
}


Measured memory_bytes: 512
class Deck:
    def __init__(self, cards):
        """cards is a string of alphabetical letters
        """
        self.cards = cards

    def shuffle(self, h):
        """take h cards from the top of deck and move to bottom

        >>> deck = Deck("abcdeefab")
        >>> deck.shuffle(4)
        >>> str(deck)
        'eefababcd'
        >>> deck.shuffle(3)
        >>> str(deck)
        'ababcdeef'
        """
        self.cards = self.cards[h:] + self.cards[:h]

    def __str__(self):
        return self.cards


def run():
    while True:
        cards = input()
        if cards == '-':
            break

        deck = Deck(cards)
        times = int(input())

        for i in range(times):
            h = int(input())
            deck.shuffle(h)

        print(deck)


if __name__ == '__main__':
    run()


Measured memory_bytes: 5612
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int H, W;
int N;
int X, Y, A;
int f[112][112];
int ans = 0;

int main(){
	
	cin>>W>>H>>N;
	
	fill( f[0], f[112], 0 );
	
	REP( i, N ){
		cin>>X>>Y>>A;
		if( A == 1 ){
			REP( i, H ){
				REP( j, X ){
					f[i][j] = 1;
				}
			}
		}
		if( A == 2 ){
			REP( i, H ){
				FOR( j, X, W ){
					f[i][j] = 1;
				}
			}
		}
		if( A == 3 ){
			REP( i, Y ){
				REP( j, W ){
					f[i][j] = 1;
				}
			}
		}
		if( A == 4 ){
			FOR( i, Y, H ){
				REP( j, W ){
					f[i][j] = 1;
				}
			}
		}
	}
	
	REP( i, H ){
		REP( j, W ){
			if( ! f[i][j] ) ans++;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;

}

Measured memory_bytes: 256
#!/usr/bin/perl
#= CPAN mocules =====================================================#
use strict;
use warnings;

#= Global values ====================================================#

#= Local routines ===================================================#
sub main(){
	my $input = <>;
	chomp $input;
	my (@data) = split(/ /, $input);

	my $after = $data[0] + $data[1];
	if($after >= 24){
		$after -= 24;
	}
	print $after."\n";


	return 0;
}

#----- 実行 -----#
exit( main() );




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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N=1e5+5;
int n,k;
int a[105],vis[N];
bool cache[N];

bool dp(int k)
{
     if(k<0)
          return true;
     if(k==0)
          return false;
     bool &ans=cache[k];     
     if(vis[k])
          return ans;
     vis[k]=1;     
    ans=false;
     for(int i=1;i<=n;i++)
          ans=ans|(!dp(k-a[i]));
     return ans;     
}

int32_t main()
{
     cin>>n>>k;
     for(int i=1;i<=n;i++)   
         cin>>a[i];
     cout<<(dp(k)?"First":"Second");     
}

Measured memory_bytes: 4224