akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,s,n) for(int i=s; i<n; i++)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
	string in;
	while(getline(cin, in), in!=".") {
		string stk = "";
		bool ok = true;
		rep(i, in.length()) {
			if( in[i] == '(' ) {
				stk += ')';
			} else if( in[i] == '[' ) {
				stk += ']';
			}
			else if( in[i] == ')' || in[i] == ']' ) {
				if( stk.length()>0 && stk[stk.length()-1] == in[i] ) {
					stk = stk.substr(0, stk.length()-1);
				} else {
					ok = false;
					break;
				}
			}
		}
		if(ok) {
			cout << (stk.length() == 0 ? "yes" : "no") << endl;
		} else {
			cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1184
import sys
input = sys.stdin.buffer.readline
MOD = 10**9 + 7
N, K = map(int, input().split())
A = list(map(int, (input().split())))
pos, neg = [], []
for a in A:
    if a<0:
        neg.append(a)   # 負
    else:
        pos.append(a)   # 0以上
if pos:
    if N==K:    # 全て選択で負の数が奇数ならfalse（正にできない）
        ok = (len(neg)%2 == 0)
    else:
        ok = True
else:
    ok = (K%2 == 0) # すべて負で奇数ならfalse（正にできない）
ans = 1
if ok == False: # false（正にできない）場合、絶対値が小さいものからk個かける
    A.sort(key=abs)
    for i in range(K):
        ans *= A[i]
        ans %= MOD
else:
    pos.sort()              # 後ろから取っていくので正は昇順
    neg.sort(reverse=True)  # 後ろから取っていくので負は降順
    if K%2:
        ans *= pos.pop()    # kが奇数個なら1個は正を選ぶ
    p = []  # 2個ずつかけた数を格納
    while len(pos)>=2:
        p.append(pos.pop() * pos.pop())
    while len(neg)>=2:  # 負を2回かけるのでxは正
        p.append(neg.pop() * neg.pop())
    p.sort(reverse=True)
    for i in range(K//2):   # 降順にk//2個見ていく
        ans *= p[i]
        ans %= MOD
print(ans)

Measured memory_bytes: 29288
from math import sqrt
P = "perfect number"
D = "deficient number"
A = "abundant number"
while True:
    n = input()
    if n==0:
        break
    if n==1:
        print D
        continue
    su = 1
    temp = n
    for i in xrange(2, int(sqrt(n))+1):
        cnt = 0
        while temp%i==0:
            temp /= i
            cnt += 1
        if cnt:
            su *= (i**(cnt+1)-1)/(i-1)
        if temp==1:
            su -= n
            break
    if temp!=1:
        su *= (temp**2-1)/(temp-1)
        su -= n
    print P if n==su else (D if su<n else A)

Measured memory_bytes: 4384
#include<bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>  boost::math::lcm(10,20) ---> use it to find lcm.*/
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
// #define int long long 
#define PI pair<int , int >
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define debug() cout << "Hi" << endl	// write debug(); in main()
const int MOD = 1e9+7;
const int MAXN = 1e5+3;
const int inf = 2e9;
int max(int a,int b){	if(a > b)return a; else return b; }
int min(int a, int b){	if(a < b)return a; else return b; }
/*		0. Go to main function first.
		1. Take all the inputs................................................
		2. Check Once whether the graph given is directed or undirected.......
		3. Tree can also be undirected.
		4. Whenever you do multiplication and division in the same line, beware.
*/
void solve(){
	//debug();
	string s;
	cin >> s;
	bool pr = true;
	int p = s.length();
	for( int i=0; i< p ; ++i){
		if(i%2 == 0){
			if(s[i] != 'h'){
				pr = false;
				break;
			}
		}else{
			if(s[i]!='i'){
				pr = false;
				break;
			}
		}
	}
	if(p%2 == 1)pr = false;
	if(pr) cout << "Yes\n";
	else cout << "No\n";
}
/*	memset() can be used to set all values as 0 or -1 for integer data types.*/

int main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("input1.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#endif // ONLINE_JUDGE
	// std::cout << std::setprecision(12); std::cout << std::fixed;
	int t;
	// cin >> t;
	t = 1;
	while(t--){
		solve();
	}
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int swap1,swap2,cup[3]={1,0,0},hoge;
	char input1,input2;
	while(scanf("%c,%c",&input1,&input2)!=EOF){
        getchar();
        if(input1=='A')swap1=0;
        else if(input1=='B')swap1=1;
        else if(input1=='C')swap1=2;
        if(input2=='A')swap2=0;
        else if(input2=='B')swap2=1;
        else if(input2=='C')swap2=2;
        hoge=cup[swap1];
        cup[swap1]=cup[swap2];
        cup[swap2]=hoge;
	}
	if(cup[0]==1)printf("A\n");
	else if(cup[1]==1)printf("B\n");
	else if(cup[2]==1)printf("C\n");
    return 0;
}

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

#ifdef ONLINE_JUDGE
#define freopen \
  if (0) freopen
#define cerr \
  if (0) cerr
#endif

#define fi first
#define se second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)

#define sqr(a) ((a)*1ll * (a))
#define sz(a) (int)a.size()
#define len(a) (int)a.length()
#define all(a) a.begin(), a.end()
#define nl '\n'

using namespace std;

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

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pi;

const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

int to_digit(char ch) {
  return ch - '0';
}

ll calc(int mask, string &s) {
  ll sum = 0, cur = 0;
  rep(i, 0, len(s) - 1) {
    cur = cur * 10ll + to_digit(s[i]);
    if (i == len(s) - 1) continue;
    if ((1<<i) & mask) {
      sum += cur;
      cur = 0;
    }
  }
  sum += cur;
  return sum;
}

void solve() {
  int n;
  string s;
  cin >> s;
  n = len(s) - 1;

  ll res = 0;
  rep(mask, 0, (1<<n) - 1) {
    res += calc(mask, s);
  }

  cout << res;
}

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

  freopen(".in", "r", stdin);

  solve();

  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long
using namespace std;
int read( ){
	int x=0,y=1;char ch=' ';
	for(;(ch!='-' && (ch>'9' || ch<'0'));ch=getchar( ));
	if(ch=='-')y=-1,ch=getchar( );
	for(;ch>='0' && ch<='9';ch=getchar( ))x=x*10+ch-48;
	return x*y;
}
const int N=1e5+10;
int n,ans,tot;
int a[N],p[110];
void ins(int x){
	for(register int i=62;i>=0;--i){
		if(!(x & (1ll<<i)))continue;
		if(!p[i]){
			p[i]=x;return;
		}
		x^=p[i];
	}
}
signed main( ){
	int x,y,z,k,sum=0;
	n=read( );
	for(register int i=1;i<=n;++i){
		a[i]=read( );
		sum^=a[i];
	}
	for(register int i=1;i<=n;++i)
		a[i]&=~sum;
	
	for(register int i=1;i<=n;++i)ins(a[i]);
	for(register int i=62;i>=0;--i)
		if((ans^p[i])>ans)ans^=p[i];
	printf("%lld\n",ans*2+sum);
	return 0;
}

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

vector<int> ans;

int main(){
	string s;
	int k;
	cin >> s >> k;
	int cnt = 0;
	int curCnt = 1;
	char curText = s[0];
	for(int i=1;i<s.size();i++){
		if(s[i] == curText){
			curCnt++;
		}else{
			cnt += curCnt / 2;
			ans.emplace_back(curCnt);
			curCnt = 1;
		}
		curText = s[i];
	}
	if(s[0] == s[(int)s.size()-1]){
		if(ans.size()){
			cout << (long long) (ans.front() / 2) + (long long) (k - 1) * (cnt - (ans.front() / 2) + (curCnt + ans.front()) / 2) + cnt - (ans.front() / 2) + curCnt / 2;
        }else{
			cout << (long long)s.size() * k / 2;
		}
	}else{
		cout << (long long) k * (cnt + curCnt / 2);
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
 
		int n = sc.nextInt();
		int[] heighs = new int[n];
		for(int i = 0; i < n ; i++){
			heighs[i] = sc.nextInt();
		}
		
		boolean ans = true;
		int nowheight = heighs[0] - 1;
		for(int i = 1; i < n; i++){
			if(heighs[i] < nowheight){
				ans = false;
			}else{
				if(heighs[i] > nowheight){
					heighs[i]--;
				}
				nowheight = heighs[i];
			}			
		}
		if(ans){
			System.out.println("Yes");
		}else{
			System.out.println("No");			
		}
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 22356
#include <iostream>
using namespace std;
const int MAX = 1e6;
typedef long long ll;
 
bool prime[MAX+1];
ll dp[MAX+1];
 
void is_prime(){
  fill(prime,prime+MAX+1,true);
 
  prime[0] = prime[1] = false;
  for(int i = 2 ; i*i <= MAX ; i++){
    if(prime[i]){
      for(int j = i*i ; j <= MAX ; j+=i){
    prime[j] = false;
      }
    }
  }
 
}
 
int eulerPhi(int n){
  int res = n;
 
  for(int i = 2 ; i*i <= n ; i++){
    if(n % i == 0){
      res -= res / i;
      while(n % i == 0) n /= i;
    }
  }
 
  if(n > 1) res -= res / n;
 
  return res;
}
 
void init(){
  is_prime();
 
  dp[1] = 2; // 0/1 , 1/1
 
  for(int i = 2 ; i <= MAX ; i++){
    if(prime[i]){
      dp[i] = dp[i-1] + (i-1);
    }
    else{
      dp[i] = dp[i-1] + eulerPhi(i);
    }
  }
 
}
 
int main(){
  int T,in;
 
  init();
 
  cin >> T;
  while(T--){
    cin >> in;
    cout << dp[in] << endl;
  }
 
  return 0;
}

Measured memory_bytes: 9944
#include <stdio.h>
 
int main()
{
  char pass[10];
  int bad = 0;
  scanf("%s", pass);
  for (int i =0;i<3;i++)
  {
   if (pass[i] == pass[i+1])
       {
         bad = 1;
         break;
       }
  }
       if (bad) printf("Bad\n");
       else printf("Good\n");
       return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
 
  int n, k, count=0;
  cin >> n >> k;
  vector<int> h(n);
  for(int i=0; i<n; i++) cin >> h[i];
  
  for(int i=0; i<n; i++){
      
      if(k <= h[i]) {
          count++;
      }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//---------------------------------------------------------------
#define fastio std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
using u32 = int32_t ;
using u64 = int64_t ;
//--------------------------------------------------------------
vector<long long> divisor(long long n){
  vector<long long> ret;
  for(long long i=1; i*i <=n; ++i){
    if(n%i == 0){
      ret.push_back(i);
      if(i*i!=n) ret.push_back(n /i);
    }
  }
  sort(ret.begin(),ret.end());
  return ret;
}



int main(int argc,char** argv){ fastio; myio;
  ll n;
  cin>>n;
  auto a = divisor(n);
  rep(i,a.size())
    a[i] = ((ll)log10(a[i])+1);
  ll ans = 11;
  rep(i,dup(sz(a),2)){
    mins(ans, max( a[i], a[a.size()-1-i] ) );
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

ll dp[200020][5][2];

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<ll> a(n);
	rep(i,n){
		cin>>a[i];
	}
	rep(i,n+1)rep(j,5)rep(k,2) dp[i][j][k]=-inf;
	dp[1][0][1]=a[0];
	dp[2][0][0]=a[1];
	dp[2][0][1]=a[1];
	dp[3][0][0]=a[2];
	FOR(i,1,n)rep(j,5)rep(k,2){
		if(dp[i][j][k]==-inf) continue;
		int now=i/2;
		if(k) now=(i+1)/2;
		FOR(l,2,5){
			int ind=i+l;
			int nk;
			if(ind/2==now+1) nk=0;
			else if((ind+1)/2==now+1) nk=1;
			else continue;
			if(ind<=n){
				chmax(dp[ind][l][nk],dp[i][j][k]+a[ind-1]);
				if(ind%2==0){
					chmax(dp[ind][l][!nk],dp[i][j][k]+a[ind-1]);
				}
			}
			//cout<<i<<' '<<ind<<' '<<nk<<' '<<dp[i][j][k]<<' '<<dp[ind][l][nk]<<endl;
		}
	}
	ll ans=-inf;
	rep(i,n+1){
		if(i/2==n/2){
			rep(j,5) chmax(ans,dp[i][j][0]);
		}
		if((i+1)/2==n/2){
			rep(j,5) chmax(ans,dp[i][j][1]);
		}
	}
	cout<<ans<<endl;
}

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

int main() {
        int n;
        cin >> n;
        bool four = false;
        for (int i=0; i<n; i++) {
                string s;
                cin >> s;
                if (s == "Y") {
                        four = true;
                        break;
                }
        }
        if (four) {
                cout << "Four" << endl;
        } else {
                cout << "Three" << endl;
        }
        return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
  int i,j,r,s,x,y,z,num = 0;
 
  char c[12];
  
  scanf("%d",&r);

   int array[r];
  
  for(i = 0;i < r;i ++)
    {
      scanf("%s %d",c,&s);
      if(c[0] == 'i')
	{
	  array[i] = s;
	}
      else if(c[6] == 'F')
	{
	  i -= 2;
	  r -= 2;
	}
      else if(c[6] == 'L'){
	i --;
	r --;
	num ++;
      }
      else{
	i --;
	r --;
	x = 0;
      
	for(j = i;j >= 0;j --){

	  if(x > 0)break;
	
	  if(s == array[j]){
	    y = i - j;
	    z = 0;
	    x ++;
	    while(y != z){
	      z ++;
	      array[j + z - 1] = array[j + 1 + z - 1];
	    }
	  
	    i --;
	    r --;
	  }
	}
      }
    }
  
  for(i = 0;i < r - num;i ++)
    {
      if(i == r - num - 1)printf("%d\n",array[r - 1 - i]);
      else printf("%d ",array[r - 1 - i]);
    }
  return 0;
}

Measured memory_bytes: 6144
#include<iostream>
using namespace std;
static const int N=100;
int main(){
   int M[N][N];
   int n,u,k,v;
   cin>>n;
   for(int i=0;i<n;i++)
   {
       for(int j=0;j<n;j++)M[i][j]=0;
   }
   for(int i=0;i<n;i++)
   {
       cin>>u>>k;
       u--;
       for(int j=0;j<k;j++)
       {
           cin>>v;
           v--;
           M[u][v]=1;
       }
   }
   for(int i=0;i<n;i++)
   {
       for(int j=0;j<n;j++)
       {
           if(j)cout<<" ";
           cout<<M[i][j];
       }
       cout<<endl;
   }
   return 0;
}

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

using namespace std;

typedef long long ll;
typedef double long dl;
typedef pair < ll , ll > pii;
typedef pair < pii, pii > p2i;
const int maxn = (int) 2e6 + 2;
const int mod = (int) 1e9 + 7;
const ll inf = (ll)1e18;

#define fi first
#define se second
#define acel ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define next continue
#define getsz(x) (int) log10(x)

int n;

int get(int a, int b, int c, int d){
    return abs(a - c) + abs(b - d);
}

int t[maxn], a[maxn], b[maxn], x, y;

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> t[i] >> a[i] >> b[i];
        if(i == 1){
            int s = a[i] + b[i];
            if(s > t[i]){
                cout << "No";
                return 0;
            }
            if((t[i] - s) % 2 == 1){
                cout << "No";
                return 0;
            }
            x = a[i], y = b[i];
        }
        else {
            int s = get(x, y, a[i], b[i]), tim = t[i];
            t[i] -= t[i - 1];
            if(s > t[i]){
                cout << "No";
                return 0;
            }
            if((t[i] - s) % 2 == 1){
                cout << "No";
                return 0;
            }
            t[i] = tim;
            x = a[i], y = b[i];
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 6784
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char i;
    cin>>i;
    if(i=='A'){
        cout<<"T";
    }else if(i=='C'){
        cout<<"G";
    }else if(i=='T'){
        cout<<"A";
    }else if(i=='G'){
        cout<<"C";
    }
    return 0;
}


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

typedef long long ll;
using namespace std;
 
 const int maxn=2e5+10;
ll n,seed;
struct node
{
	ll x,y; 
}a[1000010];

int main()
{
	int t,n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].x>>a[i].y;
	}
	ll maxn[10],minn[10];
	for(int i=0;i<6;i++)
	{
		maxn[i]=-1e16;minn[i]=1e16;
	}
	for(int i=0;i<n;i++)
	{
		maxn[0]=max(maxn[0],a[i
		].x-a[i].y);
		maxn[1]=max(maxn[1],a[i].x+a[i].y);
		maxn[2]=max(maxn[2],-a[i].x+a[i].y);
		maxn[3]=max(maxn[3],-a[i].x-a[i].y);
		minn[0]=min(minn[0],a[i].x-a[i].y);
		minn[1]=min(minn[1],a[i].x+a[i].y);
		minn[2]=min(minn[2],-a[i].x+a[i].y);
		minn[3]=min(minn[3],-a[i].x-a[i].y);			
	}
	ll big=0;
	for(int i=0;i<4;i++)
	{
		big=max(big,maxn[i]-minn[i]);
	}
	printf("%lld\n",big);
	
	return 0;
}

Measured memory_bytes: 6880
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	r,g,b,n = readline() |> split |> parseMap
	to = 0
	x = div(n,r)
	if r==1
		for i in 0:div(n,g)
			m = n-g*i
			for j in 0:div(m,b)
				if g*i+b*j<=n
					to += 1
				end
			end
		end
	elseif g == 1
		for i in 0:div(n,r)
			m = n-r*i
			for j in 0:div(m,b)
				if r*i+b*j<=n
					to += 1
				end
			end
		end
	elseif b == 1
		for i in 0:div(n,r)
			m = n-r*i
			for j in 0:div(m,g)
				if r*i+g*j<=n
					to += 1
				end
			end
		end
	else
	for i in 0:x
		m = n-r*i
		y = div(m,g)
		for j in 0:y
			l = m-g*j
			z = div(l,b)
			for k in 0:z
				if r*i+g*j+b*k == n
					to += 1
				end
			end
		end
	end
	end
	println(to)
end
main()


Measured memory_bytes: 114836
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t; using i64 = int64_t; using f64 = double_t; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define stepup(a, b, s, i) for (i32 i = (a); i <= (b); i+=(s))
#define stepdown(a, b, s, i) for (i32 i = (a); i >= (b); i-=(s))
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define foreach(xs, x) for (auto &x : (xs))
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define maximum(xs) (*max_element(all(xs)))
#define minimum(xs) (*min_element(all(xs)))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i64 n, cnt;

i32 main()
{
    cin >> n;
    cnt = 0;
    times(n, i) {
        i64 a; cin >> a;
        if (odd(a)) {
            cnt++;
        }
    }

    cout << (even(cnt) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int a,b;
    cin >> a >> b;
    int ans = a * b - (1*a+1*b-1);
    cout << ans << endl;
}

Measured memory_bytes: 3588
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let it = stdin.lock().bytes().map(|c| c.unwrap() as char);
    let (fs, ft) = (|c: &char| c.is_whitespace(), |c: &char| !c.is_whitespace());
    let token = it.skip_while(fs).take_while(ft).collect::<String>();
    token.parse().ok().unwrap()
}
#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    f(std::io::BufWriter::new(out.lock()));
}
#[allow(unused_macros)]
macro_rules! debug {
    ($($var:expr),*) => { #[cfg(debug_assertions)] {
        $({ match &$var { v => eprint!("{}={:?} ", stringify!($var), v) } })*
        eprintln!();
    }};
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let p: Vec<i32> = (0..n).map(|_| input()).collect();
    let xy: Vec<(usize, usize)> = (0..m).map(|_| (input(), input())).collect();

    let mut uf = UnionFind::new(n);
    for &(x, y) in &xy {
        uf.union(x - 1, y - 1);
    }

    let mut ans = 0;
    for i in 0..n {
        let p = p[i] as usize - 1;
        if p == i || uf.find(i) == uf.find(p) {
            ans += 1;
        }
    }
    println!("{}", ans);
}

struct UnionFind {
    parent: Vec<usize>,
    size: Vec<usize>,
}
#[allow(dead_code)]
impl UnionFind {
    fn new(n: usize) -> UnionFind {
        UnionFind {
            parent: (0..n).collect(),
            size: vec![1; n],
        }
    }
    fn find(&mut self, x: usize) -> usize {
        if self.parent[x] == x {
            x
        } else {
            let p = self.parent[x];
            self.parent[x] = self.find(p);
            self.parent[x]
        }
    }
    fn union(&mut self, x: usize, y: usize) -> bool {
        let mut x = self.find(x);
        let mut y = self.find(y);
        if x == y {
            false
        } else {
            if self.size[x] < self.size[y] {
                std::mem::swap(&mut x, &mut y);
            }
            self.parent[y] = x;
            self.size[x] += self.size[y];
            true
        }
    }
    fn size(&mut self, x: usize) -> usize {
        let p = self.find(x);
        self.size[p]
    }
}


Measured memory_bytes: 8572
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        //入力準備
       Scanner sc = new Scanner(System.in);
       
       //入力値の受け取り
       int n = sc.nextInt();
       
       //計算して出力
       
        //時間
        System.out.print(n/3600);
        System.out.print(":");
        //分
        System.out.print((n%3600)/60);
        System.out.print(":");
        //秒
        System.out.println((n%3600)%60);
    }
}


Measured memory_bytes: 26164
#include <iostream>
#include<vector>
using namespace std;
int main(void){
    int n;cin>>n;
    vector<int>temp(n);
    int sum = 0;
    for(int i=0;i<n;i++){
        int t;cin>>t;
        temp[i] = t;
        sum += t;
    }
    if(sum%10 != 0){
        cout<<sum<<endl;
    }else{
        int i;            
        int t = 0;
        for(i=0;i<temp.size();i++){
            if((sum -temp[i])%10 != 0){
                t = max(t,sum-temp[i]);
                continue;
            }
        }
        cout<<t<<endl;
    }
    return 0;
}

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


#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
 
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define fo(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define foe(i,x) for(auto& i: x)
#define ar array
#define pb push_back
#define vt vector
#define F first
#define S second

template<class T> bool umin(T& a,const T& b){return b<a?a=b,1:0;}
template<class T> bool umax(T& a,const T& b){return b>a?a=b,1:0;}

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {cin>>x;}
void read(double& d) {string t;read(t);	d=stod(t);}
void read(long double& d) {	string t;read(t);d=stold(t);}
template<class H, class... T> void read(H& h, T&... t) {read(h);read(t...);}
template<class A> void read(vt<A>& x) {	foe(a, x)read(a);}
int nxt(){int a;cin >> a;return a;}

// no change 
const ll MOD = 1e9+7;  
int n;
const int mx = 2e5+1;
void Titan(){
	read(n);
	vi v(n);
	read(v);
	ll cur = 1000;
	fo(n-1){
		ll stock = 0;
		if(v[i] < v[i+1])stock = cur /v[i];
		cur += (v[i+1] - v[i])*stock;
	}
	cout << cur;

	

	
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T = 1;
	//cin >> T;		//cmt if one test case
    fo(T){
		//cout << "Case #" << i+1 << ": " ;
		Titan();
	}
}
/*///////////////////////////////////////////////////////////
Important Notes : 
* check long long 
* check base cases
* do not loose Hope
* if case fails on 2nd test case maybe some cases are missing check them
* do not sit idle
* try to do it using pen/paper.
*/


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int dp[10005],a[2005]={0},b[2005]={0};
int main(){
	for(int i=1;i<=10003;i++) dp[i]=200000000;
	//printf("%d %d\n",dp[1],dp[10]);
	int h,n;
	scanf("%d%d",&h,&n);
	dp[0]=0;
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=h;j++){
			if(j<a[i]&&b[i]<dp[j]) dp[j]=b[i];
			if(j>=a[i]&&dp[j-a[i]]+b[i]<dp[j]) dp[j]=dp[j-a[i]]+b[i];
		}
	}
	//for(int i=1;i<=100;i++) printf("%d ",dp[i]);
	//printf("\n");
	printf("%d",dp[h]);
	return 0;
}

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

int main(){
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  int64_t ans=0;
  for(int i=0;;i++){
    if(R*i>N){
      break;
    }
    for(int j=0;;j++){
      if(R*i+G*j>N){
        break;
      }
      if((N-R*i-G*j)%B==0){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
class Integer
  def inverse(m)
    return Rational(1, self) if m.nil?

    a, b, u, v = self, m, 1, 0
    until b.zero?
        a, (t, b) = b, a.divmod(b)
        u, v = v, u - t * v
    end

    u = -u if a < 0
    u % m
  end
end

require 'openssl'

n, a, b = gets.chomp.split.map(&:to_i)
mod = 10**9 + 7

k = a > b ? a : b
cb = [] * (k + 1)
cb[0] = 1
1.upto(k) do |i|
  cb[i] = cb[i - 1] * (n - i + 1) * i.inverse(mod) % mod
end

puts (2.to_bn.mod_exp(n, mod).to_i - cb[a] - cb[b] - 1) % mod

Measured memory_bytes: 4860
n = int(input())

a = [0]*n
b = [0]*n
c = [0]*n

days = [0]*n
for i in range(n):
    days[i] = list(map(int, input().split()))

a[0], b[0], c[0] = days[0][0], days[0][1], days[0][2]

for i in range(1, n):
    a[i] = max(b[i-1]+days[i][0], c[i-1]+days[i][0])
    b[i] = max(a[i-1]+days[i][1], c[i-1]+days[i][1])
    c[i] = max(a[i-1]+days[i][2], b[i-1]+days[i][2])

print(max(a[-1], b[-1], c[-1]))

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

#define fi first
#define se second
#define debug(x) cerr << #x << " : " << x << endl;

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;


// code //
const int mxN = 3;
int ans = 0;
char d;
int main() {
	bool last=false;
	int cnt=0;
	for(int i=0; i<mxN; ++i) {
		cin >> d;
		bool is=d=='R';
		if(last&&is) cnt++;
		else if(is) {
			cnt=1;
			last=true;
		} else cnt=0;
		ans=max(ans, cnt);
	}
	cout << ans;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int N, A[10101];
//---------------------------------------------------------------------------------------------------
void _main() {
	while (cin >> N) {
		if (N == 0) return;
		rep(i, 0, N) cin >> A[i];

		int sm = 0;
		rep(i, 0, N) sm += A[i];

		int ans = 0;
		rep(i, 0, N) if (A[i] * N <= sm) ans++;
		printf("%d\n", ans);
	}
}




Measured memory_bytes: 3172
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define endl '\n'
#define loop(i, m, n) for (lli i = m; i < n; i++)
#define loope(i, m, n) for (lli i = m; i <= n; i++)
#define epool(i, m, n) for (lli i = m; i >= n; i--)
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define vt vector<lli>
#define fi first
#define se second
#define pb push_back
#define umap unordered_map
#define mmap multimap
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x, 0;
#define all(v) v.begin(),v.end()

#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
 
lli gcd(lli a, lli b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
lli lcm(lli a, lli b){
    return (a * b) / gcd(a, b);
}
 
lli modi( lli n, lli m=mod ){ 
    n%=m;
    n+=m;
    n%=m;
    return n;
}

lli mpow(lli base, lli exp){
    base %= mod;
    lli result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((lli)result * base) % mod;
        base = ((lli)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

const lli MIN=-1*1e18;
const lli INF=1e18+999999999999999999;
const lli N=2e5+5;
const ldb pi=4*atan(1);

int32_t main(){
    fast_io
    lli i = 0,j = 0;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //cout << fixed << setprecision(22);
    
    lli k,a,b;
    cin >> k >> a >> b;
    if(b/k-(a-1)/k>=1) cout << "OK";
    else cout << "NG";
    cout << endl;

}



Measured memory_bytes: 3652
#include<iostream>
#include<cstdlib>
#include<stack>
using namespace std;

int main(){

  stack<int> S;
  int a,b,x;
  string s;

  while(cin >> s ){
    if(s[0] == '+'){
      b = S.top(); S.pop();
      a = S.top(); S.pop();
      S.push(a+b);
    }else if(s[0] == '-'){
      b = S.top(); S.pop();
      a = S.top(); S.pop();
      S.push(a-b);      
    }else if(s[0] == '*'){
      b = S.top(); S.pop();
      a = S.top(); S.pop();
      S.push(a*b);  
    }else{
      S.push(atoi(s.c_str()));
    }
  }
  cout << S.top() << endl;

  return 0;
}

Measured memory_bytes: 1200
import bisect
import sys

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a_accumulated = [0] * (n + 1)
b_accumulated = [0] * (m + 1)

for idx, a in enumerate(A):
    a_accumulated[idx + 1] = a_accumulated[idx] + a # idx == 0の場合はa_accumulated[-1]を参照するが、それは0初期化されているので問題ない。

for idx, b in enumerate(B):
    b_accumulated[idx + 1] = b_accumulated[idx] + b

a_limit = bisect.bisect(a_accumulated, k)
if a_limit == 0:
    position = bisect.bisect(b_accumulated, k)
    print(position - 1)
    sys.exit(0)

best_num = 0
for i in reversed(range(0, a_limit)):
    position = bisect.bisect_right(b_accumulated, k - a_accumulated[i])
    best_num = max(best_num, i + position - 1)
print(best_num)



Measured memory_bytes: 118260
#include <iostream>

using namespace std;
int main()
{
    int N;
    cin >> N;
    char S[N-1];
    cin >> S;
    int count=0;

    for (int i = 0; i < N - 2; i++)
    {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
        {
            count++;
        }
    }
    
    cout << count;

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <utility>
#include <set>
#include <vector>
#include <queue>
using namespace std;
#define loop(i,n) for(int i=0;i<n;i++)

int main(){

  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c)cout<<1;
  else if(a==b||b==c||c==a)cout<<2;
  else cout<<3;

  return 0;
}

Measured memory_bytes: 256
/*#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include<bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define mp make_pair
#define len(s) s.size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define rocknroll cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0)
#define pq priority_queue
#define pii pair < int, int >
#define pll pair < ll, ll >
#define debug cout << " ---------------------------------------- "
#define kektor vector
#define int unsigned long long
typedef long long ll;
typedef long double ld;
typedef double dbl;
typedef unsigned long long ull;

using namespace std;

int to10(string s)
{
    reverse(all(s));
    int ans = 0;
    int k = 1;
    for(int i = 0; i < s.size(); ++i, k *= 2LL)
    {
        ans += k * (s[i] - '0');
    }
    return ans;
}
string to2(int n)
{
    string ans = "";
    if (n == 0)
        ans = "0";
    while(n > 0)
    {
        ans += ((n % 2) + '0');
        n /= 2;
    }
    for(int i = ans.size(); i <= 50; ++i)
        ans += "0";
    reverse(all(ans));
    return ans;
}
int cnt[60];

signed main()
{
    rocknroll;
    int n, k;
    cin >> n >> k;
    vector<int>v(n);
    for(auto &i : v)
        cin >> i;
    int sm = 0;
    if (k == 0)
    {
        for(int i = 0; i < n; ++i)
            sm += (v[i] ^ 0LL);
        cout << sm << endl;
        return 0;
    }
    string s = to2(k);
    vector<string>v1;
    for(int i = 0; i < n; ++i)
    {
        v1.pb(to2(v[i]));
    }
    for(int i = 0; i < n; ++i)
        for(int j = 0; j <= 50; ++j)
            cnt[j] += (v1[i][j] - '0');
    int id = 0;
    for(int i = 0; i < s.size(); ++i)
        if (s[i] == '1')
        {
            id = i;
            break;
        }
    int s1 = 0;
    string k1 = "1";
    bool flag = false;
    for(int i = id + 1; i <= 50; ++i)
    {
        if ((cnt[i] >= ((n + 1) / 2) && (s[i] == '1' || flag)) || (s[i] == '0' && !flag))
        {
            k1 += "0";
            if (s[i] == '1')
                flag = true;
        }
        else
            k1 += "1";
    }
    int s2 = 0;
    string k2 = "0";
    for(int i = id + 1; i <= 50; ++i)
    {
        if (cnt[i] >= (n + 1) / 2)
            k2 += "0";
        else
            k2 += "1";
    }
    int t1 = to10(k1);
    int t2 = to10(k2);
    for(int i = 0; i < n; ++i)
    {
        s1 += t1 ^ v[i];
        s2 += t2 ^ v[i];
    }
    cout << max(s1, s2) << endl;
    return 0;
}



Measured memory_bytes: 12788
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
H,W,K = map(int,input().split())

mod = 10**9+7

# 左(あるいは右)にn本の縦棒があり、真横と繋がっている時の場合の数
j = [0,1,1,2,3,5,8,13];
# 左(あるいは右)にn本の縦棒があり、真横と繋がっていない時の場合の数
m = [1,1,2,3,5,8,13,21];
 
# dp[h][w] : h行目を終えた時点でwにいる場合の数
dp = [[0 for _ in range(W)] for _ in range(H+1)]
dp[0][0] = 1
 
for h in range(H+1):
    for w in range(W):
        # 右に移動
        if w != 0:
            dp[h][w] += dp[h-1][w-1] * j[w] * m[W-1-w]
        # 左に移動
        if w != W-1:
            dp[h][w] += dp[h-1][w+1] * m[w] * j[W-1-w]
        # 真下に移動
        dp[h][w] += dp[h-1][w] * m[w] * m[W-1-w]
        
        dp[h][w] %= mod;

    
print(dp[H][K-1])

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <regex>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)++)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

template <class... T>
void output__(T ...a) {
  for(auto v: {a...}) {
    cout << v << " ";
  }
  cout << endl;
}

int main(){
  string in(a) out(a[0] == a[2] ? "Yes" : "No");
}


Measured memory_bytes: 256
N = int(input())

def drawal(x):
  if(x <= 5):
    return x
  elif(6<= x and x < 9):
    return x- 5
  elif(9<= x and x < 15):
    return x- 8
  else:
    def drawal9(y):
      i = 0
      while 9** (i+ 1)<= y:
        i+= 1
      return drawal(y- 9** i)+ 1
    def drawal6(z):
      i = 0
      while 6** (i+ 1)<= z:
        i+= 1
      return drawal(z- 6** i)+ 1
    return min(drawal9(x), drawal6(x))

print(drawal(N))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
        int N,L; cin>>N>>L;
        vector<string> s(N);
        REP(i,N) cin>>s[i];
        sort(ALL(s));
        REP(i,N) cout<<s[i]; cout<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  scanf("%d", &n);

  map<int, int> mp;
  REP(i,n){
    int t;
    scanf("%d", &t);
    mp[t]++;
  }

  int ans = 0;
  REPI(itr, mp){
    if(itr->second >= itr->first){
      ans += itr->second - itr->first;
    }else{
      ans += itr->second;
    }
  }

  printf("%d\n", ans);
  
  return 0;
}



Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  int ans=0;
  rep(i,n){
    if(i+1<n && a.at(i)==i+1 && a.at(i+1)==i+2){
      ans++;
      i++;
      continue;
    }
    if(a.at(i)==i+1){
      ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3728
#for i = 1 to A.length-1
#    key = A[i]
#    /* insert A[i] into the sorted sequence A[0,...,j-1] */
#j = i - 1
#   while j >= 0 and A[j] > key
#        A[j+1] = A[j]
#        j--
#    A[j+1] = key

n = int(input())
nums = list(map(int, input().split()))
for i in range(0, n):
    key = nums[i]
    j = i - 1
    while (j>=0) and (nums[j] > key):
        nums[j+1] = nums[j]
        j -= 1
    nums[j+1] = key
    print(*nums)


Measured memory_bytes: 5976
#include<iostream>
#include<string>
#include<map>
using namespace std;
#define ans pair<int, int>
ans equation(string s, int p = 0);
ans factor(string s, int p = 0);
ans term(string s, int p = 0);
int main(){
  int n;
  cin >>n;
  while(n--){
    string s;
    cin >>s;
    ans r = equation(s);
    cout <<r.first<<endl;
  }
  return 0;
}
ans equation(string s, int p){
  ans r = factor(s,p);
  while(s[r.second] == '+' || s[r.second] == '-'){
    ans r_dash = factor(s,r.second+1);
    if(s[r.second] == '+'){r.first += r_dash.first;}
    if(s[r.second] == '-'){r.first -= r_dash.first;}
    r.second = r_dash.second;
  }
  return r;
}
ans factor(string s, int p){
  ans r = term(s,p);
  while(s[r.second] == '*' || s[r.second] == '/'){
    ans r_dash = term(s,r.second+1);
    if(s[r.second] == '*'){r.first *= r_dash.first;}
    if(s[r.second] == '/'){r.first /= r_dash.first;}
    r.second = r_dash.second;
  }
  return r;
}
ans term(string s, int p){
  if(s[p] == '('){
    ans r = equation(s,p+1);
    r.second++;
    return r;
  }
  else{
    int v = 0;
    while(isdigit(s[p])){
      v = v*10+s[p++]-'0';
    }
    return ans(v,p);
  }
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define vii vector<int>
#define vcc vector<char>
#define pll pair<long long, long long>
#define mem memset
#define sof sizeof
#define PB push_back
#define MP make_pair
#define TS to_string
#define F first
#define S second
#define endl '\n'
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    unsigned long long a,b,c,d,e,f,i,j,k,m,n,o,x,y;
    cin>>n;
    unsigned ll ar[n+1];
    mem(ar,0,sof(ar));
    for(i=1;i<n+1;i++){
        for(j=i;j<n+1;j+=i){
            ar[j]++;
        }
    }
    for(i=2;i<n+1;i++){
        ar[i]=ar[i-1]+i*ar[i];
    }
    cout<<ar[n]<<"\n";
}

Measured memory_bytes: 81716
from collections import deque, defaultdict

N = int(input())

connect_dic = defaultdict(list)

edge = []
for _ in range(N - 1):
    a, b = map(int, input().split())
    edge.append((a, b))

    connect_dic[a].append(b)
    connect_dic[b].append(a)


dq = deque([])
dq.append(a)

color_dic = defaultdict(set)
used_set = set()

comp = defaultdict(int)
max_ = 0

while dq:
    n = dq.popleft()

    can = connect_dic[n]
    l = len(can)
    max_ = max(max_, l)

    a_color = color_dic[n]

    num = 0
    for c in can:
        if c in used_set:
            continue

        while num in a_color:
            num += 1

        color_dic[n].add(num)
        color_dic[c].add(num)
        a_color.add(num)
        comp[(n, c)] = num
        comp[(c, n)] = num

        if c not in used_set:
            dq.append(c)

    used_set.add(n)

print(max_)
for a, b in edge:
    print(comp[(a, b)] + 1)


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

int main() {
    int A, B;
    cin >> A >> B;
    for(int x=B*10;x<B*20;x++){
        if(int(x*0.1)==B && int(x*0.08)==A){
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256