akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
	int h[10];
	int x1=0, x2=0, x3=0;

	for(int i=0; i<10; ++i){
		cin >> h[i];
	}

	for(int i=0; i<10; ++i){
		if(h[i] >= x1){
			x3 = x2;
			x2 = x1;
			x1 = h[i];
		}else if(h[i] >= x2){
			x3 = x2;
			x2 = h[i];
		}else if(h[i] >= x3){
			x3 = h[i];
		}
	}

	cout << x1 << endl << x2 << endl << x3 << endl;

	return 0;
}

Measured memory_bytes: 0
import sys
S = list(input())
if (len(S) % 2 == 1):
    print("No")
    sys.exit()
pre = S.pop(0)
for s in S:
    if(pre == "h"):
        if(s != "i"):
            print("No")
            sys.exit()
    elif(pre != "i"):
        print("No")
        sys.exit()
    pre = s
print("Yes")





Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1e9 + 7;
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	vector<long long> pref(n);
	for (int i = 0; i < n; i++) {
		if (i == 0) pref[i] = a[i];
		else pref[i] = pref[i - 1] + a[i];
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		ans += a[i] * ((pref[n - 1] - pref[i]) % mod) % mod;
		ans %= mod;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

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


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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h.at(i);
    const int inf = 1 << 30;
    vector<int> dp(n,inf);
    dp.at(0) = 0;

    for (int i = 1; i < n; ++i) {
        dp.at(i) = dp.at(i-1) + abs(h.at(i) - h.at(i-1));
        if (2 <= i) {
            dp.at(i) = min(dp.at(i), dp.at(i-2) + abs(h.at(i) - h.at(i-2)));
        }
    }

    cout << dp.at(n-1) << endl;
    return 0;
}

Measured memory_bytes: 3960
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
	int n,h,w;
	cin>>h>>w>>n;
	h=max(h,w);
	cout<<(n/h)+(n%h>0?1:0)<<"\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,x,t;
  cin>>n>>x>>t;
  ll tm=0,p;
  while(n>p){
    p+=x;
    tm+=t;
  }
  cout<<tm<<endl;
  return 0;
}

Measured memory_bytes: 3580
import java.util.*;
import java.io.*;

public class Main 
{ 

	 static FastReader sc=new FastReader(); 
	  public static void main(String[] args) 
    {
    	String s=s();
    	long ss=0;
    	for(int i=0;i<s.length();i++){
    	    ss+=s.charAt(i)-'0';
    	}
        if(ss%9==0){
            System.out.println("Yes");
        }	
        else{
            System.out.println("No");
        }
        	
			
	
	}    	
    	
   static void input(int A[]) {
	   for(int i=0;i<A.length;i++) {
		   A[i]=sc.nextInt();
	   }
   }
     static int i() {
    	 return sc.nextInt();
     }
     static String s() {
    	 return sc.next();
     }
     static long l() {
    	 return sc.nextLong();
     }
     public static String rev(String str){  
    	    char ch[]=str.toCharArray();  
    	    String rev="";  
    	    for(int i=ch.length-1;i>=0;i--){  
    	        rev+=ch[i];  
    	    }  
    	    return rev;  
    	}  
        static void sort(int[] arr){
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            int tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }   
        Arrays.sort(arr);
}
  
        
        
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
} 






Measured memory_bytes: 36560
x=int(input())
s=[0 for i in range((10**5)+3)]
s[0]+=1
for i in range(1,(10**5)+3,1):
    if s[i]==0:
        for j in range(2,(10**5)+3,1):
            if (i+1)*j>=(10**5)+3:
                break
            else:
                s[(i+1)*j-1]+=1

for k in range(x-1,(10**5)+3,1):
    if s[k]==0:
        print(k+1)
        break

Measured memory_bytes: 3864
def solve():
    N, K = map(int, input().split())
    Ax = list(map(int, input().split()))
    if N == K:
        print(1)
        exit()

    N -= K
    ans = 1

    while N > 0:
        N = N-(K-1)
        ans += 1

    print(ans)


# Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 52908
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  ll n,x;cin >> n>>x;
  vector <ll> a;
  REP(i,n){
    ll b;
    cin >> b;
    a.pb(b);
  }
  ll sum = 0;
  for(int i = 1;i < a.size()-1;i++){
    if(a[i] + a[i-1] > x){
      sum += a[i] - x + a[i-1];
      a[i] = x - a[i-1];
      if(a[i] < 0 )
	a[i] = 0;
    }
    
  }
  while(a[a.size()-1] + a[a.size()-2] > x){
    a[a.size()-1]--;
    sum++;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define vii vector<ll> 
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7, N = 1e4 + 3;

int main(){
    fast;
    ll n;
    cin >> n;
    ll a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    ll amount = 1000;
    for(int i = 0; i < n - 1; ++i){
        ll stocks = 0;
        if(a[i] < a[i+1]) stocks += amount/a[i];
        amount += (a[i+1] - a[i]) * stocks;
    }
    cout << amount << "\n";
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}

Measured memory_bytes: 3772
//https://arc100.contest.atcoder.jp/tasks/arc100_c
//sos dp维护子集里面的最大的两个值  
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const int N=1e6;
ll dp[N+100][2],a[N+100];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<(1<<n);i++) cin>>a[i];
	
	for(int i=0;i<1<<n;i++)
	{
		dp[i][0]=a[i];
		dp[i][1]=-0x3f3f3f3f3f3f3f3f;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<1<<n;j++)
		{
			if(j>>i&1)//维护子集里面最大的两个值 
			{
				dp[j][1]=max(dp[j][1],dp[j^(1<<i)][0]);
				if(dp[j][0]<dp[j][1]) swap(dp[j][0],dp[j][1]);
				dp[j][1]=max(dp[j][1],dp[j^(1<<i)][1]);
			}
		}
	}
	ll ans=0;
	for(int i=1;i<1<<n;i++)
	{
		ans=max(ans,dp[i][0]+dp[i][1]);
		cout<<ans<<endl;
	} 
	return 0;
} 

Measured memory_bytes: 13312
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

L,R,d = LI()
ans = 0
for i in range(L,R+1):
    if i % d == 0:
        ans += 1
print(ans)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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



int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    string ans = "No";
    if(c -a-b>0 and a*a + b*b + c*c - 2*a*c - 2*a*b - 2*b*c >0){
        ans = "Yes";
    }
    cout << ans << endl;
    
}

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

int main() {
	int a, b;
    cin >> a >> b;
  
  	if (a < 10 && b < 10) {
		cout << a * b << endl;
    }else{
      	cout << "-1" << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ll ans = 0;
  string s, wox = "";
  cin >> s;
  REP(i, s.size()) {
    if (s[i] != 'x') wox += s[i];
  }
  REP(i, (ll)wox.size() / 2) {
    if (wox[i] != wox[wox.size() - 1 - i]) {
      cout << "-1\n";
      return 0;
    }
  }
  vector<ll> cx(s.size());
  ll t = 0;

  REP(i, s.size() + 1) {
    if (s[i] == 'x')
      cx[t]++;
    else {
      t++;
    }
  }

  REP(i, floor(t / 2)) { ans += abs(cx[i] - cx[t - i - 1]); }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 4308
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll INF = 1LL << 32;

int main() {
  ll h, w;
  cin >> h >> w;

  ll K = 81 * (h + w + 1);
  bool dp[h][w][K];

  rep(i, h) rep(j, w) rep(k, K) dp[i][j][k] = false;

  vvll lmap(h, vll(w, 0));
  vvll rmap(h, vll(w, 0));

  rep(i, h) rep(j, w) cin >> lmap[i][j];
  rep(i, h) rep(j, w) cin >> rmap[i][j];

  dp[0][0][abs(lmap[0][0] - rmap[0][0])] = true;

  for (ll i = 0; i < h; i++) {
    for (ll j = 0; j < w; j++) {
      for (ll k = 0; k < K; k++) {
        if (dp[i][j][k]) {
          if (i + 1 < h) {
            ll curl = lmap[i + 1][j];
            ll curr = rmap[i + 1][j];
            dp[i + 1][j][abs(k + curl - curr)] = true;
            dp[i + 1][j][abs(k - curl + curr)] = true;
          }
          if (j + 1 < w) {
            ll curl = lmap[i][j + 1];
            ll curr = rmap[i][j + 1];
            dp[i][j + 1][abs(k + curl - curr)] = true;
            dp[i][j + 1][abs(k - curl + curr)] = true;
          }
        }
      }  // k
    }    // j
  }      // i

  ll ans = 0;
  for (ll k = 0; k < K; k++) {
    if (dp[h - 1][w - 1][k]) {
      ans = k;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 81920
#include<iostream>
#include<map>
#define int long long
using namespace std;
map<char, int>m;
signed main() {
	m['('] = 1; m[')'] = -1;
	int n, cnt = 0; cin >> n;
	bool flag = 1;
	for (int i = 0; i < n; i++) {
		char c; int p; cin >> c >> p;
		cnt += m[c] * p;
		if (cnt < 0)flag = 0;
	}
	if (cnt != 0)flag = 0;
	cout << (flag ? "YES\n" : "NO\n");
}


Measured memory_bytes: 3108
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair<int, pair<int, int> >
#define pf push_front

const int maxn = 1000* 100+ 5;
int x[maxn], d[maxn], c[maxn], ans[maxn];
vector <int> aj[maxn];
set < pii > s;

void f(int v, int dis, int co){
    if(s.find({v, dis}) != s.end())
        return;
    s.insert({v, dis});
    if(dis == 0){
        if(ans[v] == 0)
            ans[v] = co;
    }
    else{
        f(v, dis - 1, co);
        for(int i = 0; i < SZ(aj[v]); i ++){
            int u = aj[v][i];
            f(u, dis - 1, co);
        }
    }
    return;
}

int32_t main(){
    int n, m;
    cin >>n >>m;
    for(int i = 0; i < m; i ++){
        int u, v;
        cin >>u >>v;
        u --;
        v --;
        aj[u].pb(v);
        aj[v].pb(u);
    }
    int Q;
    cin >>Q;
    for(int i = 0; i < Q; i ++){
        cin >>x[i] >>d[i] >>c[i];
        x[i] --;
    }
    for(int i = Q - 1; i >= 0; i --){
        f(x[i], d[i], c[i]);
    }
    for(int i = 0; i < n; i ++)
        cout <<ans[i] <<' ';
    return false;
}



Measured memory_bytes: 67828
#include <bits/stdc++.h>
#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long LL;

int main(){
	int N, M;
	scanf("%d%d", &N ,&M);
	int ans=M*1900 +(N-M)*100;
	for (int i=0; i<M; i++) ans*= 2;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll h, w, n; cin >> h >> w >> n;
    vector<vector<ll>> color(h, vector<ll>(w, 0));

    // 0行目は右方向、端に着いたら1行目（下方向に1つ）
    // 1行目は左方向、端についたら2行目（下方向に2つ）・・・
    // と埋めていくのが効率が良い
    ll pos_i = 0, pos_j = 0;
    for(ll i=1; i<=n; i++){
        ll a; cin >> a;
        // 着色とカーソル移動
        while(a>0){
            a--;
            color[pos_i][pos_j] = i;
            (pos_i%2 == 0) ? pos_j++ : pos_j--;
            if(pos_j < 0 || pos_j >= w){
                pos_j = (pos_i%2 == 0) ? w-1 : 0;
                pos_i++;
            }
        }
    }

    // 出力処理
    for(ll i=0; i<h; i++){
        for(ll j=0; j<w; j++){
            cout << color[i][j] << ((j==w-1) ? endl : " ");
        }
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int K,S;
    int ans=0;
    cin >>K>>S;
    for(int i=0;i<=min(K,S);i++){
        for(int j=0;j<=min(K,S);j++){
            if(S-i-j>=0&&S-i-j<=min(K,S)){
                ans++;
            }
        }
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d %d", $a, $b);
  $num = $b - $a;
  $Etower = 0;
  for($i = 1; $i<=$num; $i++){
    $Etower += $i;
  }
  $ans = $Etower - $b;
  echo $ans;
?>

Measured memory_bytes: 3576
a,b,c,k = list(map(int,input().split()))

ret = 0

if a < k:
    ret += a
    k -=a
else:
    ret = k
    k = 0

k -= b
if k > 0:
    if k > c:
        ret -= c
    else:
        ret -= k

print(ret)

Measured memory_bytes: 9180
#include <iostream>
#include <string.h>
using namespace std;
int main(void) {
  int H; int W;
  cin >> H >> W;
  string field[50];
  for (int i = 0; i<H; ++i) cin >> field[i];
  const int dx[8] = {1,0,-1,0,1,1,-1,-1};
  const int dy[8] = {0,1,0,-1,1,-1,1,-1};
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if (field[i][j] == '.') {
        int counter=0;
        for (int d=0; d<8; ++d) {
        	const int ni = i + dx[d];
          	const int nj = j + dy[d];
          	if (ni < 0 or H <= ni) continue;
          	if (nj < 0 or W <= nj) continue;
          	if (field[ni][nj] == '#') counter++;
        }
        cout << char(counter + '0');
      }
      else {
          cout << '#';
      }
    }
    cout << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(min((25*a+26)/2,10*b+10)-max((25*a+1)/2,10*b)>0) cout << max((25*a+1)/2,10*b) << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
use proconio::input;
use proconio::fastout;
use proconio::marker::{Chars};

#[fastout]
fn main() {
    input! {
        a:i32,
        b:i32,
    }
    if a<=8&&b<=8{
        println!("{}","Yay!");
    }else{
        println!("{}",":(");
    }
}

Measured memory_bytes: 2176
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const int MAX_N = 310;
const int MAX_M = 310;
const int P = 3;

int main() {
  string s;
  int N, C[MAX_N], VDL[P][MAX_N], dp[P][MAX_N][MAX_M];
  while(cin >>N){
    int M; cin >>M;
    REP(n, N){
      getline(cin, s); getline(cin, s);
      cin >>C[n];
      REP(p, P) cin >>VDL[p][n];
    }
    memset(dp, -1, sizeof(dp));
    REP(i, P) dp[i][0][0] = 0;
    REP(p, P){
      REP(n, N){
        REP(m, M + 1){
          if(dp[p][n][m] == -1) continue;
          if(m + C[n] <= M){
            dp[p][n][m + C[n]] = max(dp[p][n][m + C[n]], dp[p][n][m] + VDL[p][n]);
            dp[p][n + 1][m + C[n]] = max(dp[p][n + 1][m + C[n]], dp[p][n][m] + VDL[p][n]);
          }
          dp[p][n + 1][m] = max(dp[p][n + 1][m], dp[p][n][m]);
        }
      }
    }
    int ans = 0;
    REP(p, P) REP(m, M + 1) ans = max(ans, dp[p][N][m]);
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 2344
def main():
    S = str(input())
    T = str(input())

    max = 0
    for i in range(len(S)-len(T)+1):
        count = 0
        for n in range(len(T)):
            if S[i+n] == T[n]:
                count += 1
        if count > max:
            max = count
    print(len(T) - max)


main()


Measured memory_bytes: 9112
from collections import Counter
from itertools import product
import numpy as np

n,m,q  = map(int,input().split())
rails=[tuple(map(int,input().split())) for i in range(m)]
qs=[tuple(map(int,input().split())) for i in range(q)]

xlist = np.array([[0 for j in range(n)] for i in range(n)])
for (l,r) in rails:
    xlist[l-1,r-1]+=1

sumsumlist = np.cumsum(np.cumsum(xlist,axis=1),axis=0)


for (p,q) in qs:
    if p>1:
        ans = sumsumlist[q-1][q-1] - sumsumlist[q-1][p-2] - sumsumlist[p-2][q-1] + sumsumlist[p-2][p-2]
    elif p==1:
        ans = sumsumlist[q-1][q-1]

    print(ans)


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  
  int count = 0;
  
  bool flag = true;
  bool flag_2 = true;
  while(flag) {
    for(int i = 0; i < N; ++i) {
      if(A[i] % 2 == 0) {
        continue;
      } else {
        flag_2 = false;
      }
    }
    
    if(flag_2 == false) {
      cout << count << endl;
      flag = false;
    } else {
      for(int i = 0; i < N; ++i) {
        A[i] = A[i] / 2;
      }
      count++;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define MAX 1000
#define ll long long
#define P pair<int,int>
using namespace std;
const int mod = 1000000007;
//char c[MAX][MAX];
int step[MAX][MAX];
int H,W,N; 
int vy[4] ={1,-1,0,0}, vx[4] = {0,0,-1,1}; //up,down,left,right 

signed main(){
    string s,t; cin >> s >> t;
    rep(i,s.size()) if(s[i] != t[i]){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3620
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

//なんで解けたか
//何番目にあるかは対称性より関係ない
//枚数が0-3だけなので状態がまとめられる

//n枚で固定なので1個、2個、3個の枚数が決まればn-(i+j+k)で0個の皿の枚数が求まる
//状態を3つ持つだけでいい300^3=9*10^6くらいで余裕

//遷移を書いたときに、遷移元と遷移先に同じ項が出てくる
//どう解消するか→移項するだけ

int n;
double dp[310][310][310];
double rec(int i, int j, int k) {

	//メモってあればそれを使う
	//!=-1にするとdoubleのせいでバグる
	if (dp[i][j][k] >=0.0)return dp[i][j][k];

	//境界条件すべて0の状態から0枚にするのは自明に0枚必要
	if (i == 0 && j == 0 && k == 0)return 0.0;

	double res = 0.0;

	//1枚使った状態 値×確率を集める
	if (i > 0)res += rec(i - 1, j, k)*i;//残り1枚の皿が1枚減る
	if (j > 0)res += rec(i + 1, j-1, k)*j;//残り2枚の皿が1枚減って、残り1枚になる
	if (k > 0)res += rec(i, j+1, k-1)*k;//残り3枚の皿が1枚減って、残り2枚の皿が1枚増える
	
	//+1にn/(i+j+k)をかけるとnになる。あとからまとめて(i+j+k)割るので、+n
	res += n;

	res *= 1.0 / (i + j + k);

	//メモして返す
	return dp[i][j][k] = res;
}

int main() {

	cin >> n;
	int one = 0;
	int two = 0;
	int three = 0;

	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		if (a == 1)one++;
		if (a == 2)two++;
		if (a == 3)three++;
	}

	memset(dp, -1, sizeof(dp));

	cout << fixed << setprecision(10) << rec(one, two, three) << endl;

	return 0;
}

Measured memory_bytes: 233088
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N,D;
  cin >> N >> D;
  cout << (N-1)/(2*D+1) + 1 << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
# キュー
from collections import deque

n = int(input())
graph = [set() for _ in range(n+1)]

for i in range(1,n):
    a,b = map(int,input().split())
    graph[a].add((b,i))
    graph[b].add((a,i))

k = 0
root = 0
for i in range(1,n):
    if( k < len(graph[i]) ):
        root = i
        k = len(graph[i])

ans = [0] * (n+1)
d = deque()
d.append((root,0,0))

while(d):
    child,parent,color = d.pop()
    edges = graph[child]
    next_color = 1
    for tmp in edges:
        x,i = tmp
        if(x != parent):
            if(next_color == color):
                next_color += 1
            ans[i] = next_color
            d.append((x,child,next_color))
            next_color += 1

print(k)
for i in range(1,n):
    print(ans[i])

Measured memory_bytes: 81312
A = [1,-0.1,0]
while True:
    n = input()
    if n == 0:
        break
    L =sorted((raw_input().split() for _ in xrange(n)),
              key = lambda a:(a.count("0"),-a.count("1"),a.count("2")),
              reverse = True)
    print "\n".join(zip(*L)[0])

Measured memory_bytes: 4232
//思维（容斥原理 ）+带权并查集
#include<bits/stdc++.h>
using namespace std;

int n,m,k;
int fa[100005];//建一个数组
int ans[100005],cnt[100005];//ans记录同和i在friendship且有blockship或者有直接关系,cnt统计i的friendship总数量 
//容斥原理：result=cnt[find(i)]-ans[i]-1; 自己所在的friendship集合的数量减去不符合条件的朋友和自己（关键） 
 
void init(){//初始化数组
	for(int i=1;i<=n;i++){
		fa[i]=i;
		cnt[i]=1;
	}
}

//递归式
int find(int x){
    //x==fa[x]就直接返还了
    if (x != fa[x]) fa[x] = find(fa[x]);
    return fa[x];
}

void join(int x, int y) {
    int fx = find(x),fy = find(y);
    if (fx == fy) return;//相交不合并
    else {
        fa[fx] = y;//规则小看题来规定，没有明示那就随便小 
        cnt[fy]+=cnt[fx];//注意cnt的维护 
    }
}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	init();
	int x,y;
	for(int i=1;i<=m;i++){//直接关系的不算 
		scanf("%d%d",&x,&y);
		ans[x]++,ans[y]++;
		join(x,y);
	}
	for(int i=1;i<=k;i++){//同一个friendship且同一个blockship不算 
		scanf("%d%d",&x,&y);
		if(find(x)==find(y))ans[x]++,ans[y]++;
	}
	for(int i=1;i<=n;i++){
		printf("%d ",cnt[find(i)]-ans[i]-1);
	}
	return 0;
}

Measured memory_bytes: 2560
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		// スペース区切りの整数の入力
		int k = sc.nextInt();
		String s = sc.next();
      	for(int i=0;i<n;i++){
          if(i==k-1){
		System.out.print((char)(s.charAt(i)-('A'-'a')));
          }else{
		System.out.print(s.charAt(i));
          }
        }
		// 出力
	}
}

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


int main()
{

    int a,b,flag=-1;
    cin>>a>>b;

    string str,str_;

    for(int i=0 ; i<b ; i++)
    {
        str+=to_string(a);
    }

    for(int i=0 ; i<a ; i++)
    {
        str_+=to_string(b);
    }



    for(int i=0 ; i<min(a,b) ; i++)
    {
        if(str[i] != str_[i])
        {
            if(str[i] > str_[i])
            {
                cout<<str_<<endl;
                flag=0;
                break;
            }
            else
            {
                cout<<str<<endl;
                flag=0;
                break;
            }
        }
    }

    if(flag==-1)
    {
        cout<<str<<endl;
    }

}



Measured memory_bytes: 256
n = gets.to_s.chomp.chars
k = gets.to_s.to_i

sz = n.size
dpj = Array.new(sz+1){ [0] * (k+1) }
dpl = Array.new(sz+1){ [0] * (k+1) }
dpj[0][0] = 1

n.each_with_index do |c, i|
  
  (k+1).times do |j|
    dpj[i+1][j] += dpj[i][j] if c == '0'
    dpl[i+1][j] += dpj[i][j] if c >  '0'
    dpl[i+1][j] += dpl[i][j]
  end
  
  k.times do |j|
    dpj[i+1][j+1] += dpj[i][j] if c >  '0'
    dpl[i+1][j+1] += dpj[i][j] * [0, c.to_i-1].max
    dpl[i+1][j+1] += dpl[i][j] * 9
  end
end  

puts dpj[sz][k] + dpl[sz][k]

Measured memory_bytes: 3836
/* #                          */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
#define		it(x)  x.begin() 
#define		all(x)  x.begin(), x.end()
#define		pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/
void MX(int& a, int b) {
    if (a < b) a = b;
}
int main() {
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vs v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    sort(all(v));
    v.push_back("zzzzzzzzzzz");

    int votes(0);
    int mx(-1);
    vector<pair<int, string>>  p;
    for (int i = 0; i < n; i++) {
        votes++;
        if (v[i] != v[i + 1]) {
            p.push_back({ votes, v[i]});
            MX(mx, votes);
            votes = 0;
        }
    }

    for (int i = 0; i < p.size(); i++) {
        if (p[i].first == mx)
            cout << p[i].second << '\n';
    }

    return 0;
}

Measured memory_bytes: 19428
#include <iostream>
#include <algorithm>
using namespace std; 
int arrCount[200005] = { 0 }; 
bool cmp(int iNum1, int iNum2)
{ 
    return iNum1 > iNum2;
}
int main()
{
    int n, m, i, t, iSum=0,maxn(1); 
    cin >> n >> m; 
    for (i = 1; i <= n; ++i)
    { 
        cin >> t;
        ++arrCount[t]; 
        maxn=(t>maxn?t:maxn);
    }
    sort(arrCount, arrCount + maxn+1,cmp); 
    for (i = m; arrCount[i]; ++i)
    { 
        iSum += arrCount[i]; 
    }
    cout << iSum << endl; 
    return 0; 
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,a[6060],dp[2020][2020],mx[2020],gx[101010][3],sz,mmxx,al;
void ggxx(int x,int y,int vl)
{
	gx[sz][0]=x;
	gx[sz][1]=y;
	gx[sz][2]=vl;
	sz++;
}
void gggxxx(int x,int y,int vl)
{
	dp[x][y]=max(dp[x][y],vl);
	mx[x]=max(mx[x],vl);
	swap(x,y);
	dp[x][y]=max(dp[x][y],vl);
	mx[x]=max(mx[x],vl);
	mmxx=max(mmxx,vl);
}
void ggggxxxx()
{
	for(int i=0;i<sz;i++)
	{
		gggxxx(gx[i][0],gx[i][1],gx[i][2]);
	}
	sz=0;
}
int main()
{
	memset(dp,-0x3f3f3f,sizeof(dp));
	memset(mx,-0x3f3f3f,sizeof(mx));
	mmxx=-0x3f3f3f;
	cin>>n;
	for(int i=0;i<n*3;i++)
	{
		cin>>a[i];
		a[i]--;
	}
	gggxxx(a[0],a[1],0);
	for(int i=0;i<n-1;i++)
	{
		int x[3];
		x[0]=a[3*i+2];
		x[1]=a[3*i+3];
		x[2]=a[3*i+4];
		if(x[0]==x[1] && x[1]==x[2])
		{
			al++;
			continue;
		}
		for(int tt=0;tt<3;tt++)
		{
			ggxx(x[0],x[1],max(mmxx,dp[x[2]][x[2]]+1));
			for(int j=0;j<n;j++)
			{
				if(x[0]==x[1])
				{
					ggxx(j,x[2],dp[j][x[0]]+1);
				}
				ggxx(j,x[2],mx[j]);
			}
			swap(x[0],x[1]);
			swap(x[1],x[2]);
		}
		ggggxxxx();
	}
	cout<<max(mmxx,dp[a[3*n-1]][a[3*n-1]]+1)+al<<endl;
	return 0;
}

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

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

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

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

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

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    set<char> Set;
    rep(i,s.size()){
        Set.ins(s[i]);
    }
    rep(i,26){
        if (!Set.count(char(i+'a'))){
            cout<<char(i+'a')<<endl;
            return 0;
        }
    }
    cout<<"None\n";
    return 0;
}


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

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  char c[H][W];
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      char input;
      cin >> input;
      c[i][j] = input;
    }
  }

  int patterns = 0;

  for (int hBit = 0; hBit < (1<<H); ++hBit) {
    for (int wBit = 0; wBit < (1<<W); ++wBit) {

      int sum  = 0;
      for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
          if ( !((hBit & (1<<i)) || (wBit & (1<<j))) && c[i][j] == '#' ) ++sum;
        }
      }

      if (sum == K) ++patterns;

    }
  }

  cout << patterns << endl;
}


Measured memory_bytes: 3196
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

int main(void)
{
    int n;
    std::cin >> n;

    int limit = 1;
    while (n > limit * (limit - 1) / 2) {
        limit++;
    }

    for (int i = 1; i < limit; i++) {
        if (i != limit * (limit - 1) / 2 - n) {
            std::cout << i << std::endl;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int search(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key){
    i++;
  }
  return i!=n;
}

int main(){
  int i,n,A[10000],q,key,sum=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(search(A,n,key)){
      sum++;
    }
  }
  printf("%d\n",sum);
}

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

int main() {
    int n;
    cin >> n;
    if(n <= 2) {
        cout << 1 << endl;
    }
    else if(n%2 == 0) {
        cout << (n/2) << endl;
    } else {
        cout << (n/2)+1 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 44

int main(void)
{
  /* 変数の宣言 */
  int n, i;
  int f0 = 0, f1, f2;
  /* フィボナッチ数(n=0)の出力 */

  scanf("%d", &n);

  f1 = 1;
  /* フィボナッチ数の計算 */
  for( i = 1 ; i < MAX + 1 ; i++ ){
    // フィボナッチ数の計算
    f2 = f1+ f0;
    // 変数の代入
    f0 = f1;
    f1 = f2;
    if( i == n ){
      printf("%d\n", f1);
      break;
    }
  }


  return 0;
}



Measured memory_bytes: 2080
#pragma GCC optimize("O3")
    #pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize("unroll-loops")
     
    #include <algorithm>
    #include <bitset>
    #include <cassert>
    #include <chrono>
    #include <cmath>
    #include <complex>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <ctime>
    #include <deque>
    #include <functional>
    #include <iomanip>
    #include <iostream>
    #include <iterator>
    #include <limits>
    #include <climits>
    #include <list>
    #include <map>
    #include <numeric>
    #include <queue>
    #include <random>
    #include <ratio>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <string>
    #include <unordered_map>
    #include <unordered_set>
    #include <utility>
    #include <vector>
    using namespace std;
     
    typedef long long ll;
    typedef long double LD;
    #define int ll
    #define double LD
    #define pb push_back
    #define mp make_pair
    #define REP(i,n) for (int i = 0; i < n; i++)
    #define loop(i,n) for (int i = 0; i < n; i++)
    #define FOR(i,a,b) for (int i = a; i < b; i++)
    #define REPD(i,n) for (int i = n-1; i >= 0; i--)
    #define FORD(i,a,b) for (int i = a; i >= b; i--)
    #define remax(a,b) a = max(a,b)
    #define remin(a,b) a = min(a,b)
    #define mem(a, b) memset(a, b, sizeof a)
    #define append push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define print(x) cout << (x) << endl
    #define PRECISION(x) cout << fixed << setprecision(x)
    #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
     
    const double PI=acos(-1);
    const int MOD = 1000000007;
    const int FMOD = 998244353;
    const double eps = 1e-9;
     
    mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
  
  
	signed main()
	{
		string s;
		cin>>s;
		int n=s.size();
		deque<char> dq;
		loop(i,n)
		{
			dq.push_back(s[i]);
		}
		int q;
		cin>>q;
		int cnt=0;
		while(q--)
		{
			int t;
			cin>>t;
			if(t==1)
			{
				cnt++;
			}
			else
			{
				int r;
				char c;
				cin>>r>>c;
				if(r==1)
				{
					if(cnt%2==0)
					dq.push_front(c);
					else
					dq.push_back(c);
				}
				else
				{
					if(cnt%2==0)
					dq.push_back(c);
					else
					dq.push_front(c);
				}
			}
			
		}
		if(cnt%2)
		{
			while(!dq.empty())
			{
				char p=dq.back();
				cout<<p;
				dq.pop_back();
			}
		}
		else
		{
			while(!dq.empty())
			{
				char p=dq.front();
				cout<<p;
				dq.pop_front();
			}
		}
	}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <atcoder/maxflow>

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

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

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
vector<string> S;
inline void input(){
    fast_io();
    cin >> N >> M;
    for (int i = 0; i < N; i++)
    {
        string s; cin >> s;
        S.push_back(s);
    }
}

#define WALL '#'
#define PATH '.'


inline int solve(){
    atcoder::mf_graph<int> MF(N*M+10);
    int source = N*M , sink = N*M+1;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            if(S[i][j]==WALL) continue;
            if((i+j)%2==0){
                MF.add_edge(source, i*M+j, 1);
                for (int k = 0; k < 4; k++)
                {
                    int x = i + dx[k];
                    int y = j + dy[k];
                    if(x < 0|| x>=N) continue;
                    if(y < 0|| y>=M) continue;
                    if(S[x][y]==WALL) continue;
                    MF.add_edge(i*M+j, x*M+y, 1);
                }
                
            }
            else{
                MF.add_edge(i*M+j, sink, 1);
            }
        }
    }
    int ans = MF.flow(source, sink);
    vector<string> Fields = S;
    for(auto e:MF.edges()){
        if(e.from != source && e.to != sink && e.flow==1){
            int fi = e.from / M, fj = e.from % M;
            int ti = e.to / M, tj = e.to % M;
            if(fi==ti){
                Fields[fi][min(fj,tj)] = '>';
                Fields[fi][max(fj,tj)] = '<';
            }
            else{
                Fields[min(fi,ti)][fj] = 'v';
                Fields[max(fi,ti)][fj] = '^';
            }
        }
    }

    // output
    cout << ans << "\n";
    for(auto f:Fields){
        cout << f << "\n";
    }
      
    return 0;
}   

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


Measured memory_bytes: 5484
n, k = list(map(int, input().split()))
aaa = list(map(int, input().split()))

if n == 1:
    print(*(aaa * (k % 2)))
    exit()

follow = [-1] * n
tmp = {}
fix = 0
while True:
    for i in range(n):
        a = aaa[i]
        if a in tmp:
            follow[tmp[a]] = (i + 1) % n
            tmp[a] = i
            fix += 1
        else:
            tmp[a] = i
    if fix >= n:
        break
# print(follow)
loop = 1
i = 0
while True:
    j = follow[i]
    if j == 0:
        if i == n - 1:
            loop += 1
        break
    if i + 1 >= j:
        loop += 1
    # print(i, j, loop)
    i = j

k %= loop
if k == 0:
    print()
    exit()

# print(k, loop)


def simulate(aaa, s, follow):
    tmp = []
    exs = set()
    for a in aaa[s:]:
        if a in exs:
            while True:
                b = tmp.pop()
                exs.remove(b)
                if a == b:
                    break
        else:
            tmp.append(a)
            exs.add(a)

    # i = s
    # while i != 0:
    #     j = follow[i]
    #     if j == 0:
    #         if i == n - 1:
    #             tmp.append(aaa[i])
    #         break
    #     elif i + 1 >= j:
    #         tmp.append(aaa[i])
    #         i = (i + 1) % n
    #     else:
    #         i = j
    return tmp


# print(simulate(aaa * 5, 0, follow))
# print(simulate(aaa * 6, 0, follow))

i = 0
loop = 1
while loop <= k:
    j = follow[i]
    if i + 1 >= j:
        if loop == k:
            print(*simulate(aaa, i, follow))
            break
        loop += 1
    i = j


Measured memory_bytes: 55320
#include<stdio.h>
int main(void)
{
	int a,b,x[5],i;
	for(i=0;i<4;i++){
		a=0; b=0;
		scanf("%d %d",&a,&b);
		if(a==1) x[i]=b*6000;
		if(a==2) x[i]=b*4000;
		if(a==3) x[i]=b*3000;
		if(a==4) x[i]=b*2000;
	}
	for(i=0;i<4;i++) printf("%d\n",x[i]);
}

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

int main() {

  int n;
  cin >> n;
  int a;
  double ans = 0;
  for(int i = 0; i < n; i++) {
    cin >> a;
    ans = ans + 1.0 / a;
  } 
  ans = 1 / ans;
  cout << ans << endl;
}

Measured memory_bytes: 256
def divisor(n):
  ass=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ass.append(i)
      if i!=n//i:ass.append(n//i)
  return ass
n,m=map(int,input().split())
d=sorted(divisor(m))
for i in d[::-1]:
  if m//i>=n:print(i);break

Measured memory_bytes: 3060
#include <cstdio>
#include <queue>
using namespace std;

int main(void) {
    char order[16];
    priority_queue<int> S;

    while (1) {
        scanf("%s", order);
        if (order[0] == 'i') {
            int k; scanf("%d", &k);
            S.push(k);
        } else if (order[1] == 'x') {
            printf("%d\n", S.top());
            S.pop();
        } else if (order[0] == 'e') {
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 5788
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;


const int V = 100005;
vector<int> to[V*2];
bool visited[V*2];

vector<int> cnt;
void dfs(int v){
    if (visited[v]) return;
    visited[v] = true;
    for(int u : to[v]) dfs(u);
    cnt[v/V]++;
    return;
}
int main(){
    int n;
    cin >> n;
    rep(i, n){
        int x, y;
        cin >> x >> y;
        y += V;
        to[x].push_back(y);
        to[y].push_back(x);
    }

    ll ans =0;
    rep(i, V*2){
        cnt = vector<int>(2); //再定義可能らしい
        dfs(i);
        ans += (ll)cnt[0]*cnt[1];
    }
    ans -= n;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10240
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>

using namespace std;

int main(void) {


	int num1 = 0, num0 = 0;

	string s;

	cin >> s;

	//cout << atoi(s.cs()) << "\n";

	for (int k = 0; k<s.size(); k++) {
		if (s[k] - '0' == 1)num1++;
		else if (s[k] - '0' == 0)num0++;
	}

	
	cout << min(num1,num0)*2 << "\n";


	return 0;
}


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

int main(){
  int N = 0;
  int Y = 0;
  string S = "";
  cin >> N;
  
  rep(i,N){
    cin >> S;
    if(S == "Y"){
      Y++;
      break;
    }
  }
  if(Y==0)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
  
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"io"
	"os"
)

func pow(x int, y int) int {
	//_, _ = fmt.Printf("pow: %v, %v\n", x,y)
	z := x
	if y == 0 {
		return 1
	}
	var i int
	for i =1;i<y;i++ {
		z = z * x
	}
	return z
}

func answer(reader io.Reader, writer io.Writer) {
	var a, b int
	_, _ = fmt.Fscan(reader, &a)
	_, _ = fmt.Fscan(reader, &b)
	//var c int
	//c = 1
	//d = a
	var ret float64
	for i:=1; i< a+1; i++ {
		n := 0
		for n = 0; i * pow(2,n) < b;n++{

		}
		ret += float64(1)/float64(a * pow(2,n))
		//fmt.Printf("i:%d, n:%d, %.12f\n", i, n, ret)
	}
	//var r float64
	//r = float64(7)/float64(48)
	_, _ = fmt.Fprintf(writer, "%.12f", ret)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 512