akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>

using namespace std;

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

#define FOR(i,n,m) for(int i=n; i<(int)m; i++)
#define ROF(i,n,m) for(int i=n; i>(int)m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define debug true
#define dprintf debug && printf

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1e9+7;
const int MAXN = 2e5+5;

char s[MAXN];
vii ed;
int n;

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

    scanf("%s", s);
    n = strlen(s);

    if(s[0] == '0' || s[n-1] == '1'){
        printf("-1\n");
        return 0;
    }
    FOR(i,0,n-1) if(s[i] != s[n-2-i]){
        printf("-1\n");
        return 0;
    }

    int i = n/2 - 1;
    int sz, lst1, lst2, par1, par2;
    if(n&1){
        sz = 3;
        lst1 = 2, lst2 = 3, par1 = 1, par2 = 1;
        ed.pb({2,1});
        ed.pb({1,3});
    }
    else{
        sz = 4;
        if(s[i] == '0'){
            ed.pb({1,2});
            ed.pb({1,3});
            ed.pb({1,4});
            par1 = par2 = 1;
            lst1 = 2;
            lst2 = 3;
        }
        else{
            ed.pb({1,2});
            ed.pb({2,3});
            ed.pb({3,4});
            lst1 = 1;
            par1 = 2;
            par2 = 3;
            lst2 = 4;
        }
        i--;
    }
    while(i > 0){
        if(s[i] == '0'){
            ed.pb({par1,++sz});
            lst1 = sz;
            ed.pb({par2,++sz});
            lst2 = sz;
        }
        else{
            ed.pb({lst1, ++sz});
            par1 = lst1;
            lst1 = sz;
            ed.pb({lst2, ++sz});
            par2 = lst2;
            lst2 = sz;
        }
        i--;
    }

    for(auto e : ed){
        printf("%d %d\n", e.F, e.S);
    }

    return 0;
}


Measured memory_bytes: 2420
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int n, m;
  cin >> n >> m;
  cout << (n - 1) * (m - 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <unordered_map>
#define inputarr(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define prllarr(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
#define pb push_back
#define ll long long
#define mod 1000000007
#define foi ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define in(n) scanf("%lld",&n);
#define in2(x,y) scanf("%lld %lld",&(x),&(y));
#define in3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z));
#define out(n) printf("%lld\n",n);
#define out2(x,y) printf("%lld %lld\n",x,y);
#define test(t)  ll t; in(t);while(t--)
#define set(arr,n,s) for(ll i=0;i<n;i++){arr[i]=s;}

ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1){res=(res*x)%p;} y=y>>1;x=(x*x)%p;}return res;}
ll modInverse(ll a,ll p){return power(a,p-2,p);}//used with feemat little

ll gcd(ll x,ll y){if(x==0 || y==0){return max(y,x);}return gcd(y%x,x);}
ll gcdExtended(ll a,ll b,ll &x,ll &y){if(a==0){x=0;y=1;return b;}ll x1,y1;ll gcd = gcdExtended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return gcd;}//o(log(b))
;
ll dp[103][100005];
ll arr[104];
int main()
{
	ll n,k;
	in2(n,k)
	for(ll i=0;i<n;i++){
		in(arr[i])
	}
	for(ll i=k;i>=k-arr[0];i--){
		if(i<0)break;
		dp[0][i]=1;
	}
	for(ll i=1;i<n;i++){
		for(ll j=0;j<=k;j++){
			dp[i][j]+=dp[i-1][j];
			dp[i][j]%=mod;

			if(j-arr[i]-1>=0){
				dp[i][j-arr[i]-1]-=dp[i-1][j];
				if(dp[i][j-arr[i]-1]<0){
					dp[i][j-arr[i]-1]+=mod;
				}
			}
		}
		for(ll j=k-1;j>=0;j--){
			dp[i][j]+=dp[i][j+1];
			dp[i][j]%=mod;
		}
	}
	cout<<dp[n-1][0]<<endl;

}
/*error-----
convert every int to long long eg-1LL
create array with proper analysis of problem constrain
check mod also
*/






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

using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

template<typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48; 
    return x *= f;
}

const int N = 100000;

vector<int> R[N + 5], G[N + 5], V[N + 5];

int fa[N + 5];
int findset(int u) { return fa[u] == u ? u : fa[u] = findset(fa[u]); }
void addedge(int u, int v) { 
    G[u].pb(v); R[v].pb(u);
    fa[findset(u)] = findset(v); 
}

bool flag;
int cnt[3];
int col[N + 5];

void dfs(int u, int f, int c) {
    if(col[u] != -1) {
        flag |= (col[u] != c);
        return;
    }

    ++ cnt[col[u] = c];
    for(int i = 0; i < int(G[u].size()); ++i) {
        int v = G[u][i]; 
        if(v == u || v == f) { flag = true; }
        dfs(v, u, (c + 1) % 3);
    }
    for(int i = 0; i < int(R[u].size()); ++i) {
        int v = R[u][i];
        if(v == u || v == -f) { flag = true; }
        dfs(v, -u, (c + 2) % 3);
    }
}

ll calc(int x) {
    flag = 0;
    memset(cnt, 0, sizeof cnt);

    ll n = V[x].size();
    dfs(V[x][0], 0, 0);

    ll res = 0;
    if(cnt[0] && cnt[1] && cnt[2]) {
        res = 1ll * cnt[0] * cnt[1] 
            + 1ll * cnt[1] * cnt[2]
            + 1ll * cnt[2] * cnt[0];
    } else if(!flag) {
        for(int i = 0; i < int(V[x].size()); ++i) {
            res += G[V[x][i]].size();
        }
    }
    
    return flag ? n*n : res;
}

int n, m;
int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    read(n), read(m);
    memset(col, -1, sizeof col);
    for(int i = 1; i <= n; ++i) fa[i] = i;
    for(int i = 1; i <= m; ++i) {
        static int x, y;
        read(x), read(y); addedge(x, y);
    }
    for(int i = 1; i <= n; ++i) V[findset(i)].pb(i);

    ll ans = 0;
    for(int i = 1; i <= n; ++i) if(V[i].size()) { ans += calc(i); }

    printf("%lld\n", ans);

    return 0;
}


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

red = [0]*n
for i in range(n):
  a, b = map(int, input().split())
  red[i] = (a, b)
red.sort()

blue = [0]*n
for i in range(n):
  c, d = map(int, input().split())
  blue[i] = (c, d)
blue.sort()

ans = 0
pair_judge = [False]*(2*n+1)
k = 0
for i in range(n):
  a, b = blue[i][0], blue[i][1]
  while True:
    if k < n and red[k][0] < a:
      pair_judge[red[k][1]] = True
      k += 1
      continue
    else:
      break
  for j in range(b-1, -1, -1):
    if pair_judge[j]:
      ans += 1
      pair_judge[j] = False
      break

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main(){int x,y,px,py,n,res=0;cin>>x>>y>>n>>px>>py;for(;n>1;n--){cin>>x>>y;res+=(((x-px)*(y-py)>0)?(max(abs(x-px),abs(y-py))):(abs(x-px)+abs(y-py)));px=x;py=y;}cout<<res<<endl;return 0;}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const double eps=1e-5;
const int N=2e5+500;
int w[N],n,K;
int judge(int x)
{
	long long cnt=0;
	for(int i=1;i<=n&&cnt<=K;i++)cnt+=(w[i]+x-1)/x-1;
	return cnt<=K;
}
int main()
{
	scanf("%d%d",&n,&K);int mx=0;
	for(int i=1;i<=n;i++)scanf("%d",w+i),mx=max(mx,w[i]);
	int l=1,r=mx,mid;
	while(l!=r)
	{
		mid=(l+r)>>1;
		if(judge(mid))r=mid;
		else l=mid+1;
	}
	cout<<l<<endl;
}

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

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

    int n = s.size();
    int redCnt = 0, blueCnt = 0;
    rep (i, n)
    {
        if (s[i] == '0')
            redCnt++;
        else
            blueCnt++;
    }

    cout << min(redCnt, blueCnt) * 2 << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll n,t;
ll a[100010];

int main(){
  cin>>n>>t;
  rep(i,n)cin>>a[i];
  sort(a,a+n);
  ll res=1;
  rep(i,n){
    ll idx=upper_bound(a,a+n,a[i]+t)-a;
    ll cnt=idx-i;
    (res*=cnt)%=mod;
  }
  cout<<res<<endl;
  return 0;
}



Measured memory_bytes: 3928
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
int dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};

int ketasum(int a){
  int s=0;
  while (a>0) {
    s+=(a%10);
    a/=10;
  }
  return s;
}


int main(int argc, char const *argv[]) {
  int n,ans=9999;;
  std::cin >> n;
  for(int i=1; i<n; i++){
    int res=ketasum(i)+ketasum(n-i);
    ans=min(ans,res);
  }
  std::cout << ans << '\n';
  return 0;
}


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


typedef long long ll;
int main() {
  int m, k;
  cin >> m >> k;
  int max = 1 << m;
  if (k >= max) {
    cout << "-1" << endl;
    return 0;
  }
  if (m == 0) { 
    cout << "0 0" << endl;
    return 0;
  }
  if (m == 1) {
    if (k == 1) {
      cout << "-1" << endl;
    }
    else {
      cout << "0 0 1 1" << endl;
    }
    return 0;
  }
  for (int i = 0; i < max; ++i) { 
    if (i == k) continue;
    cout << i << " ";
  }
  cout << k << " ";
  for (int i = max-1; i >= 0; --i) { 
    if (i == k) continue;
    cout << i << " ";
  }
  cout << k << endl;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = "";
		int[] top = new int[] { 21, -1 };

		int n = Integer.parseInt(br.readLine());
		int i = 0;
		while ((s = br.readLine()) != null) {
			if (i == n)
				break;
			Scanner sc = new Scanner(s);
			int _angler = sc.nextInt();
			int _catch = sc.nextInt();

			if (_angler < 0 || _angler > 20)
				continue;
			if (_catch < 0 || _angler > 100)
				continue;

			if (top[1] < _catch || (top[1] == _catch && top[0] > _angler)) {
				top[0] = _angler;
				top[1] = _catch;
			}
			i++;
		}
		System.out.println(top[0] + " " + top[1]);
	}
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse

#endif

int main(void)
{
	ll n; cin >> n;
	vector<ll> a(n);
	rep(i, 0, n)
		cin >> a[i];


	vector<ll> copy_a;
	copy_a = a;
	sort(all(copy_a));

	rep(i, 0, n)
	{
		if (a[i] == copy_a.back())
			cout << copy_a[n - 2] << endl;
		else
			cout << copy_a[n - 1] << endl;
	}

	return 0;
}



Measured memory_bytes: 4736
#include <stdio.h>
#include <stdlib.h>

void InsertionSort(int *a, int n);
void Nprint(int *a, int n);

int main(void){
  int i, n, *a;

  scanf("%d", &n);
  a = (int *)malloc(sizeof(int) * n);
  if(a == NULL){
    printf("?????¢????¢??????¨??????\n");
    return -1;
  }
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  InsertionSort(a, n);
  free(a);
  return 0;
}


void InsertionSort(int *a, int n){
  int i, j, temp;

  Nprint(a, n);

  for(i = 1; i < n; i++){
    for(j = i-1; j >= 0; j--){
      if(a[j] < a[j+1])  break;
      temp = a[j];
      a[j] = a[j+1];
      a[j+1] = temp;
    }
    Nprint(a, n);
  }
}


void Nprint(int *a, int n){
  int i;

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

Measured memory_bytes: 604
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
    n <- getInt
    as <- replicateM n getInt
    let (m1 : m2 : _) = reverse $ sort as
    let ans = map (solve m1 m2) as
    mapM_ print ans

solve m1 m2 a | a == m1 = m2
              | otherwise = m1

Measured memory_bytes: 66428
# AOJ 1566 Movie
# Python3 2018.7.13 bal4u

n = int(input())
tbl = []
for i in range(n):
	a, b = map(int, input().split())
	tbl.append([b, a])
tbl.sort()
ans = saw = 0
seen = [0]*101
for i in range(1, 32):
	for j in range(n):
		if i < tbl[j][1] or tbl[j][0] < i: continue
		if seen[j]: continue
		ans += 100; seen[j] = 1; saw += 1
		break;
print(ans+(31-saw)*50)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);

#define F first
#define S second
#define pb push_back
#define int long long
#define maxn 200000
#define mod 1000000007
#define inf 1000000000000000000

#define fr(i,a,b) for(int i=a;i<b;i++)
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); //freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);
#define all(x) begin(x), end(x)
#define PII pair<int, int>
#define VI vector<int>
#define VII vector<PII>

using namespace std;

int n, m, v, p, ans;
VI x;

bool check(int pos){
    int a = x[pos];
    if(a + m < x[p]) return false;

    int rem = m*v;
    fr(i, 1, n + 1){
        if(i < p or i >= pos){
            rem -= m;
        }
        else rem -= a + m - x[i];
    }

    return (rem <= 0);
}

signed main()
{
    
    FLASH
    x.pb(inf);

    cin>>n>>m>>v>>p;
    fr(i, 1, n + 1){
        int a;
        cin>>a;
        x.pb(a);
    }
    
    sort(all(x));
    reverse(all(x));

    int l = 1, r = n;
    while(l <= r){
        int mid = (l + r)>>1;
        bool c = check(mid);

        if(c){
            ans = mid;
            l = mid + 1;
        }
        else r = mid - 1;
    }
    cout<<ans<<'\n';    
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

vector<int> G[100001];
int dp[100001][2];

void dfs( int v, int p = -1 ){
    dp[v][0] = dp[v][1] = 1;
    for( auto nv : G[v] ){
        if( nv == p ) continue;
        dfs( nv, v );
        dp[v][0] *= dp[nv][0] + dp[nv][1];
        dp[v][0] %= MOD;
        dp[v][1] *= dp[nv][0];
        dp[v][1] %= MOD;
    }
}

signed main(){
    int N; cin >> N;
    REP( i, N - 1 ){
        int from, to; cin >> from >> to;
        from--, to--;
        G[from].push_back( to );
        G[to].push_back( from );
    }

    dfs( 0 );

    cout << ( dp[0][0] + dp[0][1] ) % MOD << endl;
}


Measured memory_bytes: 14208
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    set<string> dic;
    rep(i,N) {
        string S; cin >> S;
        dic.emplace(S);
    }

    cout << dic.size() << ln;
}

Measured memory_bytes: 19248
#include<bits/stdc++.h>
using namespace std;
const int N=1e6;
int n,dp[N][2],k[N];
char c[N];
int main()
{
	scanf("%s",c+1);n=strlen(c+1);
	dp[1][0]=dp[2][0]=dp[2][1]=1;if(c[1]!=c[2])dp[2][0]++;
	for(int i=3;i<=n;i++)
	{
		if(c[i]!=c[i-1])
		dp[i][0]=dp[i-1][0]+1;
		if(c[i-1]!=c[i-3]||c[i-2]!=c[i])
		dp[i][1]=dp[i-2][1]+1;
		dp[i][0]=max(dp[i][0],dp[i-1][1]+1);
		dp[i][1]=max(dp[i][1],dp[i-2][0]+1);
		//cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
	}
	cout<<max(dp[n][0],dp[n][1]);
}


Measured memory_bytes: 4608
#include<iostream>
using namespace std;
int diff(int a,int b){return a<b?b-a:a-b;}
int main(){
    cin.tie(0);ios_base::sync_with_stdio(false);
    int x,a,b;cin>>x>>a>>b;
    int A{diff(a,x)},B{diff(b,x)};
    cout<<(A<B?'A':'B')<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n = 1, p, p0, s, c;
  int player0 = 0, player1 = 0;
  while (n) {
    // cin >> n;
    scanf("%d", &n);
    player0 = 0, player1 = 0;
    for (p = 0;p < n;p++) {
      scanf("%d%d", &s, &c);
      if (s == c) {
        player0 += s;
        player1 += s;
      } else {
        if (s < c) {
          player1 += s + c;
        } else {
          player0 += s + c;
        }
      }
    }
    if (n) printf("%d %d\n", player0, player1);
  }
  return 0;
}

Measured memory_bytes: 600
import sys
input = sys.stdin.readline


class RollingHash:
    def __init__(self, string):
        self.n = len(string)
        self.BASE = 1234
        self.MOD = 92709568269121
        self.hash = [0] * (self.n + 1)
        self.pow = [1] * (self.n + 1)

        for i, char in enumerate(string):
            self.hash[i + 1] = (self.hash[i] * self.BASE + ord(char)) % self.MOD
            self.pow[i + 1] = (self.pow[i] * self.BASE) % self.MOD

    def get_hash(self, l, r):
        """string[l:r]のハッシュ値を返す。O(1)"""
        res = (self.hash[r] - self.hash[l] * self.pow[r - l]) % self.MOD
        return res


n = int(input())
s = [input()[:-1] for i in range(n)]


s.sort(key=len)
str_set = set()
cnt = 0

for string in s:
    string = string[::-1]
    n = len(string)
    rh = RollingHash(string)

    for r in range(1, n + 1):
        if rh.get_hash(0, r) in str_set:
            cnt += 1

    set_char = set()
    for r in range(1, n + 1)[::-1]:
        set_char.add(string[r - 1])
        for char in set_char:
            if char == string[r - 1]:
                continue
            h = (rh.hash[r - 1] * rh.BASE + ord(char)) % rh.MOD
            if h in str_set:
                cnt += 1
    str_set.add(rh.get_hash(0, n))

print(cnt)

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

def main(l):
  tmp = []
  for a in l:
    n = a[1]
    for i in range(97, n+2):
      tmp.append([a[0]+chr(i), max(i, n)])
  return tmp
  
l = [['a', 97]]
for i in range(1, N):
  l = main(l)
for i in range(len(l)):
  print(l[i][0])

Measured memory_bytes: 29460
a, b, x = map(int, input().split())

from math import pi, tan, radians
# import math
l = 0
r = 180

for i in range(200000):
    
    m = (l+r)/2
    
    if b * tan(radians(180.0/2-m)) <= a:
        d = b * tan(radians(180.0/2-m)) * b * a / 2
    else:
        d = b*a*a - tan(radians(m))*a*a*a/2
    
    if d == x:
        print(m)
        exit(0)
    elif d > x:
        l = m
    else:
        r = m

print(m)


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll N;
VL A, B;

int main() {
    cin >> N;
    A.resize(N);
    B.resize(N);
    REP(i, N) { cin >> A[i] >> B[i]; }
    ll cnt = 0;
    REPR(i, N - 1) {
        if((A[i] + cnt) % B[i]) {
            cnt += B[i] - (A[i] + cnt) % B[i];
        }
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 1792
input = raw_input

n, k, s = map(int, input().split(" "))

if s == 10**9:
    M = 1
else:
    M = s + 1

if s % 2 == 0:
    a1 = s // 2
    a2 = a1
else:
    a1 = s // 2
    a2 = a1 + 1

if k == n:
    for i in range(n-1):
        print s,
    print s
else:
    for i in range(k):
        print s,
    for i in range(n-k-1):
        print M,
    print M


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

int main() {
    int x,y,i,z;
    cin >> x >> y;
    
    for(i=1;i<=10000;i++){
        if(x==0 && y==0){
            break;
        }
        if(x>y){
        cout << y <<" "<< x<<endl;
        cin >> x >> y;
        }
        else{
          cout << x <<" "<< y<<endl;
          cin >> x >> y;
        }
    }
}


Measured memory_bytes: 2964
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <string.h>
#include <stack>
#include <list>
#include <vector>

using namespace std;
int N;
vector<int> chain[101];
bool arrive[101];
int cnt;
int MAX;
void solve(int i){
  vector<int>::iterator it;
  for(it = chain[i].begin(); it != chain[i].end(); ++it){
    if(arrive[*it] == false){
      
      arrive[*it] = true;
      cnt++;
//      cout << "now:" <<i << "-" <<  *it <<  ", count:" << cnt << endl;
      MAX = max(MAX, cnt);
      solve(*it);
      cnt--;
      arrive[*it] = false;
    }
  }
}

int main(){
  while(cin >> N && N){
    MAX = 0;
    for(int i=0; i<101; ++i){
      chain[i].clear();
      arrive[i] = false;
    }
    
    for(int i=0; i<N; ++i){
      int a,b;
      cin >> a >> b;
      chain[a].push_back(b);
      chain[b].push_back(a);
    }

    for(int i=0; i<101; ++i){
      cnt = 1;
      arrive[i] = true;
      solve(i);
      arrive[i] = false;
    }
    cout << MAX << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
	string S;
	cin >> S;
	string T;
	cin >> T;
	int size;
	size = S.size();
	string t;
	t = T.substr(0, size);
	if (t == S) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(int argc,char** argv){
  string s;
  cin >> s;
  int m,n;
  m = 0;
  n = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '0'){m++;}
    else{n++;}
  }
  cout << 2 * min(m,n) << endl;
  return 0;
}


Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
        k: usize
    }
    let mut x = a;
    let mut y = b;
    for i in 0..k {
        if i % 2 == 0 {
            if x % 2 != 0 {
                x -= 1;
            }
            x /= 2;
            y += x;
        } else {
            if y % 2 != 0 {
                y -= 1;
            }
            y /= 2;
            x += y;
        }
    }
    println!("{} {}", x,y);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,sum,j;
    cin>>n;
    int a[n],b[n],c[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
        cin>>b[i];
    for(i=0;i<n;i++)
    {
        sum=0;
        for(j=0;j<=i;j++) sum=sum+a[j];
        for(j=i;j<n;j++) sum=sum+b[j];
        c[i]=sum;
    }
    sort(c,c+n);
    cout<<c[n-1]<<endl;
    return 0;

}


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

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

    if ( N[0] == N[1] && N[1]== N[2] || N[1] == N[2] && N[2]== N[3]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int main() {
  int n,m;
  cin >> n >> m;
  int a[n],c[m];
  memset(c,0,sizeof(c));
  for(int i=0; i<n; i++) {
    cin >> a[i];
    a[i]--;
    c[a[i]]++;
  }
  int d[m][n+1];
  memset(d,0,sizeof(d));
  for(int i=0; i<m; i++) {
    for(int j=0; j<n; j++) d[i][j+1]+=d[i][j]+(a[j]==i);
  }
  int dp[1<<m];
  fill(dp,dp+(1<<m),1<<29);
  dp[0]=0;
  for(int t=0; t<(1<<m); t++) {
    int l=0;
    for(int i=0; i<m; i++) if(t&(1<<i)) l+=c[i];
    for(int i=0; i<m; i++) {
      if(t&(1<<i)) continue;
      int r=l+c[i];
      dp[t|(1<<i)]=min(dp[t|(1<<i)],dp[t]+c[i]-d[i][r]+d[i][l]);
    }
  }
  cout << dp[(1<<m)-1] << endl;
  return 0;
}


Measured memory_bytes: 15304
#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)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

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

  unordered_map<string, ll> mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }

  ll maxv = 0;
  for (auto& kv : mp) {
    ll c = kv.second;
    chmax(maxv, c);
  }

  vector<string> lst;
  for (auto& kv : mp) {
    if(kv.second == maxv){
      lst.push_back(kv.first);
    }
  }
  Sort(lst);

  for(auto& s : lst){
    cout << s << endl;
  }

  return 0;
}


Measured memory_bytes: 26692
import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions

import sys
def input():
	return sys.stdin.readline().strip()

S = input()

alpha = defaultdict(int)
N = len(S)
for i in range(N):
	alpha[S[i]] += 1

num = 0
for n in alpha:
	if alpha[n] % 2 == 1:
		num += 1

if num >= 2:
	print(-1)
	exit()

alpha_num = defaultdict(deque)
for i in range(N):
	alpha_num[S[i]].append(i)

loc_list = [-1]*N
num = 0
for i in range(N):
	if len(alpha_num[S[i]]) >= 2:
		x = alpha_num[S[i]].popleft()
		y = alpha_num[S[i]].pop()
		loc_list[x] = num
		loc_list[y] = N - 1 - num
		num += 1
	elif len(alpha_num[S[i]]) == 1:
		x = alpha_num[S[i]].popleft()
		loc_list[x] = N // 2

class Bit:
	def __init__(self, n):
		self.size = n
		self.tree = [0] * (n + 1)

	def sum(self, i):
		s = 0
		while i > 0:
			s += self.tree[i]
			i -= i & -i
		return s

	def add(self, i, x):
		while i <= self.size:
			self.tree[i] += x
			i += i & -i


bit = Bit(N)
ans = 0



for i, p in enumerate(loc_list):
	bit.add(p + 1, 1)
	ans += i + 1 - bit.sum(p + 1)

print(ans)


Measured memory_bytes: 77628
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int h[100001][3];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 3; j++){
			cin >> h[i][j];
		}
	}
	int result[100001][3] = {};
	for(int i = 0; i < 3; i++){
		result[0][i] = h[0][i];
	}

	for(int i = 1; i < n; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if(j == k) continue;
				result[i][j] = max(result[i][j], result[i - 1][k] + h[i][j]);
			}
		}
	}
	cout << max(result[n - 1][0], max(result[n - 1][1], result[n - 1][2])) << endl;
}

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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        string S, T;
        cin >>S >>T;
        int A=0;
        Rep0(i, S.size())
                if (S.at(i)!=T.at(i))
                        A++;
        cout <<A <<endl;
        return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    ll r, c, s = 0, sum = 0;
    cin >> r >> c;
    vector<vector<ll>> table(r + 1);
    repi(i, r, 0)
    {
        sum = 0;
        repi(j, c, 0)
        {
            ll tmp;
            cin >> tmp;
            table.at(i).push_back(tmp);
            sum += tmp;
            cout << tmp << " ";
        }
        table.at(i).push_back(sum);
        cout << sum << endl;
    }
    repi(i, c + 1, 0)
    {
        sum = 0;
        repi(j, r, 0)
        {
            sum += table.at(j).at(i);
        }
        cout << sum << ((i+1) % (c+1) == 0 ? "\n" : " ");
    }
    return 0;
}


Measured memory_bytes: 3192
#include<iostream>

using namespace std;

int min(int a,int b) {
	return (a < b) ? a : b;
}

int main() {
	int n, k;
	int a = 1;

	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		a = min(a * 2, a + k);
	}

	cout << a << endl;

}

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

int x,y,z,ar[100005],n,m;
char tmp;
string s1,s2;

int main() {
	cin >> s1;
	for (int i = s1.length()-1; i >= 0; i--) {
		char c = s1[i];
		s2 = c + s2;
		if (s2 == "dream" || s2 == "dreamer" || s2 == "erase" || s2 == "eraser") {
			s2 = "";
		}
	}
	if (s2 != "") cout << "NO"; else cout << "YES";
}

Measured memory_bytes: 3816
import itertools

n = int(input())
xl = []
yl = []
for _ in range(n):
    x, y = map(int, input().split())
    xl.append(x)
    yl.append(y)

ret = []
for l in itertools.permutations(list(range(n))):
    tmp = 0
    for i in range(len(l)-1):
        j = l[i]
        k = l[i+1]
        tmp += (((xl[j] - xl[k]) ** 2) + ((yl[j] - yl[k]) ** 2)) ** 0.5
    ret.append(tmp)
print(sum(ret)/len(ret))

Measured memory_bytes: 4376
a = int(input())
b = int(input())
if (a==1 or b==1) and (b==2 or a==2):
  print(3)
elif (a==2 or b==2) and (b==3 or a==3):
  print(1)  
elif (a==1 or b==1) and (b==3 or a==3):
  print(2)  

Measured memory_bytes: 9156
a,b,c = gets.chomp.to_i,gets.chomp.split.map(&:to_i),gets.chomp.split.map(&:to_f)
ans = []
for aa in 0...c.size
  ans.push((b[1]-(b[0]-(c[aa]*6/1000))).abs)
end
puts ans.index(ans.min)+1

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

int main() {
  int a, b;
  cin >> a >> b;
  int t;
  t = (a * b) % 2;
  if (t == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k; cin >> n >> k;
  vector<ll> h(n);
  REP(i,n){
      cin >> h[i];
  }
  ll dp[n+105];
  REP(i,n+105){
      dp[i] = LINF;
  }
  dp[0] = 0;
  REP(i,n-1){
      FOR(j,1,k+1){
          dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
      }
  }
  cout << dp[n-1] << endl;


}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	_, m := scanInt(), scanInt()
	ll, rl := scanInt(), scanInt()

	for i := 1; i < m; i++ {
		l, r := scanInt(), scanInt()
		if rl < l || r < ll {
			fmt.Println(0)
			return
		}
		ll = max(ll, l)
		rl = min(rl, r)
	}
	fmt.Println(rl - ll + 1)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 2884
#include<stdio.h>

int main(void)
{
	int N;
	long int Y;
	
	scanf("%d %ld",&N,&Y);
	
	for(int i=0;i<=N;i++){
		for(int j=0;j<=(N-i);j++){
			if(Y==10000*i+5000*j+1000*(N-i-j)){
				printf("%d %d %d\n",i,j,N-i-j);
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 128
class UnionFind:
    def __init__(self, n):
        self.par = [-1 for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if not x==y: # 根が同じでない場合のみ併合する
            if self.rank[x] < self.rank[y]:
                self.par[y] += self.par[x] # 要素数を併合
                self.par[x] = y # 根を付け替えている
            else:
                self.par[x] += self.par[y]
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
        
    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y) 

import sys
input = sys.stdin.readline
from collections import defaultdict

N,M,K = map(int,input().split())
Fr = [0]*N
FrKi = UnionFind(N)
Bl = defaultdict(list)

for i in range(M):
    A,B = map(int,input().split())
    A -=1
    B-=1
    Fr[A]+=1
    Fr[B]+=1
    FrKi.union(A,B)
    
for i in range(K):
    A,B = map(int,input().split())
    A-=1
    B-=1
    Bl[A].append(B)
    Bl[B].append(A)
    
Ans = [0]*N
#print(FrKi.par)
#print(Fr)
for i in range(N):
    tmp = -FrKi.par[FrKi.find(i)] - Fr[i] -1
    for j in Bl[i]:
        if FrKi.same_check(i,j):
            tmp -= 1
    Ans[i] = tmp
print(*Ans)

Measured memory_bytes: 107552
#include<stdio.h>
#include<math.h>
const double PI=3.14159265359;
int main()
{
	int a,b,c;
	double S,L,h;
	scanf("%d%d%d",&a,&b,&c);
	S=a*b*sin((double)c/180*PI)/2;
	L=a+b+sqrt(a*a+b*b-2*a*b*cos((double)c/180*PI));
	h=S*2/a;
	printf("%lf %lf %lf\n",S,L,h);
	return 0;
}


Measured memory_bytes: 2040
#include<stdio.h>
int main()
{
    int n,i;
    char s[100];
    scanf("%d",&n);
    scanf("%s",s);
    for(i=0;i<=(n-1)/2;i++)
    {
        if(s[i]==s[i+1+(n-1)/2])
        {
            if(i==(n-1)/2)
                printf("Yes");
        }
        else
        {
            printf("No");
            break;
        }
    }
}

Measured memory_bytes: 128
import Data.IORef
import Control.Monad
 
main :: IO()
main = getLine >> getContents >>= (\(x:y:xs) -> solve (y - x) (min x y) xs).map read.lines >>= print
 
solve :: Int -> Int -> [Int] -> IO Int
solve a b xs = do
                a' <- newIORef a
                b' <- newIORef b
                forM_ xs $ \z -> do
                    x <- readIORef a'
                    y <- readIORef b'
                    when (z - y > x) $ writeIORef a' (z - y)
                    when (z < y)     $ writeIORef b' z
                readIORef a'

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

int main() {
	int n;
	while (cin >> n) {
		int num = 0;
		if (n > 36) {
			cout << "0" << endl;
		}
		else {
			for (int i = 0; i < 10; i++) {
				if (i > n) {
					break;
				}
				for (int j = 0; j < 10; j++) {
					if (i + j > n) {
						break;
					}
					for (int k = 0; k < 10; k++) {
						if (i + j + k > n) {
							break;
						}
						for (int l = 0; l < 10; l++) {
							if (i + j + k + l > n) {
								break;
							}
							if (i + j + k + l == n) {
								num++;
							}
						}
					}
				}
			}
			cout << num << endl;
		}
	}
	return 0;
}


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

using namespace std;
vector<int> adj[100001];
vector<int> visited(100001);
vector<int> dp(100001,0);
void add_edge(int i,int j)
{
    adj[i].push_back(j);
}

void DFS(int i)
{
    visited[i]=true;
    for(int j=0;j<(int)adj[i].size();j++){
        if(!visited[adj[i][j]])DFS(adj[i][j]);
        dp[i] = max(dp[i],1+dp[adj[i][j]]);
    }
}
int find_longest_path(int n)
{
    for(int i=1;i<=n;i++){
        if(!visited[i]){
            DFS(i);
        }
    }
    int Max=LLONG_MIN;
    for(int i=1;i<=n;i++)Max=max(Max,dp[i]);
    return Max;
}
signed main()
{
    int n,m;
    cin>>n>>m;

    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        add_edge(x,y);
    }

    int x=find_longest_path(n);
    cout<<x;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    for(int i=0;i<n;i++){
        cin >> s[i] >> t[i];
    }
    string x;
    cin >> x;
    int sum=0;
    bool sleep = false;
    for(int i=0;i<n;i++){
        if(sleep){
            sum += t[i];
        }
        if(s[i]==x){
            sleep = true;
        }

    }
    cout << sum <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

using namespace std;

int main(){
  string s;cin>>s;
  int ans = 700;
  for(int i=0;i<3;i++)if(s[i] == 'o')ans+=100;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>

using namespace std;

#define ALL(a) (a).begin(),(a).end()
#define REP(index, begin, end) for (int (index) = (begin); (index) < (end); (index)++)
#define RE(index, end) REP(index, 0, end)
#define INF INT_MAX / 3
#define LLINF LLONG_MAX / 3
#define DINT(x) printf(#x " = %d\n", x);
#define GETINT(x) scanf("%d", &x)
#define GETLL(x) scanf("%lld", &x)
#define GETSTR(x) scanf("%s", x)

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

int main()
{
	int h, w;
	vector<vector<char>> clouds;
	vector<vector<int>> yosou;
	GETINT(h);
	GETINT(w);
	RE(i, h)
	{
		char line[256];
		vector<char> line_c;
		GETSTR(line);
		RE(j, w)
		{
			line_c.push_back(line[j]);
		}
		assert(line[w] == '\0');
		clouds.push_back(line_c);
		vector<int> line_y;
		line_y.resize(w, -1);
		yosou.push_back(line_y);
	}
	assert(clouds.size() == h);
	RE(i, h)
	{
		RE(j, w)
		{
			int time = 0;
			while (j - time >= 0)
			{
				char next_c = clouds[i][j - time];
				if (next_c == 'c')
				{
					yosou[i][j] = time;
					break;
				}
				time++;
			}
		}
	}
	RE(i, h)
	{
		RE(j, w - 1)
		{
			printf("%d ", yosou[i][j]);
		}
		printf("%d\n", yosou[i][w - 1]);
	}
	return 0;
}

Measured memory_bytes: 3272
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Skill Up
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 12;
const int NBITS = 1 << MAX_N;
const int MAX_M = 12;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int cs[MAX_N], as[MAX_N][MAX_M];

/* subroutines */

/* main */

int main() {
  int n, m, x;
  scanf("%d%d%d", &n, &m, &x);

  for (int i = 0; i < n; i++) {
    scanf("%d", cs + i);
    for (int j = 0; j < m; j++) scanf("%d", as[i] + j);
  }

  int minsum = INF, nbits = 1 << n;
  for (int bits = 0; bits < nbits; bits++) {
    bool ok = true;
    for (int j = 0; ok && j < m; j++) {
      int asum = 0;
      for (int i = 0, bi = 1; i < n; i++, bi <<= 1)
	if (bits & bi) asum += as[i][j];
      ok = (asum >= x);
    }

    if (ok) {
      int csum = 0;
      for (int i = 0, bi = 1; i < n; i++, bi <<= 1)
	if (bits & bi) csum += cs[i];
      if (minsum > csum) minsum = csum;
    }
  }

  printf("%d\n", (minsum >= INF) ? -1 : minsum);
  return 0;
}


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

int main() {
  int N,A,Sum;
  cin >> N;
  A = N;
  for (int i=0;i<8;i++){
    if(N/10 == 0){
    Sum += N%10;
    break;
    }
    else{
    Sum += N%10;  
    N = N/10;
    }
  }
 if(A%Sum == 0)
   cout << "Yes" << endl;
  else
   cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int A[114514];
	for (int i = 0; i < n; i++)cin >> A[i];
	int ave = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0)ave += A[i];
		else ave -= A[i];
	}
	cout << ave << endl;
	for (int i = 1; i < n; i++) {
		ave = 2 * A[i - 1] - ave;
		cout << ave << endl;
	}
}

Measured memory_bytes: 1664
program ABC048B
    implicit none
    integer(8)::a,b,x,fa,fb
    read(5,*)a,b,x
    if(a==0)then
        fa=0
    else
        fa=(a-1)/x+1
    end if
    fb=b/x+1
    print'(i0)',fb-fa
end program ABC048B

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define ll unsigned long long
using namespace std;
ll x,y,ans;
int main()
{
	scanf("%lld%lld",&x,&y);
	 while(x<=y)
	 {
	 	ans++;
	 	x*=2;
	 }
	 cout<<ans;
	 return 0;
} 

Measured memory_bytes: 256