akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
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;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s;
	cin>>s;
	int n=s.size();
	bool h=true;
	int l=0,r=n-1;
	while(l<=r){
		if(s[l]=='x'){l++;continue;}
		if(s[r]=='x'){r--;continue;}
		if(s[l]==s[r]){
			l++;r--;
		}else{h=false;break;}
	}
	if(!h)cout<<-1<<endl;
	else{
		l=0,r=n-1;
		int out=0;
		while(l<=r){
			if(s[l]==s[r]){
				l++;r--;
				continue;
			}
			if(s[l]=='x'){
				out++;
				l++;
				continue;
			}
			if(s[r]=='x'){
				out++;
				r--;
				continue;
			}
		}
		cout<<out<<endl;
	}
}
















Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long x = sc.nextLong(), m = 100L;
		int y = 0;

		while(m < x) {
			m += m / 100;
			y++;
		}

		System.out.println(y);
	}
}

Measured memory_bytes: 35720
S = input()


def kaibun(s):
    for i in range(len(s) // 2):
        if s[i] != s[len(s) - 1 - i]:
            return False
    return True


N = len(S)

if not kaibun(S):
    print('No')
    exit()
    
if not kaibun(S[:(N-1)//2]):
    print('No')
    exit()

if not kaibun(S[(N+3)//2 - 1:]):
    print('No')
    exit()

print('Yes')


Measured memory_bytes: 3060
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
    int x, n; cin >> x >> n;
    vector<bool> p(105);

    if (n > 0) {
        rep (i, 0, n-1) {
            int val; cin >> val;
            p[val] = true;
        }
    }

    int tempx = x;
    while (p[x]) {
        x--;
    }
    int a = x;
    int y = tempx;
    while (p[y]) {
        y++;
    }
    int b = y;

    if (abs(a -tempx) <= abs(b - tempx)) {
        cout << a;
    } else {
        cout << b;
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

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

using namespace std;

int main(void){

    int n, k;

    cin >> n;
    vector<vector<bool> > A(n, vector<bool>(n, false));
    for(int i = 0; i < n; i++){
        cin >> k >> k;
        for(int j = 0; j < k; j++){
            int input;
            cin >> input;
            A[i][input-1] = true;
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(j != n-1) cout << A[i][j] << " ";
            else cout << A[i][j];
        }
        cout << endl;
    }

    return 0;
}

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

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

  int n;
  cin >> n;
  double denom;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    denom += 1.0 / a;
  }
  cout << setprecision(6) << 1 / denom << '\n';
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> A[i];
    }

    int64_t min_value = 1;
    int64_t ans = 0;
    for (int64_t i = 0; i < N; i++) {
        //min_value未満の価格提示は前のものに吸われるのでダメ
        //A[i]から1以上残るように引く。逆に最後に残るのはできるだけ小さいほうが良い
        //基本的にmin_valueの提示を繰り返していき、最後の1回だけ1になるようなちょっと大きめの提示をする
        //何回できるか
        int64_t time = (A[i] - 1) / min_value;
        ans += time;
        min_value = max(min_value, (time == 0 ? A[i] + 1 : 2));
    }

    cout << ans << endl;
}

Measured memory_bytes: 1152
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    k = i_input()
    s = s_input()

    len_s = len(s)

    if len_s <= k:
        print(s)
        exit()

    for i in range(k):
        print(s[i],end='')

    print('...')    

if __name__ == '__main__':
    main()


Measured memory_bytes: 68356
S = input()
S = S[::-1]
N = len(S)

mod = 10**9 + 7

dp = [[1] + [0]*12] + [[0]*13 for i in range(N)]

digit = 1
for i, s in enumerate(S):
  if s == '?':
    R = [j*digit % 13 for j in range(10)]
    for j in range(13):
      for r in R:
        dp[i+1][(j+r)%13] = (dp[i+1][(j+r)%13] + dp[i][j]) % mod
      
  else:
    s = int(s)
    r = s*digit % 13
    dp[i+1] = dp[i][-r:] + dp[i][:-r]
  
  digit *= 10
  digit %= 13

print(dp[-1][5])

Measured memory_bytes: 81756
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int h[N];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  for (int i = 0; i < 1000; i++) {
    int cnt = 0;
    for (int j = 1; j < N; j++) {
      if (h[j] == 0 && h[j-1] != 0) {
        cnt++;
      }
    }
    if (h[N-1] != 0) {
      cnt++;
    }
    ans += cnt;
    for (int j = 0; j < N; j++) {
      h[j] = max(h[j] - 1,0);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int r;
    cin >> r;
    print(3*r*r);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int l[10], v1, v2;
  char c;
  while (cin >> l[0]) {
    int sum = l[0];
    for (int i = 1; i < 10; i++) {
      cin >> c >> l[i];
      sum += l[i];
    }
    cin >> c >> v1 >> c >> v2;
    double t = 1. * sum / (v1 + v2), a = t * v1, last = 0;
    for (int i = 0; i < 10; i++) {
      if (last < a && a <= last + l[i]) {
        cout << i + 1 << endl;
        break;
      }
      last += l[i];
    }
  }

  return 0;
}


Measured memory_bytes: 3152
#include<stdio.h>
int main(void)
{
    int n,m;
    int i,j;
    char data[10000][2]={{0}};
    unsigned char ans[1000000];

    for(;;){
    scanf("%d",&n);
    if(n == 0)break;

    for(i = 0;i < n; i++){
        scanf(" %c %c",&data[i][0],&data[i][1]);
    }
    scanf("%d",&m);
    for(i = 0;i < m; i++){
        scanf(" %c",&ans[i]);
        for(j = 0;j < n; j++){
            if(ans[i] == data[j][0]){
                ans[i] = data[j][1];
                break;
            }
        }
    }
    printf("%s\n",ans);

    }
    return 0;
}

Measured memory_bytes: 712
#include <iostream>

using namespace std;

int ans[100000];

int main(){
    string S;
    cin >> S;
    int cnt = 1;
    int prev;
    for(int i = 1; i < S.size(); i++){
        if(S[i] == S[i-1]) cnt++;
        else{
            if(S[i] == 'L'){
                ans[i-1] = cnt;
                prev = i;
            }else{
                ans[prev] = cnt;
                //cout << ans[prev-1] << ' ' <<  ans[prev] << endl;
                if(ans[prev] == ans[prev-1]){

                }else if(ans[prev] < ans[prev-1]){
                    int sum = ans[prev]+ans[prev-1];
                    if(sum%2 != 0){
                        if(ans[prev] %2 == 0){
                            ans[prev] = sum/2;
                            ans[prev-1] = sum/2+1;
                        }else{
                            ans[prev] = sum/2+1;
                            ans[prev-1] = sum/2;
                        }
                    }else{
                        ans[prev] = sum/2;
                        ans[prev-1] = sum/2;
                    }
                }else{
                    int sum = ans[prev]+ans[prev-1];
                    if(sum%2 != 0){
                        if(ans[prev-1] %2 == 0){
                            ans[prev-1] = sum/2;
                            ans[prev] = sum/2+1;
                        }else{
                            ans[prev-1] = sum/2+1;
                            ans[prev] = sum/2;
                        }
                    }else{
                        ans[prev] = sum/2;
                        ans[prev-1] = sum/2;
                    }
                }
            }
            cnt = 1;
        }
        if(i == S.size()-1){
            ans[prev] = cnt;
            
            if(ans[prev] == ans[prev-1]){

            }else if(ans[prev] < ans[prev-1]){
                int sum = ans[prev]+ans[prev-1];
                if(sum%2 != 0){
                    if(ans[prev] %2 == 0){
                        ans[prev] = sum/2;
                        ans[prev-1] = sum/2+1;
                    }else{
                        ans[prev] = sum/2+1;
                        ans[prev-1] = sum/2;
                    }
                }else{
                    ans[prev] = sum/2;
                    ans[prev-1] = sum/2;
                }
            }else{
                int sum = ans[prev]+ans[prev-1];
                if(sum%2 != 0){
                    if(ans[prev-1] %2 == 0){
                        ans[prev-1] = sum/2;
                        ans[prev] = sum/2+1;
                    }else{
                        ans[prev-1] = sum/2+1;
                        ans[prev] = sum/2;
                    }
                }else{
                    ans[prev] = sum/2;
                    ans[prev-1] = sum/2;
                }
            }
        }
    }
    for(int i = 0; i < S.size()-1; i++){
        cout << ans[i] << ' ';
    }
    cout << ans[S.size()-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

int n;string t;
ll solve(char r, char g, char b){
    vi v(n,0);
    repD(i,n-1,0)if(t[i]==b) v[i]++;
    repD(i,n-2,0)v[i]+=v[i+1];
    repD(i,n-1,0)if(t[i]!=g) v[i]=0;
    repD(i,n-2,0)v[i]+=v[i+1];
    ll s=0;
    repD(i,n-1,0)if(t[i]==r) s+=v[i];
    return s;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    cin>>n>>t;
    ll s=0;
    s+=solve('R','G','B');
    s+=solve('R','B','G');
    s+=solve('G','R','B');
    s+=solve('G','B','R');
    s+=solve('B','R','G');
    s+=solve('B','G','R');
    rep(i,n)for(int j=2;j<n;j+=2)if(i+j<n)
        if(t[i]!=t[i+j] && t[i]!=t[i+j/2] && t[i+j]!=t[i+j/2])
            s--;
    cout<<s;

	return 0;
}
 



Measured memory_bytes: 3664
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

struct UnionFind
{
  int n;
  std::vector<int> par,size;
  UnionFind(int sz) : n(sz), par(sz,0), size(sz,1) {
    std::iota(par.begin(),par.end(),0);
  }
  int find(int x) {
    if(par[x]==x) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x=find(x);y=find(y);
    if(x==y) return;
    if(size[x]<size[y]) std::swap(x,y);
    size[x]+=size[y];
    par[y]=x;
  }
};

struct Edge
{
	int a,b,c;
	Edge(int a,int b, int c) : a(a), b(b), c(c) {}
};

std::vector<Edge> kruskal(int n,std::vector<Edge>&edges) {
	std::sort(edges.begin(), edges.end(), [] (Edge a, Edge b) { return a.c < b.c; } );
	UnionFind uf(n);
	std::vector<Edge> min_tree;
	for(Edge e:edges) {
		if(uf.find(e.a)==uf.find(e.b)) continue;
		min_tree.push_back(e);
		uf.unite(e.a,e.b);
	}
	return min_tree;
}

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<Edge> edges;
	rep(i,m) {
		int a,b,c;
		std::cin >> a >> b >> c;
		edges.emplace_back(a,b,c);
	}
	std::vector<Edge> min_tree = kruskal(n,edges);
	int sum = 0;
	for(Edge e:min_tree) {
		sum+=e.c;
	}
	print(sum);
	return 0;
}



Measured memory_bytes: 5964
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )



x,y=map(int,input().split())
if (x+y)%3!=0:
  print(0)
else:
  a=int((2*x-y)/3)
  b=int((2*y-x)/3)
  if a>=0 and b>=0:
    print(cmb(a+b,b,mod))
  else:
    print(0)


Measured memory_bytes: 122128
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vint = vector<int>;

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

	int a, b, c, d;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cout << min(a, b) + min(c, d) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

ll N;

ll dfs(ll arg){
  if(arg>N){return 0;}
  ll cnt0=0,cnt1=0,cnt2=0,tmp_arg=arg;
  while(tmp_arg){
    if(tmp_arg%10==7)cnt0++;
    if(tmp_arg%10==5)cnt1++;
    if(tmp_arg%10==3)cnt2++;
    tmp_arg/=10;
  }
  ll ret=(min({cnt0,cnt1,cnt2})?1:0);
  ret+=dfs(arg*10+7);
  ret+=dfs(arg*10+5);
  ret+=dfs(arg*10+3);

  return ret;
}

int main(){
  cin>>N;
  print(dfs(0))

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define MOD 1000000007
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

int main()
{	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0; i<n; i++)
		cin>>a[i];
	ll count=0;
	for(ll i=1; i<n-1; i++)
	{
		if( (a[i-1]< a[i] && a[i]<a[i+1]) || (a[i-1]> a[i] && a[i]>a[i+1]) )
			count++;

	}
	cout<<count;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;

#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
const ll mn=1e5+4;
ll dp[mn];
const ll MAXLOG=18;
#define LOG2(X) ((unsigned) (8*sizeof (unsigned long long) - __builtin_clzll((X)) - 1))
ll table[MAXLOG][mn];
void preprocess_rmq(ll *array, ll n) {
	for(ll i=0;i<n;i++)            
   table[ 0 ][ i ]=array[ i ];         //building base
  for(ll j=1;j<=LOG2(n);j++)
   for(ll i=0;i+(1LL<<(j-1))<n;i++) {
     table[ j ][ i ] = max ( table[ j-1 ][ i ], table[ j-1 ][ i+(1LL<<(j-1)) ] );  //use previously computed
     //printf("j:%lld i:%lld t:%lld i+(1LL<<(j-1)):%lld\n",j,i,table[j][i],i+(1LL<<(j-1)));
   }
}
ll query_rmq(ll x, ll y) {
  ll len=y-x+1;
  ll k=LOG2(len);
  //printf("Query. k:%lld x:%lld y:%lld y+1-(1LL<<k):%lld\n",k,x,y,y+1-(1LL<<k));
  return max(table[ k ][ x ],table[ k ][ y+1-(1LL<<k) ]);   // ranges may overlap
}
ll a[mn];
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,m,klim; scanf("%lld%lld%lld",&n,&m,&klim);
	for (ll i=1;i<=n;i++) scanf("%lld",a+i);
	//	for (ll j=1;j<=n;j++) printf("%lld ",a[j]);
	//		printf("end a\n");
	ll jlim;
	{
		ll j=0;
		while((1<<j)<m) j++;
		jlim=j-1;
	}
	memset(dp,0,sizeof dp);
	preprocess_rmq(dp,n+1);
	ll cur=1,prev=0;
	ll final=0;
	for (ll k=1;k<=klim;k++) {
		fill(dp,dp+n+1,-INF);
		for (ll x=1;x<=n;x++) {
			ll best=query_rmq(max(0ll,x-m),x-1);
			//printf("%lld %lld: %lld\n",max(0ll,x-m),x-1,best);
			if (best==-INF) continue;
			chkmax(dp[x],best+k*a[x]);
			chkmax(final,dp[x]);
		}
		//for (ll x=0;x<=n;x++) printf("%lld ",dp[x]);
		//printf("\n");
		preprocess_rmq(dp,n+1);
		swap(cur,prev);
	}
	printf("%lld\n",final);
}



Measured memory_bytes: 14592
n,x,y = map(int,input().split())
D = [0]*(n-1)
x -= 1
y -= 1
for i in range(n-1):
    for j in range(i+1,n):
        D[min(j-i-1,abs(x-i)+abs(y-j))] += 1
for d in D:
  print(d)


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

int dp[1 << 18][18] , N , A[18] , B[18];

int main(){
	cin >> N; for(int i = 0 ; i < N ; ++i) cin >> A[i];
	for(int i = 0 ; i < N ; ++i) cin >> B[i];
	for(int i = 0 ; i < N ; ++i) if(i & 1) swap(A[i] , B[i]);
	memset(dp , 0x3f , sizeof(dp));
	for(int i = 0 ; i < N ; ++i) dp[1 << i][i] = i;
	for(int i = 1 ; i + 1 < 1 << N ; ++i)
		for(int j = 0 ; j < N ; ++j)
			if(dp[i][j] <= 1e4){
				int cnt = __builtin_popcount(i) , num = 0;
				for(int k = 0 ; k < N ; ++k)
					if(!(i >> k & 1)){
						if((cnt & 1) && A[j] > B[k] || !(cnt & 1) && B[j] > A[k]) continue;
						dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k] , dp[i][j] + k - num);
					}else ++num;
			}
	int mn = 1e9; for(int i = 0 ; i < N ; ++i) mn = min(mn , dp[(1 << N) - 1][i]);
	printf("%d\n" , mn > 1e4 ? -1 : mn);
}

Measured memory_bytes: 18688
/*
                                                  __          __
      /\   |   |     /\   |  | |  |     /\   | / |  )   /\   |  )
     /__\  |   |    /__\  |--| |  |    /__\  |<  |-<   /__\  |-<
    /    \ |__ |__ /    \ |  | \__/   /    \ | \ |__) /    \ |  \

*/

#import<bits/stdc++.h>
typedef long long ll;
#define num 1e9
#define root 10000
#define forll(i,a,b,c) for(int i=a; i<=b; i+=c)
#define forll2(i,a,b,c) for(int i=a; i>=b; i-=c)
#define pb(n) push_back(n)
#define i(n) insert(n)

using namespace std;

int main()
{
    int n,m,t;
    cin>>n>>m>>t;
    int a;
    if(n%m==0){a=n/m;}
    else{a=(n/m)+1;}
    cout<<a*t<<"\n";
}


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

using namespace std;

int findSumOfDigits(int n){

    int sum = 0;
    while (n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(){

    int N, A, B;
    cin >> N >> A >> B;

    int total = 0;
    for (int i = 1; i <= N; ++i){
        int sum = findSumOfDigits(i);
        if(sum >= A && sum <= B){
            total += i;
        }
    }
    
    cout << total << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    ll X;
    cin >> X;
    ll ans = 0;
    ans += (X / 500) * 1000;
    X %= 500;
    ans += (X / 5) * 5;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <limits>
#include <type_traits>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

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

	double rate =
		380000.0;


	double ans = 0;
	for (size_t i = 0; i < n; i++)
	{
		double x;
		string typ;
		cin >> x >> typ;

		if (typ == "JPY")
		{
			ans += x;
		}
		else
		{
			ans += x * rate;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    while (true) {
        int x, y;
        cin >> x >> y;
        
        if (x == 0 && y == 0) break;
        
        if (x > y) {
            cout << y << ' ' << x << endl;    
        } else {
            cout << x << ' ' << y << endl;    
        }
    }
}

Measured memory_bytes: 3052
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	int N,W;
	while(cin >> N >> W && N){
		int v[1000]={};
		int maximum = 0;
		for(int i = 0 ; i < N ; i++){
			int t;
			cin >> t;
			v[i] = t;
			maximum = max(t,maximum);
		}
		int wid = maximum / W + 1;
		double ans = 0;
		double dec = 1.0 / (wid-1);
		int cnt[1000]={};
		for(int i = 0 ; i < N ; i++){
				cnt[v[i]/W]++;
		}
		int maxv = 0;
		for(int i = 0 ; i < 1000 ; i++){
			maxv = max(maxv,cnt[i]);
		}
		for(int i = 0 ; i < N ; i++){
			int pos = v[i] / W;
			ans += 1.0 / maxv * (1-pos*dec);
		}
		printf("%.8lf\n",ans+0.01);	
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

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

	int count = -1;
	int ret = 0;
	for (int i = 0; i < argN; ++i) {
		int target = i + 1;
		int tempRet = 0;
		
		while (target % 2 == 0) {
			target /= 2;
			tempRet++;
		}

		if (tempRet > count) {
			ret = i + 1;
			count = tempRet;
		}
	}

	cout << ret;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll q;cin>>q;
  for(ll i=0;i<q;i++){
    ll x,y;
    cin>>x>>y;
    if(x>y)swap(x,y);
    ll ans=x-1;
    long double k=sqrt(x*y-0.75)-x+0.5;
    ll lk=k;
    ans+=k+(x*y-1)/(x+k);
    if(x==y)cout<<ans<<endl;
    else cout<<ans-1<<endl;
  }
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int




int main()
{
   int N;

   scanf("%d",&N);
  int idx = 0;
  int array[N];
  int max = 0;
  for (int i = 0;i<N;i++)
  {
    scanf("%d",&array[i]);
    if (max<array[i])
       {
        max=array[i];
        idx = i;
       }
  }
  int sum = 0;

   for (int i =0;i<N;i++)
   {
       if (i==idx)
       sum+=array[i]/2;

       else if (i!=idx)
        sum+=array[i];
   }


   printf("%d",sum);

    return 0;
}


Measured memory_bytes: 128
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int n, a, b;

void input() {
  cin >> n;
  if (n==1) {
    cout << "Hello World" << endl;
    return;
  }
  
  cin >> a >> b;
  cout << a+b << endl;
}

int main() {
  // cout.precision(15);
  input();
  return 0;
}


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

int main() {
	int S;
	int h, m, s;
	cin >> S;
	h = S/3600;
	m = S%3600/60;
	s = S%3600%60;
	cout << h << ":" << m << ":" << s << "\n";
	
	return 0;
}

Measured memory_bytes: 3100
#include<stdio.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline long IN(void)
{
  long x=0;int f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
static inline void Radix(int A[],const int N)
{
  int temp[200001];
  rep(k,4)
  {
    int u[256]={},v[256]={};
    rep(i,N)u[A[i]>>8*k&255]++;
    rep(i,255)u[i+1]+=u[i];
    rep(i,N){temp[--u[A[N-1-i]>>8*k&255]]=A[N-1-i];}k++;
    rep(i,N)v[temp[i]>>8*k&255]++;
    rep(i,255)v[i+1]+=v[i];
    rep(i,N)A[--v[temp[N-1-i]>>8*k&255]]=temp[N-1-i];
  }
}
int main(void)
{
  int N=IN(),x,p=0,m=0,z=0,minus=0,A[200000],B[200000];
  long K=IN(),count=0,l=-2e18,r=-l,mid;
  while(N--){x=IN();if(x>0)A[p++]=x;else if(x<0)B[m++]=-x;else z++;}
  Radix(A,p),Radix(B,m);
  if(K>1l*m*p&&K<1l*m*p+1l*z*(N-1)/2)return puts("0"),0;
  if(K<=1l*m*p)r=1l;else l=-1l;
  while(l<=r)
  {
    mid=(l+r)/2;count=0;
    if(mid>=0)
    {
      int plus=p-1,minus=m-1;count+=1l*z*(p+m)+1l*z*(z-1)/2+1l*p*m;
      rep(i,plus){while(1l*A[i]*A[plus]>mid){plus--;}if(i>=plus){break;}count+=1l*plus-i;}
      rep(i,minus){while(1l*B[i]*B[minus]>mid){minus--;}if(i>=minus){break;}count+=1l*minus-i;}
    }
    else{mid*=-1l;minus=1;int low=0;rep(i,m){while(1l*A[low]*B[m-1-i]<mid&&low<p){low++;}count+=1l*p-low;}}
    if(count>=K){if(minus)r=-mid-1l;else r=mid-1l;}else{if(minus)l=-mid+1l;else l=mid+1l;}
  }
  return OUT(l),0;
}

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

#define ll long long int
#define pd push_back
#define mp make_pair
#define mod 1000000007

ll power(ll a,ll b){ll ans=1;while(b>0){if(b&1){ans = (ans*a);}b>>=1;a=a*a;}return ans;}
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}

int main() {
   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   // cout << fixed << setprecision(10);
   string s;
  cin>>s;
  if(s=="ARC"){
     cout<<"ABC"<<endl;
     }
     if(s=="ABC"){
     	cout<<"ARC"<<endl;
     }
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    string s;
    cin >> s;
    string ans_s = "hi";
    bool ans = true;
    rep(i, s.size()) {
        if (i%2==0 && s[i] != 'h') ans = false;
        if (i%2==1 && s[i] != 'i') ans = false;
    }
    if (s.size() %2 == 1) ans = false;
    if (ans == true) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int n,k,q,a[N],b[N];
int solve(int x)
{
    vector<int>v;
    vector<int>res;
    for(int i=1;i<=n;i++)
        if(a[i]>=x) v.push_back(a[i]);
    else
    {
        sort(v.begin(),v.end());
        for(int i=0;i+k<=v.size();i++)
            res.push_back(v[i]);
        v.clear();
    }
    sort(v.begin(),v.end());
    for(int i=0;i+k<=v.size();i++)
        res.push_back(v[i]);
    v.clear();
    sort(res.begin(),res.end());
    if(res.size()<q) return 1e9;
    return res[q-1]-res[0];
}
int main()
{
    scanf("%d%d%d",&n,&k,&q);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),b[i]=a[i];
    sort(b+1,b+1+n);
    int tot=unique(b+1,b+1+n)-b-1;
    int ans=1e9;
    for(int i=1;i<=tot;i++)
        ans=min(ans,solve(b[i]));
    printf("%d\n",ans);
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N, H;
    cin >> N >> H;
    priority_queue<int> Q;
    int max_A = 0;
    rep(i, N) {
        int A, B;
        cin >> A >> B;
        max_A = max(A, max_A);
        Q.push(B);
    }
    
    int ans = 0;
    while (H > 0) {
        if (Q.size() && max_A < Q.top()) {
            H -= Q.top();
            Q.pop();
            ans++;
        } else {
            break;
        }
    }

    if (H > 0) ans += (H + max_A - 1) / max_A;
    cout << ans << endl;
}

Measured memory_bytes: 892
n = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(n-2):
  l = P[i:i+3]
  if (l[0] < l[1] < l[2]) or (l[2] < l[1] < l[0]):
    ans +=1
print(ans)

Measured memory_bytes: 3060
integer(16) N,C
integer(16),allocatable::x(:),v(:),ccx(:),ccv(:),OA2(:),OB2(:)
integer(16) i
integer(16) ans
read*,N,C
allocate(x(N),v(0:N),ccx(N),ccv(0:N))
v(0)=0
do i=1,N
  read*,x(i),v(i)
  v(i)=v(i)+v(i-1)
end do
ccv(0)=0
do i=1,N
  ccx(i)=C-x(N-i+1)
  ccv(i)=V(N)-V(N-i+1-1)
end do

allocate(OA2(0:N),OB2(0:N))
OA2(0)=0
do i=1,N
  OA2(i)=max(OA2(i-1),v(i)-x(i)*2)
end do

OB2(0)=0
do i=1,N
  OB2(i)=max(OB2(i-1),ccv(i)-ccx(i)*2)
end do

ans=0
do i=1,N
  ans=max(ans,ccv(i)-ccx(i)+OA2(N-i))
end do
do i=1,N
  ans=max(ans,v(i)-x(i)+OB2(N-i))
end do

print"(i0)",ans
end

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

int main(){
  string s;
  cin>>s;
  ll n=s.size();
  vector<ll> d(26);
  rep(i,n){
    d[s[i]-'a']++;
  }
  ll res=0;
  rep(i,26) res+=d[i]*(d[i]-1)/2;
  ll ans=n*(n-1)/2+1-res;
  cout<<ans<<endl;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
 
int32_t main()
{
	fast;
	string s1, s2;
	cin>>s1>>s2;
	// string s3=s1;
	// string s4=s2;
	vector<set<int>> v(26);
	for(int i=0;i<s1.size();i++)
	{
		v[s1[i]-97].insert(i);
	}
	int ind=-1;
	int f=0;
	int c=0;
	for(int i=0;i<s2.size();i++)
	{
		int ch=s2[i]-97;
		if(v[ch].size()==0)
		{
			f=1;
			break;
		}
		auto it=v[ch].upper_bound(ind);
		if(it==v[ch].end())
		{
			c++;
			ind=*(v[ch].begin());
		}
		else
			ind=*it;
	}
	if(f)
	{
		cout<<-1<<endl;
		return 0;
	}
	cout<<(c*(int)s1.size()+ind+1)<<endl;
	return 0;
}

Measured memory_bytes: 5200
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <utility>
#include <unordered_map>

using namespace std;

typedef pair<int64_t, int64_t> P;

int main() {
  int64_t n, k;
  cin >> n >> k;
  vector<P> sushis(n);
  int64_t t, d;
  for (int64_t i = 0; i < n; i++) {
    cin >> t >> d;
    sushis[i] = make_pair(t, d);
  }
  sort(sushis.begin(), sushis.end(), [](P &a, P &b) {
                                        return a.second > b.second;
                                      });
  unordered_map<int64_t, int64_t> mp;
  for (int64_t i = 0; i < 200000; i++) {
    mp[i] = 0;
  }
  auto greater = [](P &a, P &b) { return a.second < b.second; };
  auto smaller = [](P &a, P &b) { return a.second > b.second; };
  priority_queue<P, vector<P>, decltype(greater)> candidates(greater);
  priority_queue<P, vector<P>, decltype(smaller)> currents(smaller);
  int64_t numkinds = 0;
  int64_t f = 0;
  for (int64_t i = 0; i < k; i++) {
    if (mp[sushis[i].first] == 0) numkinds++;
    mp[sushis[i].first]++;
    f += sushis[i].second;
  }
  for (int64_t i = 0; i < k; i++) {
    if (mp[sushis[i].first] > 1) {
      currents.push(sushis[i]);
    }
  }
  for (int i = k; i < n; i++) {
    if (mp[sushis[i].first] == 0)
      candidates.push(sushis[i]);
  }
  int64_t maxscore = f + numkinds*numkinds;
  while (true) {
    if (candidates.size() == 0 || currents.size() == 0) {
      break;
    }
    P candidate = candidates.top(); candidates.pop();
    if (mp[candidate.first] != 0) continue;
    P current = currents.top(); currents.pop();
    mp[candidate.first]++;
    mp[current.first]--;
    f += candidate.second - current.second;
    numkinds++;
    maxscore = max(maxscore, f + numkinds*numkinds);
  }
  cout << maxscore << endl;
  return 0;
}


Measured memory_bytes: 13128
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String buf;

		try {
			while ((buf = br.readLine())!=null) {
				StringTokenizer st = new StringTokenizer(buf);
				int a = Integer.parseInt(st.nextToken());
				int b = Integer.parseInt(st.nextToken());
				String s = Integer.toString(a+b);
				System.out.println(s.length());
			}
		} catch (Exception e) {
			System.out.println("Exception!");
		}
	}
}

Measured memory_bytes: 16896
import sys
sample = sys.stdin.read().splitlines()
N = int(sample[0])
points = [list(map(int, sample[current_day].split())) for current_day in range(1, N+1)]
dp = points[0]
ans = max(dp)
for point in points[1:]:
	for idx, num in enumerate(point):
		point[idx] = point[idx]+max(dp[(idx+1)%len(point)], dp[(idx+2)%len(point)])
	dp = point
	ans = max(ans, max(point))
print(ans)	


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

int main(){
  int n,x;
  cin >> n >> x;
  int m[n];
  int kosu=0;
  int min=1001;
  for(int i=0;i<n;i++){
    cin >> m[i];
    x-=m[i];
    kosu++;
    if(min>m[i]){
      min=m[i];
    }
  }
  while(1){
    x-=min;
    if(x>=0){
      kosu++;
    }else{
      break;
    }
  }
  cout << kosu << endl;
  return 0;
}

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

int main() {
  int X;
  cin >> X;
  bool flag;
  while (true) {
    if (X % 105 == 0) {
      flag = true;
      break;
    }
    if (X % 104 == 0) {
      flag = true;
      break;
    }
    if (X % 103 == 0) {
      flag = true;
      break;
    }
    if (X % 102 == 0) {
      flag = true;
      break;
    }
    if (X % 101 == 0) {
      flag = true;
      break;
    }
    if (X % 100 == 0) {
      flag = true;
      break;
    }
    if (X % 5 == 0) {
      X -= 105;
    } else if (X % 5 == 4) {
      X -= 104;
    } else if (X % 5 == 3) {
      X -= 103;
    } else if (X % 5 == 2) {
      X -= 102;
    } else if (X % 5 == 1) {
      X -= 101;
    } else if (X % 5 == 0) {
      X -= 100;
    }
    if (X < 0) {
      flag = false;
      break;
    } else if (X == 0) {
      flag = true;
      break;
    }
  }
  if (flag) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cstdio>
#include <cstdint>
#include <cstring>

int main(int argc, char* argv[])
{
  int N=5e5+1;
  char s[N+2];
  int l[N+2];

  int i;

  i = scanf("%s",s);
  int g = 0;
  l[g]=1;
  for (i=1;s[i];i++) {
    if (s[i-1] == s[i]) {
      l[g]++;
    } else {
      g++;
      l[g]=1;
    }
  }

  long long sum = 0;
  i = 0;
  if (s[i] == '>') {
    sum += ((long long)l[i]*(l[i]+1))/2;
    i++;
  }
  for (;i<g;i+=2) {
    int w1 = l[i  ];
    int w2 = l[i+1];
    if (w1 < w2) {
      w1--;
    } else {
      w2--;
    }
    sum += ((long long)w1*(w1+1))/2;
    sum += ((long long)w2*(w2+1))/2;
  }
  if (i==g) {
    sum += ((long long)l[i]*(l[i]+1))/2;
  }
  printf("%llu\n", sum);
  return 0;
}

Measured memory_bytes: 2176
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

using namespace std;

struct Node;
struct Color {
  int n;
};

using NodePtr = shared_ptr<Node>;
using ColorPtr = shared_ptr<Color>;

struct Node {
  int id;
  ColorPtr color = nullptr;
  vector<NodePtr> followings;
  vector<NodePtr> blockings;

  int get_n_candidates () {
    int n_followings = 0;
    for (auto x : followings) {
      if (color == x->color) n_followings++;
    }

    int n_blockings = 0;
    for (auto x : blockings) {
      if (color == x->color) n_blockings++;
    }

    return color->n - n_followings - n_blockings - 1;
  }
};

void dfs (NodePtr node0, ColorPtr color) {
  stack<NodePtr> S;
  S.push(node0);

  while (!S.empty()) {
    NodePtr node = S.top(); S.pop();

    if (!node->color) {
      node->color = color;
      color->n++;
    }

    for (auto x : node->followings) {
      if (!x->color) S.push(x);
    }
  }
}

void assign_color (vector<NodePtr> nodes) {
  for (auto node : nodes) {
    if (node->color) continue;

    ColorPtr color = make_shared<Color>();
    dfs(node, color);
  }
}

/**
 * main
 */
int main () {
  int N, M, K;
  cin >> N >> M >> K;

  vector<NodePtr> nodes(N);

  for (size_t i = 0; i < N; i++) {
    nodes[i] = make_shared<Node>();
    nodes[i]->id = i;
  }

  for (size_t i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;

    nodes[A-1]->followings.push_back(nodes[B-1]);
    nodes[B-1]->followings.push_back(nodes[A-1]);
  }

  for (size_t i = 0; i < K; i++) {
    int A, B;
    cin >> A >> B;

    nodes[A-1]->blockings.push_back(nodes[B-1]);
    nodes[B-1]->blockings.push_back(nodes[A-1]);
  }

  assign_color(nodes);

  for (size_t i = 0; i < N; i++) {
    printf("%d%c", nodes[i]->get_n_candidates(), (i == N - 1) ? '\n' : ' ');
  }
}


Measured memory_bytes: 26232
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<climits>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)

struct BIT{
    int N;
    vi dat;
    void init(int _N){
        N=_N;
        dat=vi(N+1,0);
    }
    void add(int k,int val){
        k++;
        while(k<=N){
            dat[k]+=val;
            k+=k&-k;
        }
    }
    int getSum(int k){
        k++;
        int ret=0;
        while(k){
            ret+=dat[k];
            k-=k&-k;
        }
        return ret;
    }
};

int main(){
    int N,Q;
    scanf("%d%d",&N,&Q);
    BIT bit;
    bit.init(N);
    while(Q--){
        int t,x,y;
        scanf("%d%d%d",&t,&x,&y);
        if(t){
            printf("%d\n",bit.getSum(y-1)-bit.getSum(x-2));
        }
        else{
            bit.add(x-1,y);
        }
    }

    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		int n=getInt();
		char[]in=s.next().toCharArray();
		int l=0;
		for(int i=0;i<n;++i) {
			if(in[i]==')'&&l>0)
				--l;
			if(in[i]=='(')
				++l;
		}
		int r=0;
		for(int i=n-1;i>=0;--i) {
			if(in[i]=='('&&r>0)
				--r;
			if(in[i]==')')
				++r;
		}

		String res="";
		for(int i=0;i<r;++i)
			res+='(';
		res+=String.valueOf(in);
		for(int i=0;i<l;++i)
			res+=')';
		System.out.println(res);
	}
}

Measured memory_bytes: 23892
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL N;
    VL x(5);
    cin>>N>>x[0]>>x[1]>>x[2]>>x[3]>>x[4];
    LL min_x = *min_element(ALL(x));
    LL t = N / min_x + (N % min_x == 0 ? 0 : 1);
    PUTS(t + 4);
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if ((a + b) % 2 == 1) { //a+bが奇数
    cout << (a + b) / 2 + 1 << endl;
  }
  else {
    cout << (a + b) / 2 << endl;
  }    
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



def main():
    N, M = map(int, readline().split())
    d = map(int, read().split())
    AB = list(zip(d, d))
    AB = sorted(AB)

    have = 0
    price = 0
    for x, y in AB:
        if M - have < y:
            price += x * (M - have)
            break

        else:
            price += x * y
            have += y


    print(price)

main()

Measured memory_bytes: 27496
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int  maxn=2e5+10;
int par[maxn];
int rank1[maxn];
int siz[maxn];
void f(int n) //初始化
{
    for(int i=1;i<=n;i++)
    {
        par[i]=i;
        rank1[i]=0;
        siz[i] = 1;
    }
}
int find(int x)
{
    if(par[x]==x)
    {
        return x;
    }
    else
    {
        return par[x]=find(par[x]);
    }
}
void unite(int x,int y)
{
    x=find(x);
    y=find(y);
    if(x==y)
        return ;
    if(rank1[x]<rank1[y])
    {
        par[x]=y;
        siz[y]+=siz[x];
        siz[x] = 0;
    }
    else
    {
        par[y]=x;
        siz[x]+=siz[y];
        siz[y] = 0;
    }
    if(rank1[x]==rank1[y])
        rank1[x]++;
}
int main()
{

    int n,p,m,x,y;
    cin>>n>>m;
    f(n);
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        unite(x,y);
    }
    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        ans = max(ans,siz[i]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 5948
#include<bits/stdc++.h>
using namespace std;
int a[11];
int main()
{
	int n,i,s=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	a[n-1]/=2;
	for(i=0;i<n;i++)
		s+=a[i];
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256