akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
const int N=1e6+10;

int main(){
    //freopen("a.txt", "r", stdin);
    //freopen("answers.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(a>=9 or b>=9){
        cout<<":("<<endl;
        return 0;
    }
    cout<<"Yay!"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int ans = 0, pen = 0;
		int[] x = new int[100001];
		for(int i = 0; i < M; i++) {
			int p = sc.nextInt();
			if(sc.next().equals("WA")) {
				if(x[p] >= 0)
					x[p]++;
			}
			else {
				if(x[p] >= 0) {
					ans++;
					pen += x[p];
					x[p] = -1;
				}
			}
		}
		System.out.println(ans + " " + pen);

	}

}

Measured memory_bytes: 63404
import sys
 
def main():
  N = str(input())
  L = [0,1,6,8]
  n_last = int(N[-1])
  if n_last == 3:
    print("bon")
  elif (n_last in L):
    print("pon")
  else:
    print("hon")
 
    
main()

Measured memory_bytes: 9172
#include<stdio.h>
#include<math.h>

int main(void){
  long long n;
  scanf("%lld",&n);

  long long kari = (long long)sqrt(n);
  
  long long ans1 , ans2;

  for(long long i = kari;0 < i;i --){
    if(n%i == 0){
      ans1 = i;
      ans2 = n/i;
      i = -1;
    }
  }

  printf("%lld",ans1 + ans2 - 2);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll a,b,c,d;
    cin>>b>>c>>a;
    if(b>=a)cout<<b-a<<' '<<c<<endl;
    else

    {
        a=a-b;
        c=c-a;
        if(c<=0)c=0;
        cout<<'0'<<' '<<c<<endl;
    }
}


Measured memory_bytes: 256
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main Code
int main() {
    string s;
    cin >> s;
    if (sz(s) == 3) reverse(all(s));
    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 3592
N = int(input())
num = [int(i) for i in input().split()]
 
ans = 0
flag = False
for i in range(40):
    for i in range(len(num)):
        if num[i] % 2 == 0:
            num[i] //= 2
        else:
            flag = True
    if flag == False:
        ans += 1
    else:
        break
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL a[202020];

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N) scanf("%lld", &a[i]);
    
    // 2. a[j] - j を 保存.
    // -> i < j と 仮定して, j - i = a[j] + a[i] とすると, 
    // -(a[i] - i) - 2 * i = (a[j] - j) と 変形できる.
    map<LL, LL> m;
    rep(j, N){
        LL b = a[j] - j;
        m[b]++;
    }
    
    // 3. 条件を満たすペアを検索.
    LL ans = 0;
    rep(i, N){
        LL b = -(a[i] - i) - 2 * i;
        if(m.count(b)) ans += m[b];
    }
    
    // 4. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

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

int main(){
  int N;
  cin >> N;
  vector<long> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
    if(A[i]==0){
      cout << "0" << endl;
      return 0;
    }
  }
  long ans=1;
  for(int i=0; i<N; i++){
    ans *= A[i];
    if(ans>1000000000000000000 || ans<=0){
      cout << "-1" << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4040
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 51;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, m;
vi adj[N];
bitset <51> b[1 << 20];
pi que[21];

void input()
{
	cin >> n;
	FOR (i, 1, n - 1)
	{
		int x, y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	
	cin >> m;
	FOR (i, 0, m - 1) cin >> que[i].fi >> que[i].se;
}

vi path[51];
void dfs (int cur = 1, int prev = 0)
{
    path[cur] = path[prev];
    if (cur != 1) path[cur].pb(cur);
    
	for (int i: adj[cur])
		if (i != prev)
			dfs(i, cur);
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	input();
	dfs();
	
	int p[51] = {1};
	FOR (i, 1, 50) p[i] = p[i - 1]*2;
	
	int ans = p[n - 1];
	b[0] = 0;
	
	FOR (i, 1, (1 << m) - 1)
	{
	    int x = __lg(i);
	    b[i] = b[i ^ (1 << x)];
	    
	    int freq[n + 1] = {};
	    for (int j: path[que[x].fi]) freq[j]++;
	    for (int j: path[que[x].se]) freq[j]++;
	    
	    FOR (j, 1, n)
	        if (freq[j] == 1)
	            b[i][j] = 1;
	    
	    int cnt = n - 1 - b[i].count();
	    if (__builtin_popcount(i) & 1) ans -= p[cnt];
	    else ans += p[cnt];
	}
	
	cout << ans;
}











Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define int   long long int  
#define pb push_back
#define BOOST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debugL(i)  cout<<"line no-> "<<i<<" working"<<endl
#define debugVL(i,l)  cout<<"val at line no."<<i<< " ->"<<l<<endl
const int M=1e9 + 7;
using namespace std;
int N=100000+1;
int32_t main() {
    //int q;cin>>q;
    int n;cin>>n;
    long double sum=0;
    long double prd=1;
    for(int i=0;i<n;i++)
    {
    	long double a;cin>>a;
    	sum+=(1/a);
	}
	long double ans=1/sum;
	cout<<std::setprecision(9)<<ans<<endl;
    return 0;
}













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

H, W = map(int, input().split())
L = [list(input().strip()) for _ in range(H)]

for i in range(H):
    if "#" not in L[i]:
        for j in range(i, H):
            L[i] = [None] * W
            
for i in range(W):
    f = True
    for j in range(H):
        if L[j][i] == "#":
            f = False
            break
    if f:
        for j in range(H):
            L[j][i] = None
            
for i in range(H):
    f = False
    for j in range(W):
        if L[i][j] != None:
            print(L[i][j], end = "")
            f = True
    if f:
        print()

Measured memory_bytes: 4596
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdio>
#include<utility>
#include<algorithm>
#include<map>
#include<set>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
#define all(L) L.begin(),L.end()
using ll=long long;

int N,M;
int X[100],Y[100],h[100];

void gcl(int& x,int& y){
    if(x<y) swap(x,y);
    while(y>0){
        int t=x%y;
        x=y;
        y=t;
    }
    return;
}


int main(){
    string s,t;
    cin>>s>>t;
    ll n=s.size();
    ll m=t.size();
    string ans(n,'z');
  bool ok=false;
    rep(i,0,n-m+1){
        bool flag=true;
        string u(n,'!');
        rep(j,0,m){
            u[i+j]=t[j];
        }
        rep(j,0,n){
            if(s[j]=='?'&&u[j]=='!'){
                u[j]='a';
            }else if(s[j]!='?'){
                if(u[j]=='!') u[j]=s[j];
                else if(u[j]!=s[j]){
                    flag=false;break;
                } 
            }
        }
        if(flag){
            if(ans>u) ans=u;
          ok=true;
        }
    }
    if(ok) cout<<ans<<endl;
  else cout<<"UNRESTORABLE"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define LEN 100005
 
typedef struct pp{
    char name[100];
    int t;
}P;
 
P Q[LEN];
int head,tail,n;
 
void enqueue(P x)
{
    Q[tail]=x;
    tail=(tail+1)%LEN;
 
}
P dequeue()
{
    P x=Q[head];
    head=(head+1)%LEN;
    return x;
}
 
int min(int a,int b){return a<b?a:b;}
 
int main()
{
    int elaps=0,c;
    int i,q;
    P u;
    scanf("%d %d",&n,&q);
 
    for(int i=1;i<=n;i++)
    {
        scanf("%s",&Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head=1;tail=n+1;
    while(head!=tail)
    {
        u=dequeue();
        c=min(q,u.t);
        u.t-=c;
        elaps+=c;
        if(u.t>0)enqueue(u);
        else{
            printf("%s %d\n",u.name,elaps);
        }
    }
    return 0;
}


Measured memory_bytes: 11824
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	n := readInt()
	l := make([]int, n)
	r := make([]int, n)
	sum := 0
	for i := 0; i < n; i++ {
		l[i], r[i] = readInt(), readInt()
		sum += r[i] - l[i] + 1
	}
	fmt.Println(sum)
}


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

using namespace std;

typedef long long  ll;

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

    string s;
    stack<int> st;

    while (cin >> s) {
        int a, b;
        if (s[0] == '+') {
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(b + a);
        }
        else if (s[0] == '-') {
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(b - a);
        }
        else if (s[0] == '*') {
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(b * a);
        }
        else
            st.push(stoi(s));
    }

    cout << st.top() << endl;

    return 0;
}

Measured memory_bytes: 1196
//I Guds namn
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

vector<pair<long long, long long> > Q;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	long long n, k;
	cin >> n >> k;
	for(long long i = 1ll;i <= n;i++)
	{
		long long a, b;
		cin >> a >> b;
		Q.push_back(make_pair(a, b));
	}
	sort(Q.begin(), Q.end());
	long long kk = 0;
	for(auto q : Q)
	{
		kk += q.second;
		if(kk >= k)
		{
			cout << q.first << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n;
int a[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }  
  sort(a, a + n);
  int pos = 0;
  for (int i = 0; i < n; i++) {
    int tmp = min(a[i], a[n - 1] - a[i]);
    if (abs(tmp - a[n - 1] / 2) < abs(a[pos] - a[n - 1] / 2)) pos = i;
  }
  cout << a[n - 1] << " " << a[pos] << endl;

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long s,c;
	scanf("%lld%lld",&s,&c);
	if(s>c/2) printf("%lld\n",c/2);
	else printf("%lld\n",s+(c-s*2)/4);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  char x, y;cin>>x>>y;
  if(x==y)cout<<"="<<endl;
  else if(int(x)>int(y))cout<<">"<<endl;
  else cout<<"<"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

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

// const int C ;
// const ll M = 1000000007;

template <class Type>
Type maxof(const Type x[], int N) {
  Type ans = x[0];
  for (auto i = 1; i < N; i++) {
    if (ans < x[i]) ans = x[i];
  }
  return ans;
}

template <class Type>
Type minof(const Type x[], int N) {
  Type ans = x[0];
  for (auto i = 1; i < N; i++) {
    if (ans > x[i]) ans = x[i];
  }
  return ans;
}

template <class Type>
Type sumof(const Type x[], int N) {
  Type ans = x[0];
  for (auto i = 1; i < N; i++) {
    ans += x[i];
  }
  return ans;
}

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_D ???????????????????????????

int main () {
  int n;
  cin >> n;
  ll *a = new ll[100010];
  for (auto i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << minof(a, n) << " " << maxof(a, n) << " " << sumof(a, n) << endl;
  delete[] a;
  return 0;
}

Measured memory_bytes: 3084
from sys import stdin


def get_result(data):
    N, A = data
    for a_i in A:
        if a_i % 2 == 0 and a_i % 3 != 0 and a_i % 5 != 0:
            return 'DENIED'

    return 'APPROVED'

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


Measured memory_bytes: 2940
#include <cstdio>
#include <cmath>
using namespace std;

bool bunny[100][100];
bool f[100];

int main()
{
	int N, K;
	char line[1024];
	
	scanf("%d %d ", &N, &K);
	
	for (int i = 0; i < K; i++){
		int m;
		scanf("%d", &m);
		for (int j = 0; j < m; j++){
			int n;
			scanf("%d", &n);
			bunny[i][n] = true;
			
//			printf("__%d\n", n);
		}
	}
	
	int R;
	scanf("%d", &R);
	for (int i = 0; i < R; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		
		for (int j = 0; j < K; j++){
			if (bunny[j][a] && bunny[j][b]){
				f[a] = true;
				f[b] = true;
			}
		}
	}
	
	int cnt = 0;
	for (int j = 1; j <= N; j++){
		cnt += f[j];
	}
	printf("%d\n", cnt);
	
	return 0;
}

Measured memory_bytes: 1032
#include <stdio.h>

int main() {
    char s[15];
    char res[15] = {};
    scanf("%s", &s);
    int ct = 0;
    for (int i = 0; s[i] != '\0'; i++) {
        if (s[i] == '0') {
            res[ct] = '0';
            ct++;
        } else if (s[i] == '1') {
            res[ct] = '1';
            ct++;
        } else if (ct != 0) {
            if (s[i] == 'B') {
                res[ct - 1] = '\0';
                ct -= 2;
            }
            ct++;
        }
    }
    res[ct] = '\0';
    printf("%s", res);
}

Measured memory_bytes: 1708
#include <iostream>
#include <vector>
#include <chrono>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <random>
#include <map>
#include <string>

using namespace std;

typedef long long ll;
typedef long double ld;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

int main()
{
    fastInp;

    ll n;
    cin >> n;

    vector<ll> cnt(4);
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == "AC"){
            cnt[0]++;
        }
        if (s == "WA") {
            cnt[1]++;
        }
        if (s == "TLE") {
            cnt[2]++;
        }
        if (s == "RE") {
            cnt[3]++;
        }
    }

    cout << "AC x " << cnt[0] << "\n";
    cout << "WA x " << cnt[1] << "\n";
    cout << "TLE x " << cnt[2] << "\n";
    cout << "RE x " << cnt[3] << "\n";
    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    ll n;
    cin >> n;
    vll a(n);
    ll sum = 0;
    rep(i,0,n) {
        cin >> a[i];
        sum += a[i];
        sum %= mod;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        sum -= a[i];
        if(sum < 0) sum += mod;
        ans = (ans + (a[i] * sum) % mod) % mod;
    }
    cout << ans << endl;
    return 0;
}


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

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

using namespace std;

int main(){
  string s;cin>>s;
  string c="CODEFESTIVAL2016";
  int result=0;
  rep(i, 16)if(s[i]!=c[i])result++;
  cout<<result<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
  int i, n[10];
  for (i = 0; i < 10; i ++) n[i] = 0;
  for (i = 0; scanf("%d", &n[i]) != EOF; i ++) {
    if (!n[i]) {
      i -= 2; printf("%d\n", n[i + 1]); n[i + 1] = 0;
    }
  }
  return 0;
}

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

int main() {
    int N, Alice, Bob;
    Alice = 0;
    Bob = 0;
    cin >> N;

    //カードを大きい順に並べる
    vector <int> Card(N);
    for (int i = 0; i < N; i++) {
        cin >> Card.at(i);
    }
    sort(Card.begin(), Card.end());
    reverse(Card.begin(), Card.end());

    //Nが偶数のパターン
    if (N % 2 == 0) {
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += Card.at(i);
            }
            else
                Bob += Card.at(i);
        }
    }
    //Nが奇数のパターン
    else {
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += Card.at(i);
            }
            else
                Bob += Card.at(i);
        }
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
# Date [ 2020-09-08 00:04:04 ]
# Problem [ b.py ]
# Author Koki_tkg

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

class BinaryIndexedTree:
    def __init__(self, n):
        '''1-index'''
        self.size = n + 1
        self.data = [0] * self.size
        self.element = [0] * self.size
        self.depth = 1 << n.bit_length() - 1
    
    def build(self, array):
        for i, x in enumerate(array):
            self.add(i, x)

    def add(self, i, v):
        self.element[i] += v; i += 1 # 1-index
        while i < self.size:
            self.data[i] += v
            i += i & -i
    
    def sum(self, i):
        ret = 0; i += 1 # 1-index
        while i > 0:
            ret += self.data[i]
            i -= i & -i
        return ret
    
    def query(self, l, r=None):
        '''get sum [l, r)'''
        if r == None: return self.element[l]
        return self.sum(r) - self.sum(l-1)

    def lower_bound(self, v):
        if v <= 0: return 0
        k = self.depth; i = 0
        while k > 0:
            if i+k < self.size and self.data[i+k] < v:
                v -= self.data[i+k]
                i += k
            k >>= 1
        return i + 1
    
    def upper_bound(self, v):
        if v <= 0: return 0
        k = self.depth; i = 0
        while k > 0:
            if i+k < self.size and self.data[i+k] <= v:
                v -= self.data[i+k]
                i += k
            k >>= 1
        return i + 1

def Main():
    n, q = read_ints()
    bit = BinaryIndexedTree(n)
    a = read_int_list()
    bit.build(a)
    for _ in range(q):
        t, l, r = read_ints()
        if t == 0:
            bit.add(l, r)
        else:
            print(bit.query(l, ~-r))    

if __name__ == '__main__':
    Main()


Measured memory_bytes: 136976
#include<stdio.h>
int main()
{
	int a,b,i;
	for(i=1;;i++)
	{
		scanf("%d %d",&a,&b);
		if (a==0&&b==0) break;
		if(a>b)  printf("%d %d\n",b,a);	
        else printf("%d %d\n",a,b);	
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const ll INF = (1LL << 31) - 1;
const double pi=acos(-1);

int main(){
  int a,b;
  cin >> a >> b;
  int ans=0;
  if(13<=a)ans=b;
  else if(6<=a)ans=b/2;
  else ans=0;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X;
  cin>>X;
  int N[100010];
  N[1]=0;
  N[2]=1;
  for (int i=3;i<100010;i++){
    N[i]=1;
  }
  
  for (int i=2;i<100010;i++){
    for(int j=2;j<pow(i,0.5);j++){
      if(i%j==0){
        N[i]=0;
        break;
      }
    }
  }
  
  for (int i=X;i<100010;i++){
    if(N[i]==1){
      cout<<i<<endl;
      return 0;
    }
  }
  
    cout<<"Error"<<endl;
    return 0;  
}





Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define all(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main() {
    int ans = 0;
    int btm_A = 0;
    int top_B = 0;
    int same = 0;
    int N; cin >> N;
    string s[N];
    rep(i,N) cin >> s[i];
    rep(i,N){
      int l = s[i].size();
      rep(j,l-1){
        if (s[i][j]=='A' && s[i][j+1]=='B') ans++;
      }
      if(s[i][0]=='B') top_B++;
      if(s[i][l-1]=='A') btm_A++;
      if(s[i][0]=='B' && s[i][l-1]=='A') same++;
    }
    int tmp;
    // cout << btm_A << top_B << same << endl;
    if(btm_A==top_B && same==btm_A && same>0) tmp = same-1;
    else tmp = min(btm_A, top_B);
    cout << ans+tmp << endl;
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <math.h>

int main(int argc,char* argv[]){
  double xa,ya,xb,yb,xc,yc,xd,yd;
  double rab,rbc,rcd,rda,rac,rbd;
  double sa,sb,sc,sd;
  
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd) != EOF){
    rab = sqrt((xa - xb)*(xa - xb) + (ya - yb)*(ya - yb));
    rbc = sqrt((xb - xc)*(xb - xc) + (yb - yc)*(yb - yc));
    rcd = sqrt((xc - xd)*(xc - xd) + (yc - yd)*(yc - yd));
    rda = sqrt((xd - xa)*(xd - xa) + (yd - ya)*(yd - ya));
    rac = sqrt((xa - xc)*(xa - xc) + (ya - yc)*(ya - yc));
    rbd = sqrt((xb - xd)*(xb - xd) + (yb - yd)*(yb - yd));
    
    sa = acos((rab*rab + rda*rda - rbd*rbd)/(2 * rab * rda));
    sb = acos((rab*rab + rbc*rbc - rac*rac)/(2 * rab * rbc));
    sc = acos((rbc*rbc + rcd*rcd - rbd*rbd)/(2 * rbc * rcd));
    sd = acos((rda*rda + rcd*rcd - rac*rac)/(2 * rda * rcd));
    
    //printf("%lf %lf %lf %lf %lf %lf\n",sa,sb,sc,sd,sa+sb+sc+sd,M_PI*2);
    
    if((sa + sb + sc + sd) > 2*M_PI - 0.00000000001 && (sa + sb + sc + sd) < 2*M_PI + 0.00000000001){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }

  return 0;
  
}

Measured memory_bytes: 0
/*
ACplease
　　 ●
　　/⌒ヽ
　 ｜ 　|/⌒ヽ(ヽ
　 (｀　∥ー⌒) |
　|￣||￣￣￣￣￣|
　|―||―――――|
　|　Ｕ　　　　　|
　|￣￣￣￣￣￣￣|
　|＿＿＿＿＿＿＿|
　　|―――――|
　　|―――――|
ｗｗＷｗｗＷｗＷＷｗ
*/
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#include <cassert>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}

//----------------------------------------------
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);
    srand((unsigned)time(NULL));
    
    int n; cin >> n;
    VI a(n); VIin(a);
    rep(i,n){
        if(a[i] % 2 == 0){
            if(a[i] % 3 != 0 && a[i] % 5 != 0){
                OUT("DENIED");
                return 0;
            }
        }
    }
    OUT("APPROVED");

    return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        var d = int.Parse(Console.ReadLine());
        if(d==25)
        {
            Console.WriteLine("Christmas");
        }
        else if(d==24)
        {
            Console.WriteLine("Christmas Eve");
        }
        else if(d==23)
        {
            Console.WriteLine("Christmas Eve Eve");
        }
        else
        {
            Console.WriteLine("Christmas Eve Eve Eve");
        }
    }   
}

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

//using namespace--------------------------------------------------------------------------------------------------------------
using namespace std;

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1 << 25
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << "\n";
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)

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

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

//global-----------------------------------------------------------------------------------------------------------------------
vector<int> a(10);

//function---------------------------------------------------------------------------------------------------------------------
int main() {
	rep( i, 10 ) {
		scanf( "%d", &a[ i ] );
	}
	sort( a.begin(), a.end() );
	ROF( i, 9, 7 ) {
		printf( "%d\n", a[ i ] );
	}
	return 0;
}

Measured memory_bytes: 1204
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);

    var(string, s);
    set<char> U;

    for (char c : s) {
        U.insert(c);
    }

    print(U.size() == s.size() ? "yes" : "no");

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";

    int N, K;
    int[] A;
    long ans = long.MaxValue;
    void Solve()
    {
        N = cin.Nextint;
        K = cin.Nextint;
        A = cin.Scanint;

        for (int i = 0; i < 1 << N; i++)
        {
 
            if ((i & 1) == 0) continue;
            long cost = 0;
            int low = A[0];
            int cnt = 1;
            for (int j = 1; j < N; j++)
            {
                if (low < A[j])
                {
                    cnt++;
                    low = A[j];
                }
                else if ((i >> j & 1) == 1)
                {
                    cnt++;
                    cost += (low + 1) - A[j];
                    low++;
                }
            }
            //WriteLine(i + " " + cnt);
            
            if (cnt >= K)
            {
                ans = Math.Min(ans, cost);
            }
        }

        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 11216
#include<cstdio>
#include<cstring>

using namespace std;

char A[15];
char B[15];
char C[15];

int main(){
	scanf("%s %s %s",A,B,C);
	int len1 = strlen(A);
	int len2 = strlen(B);
	int len3 = strlen(C);
	if(A[len1 - 1] == B[0] && B[len2 - 1] == C[0]){
		printf("YES\n");
	}
	else 
		printf("NO\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
    ll n; cin >> n;
    vector<ll> a(n),b(n);
    ll asum = 0, bsum = 0;
    rep(i,n){
        cin >> a.at(i);
        asum += a.at(i);
    }
    rep(i,n){
        cin >> b.at(i);
        bsum += b.at(i);
    }
    ll addtimes = bsum - asum;
    ll amustadd = 0, bmustadd = 0;
    rep(i,n){
        if(a.at(i)>b.at(i)){
            bmustadd += a.at(i) - b.at(i);
        }else if(a.at(i) < b.at(i)){
            amustadd += (b.at(i) - a.at(i))/2 + ((b.at(i) - a.at(i))%2);
            bmustadd += (b.at(i)-a.at(i))%2;
        }
    }
    if(amustadd > addtimes || bmustadd > addtimes){
        cout << "No" << endl;
    }else{
        if((addtimes - amustadd) * 2 == (addtimes - bmustadd)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 384
from heapq import *


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))


    queue = []
    heapify(queue)

    value = [0]*N
    for i, v in enumerate(B):
        value[i] = v
        heappush(queue, (-v, i))


    ans = 0

    while queue:
        v, i = heappop(queue)
        v = -v
        s = value[(i+1)%N] + value[(i-1)%N]

        if v == A[i]:
            continue
            
        minus = (v-A[i]) // s

        if minus <= 0:
            ans = -1
            break

        ans += minus
        v -= minus * s
        value[i] = v

        if v != A[i]:
            heappush(queue, (-v, i))

    print(ans)

if __name__ == "__main__":
    main()


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

    ll x;

    cin >> x;

    cout << x/500*1000+(x%500)/5*5;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[100000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> v;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        v.emplace_back(a[i], i + 1);
    }
    sort(all(v));
    for (int i = 0; i < n; ++i)
        cout << v[i].second << ' ';
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define MOD (int)1e9+(int)7
#define INF 2147483647
typedef long long ll;
typedef unsigned long long ull;
//dark power
#define int ll
//define Error、大抵は、セミコロン忘れとか、Defineは関係ない
//komennto C+udekaijo

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin>>n;
	vector<int> v(n);
	rep(i,n)cin>>v[i];
	sort(all(v),greater<int>());
	int flag=0;
	int w=0,h=0;
	rep(i,n-1){
		if(v[i]==v[i+1]){
			flag++;
			if(!!w)h=v[i];else w=v[i];
			i++;
		}
		if(flag==2)break;
	}
	cout<<w*h<<endl;
		
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
 
		Scanner scan = new Scanner(System.in);
		int money = scan.nextInt();
		int point = 0;
		while (money >= 500) {
			money -= 500;
			point += 1000;
		}
		while (money >= 5) {
			money -= 5;
			point += 5;
		}
		System.out.println(point);
		scan.close();
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
#include <functional>
#include <map>
#include <set>
using namespace std;
const int INF = 1000000009;

int a, b, c;
int main(){
	scanf("%d%d%d", &a, &b, &c);
	if(a == b){
		printf("%d\n", c);
	}else if(b == c){
		printf("%d\n", a);
	}else if(a == c){
		printf("%d\n", b);
	}
	return 0;
}

Measured memory_bytes: 888
s = str(input())
q = int(input())

x = []
pre = ''
post = ''
isone = False
for i in range(q):
    x = input().split()
    if x[0] == '1':
        if isone:
            isone = False
        else:
            isone = True
    elif x[1] == '1':
        if isone:
            post += x[2]
        else:
            pre += x[2]
    else:
        if isone:
            pre +=x [2]
        else:
            post += x[2]
    if i == q - 1:
        if isone:
            s = post[::-1] + s[::-1] + pre
        else:
            s = pre[::-1] + s + post
print(s)

Measured memory_bytes: 4468
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;
int f[100000];

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}

void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

int main() {
	int n;
	char w[101][101];
	scanf("%d", &n);
	REP(i, n) {
		scanf("%s", w[i]);
	}
	REP(i, n - 1) {
		FOR(j, i + 1, n) {
			if (strcmp(w[i], w[j]) == 0) {
				puts("No");
				return 0;
			}
		}
		//printf("%c %c\n", w[i][strlen(w[i]) - 1], w[i + 1][0]);
		if (w[i][strlen(w[i]) - 1] != w[i + 1][0]) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<int> a(N); REP(i, N) cin >> a[i];
  int ans = 0;
  REP(i, N) {
    if((i + 1) % 2 == 1) {
      if(a[i] % 2 == 1) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	ll N, M; cin >> N >> M;
	ll ans;
	if (N <= M / 2) ans = N + ((M - N * 2) / 4);
	else ans = M / 2;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() 
{
    int a,b;
    for(int i=1;i<=5;i++)
    {
        cin>>a;
        if(a==0)
        b=i;
    }
    cout<<b;
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        if (isP(s) && isP(s.substring(0, (s.length() - 1) / 2)) &&
                isP(s.substring((s.length() + 3) / 2 - 1))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
    public static boolean isP(String s) {
        for (int i = 0, j = s.length() - 1; i < j; ++i, --j) {
            if (s.charAt(i) != s.charAt(j)) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 22740
// https://atcoder.jp/contests/practice2/tasks/practice2_h
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, D;
    cin >> N >> D;
    vector<int> X(N), Y(N);
    REP(i, N) cin >> X[i] >> Y[i];
    two_sat ts(N);
    REP(i, N) REP(j, i) {
        if (abs(X[i] - X[j]) < D) {
            ts.add_clause(i, false, j, false);
        }
        if (abs(X[i] - Y[j]) < D) {
            ts.add_clause(i, false, j, true);
        }
        if (abs(Y[i] - X[j]) < D) {
            ts.add_clause(i, true, j, false);
        }
        if (abs(Y[i] - Y[j]) < D) {
            ts.add_clause(i, true, j, true);
        }
    }
    if (!ts.satisfiable()) {
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
    auto ans = ts.answer();
    REP(i, N) {
        if (ans[i]) {
            cout << X[i] << "\n";
        } else {
            cout << Y[i] << "\n";
        }
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3796
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){

		while(scan.hasNext()){
			int mon = scan.nextInt();
			int day = scan.nextInt();
			if(mon == 0){
				break;
			}
			int year = 2004;
			Calendar cal = Calendar.getInstance();
			cal.set(2004, mon - 1, day);
			int week = cal.get(Calendar.DAY_OF_WEEK);
			String s = "";
			switch(week){
				case Calendar.SUNDAY :
					s = "Sunday";
					break;
				case Calendar.MONDAY :
					s = "Monday";
					break;
				case Calendar.TUESDAY :
					s = "Tuesday";
					break;
				case Calendar.WEDNESDAY :
					s = "Wednesday";
					break;
				case Calendar.THURSDAY :
					s = "Thursday";
					break;
				case Calendar.FRIDAY :
					s = "Friday";
					break;
				case Calendar.SATURDAY :
					s = "Saturday";
					break;
				default :
					break;
			}
			System.out.printf("%s\n", s);
		}
	}
}

Measured memory_bytes: 27356