akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  int ans = 0;
  int snum = 0;
  for(int i=0;i<S.size();++i) {
    if(S[i]=='S') snum++;
    else {
      if(snum>0) {
        ans++;
        snum--;
      }
    }
  }
  cout<<S.size()-2*ans<<endl;
}



Measured memory_bytes: 3736
N,K = map(int,input().split())
l = list(map(int,input().split()))

num1 = 0
num2 = 0

for i in range(N):
    for j in range(N):
        if i > j:
            if l[i] > l[j]:
                num2 += 1
        if j > i:
            if l[i] > l[j]:
                num1 += 1
                num2 += 1

print((num1 * K + num2 * (K*(K-1)//2)) % (10**9 + 7))

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int X,Y;
vector<int> E[202020],E2[202020];

int P[21][200005],D[200005],D2[200005];

void dfs(int cur) {
	ITR(it,E[cur]) if(*it!=P[0][cur]) D[*it]=D[cur]+1, P[0][*it]=cur, dfs(*it);
}
int dist(int a,int b) {
	int ret=0,i,aa=a,bb=b;
	if(D[aa]>D[bb]) swap(aa,bb);
	for(i=19;i>=0;i--) if(D[bb]-D[aa]>=1<<i) bb=P[i][bb];
	for(i=19;i>=0;i--) if(P[i][aa]!=P[i][bb]) aa=P[i][aa], bb=P[i][bb];
	return D[a]+D[b]-2*D[(aa==bb)?aa:P[0][aa]];  // dist
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>X>>Y;
	FOR(i,N-1) {
		cin>>x>>y;
		E2[x].push_back(y);
		E2[y].push_back(x);
	}
	FOR(i,N-1) {
		cin>>x>>y;
		E[x].push_back(y);
		E[y].push_back(x);
	}
	P[0][Y]=Y;
	dfs(Y);
	FOR(i,19) FOR(x,N) P[i+1][x+1]=P[i][P[i][x+1]];
	FOR(i,N) D2[i+1]=10101010;
	
	int ret=0;
	queue<int> Q;
	D2[X]=0;
	Q.push(X);
	while(Q.size()) {
		x = Q.front();
		Q.pop();
		ret=max(ret,D[x]);
		if(D2[x]>=D[x]) continue;
		FORR(e,E2[x]) {
			if(dist(x,e)>=3) return _P("-1\n");
			if(D2[e]>D2[x]+1) D2[e]=D2[x]+1, Q.push(e);
		}
	}
	
	cout<<ret*2<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 47996
n, x = map(int, input().split())
L = list(map(int, input().split()))
s = 0
for i in range(n):
  if s + L[i] > x:
    print(i+1)
    break
  s = s + L[i]
  if i == n-1:
    print(n+1)
    break

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    string S;
    cin >> N >> S;
    int blackCoordinate = -1;
    for (int i = N - 1; i >= 0; i--) {
        if (S[i] == '#') {
            blackCoordinate = i;
            break;
        }
    }
    if (blackCoordinate == -1) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1e9;
    int black = 0, white = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == '.') ++white;
    }
    ans = white;
    for (int i = 0 ; i < N; i++) {
        if (S[i] == '.') {
            --white;
            ans = min(ans, black + white);
        } else {
            ++black;
            ans = min(ans, black + white);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 720
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    string S,T; cin >> S >> T;
    string ans = "";
    rep(i,N) {
        ans += S[i];
        ans += T[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n;
    int d1=0;
    int Rmin,R;
    
    scanf("%d",&n);
    scanf("%d",&Rmin);
    scanf("%d",&R);
    
    d1=R-Rmin;
    
    if(Rmin>R){
        Rmin=R;
    }
    
    for(int j=2;j<n;j++){
        scanf("%d",&R);
        if(d1<R-Rmin){
            d1=R-Rmin;
        }
        if(Rmin>R){
            Rmin=R;
        }
    }
    printf("%d\n",d1);
    
    return 0;
}


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

#define gc( ) std::getchar( )
#define pc( i ) std::putchar( i )
#define space ' '
#define enter '\n'
#define RE cout << "Passing [" << __FUNCTION__ << "] on " << __LINE__ << enter
#define DEBUG(...) for( auto &i: __VA_ARGS__ ) cout << i << " "; cout << enter
using std::make_pair;

template < typename T >
inline T read( )
{
 T x = 0;
 char ch = gc( );
 bool f = 0;
 while( !std::isdigit( ch ) )
 {
  f = ( ch == '-' );
  ch = gc( );
 }
 while( std::isdigit( ch ) )
 {
  x = x * 10 + ( ch - '0' );
  ch = gc( );
 }
 return f ? -x : x;
}

template < typename T >
void print( T x )
{
 if( x < 0 )
 {
  x = -x;
  pc( '-' );
 }
 if( x < 10 )
 {
  pc( x + 48 );
  return;
 }
 print < T > ( x / 10 );
 pc( x % 10 + 48 );
 return ;
}

namespace Solution
{
#define IOS std::ios::sync_with_stdio( false ), std::cin.tie( 0 ), std::cout.tie( 0 )
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
#define rdi( ) read < int > ( )
#define rdl( ) read < long long > ( )
#define pti( i ) print < int > ( i ), putchar( space )
#define ptl( i ) print < long long > ( i ), putchar( space )
#define For( i, j, k ) for( int i = j; i <= k; ++i )
 using std::cin;
 using std::cout;
 using std::endl;
 using std::vector;
 using std::map;
 using std::queue;
 using std::deque;
 using std::set;
 using std::pair;
 const int N = 204001, mod = 1e9 + 7;
 long long a, b, c, d;
 void Fakemain( )
 {
  cin >> a >> b >> c >> d;
  cout << std::max( std::max( a * d, c * b ), std::max( a * c, b * d ) );
  return;
 }

} // namespace Solution

int main( int argc, char* argv[] )
{
 Solution::Fakemain( );
 return 0;
}

Measured memory_bytes: 3592
n, m = map(int, input().split())
h = [int(i) for i in input().split()]
load = [list(map(int, input().split())) for _ in range(m)]
result = {i: 1 for i in range(n)}

for l in load:
    a, b = l[0] - 1, l[1] - 1
    if h[a] < h[b]:
        result[a] = 0
    elif h[a] > h[b]:
        result[b] = 0
    elif h[a] == h[b]:
        result[a] = 0
        result[b] = 0

print(sum(result.values()))

Measured memory_bytes: 42680
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


#define huge 1000000007
typedef long long ll;

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll K = 0;
	ll Y = 0;
	ll X = 0;
	ll m[100000] = {};
	ll p[100] = {};
	ll x[100] = {};
	//ll *x, *c, *d;
	string S,T;
	ll count = 0;
	ll sum = 0;
	ll min = 1;
	ll i = 0;
	//char p;
	cin >> A >> B;

	
	if(A+B<10)
	cout << A+B << endl;
	else
		cout << "error" << endl;

	return 0;

}



Measured memory_bytes: 256
require 'pp'
N,d=gets.chomp.split(' ').map{|n| n.to_i}
A1=gets.chomp.split(' ').map{|n| n.to_i}
A2=gets.chomp.split(' ').map{|n| n.to_i}

dp=Array.new(2){Array.new(N)}
dp[0][0]=A1[0]
1.upto(N-1){|j|
	dp[0][j]=dp[0][j-1]+A1[j]
}
dp[1][0]=dp[0][0]+A2[0]
1.upto(N-1){|j|
	up   = dp[0][j]
	left = dp[1][j-1]
	me   = A2[j]
	if(up>left)
		dp[1][j] = up + me
	else
		dp[1][j] = left + me
	end
}

puts dp[1][N-1]


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

using namespace std;

typedef long long lol;
const int N = 1e7 + 5;
const int M = 5e3 + 5;
const int mod = 1e9 + 7;
inline int pls( int a , int b ) { a += b - mod; return a + ( a >> 31 & mod ); }
inline int mns( int a , int b ) { a -= b; return a + ( a >> 31 & mod ); }
inline void inc( int & a , int b ) { a += b - mod; a += a >> 31 & mod; }
inline void dec( int & a , int b ) { a -= b; a += a >> 31 & mod; }
inline int fpow( int base , int k ) {
  int res = 1;
  while( k ) {
    if( k & 1 ) res = (long long)res * base % mod;
    base = (long long)base * base % mod; k >>= 1;
  }
  return res;
}

int n , A , fac[N] , ifac[N] , inv[N];

inline int binom( int n , int m ) { return (lol)fac[n]*ifac[m]%mod*ifac[n-m]%mod; }

int main( void ) {
  cin >> n >> A;
  fac[0] = fac[1] = ifac[0] = ifac[1] = inv[1] = 1;
  for( int i = 2 ; i <= n ; ++i ) {
    fac[i] = (lol)fac[i - 1] * i % mod;
    inv[i] = (lol)(mod-mod/i)*inv[mod%i]%mod;
    ifac[i] = (lol)ifac[i - 1] * inv[i] % mod;
  }
  int ans = 0 , tmp;
  for( int i = 2 , a , b , c ; i <= A + 1 ; ++i ) {
    a = i - 1 , b = n - A , c = max( 0 , A - i );
    for( int j = 0 ; j < i ; ++j ) {
      tmp = (lol)binom( i - 1 , j ) * (a-j) % mod * inv[a+b-j] % mod * fac[a+b+c-j] % mod;
      if( j & 1 ) dec( ans , tmp );
      else inc( ans , tmp );
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 120856
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        final int A = scan.nextInt();
        final int B = scan.nextInt();
        scan.close();

        int socket = 1;
        int tap = 0;
        boolean isLack = B > 1;

        while (isLack) {
            socket = socket - 1 + A;
            tap++;
            if (socket >= B) {
                isLack = false;
            }
        }

        System.out.println(tap);
    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>

using namespace std;

int main() {

	int S_x, S_y, G_x, G_y;

	cin >> S_x >> S_y >> G_x >> G_y;

	for (int i = 0; i < G_x - S_x; i++){
		cout << 'R';
	}
	for (int i = 0; i < G_y - S_y; i++) {
		cout << 'U';
	}
	for (int i = 0; i < G_x - S_x; i++) {
		cout << 'L';
	}
	for (int i = 0; i < G_y - S_y; i++) {
		cout << 'D';
	}
	cout << 'D';
	for (int i = 0; i < G_x - S_x + 1; i++) {
		cout << 'R';
	}
	for (int i = 0; i < G_y - S_y + 1; i++) {
		cout << 'U';
	}
	cout << "LU";
	for (int i = 0; i < G_x - S_x + 1; i++) {
		cout << 'L';
	}
	for (int i = 0; i < G_y - S_y + 1; i++) {
		cout << 'D';
	}
	cout << 'R';
	return 0;
}

Measured memory_bytes: 256
$n=<>;
$a=<>,push(@A,$a)for(1..2**$n);
for(1..2**$n){
    $s=shift(@A);
    $t=shift(@A);
    push(@A,$s>$t?$s-$t:$t>$s?$t-$s:$s);
}
print$A[0]

Measured memory_bytes: 20992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int ans[] = new int[10001];

		for (int x=1; x<=100; x++){
			for (int y=1; y<=100; y++){
				for (int z=1; z<=100; z++){
					int f = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
					if (f <= n){
						ans[f]++;
					}
				}
			}
		}

		for (int i=1; i<=n; i++){
			System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 38880
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
#else

#endif



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Togliere nei problemi con query online

    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());

    vector<int> B;
    vector<int> qq;
    int M = 0;
    for (int i = 0; i < N; i++) {
        if (i > 0 and A[i] == A[i-1]) qq[M-1]++;
        else B.push_back(A[i]), qq.push_back(1), M++;
    }

    int pp = (1<<30);
    int res = 0;
    for (int i = M-1; i >= 0; i--) {
        while (pp/2 > B[i]) pp /= 2;
        int id = lower_bound(B.begin(), B.end(), pp-B[i]) - B.begin();
        if (id == M) continue;
        if (B[i] + B[id] != pp) continue;
        int at = min(qq[i], qq[id]);
        if (i == id) at /= 2;
        res += at;
        qq[i] -= at;
        qq[id] -= at;
    }
    cout << res << "\n";
}


Measured memory_bytes: 2804
N = int(input())
*A, = map(int,input().split())
ans = [A[0]*2]*N
for i in range(1,N):
    ans[i] = A[i-1]*2 - ans[i-1]
diff = (ans[0]+ans[-1])//2 - A[-1]
for i in range(N):
    ans[i] -= diff*(-1)**i
print(*ans)

Measured memory_bytes: 14972
N, K = map(int,input().split())
trees = []
for i in range (N):
    temp = int(input())
    trees.append(temp)
trees.sort()
ans = 10**9
for i in range (N-K+1):
    low = trees[i]
    high = trees[i+K-1]
    diff = high-low
    if diff < ans:
        ans = diff
print(ans)

Measured memory_bytes: 7488
#include<iostream>
#include<string.h>
using namespace std;
long long a[1005],num[105];
int main()
{
	long long n,m,sum,q,w;
	cin>>n;
	sum=0;
	memset(a,0,sizeof(a));
	memset(num,0,sizeof(num));
	for(int i=1;i<=n;i++)
	{
	    cin>>a[i];
	    sum+=a[i];
	}
	cin>>m;
	for(int j=1;j<=m;j++)
	{
		cin>>q>>w;
	cout<<sum-a[q]+w<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

int N, monster[100001];

int main()
{
  scanf("%d", &N);
  for (int i=0; i<N+1; i++)
    scanf("%d", &monster[i]);

  long long ret=0;
  int tmp=0;
  int x;
  for (int i=0; i<N; i++) {
    scanf("%d", &x);
    tmp = min(monster[i], x);
    ret += tmp;
    x -= tmp;
    if (x) {
      tmp = min(monster[i+1], x);
      monster[i+1] -= tmp;
      ret += tmp;
    }
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    int n;cin >> n;
    vector<int> a(8);
    int top=0;
    for(int i = 0; i < n; i++) {
        int x;cin >> x;
        x /= 400;
        if(x<8) a[x]++;
        else top++;
    }
    
    int q=0;
    for(int i = 0; i < 8; i++) {
        if(a[i]>0) q++;
    }
    if(q==0 && top>0){
        cout << 1 << ' ' << top << endl;
        return 0;
    }

    cout << q << ' ' << q+top << endl;

    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
#define N 100

int main(){
  int A[N],a,i,j,n,count=0,minj;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<=n-1;i++){      
    minj=i;
    for(j=i;j<=n-1;j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    if(i!=minj){
	a=A[i];
	A[i]=A[minj];
	A[minj]=a;
	count++;	
    }
    
  }
  for(i=0;i<n;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

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

int main(void){
    int a,b; cin >> a >> b;
    string s; cin >> s;
    int flg=1;

    for(int i=0; i<a; i++){
        if(!('0'<=s[i] && s[i]<='9')) flg=0;
    }

    if(s[a]!='-') flg=0;

    for(int i=a+1; i<a+b+1; i++){
        if(!('0'<=s[i] && s[i]<='9')) flg=0;
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
#include<stack>
#include<map>
#include<queue>
#include<unordered_map>
#include<cmath>
#include<utility>

using ULL = unsigned long long;
using LL = long long;
using String = std::string;
using Ints = std::vector<int>;
using Doubles = std::vector<double>;
using Bools = std::vector<bool>;
using Strings = std::vector<std::string>;
using ULLs = std::vector<ULL>;
using LLs = std::vector<LL>;

// pythonのdictionary相当
template <typename T1, typename T2>
using Dict = std::unordered_map<T1,T2>;




int main(void) {
    int N;
    Dict<String, int> res;
    res["AC"]=0;
    res["WA"]=0;
    res["TLE"]=0;
    res["RE"]=0;
    std::cin >> N;

    for(int i=0;i<N;i++){
        String s;
        std::cin >> s;
        res[s]++;
    }


    std::cout << "AC x " << res["AC"] << std::endl;
    std::cout << "WA x " << res["WA"] << std::endl;
    std::cout << "TLE x " << res["TLE"] << std::endl;
    std::cout << "RE x " << res["RE"] << std::endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
 
 
int main () {
    string s;

    cin >> s;

    s[5] = ' ';
    s[13] = ' ';

    cout << s << endl;


}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int N,A,B;
	cin>>N>>A>>B;
	bool bA=true;
	while(true){
		if (bA){
			if (A+1<B){
				A++;
			}else{
				A--;
				if (A==0){
					cout<<"Borys"<<endl;
					return 0;
				}
			}
			bA=false;
		}else{
			if (B-1>A){
				B--;
			}else{
				B++;
				if (B>N){
					cout<<"Alice"<<endl;
					return 0;
				}
			}
			bA=true;
		}
	}
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int K = scan.nextInt();
        int S = scan.nextInt();
        long answer = 0;
        for (int x = 0; x <= K; x++) {
            int limit_y = Math.min(K, S - x);
            for (int y = 0; y <= limit_y; y++) {
                if (S - x - y <= K) {
                    answer += 1;
                }
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 22100
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e6;
ll inf = LLONG_MAX, mod1 = 1e9 + 7, mod2 = 998244353;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
    fast_io;
    ll x;
    cin >> x;
    if (x < 600) cout << 8;
    else if (x < 800) cout << 7;
    else if (x < 1000) cout << 6;
    else if (x < 1200) cout << 5;
    else if (x < 1400) cout << 4;
    else if (x < 1600) cout << 3;
    else if (x < 1800) cout << 2;
    else if (x < 2000) cout << 1;
    return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

int main() {
    int a,b;
    cin>>a>>b;
    cout<<6-a-b<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n
a
b
c

n 100
 */
int n;
char a[3][101];

int main(){
  cin>>n;
  REP(i,3)
    cin>>a[i];

  int ans=0;
  REP(i,n){
    int s=0;
    if(a[0][i]==a[1][i])
      s++;
    if(a[0][i]==a[2][i])
      s++;
    if(a[1][i]==a[2][i])
      s++;

    if(s==0)
      ans+=2;
    else if(s==1)
      ans++;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;

int main(){
   string S;
   cin >> S;
   int N = S.size();
   int ans = N;

   int i = 1;
   while(i<N){
    if(S[i-1]==S[i]){
      ans--;
      i+=2;
    }
    i++;
   }

   cout << ans <<endl;

  	return 0;
}

Measured memory_bytes: 640
/*
  表計算(表の行数rと列数c、r × c の要素を持つ表を読み込んで、
  各行と列の合計を挿入した新しい表を出力するプログラム)
  2018/02/10
*/

#include<stdio.h>
int main(void){
  int a[101][101];/*(r+1)*(c+1)の表*/
  int r,c;/*表の行数と列数*/
  int sum_line,sum_row;/*行の値の合計、列の値の合計*/
  int i,j,k;/*行、列、j列目の行*/

  scanf("%d %d",&r,&c);
  for(i=0;i<r;i++){
    sum_line = 0;
    for(j=0;j<c;j++){
      scanf("%d",&a[i][j]);
      sum_line += a[i][j];
      printf("%d ",a[i][j]);
    } 
    printf("%d\n",sum_line);
  }

  sum_line = 0;
  for(j=0;j<c;j++){
    sum_row = 0;
    for(k=0;k<r;k++){
      sum_row += a[k][j];
    }
    sum_line += sum_row;
    printf("%d ",sum_row);
  }
  printf("%d\n",sum_line);
  return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,n,s) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define rall(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;
int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void printpair(vector<pair<ll, ll>> vp)
{
  cout<<'['<<endl;
  rep(i,0,vp.size())
  {
    pair<ll, ll> p=vp[i];
    cout<<'{'<<p.first<<','<<p.second<<'}'<<endl;
  }
  cout<<'}'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
const long long INF = 1e12;
//------------------------------------------------------------
struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

ll N,K,L;
void solve()
{
    cin >> N>>K>>L;

    UnionFind road(N);
    UnionFind train(N);

    rep(i,0,K)
    {
      int p,q;
      cin>>p>>q;
      --p;--q;

      road.unite(p,q);
    }

    rep(i,0,L)
    {
      int r,s;
      cin>>r>>s;
      --r;--s;

      train.unite(r,s);
    }

    map<pair<int, int>, int> count;

    rep(i,0,N)
    {
      count[make_pair(road.root(i), train.root(i))]++;
    }

    rep(i,0,N) cout << count[make_pair(road.root(i), train.root(i))] << ' ';
    cout << endl;

    return;
}



Measured memory_bytes: 13568
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

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



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

    for(auto i: N){
        if(i == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d; cin >> n >> d;
  int cnt = 0;
  for(int i = 0; i < n; i++){
    long x,y; cin >> x >> y;
    if(sqrt(x*x+y*y) <=d) cnt++;
  }
  cout << cnt;
}
  
      

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
bool ch[3];
int main() {
	for(ll i=0;i<2;i++){
		ll n;
		cin>>n;
		n--;
		ch[n]=true;
	}
	for(ll i=0;i<3;i++){
		if(ch[i]){
			continue;
		}
		cout << i+1;
		return 0;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3572
import sys

def solve():
    A = [0 for _ in range(101)]
    for i in sys.stdin:
        a = int(i)
        A[a] += 1
    
    M = max(A)
    for i, a in enumerate(A):
        if a == M:
            print(i)

if __name__ == "__main__":
    solve()



Measured memory_bytes: 5608
#include <bits/stdc++.h>
#include<numeric>
#include<cmath>
#include<cstdlib>
#include<string>
#include <limits>
using namespace std;


int main(){
  int X,Y,Z,K;
  cin>>X>>Y>>Z>>K;
  vector<long long int> A(X),B(Y),C(Z),M,N;
  

  for(int i=0;i<X;i++)
    cin>>A.at(i);
  for(int i=0;i<Y;i++)
    cin>>B.at(i);
  for(int i=0;i<Z;i++)
    cin>>C.at(i);

  
  for(int i=0;i<X;i++){
    for(int j=0;j<Y;j++){
      M.push_back(A.at(i)+B.at(j));
    }
  }
  
  sort(M.begin(),M.end());
  reverse(M.begin(),M.end());
  
  M.resize(K);

  for(int i=0;i<Z;i++){
    for(int j=0;j<M.size();j++){
      N.push_back(C.at(i)+M.at(j));
    }
  }
  
  sort(N.begin(),N.end());
  reverse(N.begin(),N.end());
  
  for(int i=0;i<K;i++)
    cout<<N.at(i)<<endl;

}


Measured memory_bytes: 43368
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
double a[N], s;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, x = 2;
    cin >> n;
    for (ll i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    for (ll i = n - 1; i; i--)
        s += a[i] / x, x *= 2;
    x /= 2;
    cout << s + a[0] / x;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    set<int> s;
    rep(i, 0, 3) {
      int in; cin >> in;
      s.insert(in);
    }
  
    cout << s.size() << endl;
}


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

const ll INF = 1001001001;

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	vector<ll> c(n);
	rep(i,n){
		// 0-indexed
		cin >> p[i];
		p[i]--; 
	}
	rep(i,n) cin >> c[i];

	// investigate cycles and give ids
	vector<int> ID(n, -1), cy_num;
	vector<ll> cy_sum;
	int id = 0;
	for(int i = 0; i < n; i++){
		if(ID[i] != -1) continue;
		int cnt = 0, idx = i;
		ll tmp = 0;
		while(ID[idx] == -1){
			cnt++;
			ID[idx] = id;
			tmp += c[idx];
			idx = p[idx];
		}
		cy_sum.push_back(tmp);
		cy_num.push_back(cnt);
		id++;
	}

	ll ans = -INF;
	for(int i = 0; i < n; i++){
		int iid = ID[i];
		ll tmp = 0, mx = -INF;
		ll idx = i;
		// you can stop rotating a cycle anywhere
		// j stands for the number of vertices of a loop starting from i-th vertex 
		for(int j = 1; j <= min(cy_num[iid], k); j++){
			idx = p[idx];
			tmp += c[idx];
			mx = max(mx, tmp);
			ll res;
			if(cy_sum[iid] > 0) res = cy_sum[iid] * ((k-j) / cy_num[iid]) + mx;
			else res = mx;
			ans = max(ans, res);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define	       MEM(a,b)         memset(a,(b),sizeof(a))
#define	       CLR(p)           memset(p,0,sizeof(p))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
#define	       ff               first
#define	       sc              second
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//memset(ar,-1,sizeof(ar));
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
// string x(w.size(),'1');
#define MAX 1000005
#define precision(a) fixed << setprecision(a)

#define mod 1000000007



int main()
{
 //O_O ;
   string  t;
   cin>>t;
   ll l=t.length();
 if(t[l-1]=='s')
    cout<<t<<"es"<<nn;
 else
    cout<<t<<"s"<<nn;


    return 0;
}


Measured memory_bytes: 3624
n = int(input())
a = list(map(int,input().split()))
s = [a[0]]
sums = sum(a)
for i in range(1,n):
  s.append(s[i-1]+a[i])
ans = 0
for i in range(n-1):
  ans += a[i] * (sums - s[i])
b = 10**9 + 7
print(ans%b)

Measured memory_bytes: 107080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
const int MAXN = 2e5+3;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll N,K;
	cin >> N >> K;
	ll ans = 0;
	for(ll i=K;i<=N+1;i++){
		ll minidx = i*(i-1)/2;
		ll maxidx = i*(2*N-i+1)/2;
//		cout << minidx << ' ' << maxidx << '\n';
		ans = (ans+maxidx-minidx+1)%MOD;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3660
# include <iostream>
# include <vector>
# include <algorithm>

using namespace std;

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

  vector<int> num, ans;
  for(int i=0; i<n; i++) {
    int x;
    cin >> x;
    x--;
    num.push_back(x);
  }

  for(int i=0; i<n; i++){
    for(int j=num.size()-1; j>=0; j--){
      if(num[j] == j){
        num.erase(num.begin()+j);
        ans.push_back(j+1);
        break;
      }
    }
  }

  if(num.size() != 0){
    ans.clear();
    ans.push_back(-1);
  }
  reverse(ans.begin(), ans.end());
  for(int x : ans) cout << x << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;

#define File freopen("in.txt","r",stdin);
#define ll long long

const int mINF = 0x80000000;
const int INF = 0x3f3f3f3f;
const int maxn = 100000 + 10;

char a[maxn];

int main()
{
    char x, y;
    scanf("%s", a);
    x = a[0];
    y = a[1];
    int len = strlen(a);
    int flag = true;
    for(int i = 2; i < len; i++) {
        if(i % 2 == 0) {
            if(a[i] != x) {
                flag = false;
                break;
            }
        } else {
            if(a[i] != y) {
                flag = false;
                break;
            }
        }
    }
    if(!flag) {
        if(a[0] == a[len - 1]) {
            if((len - 2) % 2 == 0) {
                cout << "First" << endl;
            } else {
                cout << "Second" << endl;
            }
        } else {
            if((len - 2) % 2 == 0) {
                cout << "Second" << endl;
            } else {
                cout << "First" << endl;
            }
        }
    } else {
        cout << "Second" << endl;
    }
    return 0;

}




Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
inline ll kissme(ll x,ll y)
{
	ll res=1;
	if(x==0)return 1;
	if(x==1)return y;
	res=kissme(x/2,y);
	res=res*res%mod;
	if(x%2==1)res=res*y%mod;
	return res;
}
void read(int &x)
{
    int f=1;
    x=0;
    char s=getchar();
    while(s<'0'||s>'9')
    {
        if(s=='-')
            f=-1;
        s=getchar();
    }
    while(s>='0'&&s<='9')
    {
        x=x*10+s-'0';
        s=getchar();
    }
    x*=f;
}
void print(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
int n,m,k,ans;
char c[10][10],h[10][10];
bool check(int x,int y)
{
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			h[i][j]=c[i][j];
	for(int i=0;i<n;i++)
	{
		if((x>>i)&1)
		{
			for(int j=0;j<m;j++)
			{
				h[i][j]='.';
			}
		}
	}
	for(int j=0;j<m;j++)
	{
		if((y>>j)&1)
		{
			for(int i=0;i<n;i++)
			{
				h[i][j]='.';
			}
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(h[i][j]=='#')cnt++;
		}
	}
	return cnt==k;
}
signed main()
{
	Very_fast;
	cin>>n>>m>>k;
	for(int i=0;i<n;i++)cin>>c[i];
	for(int i=0;i<(1<<n);i++)
	{
		for(int j=0;j<(1<<m);j++)
		{
			if(check(i,j))
			{
				ans++;
			}
		}
	}
	cout<<ans<<"\n";
	return 0;
}

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

class node;
node *root, *NIL;

class node{
public:
  node *p = NIL, *l = NIL, *r = NIL;
  int key = 0;

  node(int x) : key(x){}
};


void insert(int key){
  node *x = root, *y = NIL;
  while(x != NIL){
      y = x;
      if(key >= x->key) x = x->r;
      else x = x->l;
  }

  if(y == NIL) root = new node(key);
  else if(key >= y->key) y->r = new node(key);
  else y->l = new node(key);
}

node* find(int key){
  node* x = root;

  while(x != NIL && x->key != key){
    if(key >= x->key) x = x->r;
    else x = x->l;
  }

  return x;
}

void preorder(node* n){
  if(n == NIL) return;
  cout << " " << n->key;
  preorder(n->l);
  preorder(n->r);
}

void inorder(node* n){
  if(n == NIL) return;
  inorder(n->l);
  cout << " " << n->key;
  inorder(n->r);
}

void print(){
  inorder(root);
  cout << endl;
  preorder(root);
  cout << endl;
}

int main(){
  root = NIL;

  int n; cin >> n;
  while(n--){
    string s; cin >> s;

    if(s == "insert"){
      int x; cin >> x;
      insert(x);
    }else if(s == "find"){
      int x; cin >> x;
      if(find(x) != NIL) cout << "yes" << endl;
      else cout << "no" << endl;
    }else{
      print();
    }
  }
}



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

int main() {
	int H, W;
	int a = 1;
	while (a == 1) {
		cin >> H >> W;
		if (!(H == 0 && W == 0)) {
			for (int i = 1; i <= H; i++) {
				if (i % 2 == 1) {
					for (int j = 1; j <= W; j++) {
						if (j % 2 == 1) {
							cout << "#" << flush;
						}
						else if (j % 2 == 0) {
							cout << "." << flush;
						}
					}
					cout << endl;
				}
				else if (i % 2 == 0) {
					for (int j = 1; j <= W; j++) {
						if (j % 2 == 1) {
							cout << "." << flush;
						}
						else if (j % 2 == 0) {
							cout << "#" << flush;
						}
					}
					cout << endl;
				}
			}
			cout << endl;
		}
		else if (H == 0 && W == 0) {
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3012
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;
// English Sentence (0029)
int main()
{
	map<string,int>a;
	string ret1,ret2;
	int maxnum=0,maxlen=0;
	string s;
	while (1){
		if(!(cin>>s)) break;;
		int num=++a[s];
		if(maxnum<num){ 
			maxnum=num;
			ret1=s;
		}
		if(maxlen < s.size()){
			maxlen=s.size();
			ret2=s;
		}
	}
	cout<<ret1<<" "<<ret2<<endl;
	return 0;
}

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

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

    //c%2==0 poleta=r*c/2;
    //c%2!=0 r%2==0 r*c/2;
    //c%2!=0 r%2!=0 r-1*c/2 + 2*r-1;
    unsigned long long int r,c;
    cin>>r>>c;
    if(r==1 || c==1)
        cout<<"1";
    else if(c%2==0)
        cout<<(r*c)/2;
    else if(r%2==0 && c%2!=0)
        cout<<(r*c)/2;
    else
        cout<<((r-1)*c)/2 + (c/2)+1;
}


Measured memory_bytes: 3568
def resolve():
    s=int(input())
    l=[s]
    for i in range(10**6):
        if l[i]%2==0:
            if l[i]//2 in l:
                print(i+2)
                break
            else:
                l.append(l[i]//2)
        else:
            if 3*l[i]+1 in l:
                print(i+2)
                break
            else:
                l.append(3 * l[i] + 1)
resolve()


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

int main() {
    int n, m, b, err;
    scanf("%d", &n);
    int res[n+1];
    fill(res, res+n+1, 0);
    scanf("%d", &m);
    int nums[m];
    for (int i = 0; i < m; i++) scanf("%d", &nums[i]);
    for (int i = 0; i < m; i++) {
        err = 0;
        for (int j = 1; j <= n; j++) {
            scanf("%d", &b);
            if (b == nums[i]) res[j]++;
            else err++;
        }
        res[nums[i]]+=err;
    }
    for (int i = 1; i <= n; i++) printf("%d\n", res[i]);
    return 0;
}



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

int main(){
    int aaa, bbb, ccc;
    cin >> aaa >> bbb >> ccc;
    vector<vector<int>> a(aaa, vector<int>(bbb));
    vector<int> c(aaa);
    for(int i = 0; i < aaa; i++){
        cin >> c[i];
        for(int j = 0; j < bbb; j++)cin >> a[i][j];
    }
    int ans = 12345678;
    int all = 1<<aaa;
    for(int lol = 0; lol < all; lol++){
        vector<int> level(bbb);
        int cost = 0;
        for(int i = 0; i < aaa; i++){
            if((lol>>i)&1){
                cost += c[i];
                for(int j = 0; j < bbb; j++){
                    level[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        for(int j = 0; j < bbb; j++){
            if(level[j] < ccc) ok = false;
        }
        if(ok) ans = min(ans,cost);
    }
    if(ans == 12345678) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int a[35] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k; cin >> k;
    cout << a[k-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(void){
    ll K,A,B;
    cin >> K >> A >> B;
    if( B/K != (A-1)/K ){
        printf("OK");
    }
    else{
        printf("NG");
    }
    
}


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

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

// void func(type &variable)とすることで参照渡しとなる。
void STLSort(vector<int> &x){
    sort(x.begin(), x.end());
}

void printVec(vector<int> x, int n){
    for(int i = 0; i < n - 1; i++){
        cout << x.at(i) << " ";
    }
    cout << x.at(n - 1);
}
void insertionSort(vector<int> &x, int n){
    //
    for(int i = 1; i < n; i++){
        printVec(x, n);
        cout << endl;

        int v = x.at(i);
        int j = i - 1;
        while(j  >= 0 && x.at(j) > v){
            x.at(j + 1) = x.at(j);
            j--;
        }
        x.at(j + 1) = v;
    }
}

int main(){
    int n; cin >> n;
    vector<int> x(n);

    rep(i, n){
        cin >> x.at(i);
    }

    insertionSort(x, n);
    printVec(x, n);
    cout << endl;

}



Measured memory_bytes: 3148
#pragma GCC target("avx2")
#include<bits/stdc++.h>

template<unsigned long N>
struct precalc{
    unsigned long sz, val[N + 1];
    constexpr precalc() : sz(N), val() {
        for(unsigned long i{1}; i <= N; ++i)val[i] = i;
        for(unsigned long i{2}; i <= N; ++i)if(val[i] == i)for(unsigned long j{i}; j <= N; j += i)(val[j] /= i) *= (i - 1);
        for(unsigned long i{1}; i <= N; ++i)val[i] = (val[i] + val[i - 1]) % 1000000007;
    }
};

constexpr auto v = precalc<100000>{};

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    scanf("%lu%lu", &N, &K);
    const auto& modpow = [](unsigned long a, unsigned long n, unsigned long b = 1) -> unsigned long {
        unsigned long r{b % MOD};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    unsigned long ans{0};
    for(unsigned long i{K}, p{0}; i; ){
        auto t = K / i;
        auto k = modpow(t, N);
        ans += (k + p) * v.val[i];
        i = K / (t + 1);
        p = MOD - k;
    }
    printf("%lu\n", ans % MOD);
    return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vi L(M), R(M);
    
    rep(i, M){
        cin >> L[i] >> R[i];
    }

    int maxl = L[0];
    int minr = R[0];
    rep(i, M){
        maxl = max(maxl, L[i]);
        minr = min(minr, R[i]);
    }

    if(maxl > minr){
        cout << 0 << endl;
    }else{
        cout << minr - maxl + 1 << endl;
    }
    return 0;
}

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

typedef long long LL;

const int N=1000000;

char s[N+9];
int n;

void into(){
  scanf("%s",s+1);
  n=strlen(s+1);
}

int pre[N+9],suf[N+9];

void Get_suf(){
  for (int i=1;i<=n;++i) pre[i]=pre[i-1]+(s[i]=='0'?-1:1);
  suf[n]=pre[n];
  for (int i=n-1;i>=0;--i) suf[i]=min(pre[i],suf[i+1]);
}

int Get_ans(int lim){
  int res=0,now=0;
  for (int i=1;i<=n;++i){
	if (s[i]=='?'&&suf[i]+now>=lim+2) now-=2;
	res=max(res,pre[i]+now);
  }
  return res-lim;
}

int ans;

void Get_ans(){
  ans=min(Get_ans(suf[0]),Get_ans(suf[0]-1));
}

void work(){
  Get_suf();
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 12584
// abc169_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  ll a;
  double b;
  cin >> a >> b;
  ll llb = 100*b+0.01;
  cout<<a*llb/ 100<<endl;
  return 0;
}


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

using namespace std;

int main(){
  int N; cin >> N;
  int n;
  int ans = 1000000;
  for (int i = 0; i < N; i++) {
    cin >> n;

    int cnt = 0;
    while(n % 2 == 0) {
      cnt++;
      n /= 2;
    }

    ans = min(cnt, ans);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import itertools
import collections

N, X, Y = map(int, input().split())

pos = [i for i in range(1,N+1)]
ways = list(itertools.combinations(pos,2))

dist_l = [min(abs(i-j), abs(i - X) + 1 + abs(Y - j)) for i,j in ways]

dic = collections.Counter(dist_l)
for i in range(1,N):
    print(dic[i])

Measured memory_bytes: 210432