akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n,m,q ;
	cin >> n >> m >> q ;
	vvll sum(n+1,vll(n+1,0)) ;
	for(int i=0;i<m;i++){
		ll a,b ;
		cin >> a >> b ;
		sum.at(1).at(n)++ ;
		if(b!=0)sum.at(1).at(b-1)-- ;
		if(a!=n) sum.at(a+1).at(n)-- ;
		if(a!=n&&b!=0) sum.at(a+1).at(b-1)++ ;
	}
//	cout << -1 << endl ;
	for(int i=0;i<=n;i++) for(int j=n-1;j>=0;j--) sum.at(i).at(j) += sum.at(i).at(j+1) ;
	for(int j=0;j<=n;j++) for(int i=1;i<=n;i++) sum.at(i).at(j) += sum.at(i-1).at(j) ;
	for(int i=0;i<q;i++){
		ll a,b ;
		cin >> a >> b ;
		cout << sum.at(a).at(b) << endl ;
	}
}


Measured memory_bytes: 2944
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <numeric>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rept(i,k,n) for(long long i = (k); i < (long long)(n); i++)
#define All(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Rsort(v) sort(v.begin(),v.end(),[](auto a, auto b) { return a > b; })
#define Reverse(v) reverse(v.begin(),v.end())
#define MAX 1000000007
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}


int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ma = max(max(max(a*c,b*d),a*d),b*c);
    cout<<ma<<endl;

    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N,Y;
		N=sc.nextInt();
		Y=sc.nextInt();
		int A=-1,B=-1,C=-1;
		boolean flag=false;
		for(int a=0;a<=N;a++) {
			for(int b=0;b<=N-a;b++) {
				int c=N-a-b;
				int total=a*10000+b*5000+c*1000;
				if(total==Y) {
					A=a;
					B=b;
					C=c;
					flag=true;
				
				}
				
			}
			
			
		}
			
		System.out.println(A+" "+B+" "+C);
		
	}

}


Measured memory_bytes: 23892
n,m = map(int,input().split())
edge = []
for i in range(n+1):
    edge.append([])
for i in range(m):
    a,b = map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
ans = 0

import itertools
def permutation_all(seq, choice):
    return list(itertools.permutations(seq, choice))

cond = [i for i in range(2,n+1)]
cond = permutation_all(cond, n-1)
for i in range(len(cond)):
    here = 1
    tar = cond[i]
    flag = True
    for j in range(n-1):
        if tar[j] not in edge[here]:
            flag= False
            break
        else:
            here = tar[j]
    if flag:
        ans += 1
print(ans)


Measured memory_bytes: 9616
#include <bits/stdc++.h>
#define ll long long int
#define MAX 1000000007

using namespace std;

int main()
{
    ll t,i,j,k,l,m,n;
    cin>>n;
    vector<ll> V,B;
    ll ans=0;
    for(i=0;i<n;++i){
        cin>>l;
        while(l%2==0){
            l=l/2;
            ans++;
        }
    }
    cout<<ans;


    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def color(x):
	if x <= 399:
		return 0
	elif x <= 799:
		return 1
	elif x <= 1199:
		return 2
	elif x <= 1599:
		return 3
	elif x <= 1999:
		return 4
	elif x <= 2399:
		return 5
	elif x <= 2799:
		return 6
	elif x <= 3199:
		return 7
	else:
		return 8

N = int(input())
aa = list(map(int,input().split()))
color_tb = []
nizi = 0

for a in aa:
	col = color(a)
	if col == 8:
		nizi += 1
	else:
		color_tb.append(col)

L = len(set(color_tb))

if L == 0:
	min_ans = 1
	max_ans = nizi
else:
	min_ans = L
	max_ans = L+nizi

print(min_ans,max_ans)

Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
int n, m, h[201], r[201];
int dp[201];
int rec( int idx){
  if(~dp[idx]) return dp[idx];
  int ret = 0;
  for(int i = 0; i < n + m; i++){
    if(h[idx] > h[i] && r[idx] > r[i]){
      ret = max( ret, rec(i) + 1);
    }
  }
  return dp[idx] = ret;
}
int main(){
  while( cin >> n, n){
    fill_n( dp, 201, -1);
    for(int i = 0; i < n; i++){
      cin >> h[i] >> r[i];
    }
    cin >> m;
    for(int i = 0; i < m; i++){
      cin >> h[n + i] >> r[n + i];
    }
    h[n + m] = 1000, r[n + m] = 1000;
    cout << rec( n + m ) << endl;
  }
}

Measured memory_bytes: 1160
//#include <limits.h>
//#include <math.h>
#include <stdio.h>

int main(void) {
  int n;
  char s[120],t[120];
  scanf("%d",&n);
  scanf("%s %s",&s,&t);
  for (int i = 0; s[i]!='\0'; i++)
  {
    printf("%c%c",s[i],t[i]);
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 128
N = int(input())
S = input()

lans = list()
for i in range(1, N):
    sa = S[:i]
    sb = S[i:]
    l = list()
    cnt = 0
    for j in range(i):
        if S[j] in sb and S[j] not in l:
            l.append(S[j])
            cnt += 1
    lans.append(cnt)

print(max(lans))

Measured memory_bytes: 3064
n = int(input())
xyh = sorted([list(map(int, input().split())) for i in range(n)], key=lambda x: -x[2])

for x in range(101):
    for y in range(101):
        h=xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1])
        flag = True
        for X,Y,H in xyh[1:]:
            if H != max(h-abs(x-X)-abs(y-Y),0):
                flag = False
                break
        if flag:
            print(x,y,h)
            exit()

Measured memory_bytes: 41328
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
#include <iomanip>
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 int mod=1e9+7;
const int64_t INF=1e18;

int main() {
  int N,D,X;
  cin>>N>>D>>X;
  int sum=0;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    sum++;
    sum+=(D-1)/a;
  }
  cout<<sum+X<<endl;
  return 0;  
}

Measured memory_bytes: 3544
import itertools
 
n,m,q=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(q)]
 
ms=[i for i in range(1,m+1)]
ans=0
for k in itertools.combinations_with_replacement(ms, n):
  x=0
  for j in range(q):
    if a[j][2]==k[a[j][1]-1]-k[a[j][0]-1]:
      x+=a[j][3]
  if ans<x:
    ans=x
print(ans)

Measured memory_bytes: 9084
class UnionFind():
    #https://note.nkmk.me/python-union-find/ 
    #note.nkmk.me  2019-08-18 
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


#初期入力、集合とユニオンファインド
import sys
input = sys.stdin.readline
N,M,K = (int(x) for x in input().split())
AB =set()
CD =set()
friends ={i:set() for i in range(1,N+1)}
uf =UnionFind(N+1) #union_find、1～Nで初期化、sizeは-１必要

for i in range(1,M+1):
    a,b =(int(i) for i in input().split() )
    friends[a].add(b) #友達関係入力
    friends[b].add(a)
    uf.union(a,b)

blocks ={i:set() for i in range(1,N+1)}
for i in range(1,K+1):
    c,d =(int(i) for i in input().split() )
    blocks[c].add(d)#ブロック関係入力
    blocks[d].add(c)
    

friends_candidate={i:set() for i in range(1,N+1) }    
for iam in friends_candidate.keys():
    blocks_same =0 #iamから見て、同じ集合にいるが、blockの人数
    for block in blocks[iam]:
        if uf.same(iam,block):
            blocks_same +=1
    friends_candidate[iam] =uf.size(iam)-1 - len(friends[iam]) - blocks_same  #最初の-1はuf初期化１～Nでしたから
print(*friends_candidate.values())

Measured memory_bytes: 125036
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdint>
#include <utility>
#include <tuple>
#include <map>    
#include <queue> 
#include <set>  
#include <stack> 
#include <deque>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset>

using namespace std;

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

	int K = 0;
	string t, u;

	for (int i = 0; i < S.length(); i++) {
		t += S[i];
		if (t != u) {
			u = t;
			t.clear();
			K++;
		}
	}

	cout << K << endl;
}

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


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

    vector<pair<ll,int>>fs;
    for(ll i=2;i*i<=n;i++){
        int x=0;
        while(n%i==0){
            n/=i;
            ++x;
        }
        fs.emplace_back(i,x);
    }
    if(n!=1)fs.emplace_back(n,1);

    int ans=0;
    for(auto p:fs){
        int x=p.second;
        int b=1;
        while(b<=x){
            x-=b;
            b++;
            ++ans;
        }
    }
    cout<<ans<<endl;
}

    

Measured memory_bytes: 19684
#include<stdio.h>
int main(){
  int n,d,x,a[101];
  scanf("%d %d %d",&n,&d,&x);
  int i,j;
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
    for(j=1;j<=d;j+=a[i]){
      x++;
  }
  }
  printf("%d\n",x);
  return 0;
}



Measured memory_bytes: 128
import sys

n, G = map(int, sys.stdin.readline().split())
G //= 100
p = []
t = []
for i in range(1, n+1):
    pi, ci = map(int, sys.stdin.readline().split())
    p.append(pi)
    t.append(i * pi + ci // 100)

def main():
    res = sum(p)
    for i in range(2 ** n - 1):
        s = 0
        cnt = 0
        for j in range(n):
            if i >> j & 1:
                s += t[j]
                cnt += p[j]
            else:
                m = j + 1
        if s < G:
            tmp = (G - s + m - 1) // m
            if tmp < p[m-1]:
                cnt += tmp
            else:
                continue
        res = min(res, cnt)
    
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
import java.util.*;

import javax.lang.model.util.ElementScanner6;

public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int r=Integer.parseInt(scan.next());
		double PI =Math.PI;
		System.out.print(r*2*PI);


	}
}
//end

Measured memory_bytes: 35888
x, y = map(int, input().split())
a = set([1, 3, 5, 7, 8, 10, 12])
b = set([4, 6, 9, 11])
c = set([2])
g = [a, b, c]
is_same_group = False
for gg in g:
    if x in gg and y in gg:
        is_same_group = True
        break
if is_same_group:
    print('Yes')
else:
    print("No")


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int M1, D1, M2, D2; cin >> M1 >> D1 >> M2 >> D2;
  int result = D2==1;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


int main() {
	ll n, t,ret=1001;
	cin >> n >> t;
	rep(i, n) {
		ll c1, t1;
		cin >> c1 >> t1;
		if (t1 <= t && ret > c1) {
			ret = c1;
		}
	}
	if (ret == 1001) cout << "TLE" << endl;
	else
		cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;


//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく

//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

using namespace std;

bool check(string s){
  int n = s.length();
  for(int i = 0; i < n/2; i++){
    if(s[i] != s[n/2+i]) return false;
  }
  return true;
}

int count(string *s){
  int count = 0;
  /*
  REP(i,h){
    REP(j,w){
      if( s[i][j] == '#') count++;
    }
  }*/
  return count;
}

int main(void){

  int n;
  cin >> n;
  for(int i=1; i<=n; i++ ){
    int ans = 0;
    //cout << "sqrt:" << (int)sqrt(i) << endl;
    int m = (int)sqrt(i) + 1;
    for(int x=1; x <= m; x++){
      for(int y=1; y <= m; y++){
        //z^2 + (y+x)z + x^2 + y^2 + xy - n = 0
        int d = (y+x)*(y+x) - 4*(x*x+y*y+x*y-i);
        // z = ((x+y)^2 +- sqrt(d)) / 2
        //cout << i << "," << x << "," << y << "," << d << endl;
        if( (int)sqrt(d) * (int)sqrt(d) == d ){
          double a = ((-1)*(x+y) + sqrt(d) ) / 2;
          double b = ((-1)*(x+y) - sqrt(d) ) / 2;
          if( a > 0 && floor(a)==a) ans++;
          if( b > 0 && floor(b)==a) ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int a=0,b=0,ans_a=0;
    char s[200005];
    cin>>s;
    for(long long int i=0;i<200005;i++){
        if(s[i]=='B'){
            a++;
            
        }
            
        if(s[i]=='W'){
            ans_a+=i-b;
            b++;
            
            
        }
        if(s[i]!='B'&&s[i]!='W'){
            break;
        }
    }
    if(a==0||b==0)ans_a=0;
    if(a==1&&b==1)ans_a=1;
    cout<<ans_a<<endl;
    return 0;
}

Measured memory_bytes: 384
use std::io::Read;

fn read<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();

    if (a + b) % 2 == 0 {
        println!("{}", (a + b) / 2);
    } else {
        println!("IMPOSSIBLE");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define debug(x) cerr << #x " = " << (x) << endl;
#define P(x) cerr << #x << endl;    
#define int long long
typedef pair<int, int> pii;
const int mod = 1000000007;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(9);
    
    int n;
	cin >> n;
	vector<int> a(n);
	int sum = 0;
	for(int i = 0; i < n; ++ i) cin >> a[i];
	for(int i = 0; i < n; ++ i)
	{
		for(int j = i + 1; j < n; ++ j)
		{
			sum += a[i] * a[j];
		}
	}
    cout << sum << '\n';
    
    return 0;
}






Measured memory_bytes: 256
// kartikay26
#include <bits/stdc++.h>
using namespace std;
#define debug(x...) 
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
void print(){cout << endl;} void prints(){}
template<typename T=int> T get(){T x; cin >> x; return x;}
template<typename T> void get(T* x, int n){for (int i = 0; i < n; ++i) { cin >> x[i]; }}
template<typename T> void get(T& x, int n){for (int i = 0; i < n; ++i) { cin >> x[i]; }}
template<typename T, typename... A> void print(T x,A... r){cout << x << " ";print(r...);}
template<typename T, typename... A> void prints(T x,A... r){cout << x << " ";prints(r...);}
typedef long long int ll; typedef double db; typedef vector<ll> vi; typedef pair<ll, ll> pii;
#define int ll
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define clear(x) memset(x, 0, sizeof(x))
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int mod = 1e9+7;
const int N = 305;

db dp[N+1][N+1][N+1];

int n;

db f(int i, int j, int k){
	if(i < 0 or j < 0 or k < 0 or (i==0 and j==0 and k==0)){
		return 0.0;
	}
	if(dp[i][j][k] != 0){
		return dp[i][j][k];
	}
	int z = n - i - j - k;
	return dp[i][j][k] = ((f(i-1,j,k)*i)/n + (f(i+1,j-1,k)*j)/n + (f(i,j+1,k-1)*k)/n + 1)/(1 - db(z)/n);
}

int32_t main(){

	n = get();
	int a = 0, b = 0, c = 0;
	for (int i = 0; i < n; ++i) {
		int ai = get();
		if (ai == 1) a++;
		if (ai == 2) b++;
		if (ai == 3) c++;
	}

	printf("%.10lf", f(a,b,c));

	// for (int k = 0; k < n+1; ++k) {
	// 	for (int i = 0; i < n+1; ++i) {
	// 		for (int j = 0; j < n+1; ++j) {
	// 			prints(dp[i][j][k]);
	// 		}
	// 		print();
	// 	}
	// 	print();print();
	// }
	
	return 0;
}

Measured memory_bytes: 221440
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int H1, M1, H2, M2, K; cin >> H1 >> M1 >> H2 >> M2 >> K;
	int ans = ((H2 * 60) + M2 - K) - ((H1 * 60) + M1);
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3596
import java.util.Arrays;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

public class Main {
  Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    new Main().run();
  }

  void run() {
    int n = ni();
    int[] a = new int[n];
    for (int i = 0; i < n; ++i) {
      a[i] = ni() - 1;
    }

    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      debug(a[a[i]], i);
      if (a[a[i]] == i) {
        ++cnt;
      }
    }
    cnt /= 2;

    System.out.println(cnt);
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }

}


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

int main() {
  
  int A, B;
  cin >> A >> B;
  int counter = 0;
  
  for (int i = A; i <= B; i++) {
    
    int a = i / 10000;
    int b = (i % 10000) / 1000;
    int c = ( (i % 10000) % 1000) / 100;
    int d = ( ( (i % 10000) % 1000) % 100) / 10;
    int e = ( ( (i % 10000) % 1000) % 100) % 10;
    
    if (a == e & b == d) counter++;
    
  }
  
  cout << counter << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int[] R = new int[n];
		for (int i=0; i < n; i++) {
			R[i] = sc.nextInt();
		}
//
//		int max = R[1] - R[0];
//		for (int i =0; i < n-1; i++) {
//			for (int j=i+1; j < n; j++) {
//				if (max < R[j] - R[i])
//				max = R[j] - R[i];
//			}
//		}
//
//		System.out.println(max);

		int max = R[1] - R[0];
		int i = 0;
		for ( int j=1; j < n; j++) {
			if ( R[j] - R[i] > max ) {
				max = R[j] - R[i];
			}
			if ( R[i] > R[j] ) {
				R[i] = R[j];
			}
		}

		System.out.println(max);

	}

}

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

using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using vi  = vector<int>;
#define sz(x) ((int)x.size())

struct UnionFind {
    vi data;
    int comp;
    UnionFind() {}
    UnionFind(int size) {
        init(size);
    }
    void init(int size) {
        data.assign(size, -1);
        comp = size;
    }
    void unite(int x, int y) {
        x = root(x); y = root(y);
        if(x != y) {
            if(data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
            comp--;
        }
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        if (data[x] < 0) {
            return x;
        } else {
            return data[x] = root(data[x]);
        }
    }
    int size(int x) {
        return -data[root(x)];
    }
    int components() {
        return comp;
    }
};

struct LCA {
    using Query = pii;
    vvi g;
    vi color;
    vi ancestor;
    vector<vector<pair<int, Query>>> query_set;
    vi res;
    UnionFind uf;
    LCA(const vvi &g, vector<Query> &query) :
            g         (g),
            color     (sz(g)),
            ancestor  (sz(g)),
            query_set (sz(g)),
            res       (sz(query)),
            uf        (sz(g))
    {
        int qs = sz(query);
        rep(i, 0, qs) {
            query_set[query[i].first ].emplace_back(i, query[i]);
            query_set[query[i].second].emplace_back(i, query[i]);
        }
    }
    void visit(int v, int prev) {
        ancestor[uf.root(v)] = v;
        for (auto &w : g[v]) {
            if (w == prev) {
                continue;
            }
            visit(w, v);
            uf.unite(v, w);
            ancestor[uf.root(v)] = v;
        }
        color[v] = 1;
        for (auto &p : query_set[v]) {
            Query q = p.second;
            int w = (q.second == v ? q.first : (q.first == v ? q.second : -1));
            if (w == -1 || !color[w]) {
                continue;
            }
            res[p.first] = ancestor[uf.root(w)];
        }
    }
    vi solve(int root) {
        visit(root, -1);
        return res;
    }
};

signed main() {
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    rep(v, 0, N) {
        int K;
        cin >> K;
        rep(k, 0, K) {
            int X;
            cin >> X;
            G[v].push_back(X);
        }
    }
    int Q;
    cin >> Q;
    vector<pii> queries;
    rep(i, 0, Q) {
        int U, V;
        cin >> U >> V;
        queries.emplace_back(U, V);
    }
    LCA lca(G, queries);
    vi res = lca.solve(0);

    for (int ans : res) {
        cout << ans << endl;
    }
}



Measured memory_bytes: 38804
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#define maxn 1010
#define INF 0x3f3f3f3f
#define LL long long
#define ULL unsigned long long
#define E 1e-8
#define mod 1000000007
#define P pair<int,int>
using namespace std;

int main()
{
    char s[5];
    while(cin>>s)
    {
        int a=0,b=0,c=0;
        for(int i=0; i<=2; ++i)
        {
            if(s[i]=='a')
                a++;
            else if(s[i]=='b')
                b++;
            else if(s[i]=='c')
                c++;
        }
        if(a==1&&b==1&&c==1)
            printf("Yes\n");
        else
            printf("No\n");
    }
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if 500 * a + 100 * b + 50 * c == X:
                cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include <cstdio>
const int MOD = 1000000007;
int a[200001],b[200001],fac[8001],ni[8001],f[4001][4001];
int n,x,y,p,q;
long long ans;

void read(int &k) {
    char c=getchar();
    while (c<48||c>57) c=getchar();
    k=0;
    while (c>=48&&c<=57) {
        k=k*10+c-48;
        c=getchar();
    }
}
int C(int n,int m) {
    return 1ll*fac[n]*ni[m]%MOD*ni[n-m]%MOD;
}
long long fun(long long a,int k) {
    long long s=1;
    while (k) {
        if (k&1) s=s*a%MOD;
        a=a*a%MOD;
        k>>=1;
    }
    return s;
}

int main() {
    fac[0]=1;
    for (long long i=1; i<=8000; ++i) fac[i]=fac[i-1]*i%MOD;

    ni[8000]=fun(fac[8000],MOD-2);
    for (long long i=7999; i>0; --i) ni[i]=ni[i+1]*(i+1)%MOD;

    read(n);
    for (int i=1; i<=n; ++i) {
        scanf("%d%d",&a[i],&b[i]);
        if (a[i]>x) x=a[i];
        if (b[i]>y) y=b[i];
        f[2000-a[i]][2000-b[i]]++;
    }

    for (int i=2000-x; i<=2000+x; ++i)
        for (int j=2000-y; j<=2000+y; ++j) {
            if (i>0) {
                p=f[i][j]+f[i-1][j];
                f[i][j]= p>=MOD ? p-MOD : p;
            }
            if (j>0) {
                p=f[i][j]+f[i][j-1];
                f[i][j]= p>=MOD ? p-MOD : p;
            }
        }

    for (int i=1; i<=n; ++i) {
        p=ans+f[2000+a[i]][2000+b[i]];
        ans = p>=MOD ? p-MOD : p;
        p=ans+MOD - C(a[i]+b[i]+a[i]+b[i],a[i]+a[i]);
        ans = p>=MOD ? p-MOD : p;
    }

    ans=ans*ni[2]%MOD;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 64384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv)
{
	int A, B;
	scanf("%d %d", &A, &B);
	int t;
	if (A > B) {
		t = A;
		A = B;
		B = t;
	}
	int64_t a = A;
	while (a % B)
		a += A;
	printf("%ld\n", a);
	return 0;
}


Measured memory_bytes: 128
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    n=int(input())
    S=list(map(str,input().split()))

    if len(set(S))==3:
        print('Three')
    else:
        print('Four')



resolve()

Measured memory_bytes: 2940
#include <iostream>
#include<algorithm>
#include <set>
#include <utility>
#include <cmath>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <ctime>
#include <limits>
#include <istream>
#include <ostream>
#include <complex.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define INF 1e16
#define mod 10000000007
#define mmax(x,y)(x>y?x:y);
#define mmin(x,y)(x<y?x:y);

int main()
{
	int r;
	cin>>r;
	cout<<3*r*r<<endl;



	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        String str = "";

        while(sc.hasNext()) {
        	str += sc.nextLine();
        }
        str = str.toLowerCase();

        char[] alphabet = new char[] {'a','b','c','d','e','f','g','h','i','j','k',
        							  'l','m','n','o','p','q','r','s','t','u','v',
        							  'w','x','y','z'};

        int[] ans = new int[alphabet.length];

        for(int i = 0; i < str.length(); ++i) {
        	for(int j = 0; j < alphabet.length; j++) {
        		if(str.charAt(i) == alphabet[j]) {
        			ans[j]++;
        		}
        	}
        }

        for(int i = 0; i < alphabet.length; i++) {
        	System.out.println(String.format("%s : %d", alphabet[i], ans[i]));
        }

    }
}


Measured memory_bytes: 26292
#include <cstdio>
#define MAXN 100000000
#define ll long long
int main() {
    ll n, mid = MAXN / 2;
    scanf("%lld", &n);
    while(mid * mid + mid >= 2 * n)
        mid /= 2;
    while(mid * mid + mid < 2 * n)
        mid++;
    printf("%lld\n", mid);
    return 0;
}


Measured memory_bytes: 128
n = input()

d     = [0 for i in range(n)]
f     = [0 for i in range(n)]
G     = [0 for i in range(n)]
M     = [[0 for i in range(n)] for j in range(n)]
color = [0 for i in range(n)]
tt    = [0]
WHITE = 0
GRAY  = 1
BLACK = 2

def dfs_visit(u):
    color[u] = GRAY
    tt[0] = tt[0] + 1
    d[u] = tt[0]
    for v in range(n):
        if M[u][v] == 0:
            continue
        if color[v] == WHITE:
            dfs_visit(v)
    color[u] == BLACK
    tt[0] = tt[0] + 1
    f[u] = tt[0]

def dfs():
    for u in range(n):
        if color[u] == WHITE:
            dfs_visit(u)
    for u in range(n):
        print "%d %d %d" %(u + 1, d[u], f[u])

### MAIN
for i in range(n):
    G = map(int, raw_input().split())
    for j in range(G[1]):
        M[G[0]-1][G[2+j]-1] = 1

dfs()

Measured memory_bytes: 6496
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	long double a, b; //long double は10進数で約19桁の精度
	cin >> a >> b;
    b += (long double)8.0 * pow(0.5, 63);
	cout << (ll)(b*a) << endl; //Aとの積を100で割って出力
}


Measured memory_bytes: 3736
for i in range(5):
    x=int(input())
    a=1000-x
    if x!=0:
        b=0
        b+=(a//500)#500
        
        b+=(a%500)//100#100
        
        b+=((a%500)%100)//50#50
        
        b+=(((a%500)%100)%50)//10#10
        
        b+=((((a%500)%100)%50)%10)//5
        
        b+=((((a%500)%100)%50)%10)%5
    elif x==0:
        break
        
    print(b)



Measured memory_bytes: 5596
u, l, d, r = map(int, input().split())
mod = 10 ** 9 + 7

def extGCD(a, b):
    if b == 0:
        return a, 1, 0
    g, y, x = extGCD(b, a%b)
    y -= a//b * x
    return g, x, y

def moddiv(a, b):
    _, inv, _ = extGCD(b, mod)
    return (a * inv) % mod

f = [0] * (2 * 10 ** 6 + 10)
f[0] = 1
for i in range(1, 2 * 10 ** 6 + 10):
    f[i] = (f[i-1] * i) % mod

def comb(a, b):
    return moddiv(moddiv(f[a+b], f[a]), f[b])

ans = 0
d += 1
r += 1
ans += comb(d, r)
ans += comb(u, l)
ans -= comb(d, l)
ans -= comb(u, r)
print(ans % mod)

Measured memory_bytes: 82164
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
ll A,B;

int main() {
	cin>>A>>B;

	if(abs(A-B)%2==0){
		cout<<abs(A-B)/2+min(A,B)<<endl;
	}else{
		cout<<"IMPOSSIBLE"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i = i+1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]

    return i+1

n = int(input())
A = list(map(int, input().split()))
#print(partition(A, 0, len(A)-1), A)
k = partition(A, 0, len(A)-1)
#print(k)
#print(A)
for i in range(len(A)):
    if i == k:
        print('['+str(A[i])+']', end=' ')
    elif i == n-1:
        print(A[i])
    else:
        print(A[i], end=' ')

Measured memory_bytes: 18312
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <iostream>
using namespace std;

int main() {
  long N;
  cin >> N;
  if (N == 0) {
    cout << 0 << endl;
    return 0;
  }
  long nn2 = 1;
  long n2 = 2;
  vector<int> S = {};
  while (N != 0) {
    if (N % n2 != 0) {
      S.insert(S.begin(),1);
      N -= nn2;
    }
    else {
      S.insert(S.begin(),0);
    }
    nn2 *= -2;
    n2 *= 2;
  }
  for (int i=0; i<S.size(); i++) {
    cout << S[i];
  }
  cout << endl;
}

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

int main(){
  string s;
  cin >> s;
  if(s.at(0) == s.at(1) || s.at(2) == s.at(1) || s.at(2) == s.at(3)) cout << "Bad" << endl;
  else cout << "Good" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i = 0; i < n; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            if(a * a + b * b == c* c || b * b + c * c == a * a || c * c + a * a == b * b){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }
    }
}


Measured memory_bytes: 33628
#include<iostream>
using namespace std;
int main() {
	long int datas, max, min, sum, data;
	cin >> datas;
	cin>>data;
	max = min = sum = data;
	for (int i = 1; i < datas; i++) {
		cin >> data;
		if (data > max)max = data;
		if (data < min)min = data;
		sum += data;
	}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	const int n = s.size();
	if(s == string(n, '0')){
		cout << 0 << endl;
		return 0;
	}
	vector<bool> select(n);
	const int first = find(s.begin(), s.end(), '1') - s.begin();
	select[first] = true;
	for(int i = first + 1; i + 1 < n; ){
		if(s[i + 1] == '0'){
			++i;
		}else{
			select[i] = select[i + 1] = true;
			i += 2;
		}
	}
	ll answer = 0, pos = 0, k00 = 0, k01 = 0, k10 = 0, k11 = 0;
	for(int i = 0; i < n; ++i){
		if(!select[i]){ continue; }
		if(pos % 2 == 0){
			k01 += s[i] - '0';
		}else{
			k00 += s[i] - '0';
		}
		answer += k01;
		++pos;
	}
	for(int i = n - 1; i >= 0; --i){
		if(select[i]){
			--pos;
			if(s[i] == '1'){
				if(pos % 2 == 0){
					--k01;
					++k11;
				}else{
					--k00;
					++k10;
				}
			}
		}else{
			swap(k10, k11);
			if(s[i] == '1'){
				if(pos % 2 == 0){
					++k11;
				}else{
					++k10;
				}
			}
			answer += k01 + k11;
		}
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 3784
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; LL k; cin >> n >> k;

    vector<pair<LL, LL>> cnt(n);
    rep(i, n) cin >> cnt[i].first >> cnt[i].second;

    sort(cnt.begin(), cnt.end());

    LL ans = 0;
    LL sum = 0;
    for (auto &p: cnt) {
        sum += p.second;
        if (sum >= k) {
            ans = p.first;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pow2(x) (ll(1)<<x)
#define pb push_back
#define mp make_pair
#define w(t) int t;scanf("%d",&t);while(t--)
#define For(i,n) for(int i=0;i<n;i++)
#define scan(n) int n;scanf("%d", &n);
using namespace std;
const int sz = 1e5 + 7;
int main()
{
    scan(n);
    int dp[3][n];
    int v[3][n];
    For(i,n)
    {
        For(j,3)
            scanf("%d", &v[j][i]);
    }
    dp[0][0] = v[0][0];
    dp[1][0] = v[1][0];
    dp[2][0] = v[2][0];
    for(int i=1;i<n;i++)
    {
        dp[0][i] = max(dp[1][i-1],dp[2][i-1]) + v[0][i];
        dp[1][i] = max(dp[0][i-1],dp[2][i-1]) + v[1][i];
        dp[2][i] = max(dp[0][i-1],dp[1][i-1]) + v[2][i];
//        cout<<max(dp[0][i],max(dp[1][i],dp[2][i]))<<endl;
    }
    cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
}


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{

    int a[3][3];
    rep(i, 3) rep(j, 3) cin >> a[i][j];

    int n;
    cin >> n;
    int b[n];
    rep(i, n)
    {
        int b;
        cin >> b;
        rep(i, 3) rep(j, 3) if (a[i][j] == b) a[i][j] = -1;
    }

    bool flag = 0;

    rep(i, 3) if (a[i][0] == -1 && a[i][1] == -1 && a[i][2] == -1) flag = 1;
    rep(i, 3) if (a[0][i] == -1 && a[1][i] == -1 && a[2][i] == -1) flag = 1;

    if (a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1)
        flag = 1;

    if (a[0][2] == -1 && a[1][1] == -1 && a[2][0] == -1)
        flag = 1;

    if (flag)
        OP("Yes");
    else
        OP("No");

    return 0;
}

Measured memory_bytes: 256
N,M,X,Y=map(int,input().split())
x=[int(_) for _ in input().split()]
y=[int(_) for _ in input().split()]
x.sort()
y.sort()
if x[-1]<y[0] and x[-1]>X and y[0]<=Y:
    print('No War')
else:
    print('War')

Measured memory_bytes: 38384
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//223
	ll n;
	cin>>n;
	ll div = 1;
	int sum = 0;
	while(div<=n) {
		sum+=(n/div)%10;
		div*=10;
	}
	if(n%sum==0)cout<<"Yes";
	else cout<<"No";
	
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3620
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::endl;

bool can_make_str(std::string S, std::string T) {
	int len = S.length();
	int sind1 = -1;
	int tind1 = -1;
	int sind2 = -1;
	int tind2 = -1;
	bool smode = true;
	bool sfind = false;
	bool tfind = false;
	bool sseq = true;
	bool tseq = true;

	for (int n = 0; n < len; n++) {
		if ( smode ) {
			for (int i = sind1+1; i < len && !sfind && sseq; i++) {
				if ( S[i] == S[n] ) {
					sfind = true;
					sind1 = i;
				}
			}
			for (int i = tind1+1; i < len && !tfind && tseq; i++) {
				if ( T[i] == S[n] ) {
					tfind = true;
					tind1 = i;
				}
			}
			smode = false;
		}
		else {
			for (int i = sind2+1; i < len && !tfind && tseq; i++) {
				if ( S[i] == S[n] ) {
					tfind = true;
					sind2 = i;
				}
			}
			for (int i = tind2+1; i < len && !sfind && sseq; i++) {
				if ( T[i] == S[n] ) {
					sfind = true;
					tind2 = i;
				}
			}
			smode = true;
		}
		if ( sfind ) {
			sfind = false;
		}
		else {
			sseq = false;
		}
		if ( tfind ) {
			tfind = false;
		}
		else {
			tseq = false;
		}
	}
	return ( sseq || tseq );
}

int main(void) {
	std::string S,T;
	cin >> S >> T;

	if ( can_make_str(S,T) ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3172
from collections import deque
s = input()
q = int(input())

header = []
footer = []
flag = 0
for i in range(q):
    x = list(input().split())
    if int(x[0]) == 1:
        if flag ==0:
            flag = -1
        else:
            flag = 0
        continue
    if int(x[1]) +flag == 1:
        header.append(x[2])
        # s2 = deque(s)
        # # s.insert(0, x[2])
        # s2.appendleft(x[2])
        # s = list(s2)
    else:
        # s.append(x[2])
        footer.append(x[2])
# ans = ''.join(s)
head = ''.join(reversed(header))
ans = head +s + ''.join(footer)
if flag == -1:
    print(ans[::-1])
else:
    print(ans)

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

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

    char s[50];
    int k;
    int n;

    cin >> n >> k >> s;

    s[k - 1] = s[k - 1] + 32;
    cout << s << endl;

    return 0;
}

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

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<vector<char>> grid(h, vector<char>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> grid[i][j];
		}
	}
	
	int powh = pow(2, h);
	int poww = pow(2, w);
	
	int resp = 0;
	for (int i = 0; i < powh; i++) {
		for (int j = 0; j < poww; j++) {
			int count_blacks = 0;
			int row = i;
			for (int k = 0; k < h; k++) {
				if (row % 2 == 0) {
					int col = j;
					for (int l = 0; l < w; l++) {
						if (col % 2 == 0) {
							count_blacks += (grid[k][l] == '#');
						}	
						col /= 2;
					}
				}
				row /= 2;
			}
			resp += (count_blacks == k);
		}
	}
	cout << resp << endl;

	return 0;
}

Measured memory_bytes: 4012
#include<stdio.h>
int n, F[45];

int fibonacci(int n){
  if(n == 0 || n == 1)    return F[n] = 1;
  if(F[n] != -1)          return F[n];
  return F[n] = fibonacci(n - 1) + fibonacci(n - 2);
}

int main(){
  int i;

  for(i = 0; i < 45; i++)
    F[i] = -1;

  scanf("%d", &n);
  printf("%d\n", fibonacci(n));
  
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=100010;
const int inf=2147483647;
int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x*f;
}
int n,m,a[Maxn],v[Maxn],tim=0;
int fa[Maxn];vector<int>h[Maxn];
int findfa(int x){return((fa[x]==x)?x:fa[x]=findfa(fa[x]));}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;i++)a[i]=read(),fa[i]=i;
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		int fx=findfa(x),fy=findfa(y);
		if(fx!=fy)fa[fx]=fy;
	}
	for(int i=1;i<=n;i++)
	{
		int t=findfa(i);
		h[t].push_back(i);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	if(findfa(i)==i)
	{
		++tim;
		for(int j=0;j<h[i].size();j++)
		{
			int x=h[i][j];
			v[x]=tim;
		}
		for(int j=0;j<h[i].size();j++)
		{
			int x=h[i][j];
			if(v[a[x]]==tim)ans++;
		}
	}
	printf("%d",ans);
}


Measured memory_bytes: 6912
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<map>
#include<iomanip>
#include<limits>
#include<queue>
#include<set>


using namespace std;

int main(){


	string S;

	cin >> S;

	int a = S[0] - '0';
	int b = S[1] - '0';
	int c = S[2] - '0';
	int d = S[3] - '0';

	if(a + b + c + d == 7){
		printf("%d+%d+%d+%d=7\n",a,b,c,d);
	}else if(a + b + c - d == 7){
		printf("%d+%d+%d-%d=7\n",a,b,c,d);
	}else if(a + b - c + d == 7){
		printf("%d+%d-%d+%d=7\n",a,b,c,d);
	}else if(a + b - c - d == 7){
		printf("%d+%d-%d-%d=7\n",a,b,c,d);
	}else if(a - b + c + d == 7){
		printf("%d-%d+%d+%d=7\n",a,b,c,d);
	}else if(a - b + c - d == 7){
		printf("%d-%d+%d-%d=7\n",a,b,c,d);
	}else if(a - b - c - d == 7){
		printf("%d-%d-%d-%d=7\n",a,b,c,d);
	}else if(a - b - c + d == 7){
		printf("%d-%d-%d+%d=7\n",a,b,c,d);
	}

	return 0;

}


Measured memory_bytes: 256
def pow(a,b,c):
    ans = 1
    while b > 0:
        if b & 1:
            ans = ans*a % c
        a = a*a % c
        b = b >> 1
    return ans
def cmb(a,b,c):
    b = min(b,a-b)
    num = 1
    for i in range(b):
        num = num*(n-i) % c
    den = 1
    for i in range(b):
        den = den*(i+1) % c
    return num*pow(den,c-2,c) % c
mod = 10**9+7
n,a,b = map(int,input().split())
ans  = (pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod
if ans < 0:
    ans = ans + mod
print(ans)

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

int main()
{
	string s, t;
	int i;

	i = 0;
	cin >> s >> t;
	if (s[0] == t[0])
	{
		i++;
	}
	if (s[1] == t[1])
	{
		i++;
	}	
	if (s[2] == t[2])
	{
		i++;
	}

	cout << i;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<utility>

struct Card {
  char suit;
  int value, order;
};

int partition(Card src[], int p, int r) {
  Card x = src[r];
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (src[j].value <= x.value) {
      i++;
      std::swap(src[i], src[j]);
    }
  }

  std::swap(src[i + 1], src[r]);

  return i + 1;
}

void quick_sort(Card src[], int p, int r) {
  if (p < r) {
    int q = partition(src, p, r);
    quick_sort(src, p, q - 1);
    quick_sort(src, q + 1, r);
  }
}

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

  Card cards[n];
  for (int i = 0; i < n; i++) {
    scanf(" %c %d", &cards[i].suit, &cards[i].value);
    cards[i].order = i;
  }

  quick_sort(cards, 0, n - 1);

  bool stable = true;
  for (int i = 1; i < n; i++) {
    Card a = cards[i];
    Card b = cards[i - 1];
    if (a.value == b.value && a.order < b.order) {
      stable = false;
    }
  }

  if (stable) printf("Stable\n");
  else printf("Not stable\n");

  for (int i = 0; i < n; i++) printf("%c %d\n", cards[i].suit, cards[i].value);

  return 0;
}



Measured memory_bytes: 3896
def counting_sort(A, k):
    C = [0 for i in range(k)]
# C[i]にiの出現数を記録する
    for l in A:
        C[l] += 1
# C[i]にi以下の数の出現数を記録する
    for i in range(1, k):
        C[i] = C[i] + C[i-1]

    B = [None for i in range(len(A))]
    for l in A[::-1]:
        B[C[l]-1] = l
        C[l] -= 1

    return B

input()
a = list(map(int, input().split()))
b = counting_sort(a, 10000)
print(*b)


Measured memory_bytes: 224388
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int a,b,c,d,k;
int main()
{
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&k);
    printf("%d\n",(c-a)*60+(d-b)-k);
    return 0;
}

Measured memory_bytes: 3736