akhauriyash/Code-Regression huggingface dataset:
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 500005
using namespace std;
int n;
int a[27][maxn];
int tree[27][4*maxn];
void build(int node,int st,int en,int no)
{
	if(st==en)
	{
		tree[no][node] = a[no][st];
		return;
	}
	int mid = (st+en)/2;
	build(2*node,st,mid,no);
	build(2*node + 1,mid+1,en,no);
	tree[no][node] = tree[no][2*node] + tree[no][2*node + 1];
}
int query(int node,int st,int en,int le,int re,int no)
{
	if(st==le && en==re) return tree[no][node];
	int mid = (st+en)/2;
	if(re<=mid) return query(2*node,st,mid,le,re,no);
	else if(le>mid) return query(2*node + 1,mid+1,en,le,re,no);
	else return query(2*node,st,mid,le,mid,no) + query(2*node + 1, mid+1,en,mid+1,re,no);
}
void update(int node,int st,int en,int idx,int val,int no)
{
	if(st==en)
	{
		tree[no][node] = val;
		return;
	}
	int mid = (st+en)/2;
	if(idx<=mid) update(2*node , st,mid,idx,val,no);
	else update(2*node + 1,mid+1,en,idx,val,no);
	tree[no][node] = tree[no][2*node] + tree[no][2*node + 1];
}
signed main()
{
    fast;
    
    string s;
    ll i,j;
    cin>>n;
    cin>>s;
    for(i=0;i<26;i++)
    {
    	for(j=0;j<n;j++)
    	{
    		ll in = s[j] - 'a';
    		if(in==i) a[i][j+1] = 1;
    	}
    }
    for(i=0;i<26;i++)
    {
    	build(1,1,n,i);
    }
    ll q;
    cin>>q;
    while(q--)
    {
    	ll no;
    	cin>>no;
    	if(no==2)
    	{
    		ll le,re;
    		cin>>le>>re;
    		ll ans = 0;
    		for(i=0;i<26;i++)
    		{
    			if(query(1,1,n,le,re,i)) ans++;
    		}
    		cout<<ans<<"\n";
    	}
    	else
    	{
    		ll p;
    		char val;
    		cin>>p>>val;
    		ll c = val - 'a';
    		ll initial = s[p-1] - 'a';
    		s[p-1] = val;
    		if(initial==c) continue;
    		a[initial][p] = 0;
    		a[c][p] = 1;
    		update(1,1,n,p,0,initial);
    		update(1,1,n,p,1,c);
    	}
    }
}

Measured memory_bytes: 211996
s = input()

i = 0
while True:
    if s[i] == 'A':
        A_index = i
        break
    i += 1
j = len(s) - 1
while True:
    if s[j] == 'Z':
        Z_index = j
        break
    j -= 1

print(j - (i - 1))


Measured memory_bytes: 3512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define N 1000010
int n,i;
int main(){
    while (scanf("%d %d",&n,&i)!=EOF){
        printf("%d\n",n+1-i);
    }
    return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include<string>
#include "stdio.h"
#include "stdlib.h"

using namespace std;

struct Node{
  int key;
  Node* parent;
  Node* left;
  Node* right;
};

Node* NIL;
Node* root;

void insert(int input){
  Node* node_now_parent = NIL;
  Node* node_now = root;

  Node* z;
  z = (Node*) malloc(sizeof(Node));
  z->key    = input;
  z->parent = NIL;
  z->left   = NIL;
  z->right  = NIL;

  while( node_now != NIL ){
    node_now_parent = node_now;

    if(z->key <=  node_now->key){
      node_now = node_now->left;
    }else{
      node_now = node_now->right;
    }
  }

  if(node_now_parent == NIL){
    root = z;
  }else{
    if( z->key <= node_now_parent->key ){
      node_now_parent->left = z;
    }else{
      node_now_parent->right = z;
    }
    z->parent = node_now_parent;
  }
};


void preOrder(Node* node){
  if(node == NIL){
    return;
  }
  printf(" %d", node->key);
  preOrder(node->left);
  preOrder(node->right);
}

void inOrder(Node* node){
  if(node == NIL){
    return;
  }
  inOrder(node->left);
  printf(" %d", node->key);
  inOrder(node->right);
}

void print(Node* node){
  inOrder(node);
  printf("\n");
  preOrder(node);
  printf("\n");
}

int main(void){
  int N;
  scanf("%d", &N);
  
  string command;
  int key;
  for(int i=0;i<N;i++){
    cin >> command;
    if(command == "insert"){
      cin >> key;
      insert(key);
    }else if(command == "print"){
      print(root);
    }else{
      printf("No command!");
    }
  }
  return 0;
}


Measured memory_bytes: 26780
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s=sc.nextLine();
		char c;
		int i,length=s.length();
		for(i=0;i<length;i++){
			c=s.charAt(i);
			if(Character.isLowerCase(c))System.out.print(Character.toUpperCase(c));
			else if(Character.isUpperCase(c))System.out.print(Character.toLowerCase(c));
			else System.out.print(c);
		}
		System.out.print("\n");
	}
}



Measured memory_bytes: 26472
# 2019-11-15 14:37:47(JST)
import sys
# import collections
import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    a, b = [int(x) for x in sys.stdin.readline().split()]
    if abs(a) == abs(b):
        ans = 0
    else:
        ans = (a + b) / 2
    
    print(int(ans) if ans == math.floor(ans) else 'IMPOSSIBLE')


if __name__ == "__main__":
    main()


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

const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;

  long long ans = 1;
  int prev = -1;
  for(int i=0;i<n;i++) {
    if(s1[i] == s2[i]) {
      if(prev == -1) ans *= 3;
      else if(prev == 1) ans = ans * 2 % mod;

      prev = 1;
    }
    else {
      if(prev == -1) ans *= 6;
      else if(prev == 1) ans = ans * 2 % mod;
      else if(prev == 2) ans = ans * 3 % mod;

      prev = 2;
      i++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

n,m = map(int, input().split())
a = list(map(int, input().split()))
lcm_a = a[0]
for i in a[1:]:
  lcm_a = lcm_a * i // fractions.gcd(lcm_a,i)
  if lcm_a > m * 2:
    print(0)
    exit()
if all([(lcm_a // i) % 2 for i in a]):
  ans = (m - lcm_a // 2) // lcm_a + 1
  print(ans)
else:
  print(0)


Measured memory_bytes: 16308
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;char str[20];
	scanf("%d", &n);
	int a = 0, b = 0, c = 0, d = 0;
	while(n--)
	{
		scanf("%s", str);
		switch(str[0]){
			case'A':a++; break;
			case'W':b++;break;
			case'T':c++;break;
			case'R':d++;break;
		}
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", a, b, c, d);
	return 0;
} 

Measured memory_bytes: 3820
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    l = 0
    r = 0
    sum = 0
    orResult = 0
    while r < N and l < N:
        if A[r] & orResult == 0:  # このとき繰り上がることがない
            sum += r - l + 1
            orResult |= A[r]
            r += 1
        else:
            orResult ^= A[l]
            l += 1
        if l > r and l != N:
            r = l
            orResult = A[r]
            sum += 1
    print(sum)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24992
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ll ans = 0;
    if (a[0] > x) {
        ans += a[0] - x;
        a[0] = x;
    }
    for (int i = 1; i < n; ++i) {
        if (a[i] + a[i - 1] > x) {
            ans += a[i] + a[i - 1] - x;
            a[i] -= a[i] + a[i - 1] - x;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;


/**
 * AIZU ONLINE JUDGE
 * 3126
 *  2020/5/1
 */
public class Main {


    boolean main() throws IOException {

        Scanner sc = new Scanner(systemin);

        int N = sc.nextInt();
        sc.nextLine();

        int cnt = 0;
        for(int i = 0; i < N; i++) {
            String s = sc.nextLine();
            if (s.equals("E869120")) {
                cnt++;
            }
        }
        System.out.printf("%d\n", cnt);

        sc.close();
        return false;
    }



    PrintStream log;
    PrintStream result = System.out;
    BufferedReader systemin;

    static Main instance = new Main();

    Main() {
        systemin = new BufferedReader(new InputStreamReader(System.in));
        log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    }

    public static void main(String[] args) throws IOException {

        instance.main();

        instance.systemin.close();
    }


}




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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int a, b;

signed main() {
	cin >> a >> b;

	int n = b - a - 1;
	int A = n * (n + 1) / 2;
	cout << A - a << endl;

	return 0;
}

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


int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    set<string> values; // insert するときに重複を取り除いてくれます
    for (int i = 0; i < n; ++i) {
        values.insert(s[i]); // 挿入します
    }
    cout << values.size() << endl;
}

Measured memory_bytes: 25084
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    total_bar_count, choosed_bar_count = list(map(int, input().split()))
    bar_lengths = list(map(int, input().split()))

    bar_lengths.sort(reverse=True)
    total_bar_length = sum(bar_lengths[:choosed_bar_count])
    print(total_bar_length)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define LL long long
#define UP(i,l,h) for(int i=l;i<h;i++)
#define DOWN(i,h,l) for(int i=h-1;i>=l;i--)
#define W(t) while(t)
#define INF 0x3f3f3f3f
#define MEM(a,b) memset(a,b,sizeof(a))
#define MAXN 200010
using namespace std;

int main(){
    char ch[15];
    scanf("%s",ch);
    if(ch[0]=='Y'&&ch[1]=='A'&&ch[2]=='K'&&ch[3]=='I') puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>

//問題勘違いしてた。これはこれで使えるコード

using namespace std;

int main()
{
  long long N,K;
  cin>>N>>K;
  vector<long long> v;
  long long h;
  for(int i=0;i<N;i++)
  {
    cin>>h;
    v.push_back(h);
  }

  if(N<=K)
  {
    cout<<0<<endl;
    return 0;
  }
  sort(v.begin(),v.end());

  for(int i=1;i<=K;i++)
  {
    long long& v0=v.back();
    //cout<<v0<<endl;
    v.pop_back();
  }

  long long ret=accumulate(v.begin(),v.end(),(long long)0);
  cout<<ret<<endl;

  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//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) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) 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,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集
template<typename T>
struct SegmentTree{

  vector<T> node;
  int n0;
  SegmentTree(vector<T>& v){
    int n = v.size();
    n0 = 1;
    while(n0 < n) n0 <<= 1;
    node.assign(2*n0,0);

    for(int i=0; i<n; i++) node[i+n0-1] = v[i];
    for(int i=n0-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
  }

  void update(int k, T x){
    k += n0-1;
    node[k] = x;
    while(k > 0){
      k = (k-1)/2;
      node[k] = node[k*2+1] + node[k*2+2];
    }
  }

  /* 区間[l,r]の和 */
  T query(int a, int b, int k, int l, int r){
    if(r <= a || b <= l) return 0;
    
    if(a <= l && r <= b) return node[k];
    else{

      T vl = query(a, b, 2*k+1, l, (l+r)/2);
      T vr = query(a, b, 2*k+2, (l+r)/2, r);
      return vl + vr;
    }
  
  }
  
  /* 区間[0, n)中のk番目の1のindex*/
  int find_kth(int v, int l, int r, int k){
    if(k > node[v]) return -1;
    if(l + 1 == r) return l;
    if(node[v*2+1] >= k){
      return find_kth(v*2+1, l, (l+r)/2, k);
    }else{
      return find_kth(v*2+2, (l+r)/2, r, k-node[v*2+1]);
    }
  }


  T query(int l, int r){
    return query(l, r, 0, 0, n0);
  }

  T find_kth(int k){
    if(k == 0) return -1;
    return find_kth(0, 0, n0, k);
  }
  
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(5);
  
  string s; cin >> s;
  vector<vector<int>> v(26);
  REP(i,s.size()){
    v[s[i]-'a'].push_back(i);
  }

  for(int i=0; i<26; i++){
    for(int j=1; j<v[i].size(); j++){
      if(v[i][j] - v[i][j-1] <= 2){
        cout << v[i][j-1]+1 << " " << v[i][j]+1 << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 3980
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int d[n];
    for(int i=0; i<n; i++){
        cin >> d[i];
    }
    long long ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
transport = [0]*5
N = int(input())
for i in range(5):  # 一番効率の悪い（キャパが少ない）交通機関を使うのにかかる時間
    transport[i] = [0]*2
    transport[i][1], transport[i][0] = i, int(input())

transport = sorted(transport)
if N % transport[0][0] == 0:
    time = N // transport[0][0]
else:
    time = N // transport[0][0] + 1
time += 4  # 他の交通機関を使うのにかかる時間
print("{}".format(time))


Measured memory_bytes: 3060
import java.io.*;

class Main{
	public static void main(String[] args){
		try{
			BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
			String str = buf.readLine();
			int input_time = Integer.parseInt(str);
			int h = input_time/3600;
			int m = (input_time - ( h * 3600))/60;
			int s = input_time % 60;
			System.out.println( h + ":" + m + ":" + s );
			
		} catch(IOException e){
		}
	}
}


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

using namespace std;

static const int INF = 1e9 + 7;

using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using ull = unsigned long long;



void hawawa()
{
  int num[4] = {};
  int n;
  cin >> n;
  vector<long long> a(n);
  for (auto&& i : a) {
    cin >> i;
    i %= 4;
    num[i]++;
  }
  num[1] += num[3];
  if (num[1] + !!num[2] > num[0] + 1) {
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  hawawa();
}

Measured memory_bytes: 1024
def check(p,A):
    cnt = 0
    for a in p:
        if a >= A:
            cnt+=1
    return cnt >= A

def main():
    N=int(input())
    p=list(map(int,input().split()))
    for A in range(100,-1,-1):
        if check(p,A):
            print(A)
            return

if __name__ == "__main__":
    main()

Measured memory_bytes: 7748
#define _CRT_SECURE_NO_WARNINGS
#pragma _attribute_((optimize("-O2")))

#include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <sstream>
#include <time.h>
#include <iomanip>

#define ll long long

//#define Local

using namespace std;

string in;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input1.txt", "r", stdin);
	//freopen("output1.txt", "w", stdout);

	while (cin >> in)
	{

		int cont = 0;
		bool f = 0;
		if (in.length() == 2)
		{
			if (in[0] == in[1])
			{
				cout << "1 2" << endl;
				continue;
			}
		}
		else
			for (int a = 2; a < in.length(); a++)
			{
				if (in[a - 2] == in[a - 1] || in[a - 2] == in[a] || in[a - 1] == in[a])
				{
					cout << a - 1 << " " << a + 1 << endl;
					f = 1;
					break;
				}
			}
		if (!f)
			cout << "-1 -1" << endl;
	}

#ifdef Local
	cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
	return 0;
}

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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<int> s(n, -1);
    
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        
        a--;
        b--;
        
        s[b] = max(s[b], a);
    }
        
    int ans = 0;
    int l = 0;
    
    for (int i = 1; i < n; i++) {
        if (l <= s[i]) {
            ans++;
            l = i;
        }
    }
    
    cout << ans << endl;
}

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

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<a)
    {
        cout<<k<<endl;
        return 0;
    }
    if(a==k or (a+b)>=k)
    {
        cout<<a<<endl;
        return 0;
    }
    int x=k-(a+b);
    cout<<a-x<<endl;
    
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define w(t) while(t--)
#define fo(i,n) for(int i = 0;i < n;i++)
#define vi vector<int>

using namespace std;

int main(){
    int i,a,b,k,f = 0;
    cin>> k;
    cin>> a>> b;
    for(i = a;i <= b;i++){
        if(i %k == 0)
            {
                f = 1;
                break;
            }
    }
    if(f)
        cout<< "OK"<<endl;
    else
        cout<<"NG"<<endl;
    // a <= q*k + r <= b 
   

}

Measured memory_bytes: 3596
n, k = map(int, input().split())
A = list(map(int, input().split()))

Before = []
After = []

for i in range(n):
    now = A[i]
    before = 0
    after = 0
    for j in range(i):
        if now > A[j]:
            before += 1
    for l in range(i+1,n):
        if now > A[l]:
            after += 1
    Before.append(before)
    After.append(after)

ans = 0
mod = 10**9+7
for i in range(n):
    if k%2 == 0:
        multi_one = int(k/2) * (k-1) % mod
        multi_two = int(k/2) * (k+1) % mod 
    else:
        multi_one = int((k-1)/2) * k % mod
        multi_two = int((k+1)/2) * k % mod
    plus = multi_one*Before[i]%mod + multi_two*After[i]%mod
    ans = (ans + plus) % mod

print(ans)

Measured memory_bytes: 3188
n,m=map(int,input().split())
a=[0]*(n+1)
if m>0:
  for _ in range(m):
    a[int(input())]+=1
dp=[0]*(n+1)
dp[0]=1
if a[1]!=1:
  dp[1]=1
if n==1:
  if a[1]==0:
    print(1)
    exit()
  else:
    print(0)
    exit()
for i in range(2,n+1):
  if a[i-2]==0 and a[i-1]==0:
    dp[i]=dp[i-2]+dp[i-1]
  elif a[i-1]!=0 and a[i-2]==0:
    dp[i]=dp[i-2]
  elif a[i-2]!=0 and a[i-1]==0:
    dp[i]=dp[i-1]
  else:
    dp[i]=0
print(dp[n]%(10**9+7))    


Measured memory_bytes: 505060
#include<iostream>
using namespace std;
int main(){
	int a=0;
	int w=0; //????????¢??????
	int h=0; //????????¢????¨?
	int x=0; //????±???¨????????????????????§?¨????w-x???h-y????????????
	int y=0;
	int r=0; //????±???¨??????????????????
	cin>>w>>h>>x>>y>>r;
	if(x-r>=0&&x+r<=w){
		if(y-r>=0&&y+r<=h){
			cout<<"Yes"<<endl;
		}else{
			a=1;
		}
	}else{
		a=1;
	}
	if(a==1){
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 1156
H,K=map(int,input().split())
 
s=list(map(int,input().split()))
 
sum=0

s.sort(reverse=True)

if K>=len(s):
  for A in range(len(s)):
    s[A]=0

else:
  for A in range(K):
    s[A]=0



for A in s:
  sum+=A
 
print(sum)

Measured memory_bytes: 87372
# coding: utf-8
# Your code here!

while True:
   H, W = map(int, input().split())
   if H + W == 0: break
   
   for i in range(1, H + 1):
      for j in range(1, W + 1):
         if i % 2 == 1:
            if j % 2 == 1:
               print("#", end = "")
            else:
               print(".", end = "")
         else:
            if j % 2 == 1:
               print(".", end = "")
            else:
               print("#", end = "")
      print("")
   print("")



Measured memory_bytes: 7012
import Data.ByteString.Char8 as BC hiding (length, group, tail, map, sort)
import Prelude hiding (getContents, lines, drop, putStrLn)
import Data.Maybe
import Data.List hiding (lines)

main =
    getContents >>=
        print . length . group . sort . tail . map (fst . fromJust . readInt) . lines

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

int main(){
  
  string a,b;
  cin >> a >> b;
  
  int x,y;
  cin >> x >> y;
  
  string c;
  cin >> c;
  
  if( a == c ){
    
    cout << x-1 << " " << y << endl;
    
  }
  
  else{
    
    cout << x << " " << y-1 << endl;
    
  }
  
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

class edge {
public:
	int now;
	std::vector<int> next;
	std::vector<int> dis;
	int color;
	// 訪問済みの場合falseに
	bool visited;

	edge(){};

	edge(int n){
		now = n;
		visited = true;
	}
};



std::vector<edge> edges;


void calc(int now) {
	if (edges[now].visited) {
		edges[now].visited = false;
		for (size_t i = 0; i < edges[now].next.size(); i++) {
			if (edges[edges[now].next[i]].visited) {
				if (edges[now].dis[i] % 2 == 0) {
					edges[edges[now].next[i]].color = edges[now].color;
				}
				else {
					edges[edges[now].next[i]].color = (edges[now].color+1)%2;
				}

				calc(edges[now].next[i]);
			}
		}
	}
}

int main(int argc, char const *argv[]) {
	int n;
	std::cin >> n;

	for (int i = 0; i < n; i++) {
		edges.push_back(edge(i));
	}

	for (size_t i = 0; i < n-1; i++) {
		int u,v,w;
		std::cin >> u >> v >> w;
		u--;
		v--;
		edges[u].next.push_back(v);
		edges[v].next.push_back(u);
		edges[u].dis.push_back(w);
		edges[v].dis.push_back(w);
	}

	edges[0].color = 0;
	calc(0);

	for (size_t i = 0; i < n; i++) {
		std::cout << edges[i].color << '\n';
	}


	return 0;
}


Measured memory_bytes: 15464
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int R,G;
  cin >> R >> G;
  cout << 2*G-R << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
ans = [0]*n

for i in range(n-1, -1, -1):
  now = 0
  for j in range(i+i+1, n, i+1):
    now += ans[j]
  if now % 2 != a[i]:
    ans[i] = 1

print(sum(ans))
for i in range(n):
  if ans[i] == 1:
    print(i+1)

Measured memory_bytes: 7276
N=int(input())
A=list(map(int,input().split()))

MINUS=0

for a in A:
    if a<0:
        MINUS+=1

ABS=[abs(a) for a in A]

if MINUS%2==0:
    print(sum(ABS))

else:
    print(sum(ABS)-min(ABS)*2)


Measured memory_bytes: 14412
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    if ((C + B - 1) / B <= (A + D - 1) / D){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

/**
 * Gluttony
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            long K = sc.nextLong();
            sc.nextLine();

            long[] A = new long[N];
            long[] F = new long[N];

            String[] a = sc.nextLine().split(" ");
            for (int i = 0; i < N; i++) {
                A[i] = Long.parseLong(a[i]);
            }
            a = sc.nextLine().split(" ");
            for (int i = 0; i < N; i++) {
                F[i] = Long.parseLong(a[i]);
            }

            //long sum = Arrays.stream(A).sum();
            long sum = 0;
            for (int i = 0; i < N; i++) {
                sum += A[i];
            }
            if (sum <= K) {
                System.out.println(0);
                return;
            }

            Arrays.sort(A);
            Arrays.sort(F);

            long min = 0;
            long max = 0;
            for (int i = 0; i < N; i++) {
                max = Math.max(max, A[i] * F[N - 1 - i]);
            }

            while (max - min > 1) {
                long mid = (min + max) / 2;

                long need = 0;
                for (int i = 0; i < N; i++) {
                    need += Math.max(0, A[i] - mid / F[N - 1 - i]);
                }

                if (need > K) {
                    min = mid;
                } else {
                    max = mid;
                }
            }

            System.out.println(max);
        }

    }

}


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

int main()
{
    int a,b,c;
    int n;

    cin >> a >> b >> c >> n;

    int cnt = 0;
    for(int i = 0;i <= a;i++){
        for(int j = 0;j <= b;j++){
            for(int k = 0;k <= c;k++){
                int sum = 500*i+100*j+50*k;
                if(sum == n) cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use std::cmp::*;
use std::collections::*;

fn main() {
    input! {
        n:usize,
        m:usize,
        s:usize,
        uvab:[(usize,usize,usize,i64);m],
        cd:[(usize,i64);n],
    }
    let mut g = Graph::new(n * 2501);
    for e in uvab.iter() {
        for i in e.2..=2500 {
            g.add_directional_edge(p2i(e.0 - 1, i), p2i(e.1 - 1, i - e.2), e.3);
            g.add_directional_edge(p2i(e.1 - 1, i), p2i(e.0 - 1, i - e.2), e.3);
        }
    }
    for i in 0..n {
        for j in 0..=2500 {
            g.add_directional_edge(p2i(i, j), p2i(i, min(j + cd[i].0, 2500)), cd[i].1);
        }
    }
    let dist = dijkstra(&g, p2i(0, min(s, 2500)));
    for i in 1..n {
        let mut ans = std::i64::MAX;
        for j in 0..=2500 {
            ans = min(ans, dist[p2i(i, j)]);
        }
        println!("{}", ans);
    }
}

fn p2i(x: usize, y: usize) -> usize {
    x * 2501 + y
}

// グラフの辺
#[derive(Debug, Copy, Clone)]
struct Edge {
    to: usize,
    cost: i64,
}
impl Edge {
    pub fn new(to: usize, cost: i64) -> Edge {
        Edge { to: to, cost: cost }
    }
}

// 隣接リストによるグラフ
struct Graph {
    adjacency: Vec<Vec<Edge>>,
}
impl Graph {
    pub fn new(size: usize) -> Self {
        Graph {
            adjacency: vec![vec![]; size],
        }
    }
    // 頂点数を取得
    fn len(&self) -> usize {
        self.adjacency.len()
    }
    // 有向辺を追加する
    fn add_directional_edge(&mut self, from: usize, to: usize, cost: i64) {
        self.adjacency[from].push(Edge::new(to, cost));
    }
    // 無向辺を追加する
    fn add_undirectional_edge(&mut self, from: usize, to: usize, cost: i64) {
        self.add_directional_edge(from, to, cost);
        self.add_directional_edge(to, from, cost);
    }
}
impl std::ops::Index<usize> for Graph {
    type Output = Vec<Edge>;
    fn index(&self, vertex: usize) -> &Self::Output {
        &self.adjacency[vertex]
    }
}

fn dijkstra(g: &Graph, start: usize) -> Vec<i64> {
    use std::cmp::Reverse;
    let mut res = vec![std::i64::MAX; g.len()];
    res[start] = 0;
    let mut heap = std::collections::BinaryHeap::new();
    heap.push(Reverse((0, start)));
    while let Some(Reverse((dist, now))) = heap.pop() {
        if res[now] == dist {
            for e in g[now].iter() {
                if res[now] + e.cost < res[e.to] {
                    res[e.to] = res[now] + e.cost;
                    heap.push(Reverse((res[e.to], e.to)));
                }
            }
        }
    }
    res
}

Measured memory_bytes: 22056
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2e5+5;
ll n,d,a,x[N],pos,di,sub[N],ans;
struct mos{
	ll x,h;
}q[N];
bool cmp(mos a,mos b){
	return a.x<b.x;
}
int main(){
	cin>>n>>d>>a;
	for(int i=1;i<=n;i++){
		cin>>q[i].x>>q[i].h;
		x[i]=q[i].x;
	}
	sort(q+1,q+n+1,cmp);
	sort(x+1,x+n+1);
	for(int i=1;i<=n;i++){
		di-=sub[i];
		ll xx=q[i].x+d+d;
		int pos=upper_bound(x+1,x+n+1,xx)-x;
		q[i].h-=di;
		ll need=(q[i].h>0?(q[i].h-1)/a+1:0);
		sub[pos]+=need*a;
		di+=need*a;
		ans+=need;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6528
#include<stdio.h>
int main(void) {
    int s, m ,h;
    scanf("%d", &s);
    h = s/3600;
    s -= h*3600;
    m = s/60;
    s -= m*60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
using namespace std;
int main(){
  int N;
  int div4 = 0;
  int div2 = 0;
  int nodiv = 0;
  int i = 0;
  cin >> N;
  int a[N];
  for(i = 0; i < N; i++){
    cin >> a[i];
  }
  for(i = 0; i < N; i++){
    if((a[i] % 4) == 0){
      div4 = div4 + 1;
    }else if((a[i] % 2) == 0){
      div2 = div2 + 1;
    }else{
      nodiv = nodiv + 1;
    }
  }
  if(div2 != 0){
    if((div2 % 2) != 0){
      nodiv = nodiv + 1;
    }
  }
  if(div4 >= (nodiv - 1)){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include<map>

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

using namespace std;


int inputValue() {
  int a;
  cin >> a;
  return a;
};
void inputVector(vector<int>* v) {
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int a;
  while (cin >> a) {
    if (a == -1)break;
    v->push_back(a);
  }
};

void inputVector(vector<int> * p, int a) {
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

void inputVector2(vector<vector<int>>& v, int r, int c) {
  int temp;
  for (size_t i = 0; i < r; i++)
  {
    for (size_t j = 0; j < c; j++)
    {
      scanf("%d", &temp);
      v[i][j] = temp;
    }
  }
}
void inputVector3(vector<int>* v0, vector<int>* v1) {
  int a;
  unsigned short count = 0b0;
  while (cin >> a) {
    if (a == -1)break;
    if (count)v0->push_back(a); else v1->push_back(a);
    count = count ^ 1;
  }
};

template <typename T>
void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  }
  else {
    cout << a << "\n";
  }
}

int main(int argc, const char * argv[]) {
  int a;
  map<string, bool> isUsed;
  string s1;
  string s2;
  string kotae = "Yes";
  scanf("%d", &a);
  cin >> s1;
  isUsed[s1] = true;
  while (cin >> s2) {
    if (isUsed[s2]) {
      kotae = "No";
      break;
    }
    isUsed[s2] = true;
    if (*(s1.end()-1) != *s2.begin()) {
      kotae = "No";
      break;
    }
    s1 = s2;
  }
  cout << kotae << endl;
}

Measured memory_bytes: 256
n=int(input())
s=input()
t=input()
ans=""
for i in range(n+1):
    s1=s[:n-i]
    s2=s[n-i:]
    t1=t[:i]
    t2=t[i:]
    if s2==t1:
        ans=s1+s2+t2
print(len(ans))


Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
from itertools import combinations, combinations_with_replacement, product, permutations


import sys
# sys.setrecursionlimit(10**6)
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, X, CA):
    A = [ca[1:] for ca in CA]
    C = [ca[0] for ca in CA]
    ans = INF
    for k in range(1, N+1):
        for i in combinations(range(N), r=k):
            m = [0] * M
            t = 0
            for j in i:
                for k, a in enumerate(A[j]):
                    m[k] += a
                t += C[j]
            if min(m) >= X:
                ans = min(ans, t)
    if ans == INF:
        ans = -1
    return ans


def main():
    N, M, X = read_int_n()
    CA = [read_int_n() for _ in range(N)]
    print(slv(N, M, X, CA))


if __name__ == '__main__':
    main()


Measured memory_bytes: 68236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

void Suhaib_Sawalha (){

    int n;
    cin >> n;
    long double a[n] , ans;
    for (int i = 0 ; i < n ; ++i)
        cin >> a[i];
    sort(a,a+n);
    ans = (a[0]+a[1]) / 2.0;
    for (int i = 2 ; i < n ; ++i)
        ans = (ans + a[i]) / 2.0;
    
    cout << fixed << setprecision(20) << ans;

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

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

#define is_uruu leapyear
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(a);i>(b);--i)

int stack[4], top;
    
void push(int x){
	stack[++top] = x;
}

int  pop(){
	return stack[top--];
}
    
int main() {
	int a, b;
	string c;
	top = 0;
	while(cin >> c){
		if(c == "+"){
			a = pop();
			b = pop();
			push(a+b);
			continue;
		}
		if(c == "-"){
			a = pop();
			b = pop();
			push(b-a);
			continue;
		}
		if(c == "*"){
			a = pop();
			b = pop();
			push(a*b);
			continue;
		}
		push(atoi(c.c_str()));
	}
	cout << pop() << endl;
    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

int main() {
	int N, K;
	string S;
	string out;
	cin >> N >> S >> K;
	for (int i = 0; i < N; i++) {
		if (S[i] == S[K - 1])out+=S[i];
		else out += "*";
	}
	print(out);



	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

s = sum(b)
f = -1
#print(s)                                                                      

for index,i in enumerate(a):
#    print("index = {} {}".format(index,i))                                    
#    print("f = {}".format(f))                                                 
    if i == f + 1:
#        print("f = {}".format(f))                                             
        s += c[f-1]
    f = i

print(s)


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

int main() {
    int a[11],r,d;

    cin >> r >> d >> a[0];
    for(int i=1; i<=10; i++){
        a[i] = r * a[i-1] - d;
        cout << a[i] << endl;
    }
    return 0;
}
   


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

using namespace std;

const int N = 1e5 + 5;

int n, m;
vector<int> g[N];
int a[N], b[N];
int p[N];
bool used[N];
long long sum[N];
priority_queue<pair<int, int> > st[N];

int find(int x) { return p[x] < 0 ? x : p[x] = find(p[x]); }


bool can(long long x) {
  for (int i = 0; i < n; ++i) {
    while (!st[i].empty())
      st[i].pop();
    for (int u : g[i])
      st[i].push(make_pair(-a[u], u));
    sum[i] = b[i];
  }
  fill(p, p+n, -1);
  fill(used, used+n, 0);
  int cnt = 0;
  stack<int> stak;
  for (int i = 0; i < n; ++i) {
    if (x >= a[i]) {
      stak.push(i);
      used[i] = 1;
    }
  }
  // cerr << " cek " << x << endl;
  while (!stak.empty()) {
    int v = stak.top();
    stak.pop();
    v = find(v);
    // cerr << " sumber " << v << endl;
    while (!st[v].empty()) {
      auto it = st[v].top();
      int u = it.second;
      if (a[u] > sum[v] + x) break;
      st[v].pop();
      used[u] = 1;
      u = find(u);
      // cerr << " tambah " << u << endl;
      if (u == v) continue;
      if (st[u].size() > st[v].size()) swap(u, v);
      while (!st[u].empty()) {
        st[v].push(st[u].top());
        st[u].pop();
      }
      sum[v] += sum[u];
      p[u] = v;
    }
  }
  for (int i = 0; i < n; ++i) if (!used[i]) return false;
  return true;
}

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i)
    scanf("%d %d", a+i, b+i);
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v); --u, --v; 
    g[u].push_back(v);
    g[v].push_back(u);
  }
  long long lo = 0, hi = 0;
  for (int i = 0; i < n; ++i)
    a[i] -= b[i];
  for (int i = 0; i < n; ++i)
    if (a[i] > hi) hi = a[i];
  long long all = 0;
  for (int i = 0; i < n; ++i)
    all += b[i];
  while (lo < hi) {
    long long mid = (lo + hi) >> 1;
    if (can(mid))
      hi = mid;
    else
      lo = mid + 1;
  }
  // cerr << lo << endl;
  printf("%lld\n", lo+all);
  return 0;
}

Measured memory_bytes: 16512
N=int(input())
list=[]
for i in range(N):
  a,b=input().split()
  list.append((float(a), b))
sum=0
for i in range(N):
  if list[i][1]=="JPY" :
    sum+=list[i][0]
  else :
    sum+=list[i][0]*380000
print(sum)

Measured memory_bytes: 9096
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int x;
bool a[1001];
int main()
{
	a[1]=true;
	scanf("%d",&x);
	for (int i=2;i<=31;i++)
	{
		int j=i;
		while (j*i<=x)
		{
			j=j*i;
			a[j]=true;
		}
	}
	for (int i=x;i>0;i--)
		if (a[i])
		{
			printf("%d",i);
			break;
		}
	system("pause");
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  
  int alphb[26];
  fill_n(alphb, 26, 0);
  
  if(s.size() % 2 != 0){
    cout << "No" << endl;
    return 0;
  }
  
  for(int i = 0; i < s.size(); i++){
    alphb[s[i] - 'a']++;
  }
  
  for(int i = 0; i < 26; i++){
    if(alphb[i] % 2 != 0){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
}
     

Measured memory_bytes: 256
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

void solve(){

   int n;// = sz(s);
   cin>>n;
   string s, t;
   cin >> s >> t;

   for (int i = 0; i < n; ++i)
   {
      cout<<(s[i]);
      cout<<t[i];
   }

}

int32_t main(){_
   
   solve();
   

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define int long long
const unsigned int M = 1000000007;
using namespace std;
int freq[1000007];
int32_t main()
{
    IOS int t = 1;
    //cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int a[n];
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        int x = a[0];
        for (int i = 1; i < n; i++)
        {
            x ^= a[i];
        }
        cout << endl;
        for (int i = 0; i < n; i++)
        {
            int sum = x ^ a[i];
            cout << sum <<" ";
        }
      cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 5212
from collections import deque

n = int(input())
uvw = [list(map(int, input().split())) for i in range(n-1)]
tree = [list() for i in range(n)]
queue = deque([0])
ans = [0] + [-1] * (n-1)
for u,v,w in uvw:
  u -= 1
  v -= 1
  w %= 2
  tree[u].append((v,w))
  tree[v].append((u,w))
while len(queue):
  i = queue.popleft()
  for NEXT,w in tree[i]:
    if ans[NEXT] == -1:
      if w % 2:
        ans[NEXT] = 1 if ans[i] == 0 else 0
      else:
        ans[NEXT] = ans[i]
      queue.append(NEXT)
print(*ans, sep="\n") 

Measured memory_bytes: 60520
program abc162a
  implicit none

  integer :: n, a(3)

  read *, n

  a(1) = n/100
  a(2) = (n-a(1)*100)/10
  a(3) = ((n-a(1)*100) - a(2)*10)

  if (a(1) == 7 .or. a(2) == 7 .or. a(3) == 7) then
     print *, 'Yes'
  else
     print *, 'No'
  end if

  stop
end program abc162a

Measured memory_bytes: 2800
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

//シミュレートして，その局面ごとの最善手をうち続ければいい。
//（未完）

int main(void){
	int N;
	cin>>N;
	int a,c[9]={};//1-3199
	rep(i,N){
		cin>>a;
		if(a>=3200)a=3200;
		c[a/400]++;
	}
	int min=0,max=0;
	rep(i,8){
		if(c[i]>0){
			min++;
			max++;
		}
	}
	max+=c[8];
	if(min==0 && c[8]>0)min=1;
	cout<<min<<" "<<max<<endl;
	return 0;
}

Measured memory_bytes: 256
local function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read"*n"end end return unpack(r)end
N=io.read"*n"
K=io.read"*n"
Q=io.read"*n"
c={}
for i=1,Q do
	local a=io.read"*n"
	if(c[a])then c[a]=c[a]+1
	else c[a]=1 end
end
for i=1,N do
	print(((c[i]or 0)>Q-K) and"Yes"or"No")
end

Measured memory_bytes: 2356
#include<stdio.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i = 0;i < n;i++)
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(s) printf("%c",s)
int main(void){
  int col[8]={0,0,0,0,0,0,0,0};
  int n,cnt=0,ans=0,min,max;
  scanf("%d",&n);
  int a;
  FOR(n){
    scanf("%d",&a);
    if(a<3200){
      col[a/400]=1;
    }else{
      cnt++;
    }
  }
  FOR(8){
    ans+=col[i];
  }
  if(!ans){
    min=1;
    max=cnt;
  }else{
    min=ans;
    max=ans+cnt;
  }
  printf("%d %d\n",min,max);
  return 0;
}
/*
scanf("%d",&n);
scanf("%d %d",&a,&b);
*/

Measured memory_bytes: 128
import math

class Pos:
  def init(x, y):
    self.x = x
    self.y = y

def kock(n, p1, p2):
  if n == 0: return

  s, t = Pos(), Pos()
  s.x = (2 * p1.x + 1 * p2.x) / 3
  s.y = (2 * p1.y + 1 * p2.y) / 3
  t.x = (1 * p1.x + 2 * p2.x) / 3
  t.y = (1 * p1.y + 2 * p2.y) / 3

  cos60 = math.cos(math.radians(60))
  sin60 = math.sin(math.radians(60))

  u = Pos()
  u.x = (t.x - s.x) * cos60 - (t.y - s.y) * sin60 + s.x
  u.y = (t.x - s.x) * sin60 + (t.y - s.y) * cos60 + s.y

  kock(n-1, p1, s)
  print("{:.5f} {:.5f}".format(s.x, s.y))
  kock(n-1, s, u)
  print("{:.5f} {:.5f}".format(u.x, u.y))
  kock(n-1, u, t)
  print("{:.5f} {:.5f}".format(t.x, t.y))
  kock(n-1, t, p2)

n = int(input())

p1, p2 = Pos(), Pos()
p1.x, p1.y = 0.0, 0.0
p2.x, p2.y = 100.0, 0.0

print("{:.5f} {:.5f}".format(p1.x, p1.y))
kock(n, p1, p2)
print("{:.5f} {:.5f}".format(p2.x, p2.y))



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

int main(){
    string W,T;
    int count = 0;
    cin >> W;
    while(cin >> T){
        for(int i=0;i<T.length();i++){
            T[i] = tolower(T[i]);
        }
        if(W.compare(T) == 0) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3144
n = int(input())
xy = []
for i in range(n):
    x,y = map(int, input().split())
    xy.append([x,y])
ans = 0    
for i in range(n):
    for j in range(n):
        ans += ((xy[i][0]-xy[j][0])**2 + (xy[i][1]-xy[j][1])**2)**0.5
        
print(ans/n)
    

Measured memory_bytes: 3060