akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int INF = 1001001001;

int main(){
  int n; cin >> n;
  string s; cin >> s;
  int i = 0;
  int left = 0 ,right = 0;
  for(int i=0;i<n-1;i++){
    if(s.at(i) == '(') right++; else right--;
    if(s.at(i) == ')' && s.at(i+1) == '(' && right < 0){
      left += (-1 * right);
      right = 0; 
    }
  }
  if(s.at(n-1) == '(') right++; else right--;
  if(right < 0){
    left += (-1*right);
    right = 0;
  }
  while(right--){
    s.push_back(')');
  }
  string ans;
  while(left--){
    ans.push_back('(');
  }
  for(int i=0;i<s.size();i++){
    ans.push_back(s.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
s=input()
f=int(s[:2])
b=int(s[2:])
if 1<=f<=12 and 1<=b<=12:
  print('AMBIGUOUS')
  exit()
elif 1<=b<=12:
  print('YYMM')
  exit()
elif 1<=f<=12:
  print('MMYY')
  exit()
else:
  print('NA')
  exit()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll mod = 1000000007;

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

  int n;
  cin >> n;

  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  vector<int> v(n, 0);
  for (int i = 0; i < n / 2; i++) {
    v[i] = n - (i * 2 + 1);
    v[n - 1 - i] = n - (i * 2 + 1);
  }

  vector<int> count(n, 0);
  for (int i = 0; i < n; i++) {
    int ai = a[i];

    count[ai]++;
  }

  for (int i = 0; i < n; i++) {
    int vv = v[i];

    if (i == n / 2 && n % 2 != 0) {
      if (count[vv] == 1) continue;
    }

    if (count[vv] == 2) continue;

    cout << 0 << endl;
    return 0;
  }

  ll ans = 2;
  for (int i = 1; i < n / 2; i++) {
    ans *= 2;
    ans %= mod;
  }

  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define inf 10000000LL
#define fast_io	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
#define range 500005
#define lg 22
using namespace std;

int main()
{
	ll n;
	fast_io;
	cin>>n;
	
	ll A[n+1];
	ll x,max_=0,s=0;
	for(ll i=1;i<=n;i++)
	cin>>A[i];
	
	max_=A[1];
	for(ll i=2;i<=n;i++)
	{
		x=max(max_-A[i],0LL);
		s+=x;
		A[i]+=x;
		max_=max(max_,A[i]);
	}
	
	cout<<s<<endl;
}

Measured memory_bytes: 5180
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <math.h>
#include <map>
#include <set>
using namespace std;
int main ()
{
    int a,b,c;
    scanf("%i%i%i",&a,&b,&c);
    if(a==b && a!=c)	printf("Yes");
    else if(a==c && a!=b)	printf("Yes");
    else if(b==c && a!=b)	printf("Yes");
    else	printf("No");
	return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int MAX_N = 300010;
ll INF = 1LL<<60;
vector<vector<P>> edges(MAX_N);
vector<ll> dist(MAX_N,INF);

void dijkstra(int s) {
    priority_queue<P,vector<P>,greater<P>> que;
    dist[s] = 0;
    que.push(P(0,s));
 
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v =  p.second;
        if (dist[v] < p.first) continue;
        for (int i = 0;i < edges[v].size();++i) {
            P e = edges[v][i];
            if (dist[e.first] > dist[v]+e.second) {
                dist[e.first] = dist[v]+e.second;
                que.push(P(dist[e.first],e.first));
            }
        }
    }
}

int main() {
    int n,m;
    cin >> n >> m;
    for (int i = 0;i < m;++i) {
        int u,v;
        cin >> u >> v;
        u--;v--;
        for (int j = 0;j < 3;++j) edges[u*3+j].push_back(P(v*3+(j+1)%3,1));
    }
    int s,t;
    cin >> s >> t;
    s--;t--;
    dijkstra(s*3);
    cout << (dist[t*3] < INF ? dist[t*3]/3 : -1) << endl;
    return 0;
}

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

int main(){
  string n;
  cin >> n;
  string ans;
  for(int i=0; i<3; i++){
    if(n[i]=='1'){
      cout<< '9';
    }
    else{
      cout<<'1';
    }
  }

}

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

using namespace std;

int main()
{
    int n,k,a,c,sum=0;
    cin>>n>>k;
    multiset<int,greater<int>>s;
    for(a=0;a<n;a++)
    {
        cin>>c;
        s.insert(c);
        multiset<int>::iterator it=s.begin();
        sum+=c;
        if(s.size()>k)
        {
            s.erase(s.begin());
            sum-=*it;
        }

    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define sort_v(a) sort(a.begin(), a.end())

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

int main()
{
    double t, x;
    cin >> t >> x;
    cout << t / x << endl;
}


Measured memory_bytes: 256
package main

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

func getNextWord(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextWord(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)

	p := getNextInt(scanner)
	q := getNextInt(scanner)
	r := getNextInt(scanner)
	max := maxint(p, maxint(q, r))

	fmt.Fprintln(writer, p+q+r-max)

	writer.Flush()
}
func maxint(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    unordered_set<int> st;
    
    int cnt = 0;
    rep(i, n) {
        if (st.count(a[i])) {
            cnt++;
        } else {
            st.insert(a[i]);
        }
    }
    int ans = n - ((cnt+1)/2)*2;
    cout << ans << endl;
}

Measured memory_bytes: 4772
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    int n, a, b;
    cin >> n >> a >> b;
    int count = 0;
    int k;
    for (int i = 1; i <= n; i++){
        k = 0;
        k += (i%10)+(i/10%10)+(i/100%10)+(i/1000%10)+i/10000;
        if (k >= a && k <= b) count+=i;
    }
    cout << count << endl;
    return 0;
}


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

typedef struct node{
  vector<node *> nexts;
} node;

int count(node *e, node *bef, int length){
  int sum = 1;
  if(length > 0){
    vector<node *>::iterator it;
    for(it = e->nexts.begin(); it != e->nexts.end(); ++it){
      if((*it) != bef){
        sum += count((*it), e, length-1);
      }
    }
  }
  return sum;
}

int main(int argc, char *argv[]){
  int N, K;
  cin >> N >> K;
  int A[N-1];
  int B[N-1];
  node* e = new node[N];
  int i;
  int a, b;
  for(i=0; i<N-1; ++i){
    cin >> a >> b;
    A[i] = a-1;
    B[i] = b-1;
    e[a-1].nexts.push_back(&e[b-1]);
    e[b-1].nexts.push_back(&e[a-1]);
  }
  int ans;
  if(K%2 == 0){
    int ma = 0;
    for(i=0; i<N; ++i){
      ma = max(ma, count(&e[i], NULL, K/2));
    }
    ans = N - ma;
  }else{
    int ma = 0;
    for(i=0; i<N-1; ++i){
      ma = max( ma, count(&e[A[i]], &e[B[i]], (K-1)/2) + count(&e[B[i]], &e[A[i]], (K-1)/2) );
    }
    ans = N - ma;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
import math as m

def is_prime(num):
    for i in range(2, int(m.sqrt(num)) + 1):
         if num % i == 0: return False
    return True

N = int(input())

number_of_prime = 0

for _ in range(N):
    if is_prime(int(input())):
        number_of_prime += 1

print(number_of_prime)


Measured memory_bytes: 5676
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

ll N,M;

int main() {
  cin >> N >> M;
  vector<P> drinks(N);
  rep(i,N) cin >> drinks[i].first >> drinks[i].second;
  ll ans = 0;
  sort(drinks.begin(), drinks.end());
  rep(i,N) {
    if (M == 0) break;
    int buy = min(M, drinks[i].second);
    M-=buy;
    ans += buy*drinks[i].first;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 4808
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b,c;
	cin>>a>>b>>c;
	if(c>=a&&c<=b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var m, n int
	fmt.Scan(&m, &n)
	fmt.Println(pow(m, n))
}
func pow(m, n int) int {
	r := 1
	for n > 0 {
		if (n & 1) == 1 {
			r = r * m % 1000000007
		}
		m = m * m % 1000000007
		n = n >> uint(1)
	}
	return r
}



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

sys.setrecursionlimit(10000)

N = int(input())
import bisect

L = [1]
ans = 1
for i in range(N):
    A = int(input())
    res = bisect.bisect_right(L, -A)
    if res != ans:
        L[res] = -A
    else:
        L.append(-A)
        ans += 1
print(ans)

Measured memory_bytes: 7068
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
///


int main(){

    ll x,y,z;
    cin>>x>>y>>z;
    PC("%lld", (x *y)/2 );
    NL;


    return 0;
}

Measured memory_bytes: 256
count = 0 #お菓子を持っていない人数
N, K = map(int, input().split()) #N,Kの入力
#print(N, K)

array = [0] * N #要素が0のN人分の要素を持つ配列を用意
#print(array)

for b in range(1,K+1): #K個のお菓子分繰り返す
    a = int(input()) #お菓子bを計何人持っているか
    i = list(map(int, input().split())) #お菓子を持っている人の番号
    #print(i[0])
    for c in range(a):
        #print(a, array[i[c]])
        array[i[c]-1] = 1


for k in range(N):
    if array[k] == 0:
        count += 1
#print(array)
print(count)

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

int main() {
  int64_t a,b,n;
  cin>>a>>b>>n;

  int64_t ans;

  if(n>=b-1) {
    ans = a*(b-1)/b;
  }
  else {
    ans = a*n/b;
  }

  cout<<ans<<endl;

  return 0;
}

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

int main() {
    string n;
    cin >> n;
    int sum = 0;
    for (char i : n) {
        sum += i - '0';
    }
    if (sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3696
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define It it=se.begin();it!=se.end();it++
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(x) begin(x),end(x)
#define unmap unordered_map
#define pii pair<int,int>
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vi vector<int>
#define ld long double
#define ll long long
#define pb push_back
#define sh short int
#define mid (l+r)/2
#define S second
#define F first
using namespace std;
const int inf = 1e9+9;
const int mod = 1e9+7;
int n,m,k,mn = inf;
int a[19],c[19];
int b[19][19];
void solve(int mask){
    int ret = 0;
    for(int i=0;i<m;i++) c[i] = 0;
    for(int i=0;i<n;i++){
        if(mask&(1ll<<i)){
            for(int j=0;j<m;j++){
                c[j] += b[i][j];
            }
            ret += a[i];
        }
    }
    for(int i=0;i<m;i++){
        if(c[i] < k) return;
    }
    mn = min(mn,ret);
}
int main(){
    fast,cin>>n>>m>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
        for(int j=0;j<m;j++){
            cin>>b[i][j];
        }
    }
    for(int i=0;i<(1ll<<n);i++){
        solve(i);
    }
    if(mn == inf) cout<<"-1"<<endl;
    else cout<<mn<<endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

    int s = 0, t = 0;
    REP(i, 0, S.size()) {
        if (S[i] == 'S') {
            s++;
        } else {
            if (s > 0) s--;
            else t++;
        }
    }
    cout << s + t << endl;
    return 0;
}

Measured memory_bytes: 640
from collections import Counter

N = int(input())
As = list(map(int, input().split()))

def solve():
    if set(As) == {0}:
        print('Yes')
    elif N % 3:
        print('No')
    else:
        m = N//3
        cnt = Counter(As)
        vs = []
        for v in cnt.keys():
            if cnt[v] % m:
                print('No')
                return
            vs += [v] * (cnt[v]//m)
#        print(vs)
        A, B, C = vs
#        print(A, B, C)
        if A^B^C:
            print('No')
        else:
            print('Yes')

solve()


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

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

 rep(i,s.size()){
   s[i]='x';
 } 
  cout<<s<<endl;

  return 0;
}


Measured memory_bytes: 3632
N=int(input())
d=[0]*N;D=[0]*N
s=0
for i in range(N):
  d[i],D[i]=map(int,input().split())
  if d[i]==D[i]:s+=1
  else:s=0
  if s==3:
    print('Yes')
    exit()
    
print('No')

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

int main(void){
    
    char a;
    
    cin >> a;
    
    if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o') cout << "vowel" << endl;
    else cout << "consonant" << endl;
    
    return 0;

}

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

using ll = long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ s >> p.first >> p.second; return s;}

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

    rep(i, 5) {
        if (x[i] == 0) {
            cout << (i+1) << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

const int INF = 1<<29;

int n,m,a[60],b[60],c[60],d[60];
int func(int id) {
    int best = INF;
    int ans = -1;
    rep(i, 0, m) {
        int dist = abs(a[id] - c[i]) + abs(b[id] - d[i]);
        if (dist < best) {
            best = dist;
            ans = i;
        }
    }
    return ans + 1;
}

int main() {
    cin >> n >> m;
    rep(i, 0, n) {
        cin >> a[i] >> b[i];
    }
    rep(i, 0, m) {
        cin >> c[i] >> d[i];
    }
    rep(i, 0, n) {
        cout << func(i) << endl;
    }
}


Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())
    count = 0
    for i in range(n):
        d1, d2 = [int(x) for x in input().rstrip().split(" ")]
        if d1 == d2:
            count += 1
            if count >= 3:
                print("Yes")
                return
        else:
            count = 0

    print("No")


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61984
#include <bits/stdc++.h>
#define X first
#define Y second
#define LL long long
#define MP make_pair
#define PB push_back
#define SZ(a) (int)(a.size())
const int INF = 1000 * 1000 * 1000 + 47;
using namespace std;
int n;
int a[200005];
int b[200005];
int main()
{
	LL ans = 0;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	set<pair<int , int> > m;
	for(int i = 0; i < n; i++)
	{
		cin >> b[i];
		if(b[i] != a[i])
			m.insert({b[i] , i});
	}
	while(SZ(m))
	{
		auto p = *(--m.end());
		m.erase(--m.end());
		int val1 = b[(p.Y - 1 + n) % n];
		int val2 = b[(p.Y + 1) % n];
		int nxtVal = p.X % (val1 + val2);
		if(nxtVal == p.X)
		{
			cout << -1;
			return 0;
		}
		if(nxtVal <= a[p.Y])
		{
			if((a[p.Y] - nxtVal) % (val1 + val2))
			{
				cout << -1;
				return 0;
			}
			else
			{
				b[p.Y] = nxtVal;
				ans += (p.X - a[p.Y]) / (val1 + val2);
			}
		}
		else
		{
			b[p.Y] = nxtVal;
			ans += p.X / (val1 + val2);
			m.insert({nxtVal , p.Y});
		}
	}
	
	cout << ans;
}


Measured memory_bytes: 11136
import java.util.*;
import static java.lang.Math.*;

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

		// 入力
		int n = sc.nextInt();//
		ArrayList<Integer> list = new ArrayList<Integer>(); 
		for(int i = 0; i < n; i++){
			list.add(sc.nextInt());
		}

		Collections.sort(list);

		int sum = 0;
		for(int i = 0; i < n - 1; i++){
			sum = sum + list.get(i);
		}

		String result = "No";
		if(list.get(n - 1) < sum) result = "Yes";

		// 出力
		System.out.println(result);
	}

}




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

using namespace std;

static const int INF = 1e9 + 7;

void hawawa()
{
  long long x, y;
  cin >> x >> y;
  long ans;
  if ((x < 0 && 0 < y) || (0 < x && y < 0)) {
    ans = abs(abs(x) - abs(y)) + 1;
  } else if (x == 0) {
    ans = abs(y) + (y < 0);
  } else if (y == 0) {
    ans = abs(x) + (x > 0);
  } else if (x > y) {
    ans = abs(abs(x) - abs(y)) + 2;
  }  else {
    ans = abs(abs(x) - abs(y));
  }
  cout << ans << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  hawawa();
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod=998244353;
ll mod_conb[500005]={0};
ll npr[500005]={0},gyk[500005]={0};
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll ret=pow(x,y/2);
  ret*=ret;
  ret%=mod;
  if(y%2==1) ret*=x;
  ret%=mod;
  return ret;
}
int main(){
  ll n,a,b,k;
  cin>>n>>a>>b>>k;
  if(k==0){
    cout<<1<<endl;
    return 0;
  }
  npr[0]=1;
  npr[1]=n;
  for(ll i=1;i<n;i++) npr[i+1]=(npr[i]*(n-i))%mod;
  gyk[n]=pow(npr[n],mod-2)%mod;
  for(ll i=n;i>=1;i--) gyk[i-1]=(gyk[i]*i)%mod;
  for(ll i=0;i<=n;i++){
    mod_conb[i]=(npr[i]*gyk[i])%mod;
  }
  ll ans=0;
  for(ll i=0;i<=n;i++){
    if(a*i>k) continue;
    if((k-a*i)%b!=0) continue;
    ll j=(k-a*i)/b;
    if(j>n) continue;
    ans+=(mod_conb[i]*mod_conb[j])%mod;
    ans%=mod;
  }
  cout<<ans<<endl;
}


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

typedef long long ll;
const int MOD = 1e9 + 7;

const ll INF = 1e18;
const int MX = 2005;
ll dp[MX][MX];

inline void chmax(ll& a, ll b) {
  a = max(a, b);
}
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for(int i = 0; i < n+1; i++) {
    for(int j = 0; j < n+1; j++) {
      dp[i][j] = -INF;
    }
  }
  dp[0][0] = 0;
  vector<pair<int, int> > p;
  for(int i = 0; i < n; i++) {
    p.emplace_back(make_pair(a[i], i));
  }
  sort(p.rbegin(), p.rend());
  for(int i = 0; i < n; i++) {
    int pi = p[i].second;
    for(int l = 0; l < i+1; l++) {
      int r = i-l;
      chmax(dp[i+1][l+1], dp[i][l]+ll(pi-l)*a[pi]);
      chmax(dp[i+1][l], dp[i][l]+ll((n-r-1)-pi)*a[pi]);
    }
  }
  ll ans = 0;
  for(int i = 0; i < n+1; i++) { 
    chmax(ans, dp[n][i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 34964
#include<iostream>
#include<algorithm>
#include<set>
#include <string>

using namespace std;     //名前空間指定
std::string str;                //string型オブジェクト str　の宣言
set<string> anser;               //文字列クラスの宣言

int main(){
    int num;
    cin >> num;
    while (num>0) {
        num--;
        anser.clear(); //初期化
        cin >> str; //文字列の代入
        for(int i=1; i<(int)str.size(); i++){
            std::string a = str.substr(0,i);
            std::string b = str.substr(i);
            std::string c = a;
            std::string d = b;
            std::reverse(c.begin(), c.end());
            std::reverse(d.begin(), d.end());
            std::string t[4] = {a, c, b, d};
            for(int j=0; j<2; j++){
                for(int k=2; k<4; k++){
                    anser.insert(t[j] + t[k]);
                    anser.insert(t[k] + t[j]);
                }
            }
        }
        std:: cout<<anser.size()<<endl;
    }
}



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

int main(){
 int N;
 cin >> N;
 int K[N];
 int P[N];
 int win;

 for(int i=0; i<N; i++){
  cin >> K[i] >> P[i];
 }

 for(int i=0; i<N; i++){
  while(K[i]!=0){
   if(win==P[i]) win=0;
   win++;
   K[i]--;
  }
  cout << win << endl;
  win=0;
 }

 return 0;
}

Measured memory_bytes: 3100
def abc096_dx():
    n = int(input())
    primes = [2, 3]

    for num in range(5, 55555, 2):
        is_prime = True
        for i in range(1, len(primes)):
            if primes[i] ** 2 > num:
                break
            if num % primes[i] == 0:
                is_prime = False
                break
        if is_prime:
            primes.append(num)

    ans = []
    for num in primes:
        if num % 5 == 1:
            ans.append(str(num))
        if len(ans) == n:
            break
    return " ".join(ans)
print(abc096_dx())

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

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

	if ((s.at(0) == s.at(1)) && (s.at(2) == s.at(3) && (s.at(0) != s.at(2)))
		|| (s.at(0) == s.at(2)) && (s.at(1) == s.at(3) && (s.at(0) != s.at(1)))
		|| (s.at(0) == s.at(3)) && (s.at(1) == s.at(2)) && (s.at(0) != s.at(1)))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

string s;
int N;

int main(){
    cin >> s;
    N = s.size();

    vi bit(N+1,0);     // bit[i] : s[0,i)のビット表現
    for(int i=0;i<N;i++){
        char c = s[i] - 'a';
        bit[i+1] = bit[i] ^ (1<<c);
    }

    vi dp(N+1,INF);     // dp[i] : s[0,i)の最小分割数
    dp[0] = 0;

    vi low(1<<26,INF);  // low[i] : ビット状態がiになる最小分割数
    low[0] = 0;

    for(int i=0;i<N;i++){
        // use s[i]
        dp[i+1] = min(dp[i+1] , low[bit[i+1]]+1);
        for(int j=0;j<26;j++){
            int x = 1 << j;
            if(low[bit[i+1]^x] == INF) continue;
            dp[i+1] = min(dp[i+1] , low[bit[i+1] ^ x] + 1);
        }
        low[bit[i+1]] = min(low[bit[i+1]],dp[i+1]);
    }

    cout << dp[N] << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N+1);
  ll ans = 0;
  for(int i=1; i<=N; i++){
    cin >> A.at(i);
    if(A.at(i-1) > A.at(i)){
     ans += A.at(i-1) - A.at(i);
     A.at(i) = A.at(i-1);      
    }
    
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],s[200005],t;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    s[1]=1,t=1;
    for(int i=2;i<=n;i++)
	{
        if(a[i]<=a[s[t]]) s[++t]=i;
        else
		{
            int l=1,r=t;
            while(l<r)
			{
                int mid=(l+r)/2;
                if(a[s[mid]]<a[i]) r=mid;
                else l=mid+1;
            }
            s[l]=i;
        }
    }
    cout<<t;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n,m,l;
    cin >> n >> m >> l;
    int A[100][100]={};int B[100][100];long c[100][100]={};
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> A[i][j];
        }
    }
    for(int j=0;j<m;j++){
        for(int k=0;k<l;k++){
            cin >> B[j][k];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                c[i][j]+=A[i][k]*B[k][j];
            }
            cout << c[i][j];
            if(j!=l-1){
                cout << " ";
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3228
#include<iostream>


using namespace std;

int main() {
	char a, b;

	//入力
	cin >> a >> b;

	if (a == 'H') {
		//AtCoDeerくんは正直者
		if (b=='H') {
			//TopCoDeerくんは正直者
			cout << "H" << endl;
		}
		else if (b == 'D') {
			//TopCoDeerくんはうそつき
			cout << "D" << endl;
		}
	}
	else if (a == 'D') {
		//AtCoDeerくんはうそつき
		if (b == 'H') {
			//TopCoDeerくんは正直者
			cout << "D" << endl;
		}
		else if (b == 'D') {
			//TopCoDeerくんはうそつき
			cout << "H" << endl;
		}
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    
    public static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        ModLcm ml = new ModLcm((int)1e6+6);
        
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(sc.next());
            ml.lcm(a[i]);
        }
        
        int lcm = ml.getModLcm(MOD);
        //System.out.println(lcm);
        
        long ans = 0;
        for(int i=0; i<n; i++){
            long inv = ModLcm.mod_pow(a[i], MOD-2, MOD);
            ans += lcm * inv;
            ans %= MOD;
        }
        
        System.out.println(ans);
        
    }
    
}

class ModLcm{
    private int max;
    private int[] exponent;
    
    public ModLcm(int max){
        this.max = max;
        exponent = new int[max];
    }
    
    public void lcm(int n){
        while(n%2==0){
            int ex = 0;
            while(n%2==0){
                ex++;
                n /= 2;
            }
            exponent[2] = Math.max(exponent[2], ex);
        }
        for(int i=3; i*i<=n; i+=2){
            int ex = 0;
            while(n%i==0){
                ex++;
                n /= i;
            }
            exponent[i] = Math.max(exponent[i], ex);
        }
        if(n!=1){
            exponent[n] = Math.max(1, exponent[n]);
        }
    }
    
    public static long mod_pow(long x, long p, long m){
        long a = 1;
        while(p>0){
            if(p%2==1){
                a = a*x%m;
            }
            x = x*x%m;
            p /= 2;
        }
        return a;
    }
    
    public int getModLcm(int mod){
        long res = 1;
        for(int i=0; i<max; i++){
            if(exponent[i]==0){
                continue;
            }
            res *= mod_pow(i, exponent[i], mod);
            res %= mod;
        }
        return (int)res;
    }
}

Measured memory_bytes: 35520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define irep(i,a,b) for(typeof(i) i = (a); i < (b); ++i)
#define itrep(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)

vector<vector<int> > X(100001);
vector<int> C(100001, 100001);
vector<int> T(100001, -1);

void loop(int prv, int me, int cost) {
	if (cost + 1 >= C.at(me)) return;
	C.at(me) = cost + 1;
	T.at(me) = prv;
	vector<int>* s = &X.at(me);
	for (auto it = s->begin(); it != s->end(); it++) {
		if (*it != prv) {
			if (C.at(*it) > cost + 2) {
				loop(me, *it, cost + 1);
			}
		}
	}
	return;
}

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

	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		X.at(A - 1).push_back(B - 1);
		X.at(B - 1).push_back(A - 1);
	}

	C.at(0) = 0;
	T.at(0) = -1;
	int count = 1;
	int cost = 0;
	set<int> bag;
	set<int> nb;
	bag.insert(0);
	while (bag.size() > 0) {
		nb.clear();
		cost++;
		for (auto it = bag.begin(); it != bag.end(); it++) {
			for (auto jt = X[*it].begin(); jt != X[*it].end(); jt++) {
				if (C.at(*jt) > cost) {
					C.at(*jt) = cost;
					T.at(*jt) = *it;
					nb.insert(*jt);
				}
			}
		}
		bag.clear();
		bag = nb;
	}

	cout << "Yes" << endl;
	for (int i = 1; i < N; i++) {
		cout << T.at(i) + 1 << endl;
	}
}


Measured memory_bytes: 19676
def resolve():
    import sys
    from collections import deque
    input = sys.stdin.readline
    n,m = map(int,input().split())
    edge = [[] for i in range(n)]
    edgecnt=[0]*n
    ans=[0]*n
    for i in range(n+m-1):
        a,b= map(int,input().split())
        edge[a-1].append(b-1)
        edgecnt[b-1]+=1
    for i,j in enumerate(edgecnt):
        if j==0:
            ans[i]=-1
            chkedge=deque([i])
            break
    while chkedge:
        chk=chkedge.popleft()
        for i in edge[chk]:
            edgecnt[i]-=1
            if edgecnt[i]==0:
                ans[i]=chk
                chkedge.append(i)
    for i in ans:print(i+1)

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 58800
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;

int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	REP(i,n)cin>>a[i];
	sort(ALL(a));
	int ma=a[n-1];
	vector<P>b(n-1);
	REP(i,n-1){
		if(a[i]>=ma/2)b[i]=MP(ma-a[i],a[i]);
		else b[i]=MP(a[i],a[i]);
	}
	sort(ALL(b));
	cout<<ma<<" "<<b[n-2].second<<endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int x, n;
    cin >> x >> n;
    vector<int> v;
    for (int i=0; i<n; i++) {
        int p;
        cin >> p;
        v.push_back(p);
    }
    for (int i=0; i<100; i++) {
        if (find(v.begin(), v.end(), x - i) == v.end()) {
            cout << x - i << endl;
            return 0;
        } else if (find(v.begin(), v.end(), x + i) == v.end()) {
            cout << x + i << endl;
            return 0;
        }
    }
}

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

int next(int a, int b, int c, int x){
    return (a*x+b)%c;
}

int main(void){
    while(true){
         int n, a, b, c, x, ri[110];
        cin >> n >> a >> b >> c >> x;
        if((n+a+b+c+x)==0) break;
        for(int i=0;i<n;++i){
            cin >> ri[i];
        }
        int frame = 0, now=0;
        while(frame<=10000){
            if(ri[now]==x) ++now;
            if(now==n) break;
            x = next(a, b, c, x);
            ++frame;
        }
        if(frame<=10000) cout << frame << endl;
        else cout << "-1" << endl;
    }
}


Measured memory_bytes: 3028
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

f cs = [let s = replicate (arr!i) '*' in cond "-" s $ null s | i <- [0..9]]
  where
    arr = array (0,9) $ [(i,0) | i <- [0..9]] ++ (map (fnTuple (head, length)) . group . sort $ cs)


main = do
    n <- getInt
    unless (n==0) $ replicateM n getInt >>= mapM_ putStrLn . f >> main


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

const ll INF = 1001001001;

const double PI=3.141592653;

const ll sosu = 1000000007;//大きい素数

//提出のときに言語がc＋＋似合っていることを確認する

//絶対値の関数
int z(int a,int b){
  if(a>b) return a-b;
  else return b-a;
}

int main(){
   int n; cin>>n;
   int a=n%10;
   if(a==3){
     cout<<"bon"<<endl;
   }else if(a==0 || a==1 || a==6|| a==8){
     cout<<"pon"<<endl;
   }else{
     cout<<"hon"<<endl;
   }
   return 0;
}



Measured memory_bytes: 3600
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
int llup(const void *a, const void *b){return*(ll*)a>*(ll*)b?1:-1;}
int lldown(const void *a, const void *b){return *(ll*)a>*(ll*)b?-1:1;}

int N, M, Q, L[200200], R[200200], a[555][555] = {};
int main(){
	scanf("%d%d%d", &N, &M, &Q);
	for(int i=0; i<M; i++){
		scanf("%d%d", L+i, R+i);
		a[L[i]][R[i]]++;
	}
	for(int i=1; i<=N; i++){
		for(int j=i; j<=N; j++){
			a[i][j] += a[i][j-1];
		}
	}
	while(Q--){
		int p, q;
		scanf("%d%d", &p, &q);
		int sum = 0;
		for(int i=p; i<=q; i++)sum += a[i][q];
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 4360
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_D
{
    class D064
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();

            List<char> list = new List<char>();

            int counter = 0;
            for(int i = 0; i < N; i++)
            {
                char c = S[i];

                if (c == '(')
                {
                    list.Add(c);
                    counter++;
                }
                else
                {
                    if (counter > 0)
                    {
                        for(int k = list.Count - 1; k >= 0; k--)
                        {
                            if (list[k] == '(')
                            {
                                list[k] = '[';
                                counter--;
                                list.Add(']');
                                break;
                            }
                        }
                    }
                    else
                    {
                        list.Insert(0, '[');
                        list.Add(']');
                    }
                }
            }

            for(int i = 0; i < counter; i++)
            {
                list.Add(')');
            }

            string r = new string(list.ToArray()).Replace('[', '(').Replace(']', ')');
            Console.WriteLine(r);
        }

    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
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 main(){
	ll a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	if(v<=w){
		cout<<"NO"<<endl;
		return 0;
	}

	if((abs(b-a)+.0)/abs(v-w)<=t){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

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


void solve() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  map<string, int> mp;
  // 
  string in;
for (int i = 0; i < n; i++) {
    cin >> in;
      auto itr = mp.find(in);
      if (itr == mp.end()) {
          mp[in] = 0;
      } else {
          mp[in]++;
      }
  }
  // maxを知る
  int max_count = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
      max_count = max(max_count, itr->second);
  }
  // v == maxを出力
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
      if (max_count == itr->second) {
          cout << itr->first << endl;
      }

  }


}

int main() {
  solve();
}


Measured memory_bytes: 23808
#include<stdio.h>
int main(void)
{
	double n,a,p=0,i;
	scanf("%lf", &n);
	for(i=0; i<n; i++)
	{
		scanf("%lf", &a);
		p+=1.0/a;
	}
	printf("%f\n", 1.0/p);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,m) for(int i=(n);i<(m);i++)
int main(){
  int N;
  cin>>N;
  int A[N];
  rep(i,0,N) cin>>A[i];
  int ans;
  sort(A,A+N);
  rep(i,A[0],A[N-1]+1){
    int cost=0;
    rep(j,0,N) cost+=(A[j]-i)*(A[j]-i);
    if(i==A[0]) ans=cost;
    else if(cost<ans) ans=cost;
  }
  cout<<ans<<endl;   
}

Measured memory_bytes: 256
// Author : ps41

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

Measured memory_bytes: 6704
# B - Shiritori

N = int(input())
W = []
for i in range(N):
    W.append(str(input()))

word = set()
word.add(W[0])
ans = 'Yes'
for i in range(1, N):
    if W[i] in word:
        ans = 'No'
        break
    if W[i-1][-1] != W[i][0]:
        ans = 'No'
        break
    word.add(W[i])

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, X, Y; cin >> N >> X >> Y;
  vector<int> cs(N); for (int i = 1; N - i > 0; ++i) cs[i] = N - i;
  for (int i = 1; i < N; ++i) for (int j = i + 1; j <= N; ++j)
    if (j - i > abs(X - i) + 1 + abs(Y - j)) {--cs[j - i]; ++cs[abs(X - i) + 1 + abs(Y - j)];}
  for (int k = 1; k < N; ++k) cout << cs[k] << endl;}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d" , &a,&op,&b);
        if (op == '+'){
            printf("%d\n",a+b);
        }else if (op == '-'){
            printf("%d\n",a-b);
        }else if (op == '*'){
            printf("%d\n",a*b);
        }else if (op == '/'){
            printf("%d\n",a/b);
        }else if (op == '?'){
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <map>
#include <utility>
#include <vector>
#include <queue>
#include <climits>

using namespace std;

typedef struct {
    int from, to;
    int cost;
} edge;

int main() {
    while (true) {
        int b_goal[2];
        int n_bases, n_roads, b_start;
        cin >> n_bases >> n_roads >> b_start >> b_goal[0] >> b_goal[1];

        if (n_bases == 0) break;

        map< int, vector<edge> > edges;
        map< int, vector<edge> > redges;

        while (n_roads--) {
            int b_from, b_to, cost;
            cin >> b_from >> b_to >> cost;
            edge e = { b_from, b_to, cost };
            edges[b_from].push_back(e);
            redges[b_to].push_back(e);
        }

        map<int, int> cost_from_start;
        for (int b = 1; b <= n_bases; ++b) {
            cost_from_start[b] = INT_MAX;
        }

        queue<edge> q;

        {
            vector<edge> ee = edges[b_start];
            for (size_t i = 0; i < ee.size(); ++i) {
                q.push(ee[i]);
            }
        }

        cost_from_start[b_start] = 0;
        for (; !q.empty(); q.pop()) {
            edge e = q.front();

            int new_cost = cost_from_start[e.from] == INT_MAX ? INT_MAX : cost_from_start[e.from] + e.cost;
            if (new_cost < cost_from_start[e.to]) {
                cost_from_start[e.to] = new_cost;

                vector<edge> ee = edges[e.to];
                for (size_t i = 0; i < ee.size(); ++i) {
                    q.push(ee[i]);
                }
            }
        }

        map<int, vector<int> > costs_from_goal;
        for (int b = 1; b <= n_bases; ++b) {
            costs_from_goal[b] = vector<int>(2, INT_MAX);
        }

        for (int I = 0; I <= 1; I++) {
            vector<edge> ee = redges[b_goal[I]];
            for (size_t i = 0; i < ee.size(); ++i) {
                q.push(ee[i]);
            }

            costs_from_goal[b_goal[I]][I] = 0;
            for (; !q.empty(); q.pop()) {
                edge e = q.front();

                int new_cost = costs_from_goal[e.to][I] == INT_MAX ? INT_MAX : costs_from_goal[e.to][I] + e.cost;
                if (new_cost < costs_from_goal[e.from][I]) {
                    costs_from_goal[e.from][I] = new_cost;

                    vector<edge> ee = redges[e.from];
                    for (size_t i = 0; i < ee.size(); ++i) {
                        q.push(ee[i]);
                    }
                }
            }
        }

        int min = INT_MAX;
        for (int b = 1; b <= n_bases; ++b) {
            if (cost_from_start[b] == INT_MAX) continue;
            if (costs_from_goal[b][0] == INT_MAX) continue;
            if (costs_from_goal[b][1] == INT_MAX) continue;

            int v = cost_from_start[b] + costs_from_goal[b][0] + costs_from_goal[b][1];
            if (v < min) {
                min = v;
            }
        }
        cout << min << endl;
    }
}

Measured memory_bytes: 3200
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int x,y,exe_time=0,exe_e=0,exe_s=0,num=1;
        x=sc.nextInt();
        y=sc.nextInt();
        for(int a=0;a<y;a++){
            num = num*2;
        }
        exe_e = 1900*y*num;
        exe_s = 100*(x-y);
        exe_s = exe_s*num;
        exe_time = (exe_s+exe_e);
        System.out.println(exe_time);
    }
}


Measured memory_bytes: 21844