akhauriyash/Code-Regression huggingface dataset:
gets
arr = gets.chomp.split(" ").map(&:to_i)
odd_count = arr.count(&:odd?)
return puts "Yes" if odd_count.size == 0

count_4 = arr.count { |n| n % 4 == 0 }
if odd_count <= arr.size / 2
  puts count_4 >= odd_count ? "Yes" : "No"
elsif arr.size.even?
  puts "No"
elsif odd_count == (arr.size / 2 + 1)
  puts "Yes"
else
  puts "No"
end

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

int main(){
  int h, w, m;
  cin >> h >> w >> m;
  vector<int> hcnt(h, 0), wcnt(w, 0);
  vector<vector<int>> bomb(h);
  int a, b;
  for(int i=0; i<m; ++i){
    cin >> a >> b;
    --a; --b;
    bomb[a].push_back(b);
    ++hcnt[a];
    ++wcnt[b];
  }
  for(int i=0; i<h; ++i) sort(bomb[i].begin(),bomb[i].end());
  vector<int> hi(0), wi(0);
  int hmaxnum = 1;
  for(int i=0; i<h; ++i){
    if(hcnt[i] == hmaxnum) hi.push_back(i);
    else if(hcnt[i] < hmaxnum) continue;
    else{
      hmaxnum = hcnt[i];
      hi = {i};
    }
  }
  int wmaxnum = 1;
  for(int i=0; i<w; ++i){
    if(wcnt[i] == wmaxnum) wi.push_back(i);
    else if(wcnt[i] < wmaxnum) continue;
    else{
      wmaxnum = wcnt[i];
      wi = {i};
    }
  }
  for(int ha:hi) for(int wa:wi){
    auto it = lower_bound(bomb[ha].begin(),bomb[ha].end(),wa);
    if(*it != wa){
      cout << hmaxnum +wmaxnum << endl;
      return 0;
    }
  }
  cout << hmaxnum +wmaxnum -1 << endl;
  return 0;
}

Measured memory_bytes: 26184
import java.util.Scanner

import scala.collection.mutable

object Main extends App {
  val sc = new Scanner(System.in)
  val (n, m) = (sc.nextInt(), sc.nextInt())
  val routes = (1 to m).map { _ => (sc.nextInt(), sc.nextInt()) }

  val table = buildTable(n, routes)
  val result = mutable.ArrayBuffer.fill(n + 1)(0)
  val nextRooms = mutable.Queue(1)
  while(nextRooms.nonEmpty) {
    val room = nextRooms.dequeue()
    table(room).foreach { nextRoom =>
      if(result(nextRoom) == 0) {
        result(nextRoom) = room
        nextRooms += nextRoom
      }
    }
  }

  println("Yes")
  (2 to n).foreach { room => println(result(room)) }

  def buildTable(n: Int, routes: Seq[(Int, Int)]): mutable.ArrayBuffer[List[Int]] = {
    val builder = mutable.ArrayBuffer.fill[List[Int]](n + 1)(Nil)
    routes.foreach { case(x, y) =>
      builder(x) +:= y
      builder(y) +:= x
    }
    builder
  }
}


Measured memory_bytes: 93008
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include<iomanip>
#include<tuple>
#include<functional>
using namespace std;
typedef long long unsigned int ll;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
    int n;
    cin>>n;
    int x;
    int cnt1[100003];
    int cnt2[100003];
    int mx1,mx2,x1,x2;
   fill(cnt1,cnt1+100003,0);
   fill(cnt2,cnt2+100003,0);
    for(int i=0;i<n;i++){
        cin>>x;
    
        if(i%2==0){
        cnt1[x]++;
        if (mx1<cnt1[x]){
            mx1=cnt1[x];
            x1=x;
        }
        }
        else{
           cnt2[x]++; 
           if (mx2<cnt2[x]){
            mx2=cnt2[x];
            x2=x;

        }

    }
    }
    sort(cnt1,cnt1+100003);
    sort(cnt2,cnt2+100003);

    if(x1!=x2){
        cout<<n-mx1-mx2<<endl;
    }
    else{
        cout<<n-max(mx1+cnt2[100001],mx2+cnt1[100001])<<endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  ll n;
  cin >> n;
  ll sum = 0;
  for(ll i = 1; i <= n; i++) {
    if(i%3 != 0 && i%5 != 0) sum += i;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl;
  for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
  int N, k;
  cin >> N >> k;
  vector<int> x(N);
  for(int i=0; i<N; i++) cin >> x[i];

  // vector<int> anses;
  // const int INF =  2e8+1;
  const int INF = 1e8 + 1e8 + 1e8 + 1;//
  int ans = INF;
  for(int i=0; i<N; i++){
    if(i+k-1 >= N) break;
    int sx = x[i];
    int gx = x[i+k-1];
    if(sx < 0 && gx < 0) ans = min(ans, -sx);
    else if(sx >= 0  &&  gx >= 0) ans = min(ans, gx);
    else if(sx <= 0 && 0 <= gx){
      int tmp = min(2*(-sx) + gx,  -sx + 2*gx);
      ans = min(ans, tmp);
    }
  }

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


Measured memory_bytes: 3700
S = [str(s) for s in input()]

A = []

for x in range(len(S)):
    if x % 2 == 0:
        if S[x] in ['R', 'U', 'D']:
            A.append('Yes')
        else:
            A.append('No')
    elif x % 2 == 1:
        if S[x] in ['L', 'U', 'D']:
            A.append('Yes')
        else:
            A.append('No')

# print(A)

if 'No' not in A:
    print('Yes')
else:
    print('No')

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

N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A)
max_num = B[len(A)-1]

for i in range(len(A)):
  if A[i] == max_num:
    print(B[len(A)-2])
  else:
    print(max_num)
  


Measured memory_bytes: 14112
/**
 *    author:  RM07
 *    created: August 15, 2020 5:31 PM
 *    motto: Knowledge is Power, Strive for Excellence
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long 
signed main(){
    string str;
    cin >> str;
    int n = str.length();
    int currLength = 0;
    int maxLength = 0;
    for(int i = 0 ; i < n ; i++){
        if(str[i] == 'S') {
            currLength = 0;
        } else {
            currLength++;
            if(currLength > maxLength){
                maxLength = currLength;
            }            
        }
    }
    cout << maxLength << endl;
}

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

int main()
{
  int n;
  int d=0;
  cin >> n;
  string s;
  cin >> s;
  for (int i=0;i<n-1;i++)
    if (s[i]=='A')
      if (s[i+1]=='B')
        if (s[i+2]=='C')
          d++;
  cout << d;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;

ll arr[300005];
bool decreasing (ll a, ll b){
    if (a > b)
        return true;
    else
        return false;
}
int main()
{
    ll n;
    cin >> n;
    ll g = 3*n;
    
    for (ll i = 1; i<= g; i++){
        cin >> arr[i];
    }
    
    sort(arr+1, arr+g+1, decreasing);
    int cntr = 0;
    ll total = 0;
    for (ll i = 1; i<= g; i++){
        if (cntr == n)
            break;
        
        if (i%2==0){
            cntr++;
            total = total + arr[i];
        }
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a < b) {
            if (b < c) {
                System.out.printf("%d %d %d\n", a, b, c);
            } else if (a < c) {
                System.out.printf("%d %d %d\n", a, c, b);
            } else {
                System.out.printf("%d %d %d\n", c, a, b);
            }
        } else {
            if (a < c) {
                System.out.printf("%d %d %d\n", b, a, c);
            } else if (b < c) {
                System.out.printf("%d %d %d\n", b, c, a);
            } else {
                System.out.printf("%d %d %d\n", c, b, a);
            }
        }
    }
}



Measured memory_bytes: 26420
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int MOD = 1e9 + 7;
const int MAXN = 401;
int f[MAXN][MAXN] , dp[MAXN][MAXN] , way[MAXN][MAXN];
int a[MAXN] , b[MAXN] , n , c;
void init(){
	for(int i = 1 ; i <= 400 ; ++ i)
		f[i][0] = 1;
	for(int i = 1 ; i <= 400 ; ++ i)
		for(int j = 1 ; j <= 400 ; ++ j)
			f[i][j] = 1ll * i * f[i][j - 1] % MOD;
	for(int i = 1 ; i <= 400 ; ++ i)
		for(int j = 0 ; j <= 400 ; ++ j)
			f[i][j] = (f[i - 1][j] + f[i][j]) % MOD;
}
int main(){
	init();
	cin >> n >> c;
	for(int i = 1 ; i <= n ; ++ i)
		cin >> a[i];
	for(int i = 1 ; i <= n ; ++ i)
		cin >> b[i];
	dp[0][0] = 1;
	for(int i = 1 ; i <= n ; ++ i)
		for(int j = 0 ; j <= c ; ++ j)
			for(int k = 0 ; k <= j ; ++ k)
				dp[i][j] = (1ll * dp[i - 1][k] * (f[b[i]][j - k] - f[a[i] - 1][j - k] + MOD) + dp[i][j]) % MOD;
	cout << dp[n][c] << endl;		
	return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<string.h>
#include<bits/stdc++.h>
using namespace std;
int ab(int a)
{
    if(a<0)
        return -a;
    return a;
}
int dis(int a,int b,int c,int d)
{
    return ab(a-c)+ab(b-d);
}
int main()
{
    int n;
    int m;
    scanf("%d %d",&n,&m);
    int a[n],b[n],c[m],d[m];
    for(int i=0;i<n;i++)
        scanf("%d %d",a+i,b+i);
    for(int i=0;i<m;i++)
        scanf("%d %d",c+i,d+i);
    for(int i=0;i<n;i++)
    {
        int sr[m];
        for(int j=0;j<m;j++)
            sr[j]=dis(a[i],b[i],c[j],d[j]);
        int mini=sr[0];
        for(int j=1;j<m;j++)
            if(mini>sr[j])
            mini=sr[j];
        for(int j=0;j<m;j++)
            if(sr[j]==mini)
        {
            printf("%d\n",j+1);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))

if M == 0:
    print(0, 0)
    exit(0)

P, S = [], []
solved = set({})
counter = {i: 0 for i in range(1, N + 1)}
value1 = 0
value2 = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)
    P.append(p)
    S.append(s)

    if p in solved:
        continue

    if s == 'AC':
        solved.add(p)
        value1 += 1
        value2 += counter[p]

    else:
        counter[p] += 1

print(value1, value2)

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

int main(){
	int n,i=0; cin>>n;
	if(n>=1&&n<4){
		cout<<1<<endl;
		return 0;
	}
	else if(n==4){
		cout<<4<<endl;
		return 0;
	}
	for(i;i<n/2;i++){
		if(i*i>n)break;
	}
	cout<<(i-1)*(i-1)<<endl;
	return 0;
}

Measured memory_bytes: 256
import heapq
import math
import sys

input = sys.stdin.readline


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

    def C(m):
        cnt = 0
        for i in range(N):
            cnt += math.ceil(A[i]/m)-1
        return cnt

    l, r = 0, max(A)
    while r - l > 1:
        mid = (l+r)//2
        if C(mid) <= K:
            r = mid
        else:
            l = mid
    
    print(r)

if __name__ == "__main__":
    main()




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

int main(){
    int K,A,B,count;

    cin >> K >> A >> B;

    for(int i=A;i<=B;i++){
        if(i%K==0){
            count++;
        }
    }

    if(count!=0){
        cout << "OK" << endl;
    }

    else{
        cout << "NG" << endl;
    }



}

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

int main() {
	
	int n;
	cin >> n;
	vector<vector<int>> e(n,vector<int>());
	vector<int>dist(n,-1);
	queue<int> que;
	for(int i=0; i<n; i++){
		int u,k;
		cin >> u >> k;
		for(int j=0; j<k; j++){
			int a;
			cin >> a;
			a--;
			e.at(i).push_back(a);
		}
	}
	que.push(0);
	dist.at(0) = 0;
	while(!que.empty()){
		int v = que.front();
		que.pop();
		for(auto nv:e.at(v)){
			if(dist.at(nv)!=-1) continue;
			dist.at(nv) = dist.at(v)+1;
			que.push(nv);
		}
	}
	for(int i=0; i<n; i++){
		cout << i+1 << ' ' << dist.at(i) << endl;
	}
	
	
}


Measured memory_bytes: 3184
#include<stdio.h>

int main(void)
{
  char str[27] = {0};
  char c;
  int flag = 1;//真偽値的な
  int cnt = 0;//一つのアルファベットがstrに含まれる回数
  int i = 0;//配列のインデックスを動かす

  scanf("%s", str);

  for(c = 'a'; c <= 'z'; c++){
    while(str[i] != '\0'){
      if(str[i] == c){
        cnt++;
      }
      i++;
    }
    //同じ文字が2回以上出てきたらnoなので
    if(cnt > 1){
      flag = 0;
      break;
    }
    cnt = 0;
    i = 0;
  }

  if(flag == 1){
    printf("yes\n");
  }else{
    printf("no\n");
  }

  return 0;
}


Measured memory_bytes: 128
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 998244353
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 202000;
int n,k,l[MAXN],r[MAXN],dp[MAXN];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n >> k;
  for(int i=1;i<=k;i++){
    cin >> l[i] >> r[i];
  }
  dp[1]=1;
  dp[2]=(mod-dp[1])%mod;
  for(int i=1;i<=n;i++){
    dp[i] = (dp[i]+dp[i-1]+mod)%mod;
    // cerr << dp[i] << endl;
    for(int j=1;j<=k;j++){
      int x = i+l[j];
      if(x>n)continue;
      int y = min(n,i+r[j]);
      dp[x] = (dp[x]+dp[i]+mod)%mod;
      dp[y+1] = (dp[y+1]-dp[i]+mod)%mod;
    }
  }
  cout << dp[n] << endl;


return 0;
}
///....


Measured memory_bytes: 5204
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

const ll INF=10000000000;

int main(){
    ll n;
    cin>>n;
    lvec a(n);
    rep(i,n) cin>>a[i];
    lvec s(n+1,0);
    for(int i=0;i<n;i++) s[i+1]=s[i]+a[i];
    ll ans=INF;
    for(int i=1;i<n;i++){
        if(abs(s[i]-(s[n]-s[i]))<ans) ans=abs(s[i]-(s[n]-s[i]));
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main(){
   long long A,V;
   long long B,W;
   cin >> A >> V >> B >> W;
   long long T;
   cin >> T;
   if( V <= W ) {
      cout << "NO" << endl;
      return 0;
   }
   int U = V-W;
   if( U*T >= abs(B-A) ){
      cout << "YES" <<endl;
   }
   else
      cout << "NO" << endl;
   return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int ans = k;
		for(int i = 0; i < n-1; i++) {
			ans *= (k-1);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

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

signed main()
{
  int N, a, b;
  cin >> N >> a >> b;

  i64 ans = 0;
  for (int i = 1; i <= N; ++i) {
    int hoge = f(i);
    if (a <= hoge && hoge <= b) ans += i;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  priority_queue<int> p;
  for(int i=0; i<n; i++){
    int tmp;
    cin >> tmp;
    p.push(tmp);
  }
  for(int i=0; i<m; i++){
    int tmp=p.top();
    p.pop();
    p.push(tmp/2);
  }
  long long int ans = 0;
  while(!p.empty()){
    ans += p.top();
    p.pop();
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 892
#include <stdio.h>

int main(void)
{
    int A,B;
    scanf("%d\n%d",&A,&B);
    int C=abs(A-B);
    int D=16-A-B;
    if(D-C<2&&C!=0){
    	printf(":(\n");
    	}else{
    		printf("Yay!\n");
    	}
	return 0;
}

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

void printVector(vector<int> &v) {
	for (auto x: v)
		cout << x << " ";
	cout << endl;
}

int main() {

	IOS

	int n, k, c;
	cin >> n >> k >> c;

	string s;
	cin >> s;

	vector<int> earliest, latest;

	for (int i = 0; i < n && earliest.size() < k; i++) {
		if (s[i] == 'o') {
			earliest.push_back(i);
			i += c;
		}
	}

	if (earliest.size() == k) {

		for (int i = n-1; i >= 0 && latest.size() < k; i--) {
			if (s[i] == 'o') {
				latest.push_back(i);
				i -= c;
			}
		}

		if (latest.size() == k) {
			reverse(latest.begin(), latest.end());

			for (int i = 0; i < k; i++)
			if (latest[i] == earliest[i])
				cout << earliest[i]+1 << endl;
		}
	}

	return 0;
}

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

int main() {
	int a,b,c;
	cin >> a >>b >>c;

	if(a==b)
		{ if (a==c)
     			{cout << "1" ;}
  		else{cout << "2";}
	}
	else
		{ if (a==c)
   			{cout << "2" ;}
 		else if (b==c)
 			 {cout << "2";}
		else{cout << "3" ;}
	}

	return 0;
}

Measured memory_bytes: 256
def binary_search(t,S):
  start = 0
  end = len(S)-1
  flag = False
  while start <= end:
    mid = (start + end) //2
    if t == S[mid]:
      flag = True
      break
    elif t < S[mid]:
      end = mid -1
    else:
      start = mid + 1
  if flag:
    return True
  else:
    return False

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

ans = 0
for t in T:
  if binary_search(t, S):
    ans += 1
print(ans)


Measured memory_bytes: 16716
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	unsigned long long a;
	double b;
	cin>> a >>b;
    b += 0.001;
	unsigned long long c = (unsigned long long)(100*b)*a/100;
	cout<< c <<endl;
}

Measured memory_bytes: 3740
n = int(input())
a = list(map(int, input().split()))
b = [0]*(10**5+3)
c = [0]*(10**5+3)
for i in range(n):
  if i%2==0:
    b[a[i]]+=1
  else:
    c[a[i]]+=1
bm=max(b)
cm=max(c)
if b.index(max(b))==c.index(max(c)):
  b[b.index(max(b))]=0
  c[c.index(max(c))]=0
  bm2=max(b)
  cm2=max(c)
  print(min(n-bm-cm2,n-cm-bm2))
else:
  print(n-bm-cm)

Measured memory_bytes: 85600
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char s[200000];
int main(){
	scanf("%s",&s);
	//a=(char)s;
	printf("%c",s[0]);
	scanf("%s",&s);
//	a=(char)s;
	printf("%c",s[0]);
	scanf("%s",&s);
//	a=(char)s;
	printf("%c",s[0]);
	return 0;
}

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

using namespace std;
int n,m,k,i,j,x,y,a[500005],nr[500005];
int tree[2000005];
vector<int>q[500005];
struct queries{
int l,r,poz,sol;
}v[500005];
bool cmp1(queries a,queries b)
{
    return a.l<b.l;
}
bool cmp2(queries a,queries b)
{
    return a.poz<b.poz;
}
void update(int nod,int st,int dr,int poz)
{
    if(st==dr)
        tree[nod]=1;
    else{
        int mij=(st+dr)>>1;
        if(poz<=mij)update(2*nod,st,mij,poz);
        else update(2*nod+1,mij+1,dr,poz);
        tree[nod]=tree[2*nod]+tree[2*nod+1];
    }
}
int query(int nod,int st,int dr,int l,int r)
{
    if(l<=st&&dr<=r)
        return tree[nod];
    else {
        int mij=(st+dr)>>1,x1=0,x2=0;
        if(l<=mij)x1=query(2*nod,st,mij,l,r);
        if(mij<r)x2=query(2*nod+1,mij+1,dr,l,r);
        return x1+x2;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    for(i=1;i<=n;i++)
        {
            cin>>a[i];
            if(q[a[i]].size()==0)
                update(1,1,n,i);
            q[a[i]].push_back(i);

        }
    for(i=1;i<=m;i++)
    {
         cin>>v[i].l>>v[i].r;
         v[i].poz=i;
    }
    sort(v+1,v+m+1,cmp1);
    j=1;
    for(i=1;i<=m;i++)
    {
        while(j<v[i].l)
        {
            nr[a[j]]++;
            if(!q[a[j]].empty())
                update(1,1,n,q[a[j]][nr[a[j]]]);
            j++;
        }
        v[i].sol=query(1,1,n,v[i].l,v[i].r);
    }
    sort(v+1,v+m+1,cmp2);
    for(i=1;i<=m;i++)
        cout<<v[i].sol<<'\n';
    return 0;
}


Measured memory_bytes: 47044
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main() {
	char s[4], ans=0,j=0;
	for (int i = 0; i < 4; i++) {
		cin >> s[i];
	}
	for (int i = 1; i < 4; i++) {
		if (s[i] == s[j]) {
			ans = 1;	
			break;
		}
		j++;
	}
	if (ans == 1) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}
	return 0;
}

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

using namespace std;

int main(void){
	
	double weight[]={48,51,54,57,60,64,69,75,81,91};
	double n;
	string name[11]={"light fly",
					 "fly",
					 "bantam",
					 "feather",
					 "light",
					 "light welter",
					 "welter",
					 "light middle",
					 "middle",
					 "light heavy",
					 "heavy"};

	while(scanf("%lf",&n)!=EOF){
		
		if(n<=weight[0]){
			cout<<name[0]<<endl;
		}
		else if(weight[9]<n){
			cout<<name[10]<<endl;
		}
		else{
			for(int i=0;i<sizeof(weight)-1;i++){
				if(weight[i]<n && n<=weight[i+1]){
					cout<<name[i+1]<<endl;
					break;
				}					
			}
		}
	}
}

Measured memory_bytes: 0
inf = float('inf')

n = int(input())
h = list(map(int, input().split()))

dp = [inf] * n
dp[0] = 0

for i in range(n):
    for j in 2, 1:
        if i + j < n:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))

print(dp[n - 1])


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

int main() {
    vector<vector<int>> c(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) cin >> c[i][j];
    }
    for (int i = 1; i < 3; i++) {
        for (int j = 1; j < 3; j++) {
            if ((c[0][j-1] - c[0][j]) != (c[i][j-1] - c[i][j])) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    for (int i = 1; i < 3; i++) {
        for (int j = 1; j < 3; j++) {
            if ((c[j-1][0] - c[j][0]) != (c[j-1][i] - c[j][i])) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
 	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,M;
int a[305][305],ans;
int cnt[305],pos[305];
bool vis[305];
void Solve() {
    read(N);read(M);
    for(int i = 1 ; i <= N ; ++i) {
	for(int j = 1 ; j <= M ; ++j) {
	    read(a[i][j]);
	}
    }
    for(int i = 1 ; i <= N ; ++i) {cnt[a[i][1]]++;pos[i] = 1;}
    for(int i = 1 ; i <= M ; ++i) ans = max(ans,cnt[i]);
    for(int k = 1 ; k < M ; ++k) {
	int t = 1;
	for(int j = 1 ; j <= M ; ++j) {
	    if(cnt[j] > cnt[t]) t = j;
	}
	vis[t] = 1;
	for(int i = 1 ; i <= N ; ++i) {
	    cnt[a[i][pos[i]]]--;
	    while(vis[a[i][pos[i]]]) {++pos[i];}
	    cnt[a[i][pos[i]]]++;
	}
	int tmp = 0;
	for(int j = 1 ; j <= M ; ++j) {
	    tmp = max(tmp,cnt[j]);
	}
	ans = min(ans,tmp);
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 640
/*---------------Go Code GO---------------*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using Order_Set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff


long long N,M, solved;
long long penalty[100005], totalpenalty;
bitset<100005> AC;

int main()
{
    O_O;
    long long i,j,k,l,tst=0,ans=0, csno=0;
    string verdict;
    cin>>N>>M;
    while(M--)
    {
        cin>>k>>verdict;
        if(verdict=="WA"&&AC[k]==0) penalty[k]++;
        else if(verdict=="AC"&&AC[k]==0) AC[k]=1, solved++, totalpenalty+=penalty[k];
    }
    cout<<solved<<' '<<totalpenalty<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
# define    all(a)              a.begin(), a.end()
#define forn(i, a, b) for (int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define MOD int(1e9+7)
using namespace std;

typedef long long int ll;

bool cmp(int a, int b) {
    return a < b;
}

void printV(vector<int> nums) {
    for (int i: nums) {
        printf("%d ", i);// << " ";
    }
    printf("\n");
}

// void printV(vector<ll> nums) {
//     for (ll i: nums) {
//         printf("%lld ", i);// << " ";
//     }
//     printf("\n");
// }



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

bool valid(int i, int j, int n, int m) {
    if (i >= 0 && i < n && j >=0 && j < m)
        return true;
    else 
        return false;
}


int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    // ios_base::sync_with_stdio(false);
    // cin.tie(0);cout.tie(0);
    // time_t start, end;
    // time(&start);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int mx = 0, cnt = 0;
    for (char c: s) {
        if (c == 'I')
            cnt++;
        else
            cnt--;
        mx = max(mx, cnt);
    }
    cout << mx << endl;
    // time(&end); 
    // double time_taken = double(end - start);
    // cout << "Time Taken: " << fixed << time_taken << setprecision(5);
    // cout << " sec" << endl;
    return 0;
}      

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define mset(x) memset(x, 0, sizeof(x))
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s;
    cin >> s;
    size_t i;
    rep(i, s.size()) {
        if (i % 2 == 0) {
            if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define int long long
#define vin vector<int>
#define vcn vector<char>
#define ver pair<int,int>
#define pb push_back
#define ld long double
#define x first
#define y second
#define blush fflush(stdout);fflush(stdin);
#define $(a) (int)a.size()
#define scanf oshibka();
#define printf oshibka(); 
using namespace std;
void oshibka(string s="classic/pleasantly oshibka", vin v={})
{cout<<s<<'\n';for(int i=0;i<$(v);i++)cout<<v[i]<<' ';exit(0);}
void i_love_misaka_mikoto();
main(){
    #ifdef RNS
        freopen("input.txt","r",stdin);
        #ifndef DBG
            freopen("output.txt","w",stdout);
        #endif
    #else
        ios_base::sync_with_stdio(false);
    #endif
    i_love_misaka_mikoto();
    #ifdef RNS
        cout<<'\n'<<(ld)clock()/CLOCKS_PER_SEC<<'\n';
    #endif
}


void i_love_misaka_mikoto(){
    int n,t;
    cin>>n>>t;
    cout<<fixed<<setprecision(10)<<(ld)n/t;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 4e18L + 1;
const int IINF = 2e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) ;
#define cerr if(0)cout
#endif

const ll N = 2e5, M = 1e9;

pair<ll, ll> start, fin;
ll n;

vector<pair<ll, ll> >fountains;

void sw(ll& x){ x = M - x;}

ld pi = acos(-1);

int main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    cout << setprecision(15) << fixed;
    cin >> start.ft >> start.sd >> fin.ft >> fin.sd;
    bool sw_x = start.ft > fin.ft, sw_y = start.sd > fin.sd;
    if(sw_x){
        sw(start.ft);
        sw(fin.ft);
    }
    if(sw_y){
        sw(start.sd);
        sw(fin.sd);
    }
    cin >> n;
    rep(i, 0, n){
        pair<ll, ll> t1; cin >> t1.ft >> t1.sd;
        if(sw_x){
            sw(t1.ft);
        }
        if(sw_y){
            sw(t1.sd);
        }
        if(t1.ft >= start.ft and t1.sd >= start.sd and t1.ft <= fin.ft and t1.sd <= fin.sd){
            fountains.pb(t1);
        }
    }
    if(start.ft == fin.ft or start.sd == fin.sd){
        cout << 100.0 * (fin.ft - start.ft + fin.sd - start.sd) + SZ(fountains) * (10 * pi - 20) << "\n";
    } else {
        fountains.pb(fin);
        sort(all(fountains));
        set<pair<ll, ll> >lis = {{start.sd, 0}};
        for(auto& f : fountains){
            auto it = lis.lower_bound({f.sd, INF});
            auto it1 = it, it2 = it; it--;
            DBG(f.ft, f.sd, (*it).ft, (*it).sd);
            pair<ll, ll> cnd = {f.sd, (*it).sd + 1};
            while(it2 != lis.end() and (*it2).sd <= cnd.sd){
                it2++;
            }
            lis.erase(it1, it2);
            lis.insert(cnd);
        }
        ll f_cnt = (*lis.rbegin()).sd - 1;
        DBG(f_cnt);
        if(f_cnt == min(fin.ft - start.ft + 1, fin.sd - start.sd + 1)){
            cout << 100.0 * (fin.ft - start.ft + fin.sd - start.sd) - (f_cnt - 1) * (20 - 5 * pi) + (10 * pi - 20) << "\n";
        } else {
            cout << 100.0 * (fin.ft - start.ft + fin.sd - start.sd) - f_cnt * (20 - 5 * pi) << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 16620
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <queue>
#include <vector>

using namespace std;

const double PI = atan(1)*4;

int main() {
  int r, d;
  double x = 0, y = 0, t = PI / 2.0;
  for (;;) {
    scanf("%d,%d", &r, &d);
    if (!r && !d) {
      printf("%d\n%d\n", int(x), int(y));
      return 0;
    }
    x += double(r) * cos(t);
    y += double(r) * sin(t);
    t -= double(d) * PI / 180.0;
  }
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

int main(){
    string A,B;
    cin>>A>>B;
    int cnt=0;
    while(A!=B){
        if(A[0]==A[4]&&A[1]==A[3]){
            cnt++;
        }
        A[4]++;
        if(A[4]==58){
            A[4]='0';
            A[3]++;
            if(A[3]==58){
                A[3]='0';
                A[2]++;
                if(A[2]==58){
                    A[2]='0';
                    A[1]++;
                    if(A[1]==58){
                        A[1]='0';
                        A[0]++;
                    }
                }
            }
        }

    }
    if(B[0]==B[4]&&B[1]==B[3]){
        cnt++;
    }
    cout<<cnt;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		
		if(a*c<=b)	System.out.println(c);
		else System.out.println(b/a);

	}
	
}


Measured memory_bytes: 23764
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	a, b := sc.nextStr(), sc.nextStr()
	n, _ := strconv.Atoi(a + b)
	ok := false
	for i := 1; i <= 1000; i++ {
		if i*i == n {
			ok = true
		}
	}
	if ok {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}

	wtr.Flush()
}


Measured memory_bytes: 640
/*-------property of the half blood prince-----*/

#include <bits/stdc++.h>
#include <dirent.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define MIN(X,Y) X<Y?X:Y
#define MAX(X,Y) X>Y?X:Y
#define ISNUM(a) ('0'<=(a) && (a)<='9')
#define ISCAP(a) ('A'<=(a) && (a)<='Z')
#define ISSML(a) ('a'<=(a) && (a)<='z')
#define ISALP(a) (ISCAP(a) || ISSML(a))
#define MXX 10000000000
#define MNN -MXX
#define ISVALID(X,Y,N,M) ((X)>=1 && (X)<=(N) && (Y)>=1 && (Y)<=(M))
#define LLI long long int
#define VI vector<int>
#define VLLI vector<long long int>
#define MII map<int,int>
#define SI set<int>
#define PB push_back
#define MSI map<string,int>
#define PII pair<int,int>
#define PLLI pair<LLI,LLI>
#define PDD pair<double,double>
#define FREP(i,I,N) for(int (i)=(int)(I);(i)<=(int)(N);(i)++)
#define eps 0.0000000001
#define RFREP(i,N,I) for(int (i)=(int)(N);(i)>=(int)(I);(i)--)
#define SORTV(VEC) sort(VEC.begin(),VEC.end())
#define SORTVCMP(VEC,cmp) sort(VEC.begin(),VEC.end(),cmp)
#define REVV(VEC) reverse(VEC.begin(),VEC.end())
#define INRANGED(val,l,r) (((l)<(val) || fabs((val)-(l))<eps) && ((val)<(r) || fabs((val)-(r))<eps))
#define INRANGEI(val,l,r) ((val)>=(l) && (val)<=(r))
#define MSET(a,b) memset(a,b,sizeof(a))
using namespace std;
using namespace __gnu_pbds;

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction


//typedef tree < int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

int main(){
    int n;
    cin>>n;
    int mnn = 1000000009;
    int mni = -1;
    FREP(i,1,n){
        int idx , score;
        cin>>idx>>score;
        if(score<mnn){
            mnn =score;
            mni = idx;
        }
    }
    cout<<mni+mnn<<"\n";
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
n, m = map(int, input().split())
l, r = map(int, input().split())
for i in range(m - 1):
    tmp_l, tmp_r = map(int, input().split())
    if l < tmp_l:
        l = tmp_l
    if tmp_r < r:
        r = tmp_r

print(r - l + 1 if (r- l + 1) >= 0 else 0)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        for(int i=0;i<=X;i++){
            if(i*4 + (X-i)*2 == Y){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }

}


Measured memory_bytes: 35712
#include <iostream>
using namespace	std;
int main(){
  for(int n;cin>>n&&n;){
    int r=1e9;
    for(int c0=0;c0<=25;c0++)
      for(int c1=0;c1<=16;c1++)
        for(int c2=0;c2<=10;c2++)
          for(int c3=0;c3<=5;c3++)
            for(int c4=0;c4<=4;c4++)
              for(int c5=0;c5<=3;c5++)
                if(n==c0*200+c1*300+c2*500+c3*1000+c4*1200+c5*1500) r=min(r,c0*380+c1*550+c2*850+c3*1520+c4*1870+c5*2244);
    cout<<r<<endl;
  }
  return 0;
}

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

int main()
{
    int a, b, c, k;
    int ans=0;

    cin >> a >> b >> c >> k;

    if (k > a) {
        ans += a;
        k -= a;

        if (k > b) {
            k -= b;

            ans -= k;
        }
       

    }
    else {
        ans += k;
    }

    cout << ans << endl;
}




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

using namespace std;

typedef long long LL;
typedef pair<int,int> pi;
typedef vector<int> vi;
#define ST first
#define ND second
#define PB push_back
#define DET(a,b,c) (LL(b.x-a.x)*LL((c.y-a.y))-LL((c.x-a.x))*LL((b.y-a.y)))

const int MAXN = 3001;
string s,t;
int n,m;
int dp[MAXN][MAXN];
vector<char>outq;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>s>>t;
    n = s.size(); m = t.size();
    for(int i=1; i<=n;i++) {
        for(int j=1; j<=m;j++) {
            dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            if(s[i-1]==t[j-1]) {
                dp[i][j] = dp[i-1][j-1]+1;
            }
        }
    }
    int x = n, y=m;
    while(dp[x][y]!=0) {
        if(s[x-1]==t[y-1]) {
            outq.PB(s[x-1]);
            x--; y--;
        }
        else if(dp[x-1][y]>dp[x][y-1]) x--;
        else y--;
        //cout<<x<<" "<<y<<"\n";
    }
    reverse(outq.begin(),outq.end());
    for(auto it:outq) cout<<it;
}


Measured memory_bytes: 35456
#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>;
const int INF = 1000000000;
const int MOD = 1000000007;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int k;
  int a, b;
  cin >> k >> a >> b;

  for(int i = a; i <= b; ++i){
    if(i % k == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int n, m;

char a[512][512];
long long base1 = 31, pows1[512] = { 1, 31 }, mod1 = 1000000009;
long long base2 = 31, pows2[512] = { 1, 31 }, mod2 = 1000000007;
long long rowH1[512], colH1[512];
long long rowH2[512], colH2[512];

int main () {
    for ( int i = 2 ; i < 512 ; i ++ ) { pows1[i] = pows1[i-1]*pows1[1]%mod1; }
    for ( int i = 2 ; i < 512 ; i ++ ) { pows2[i] = pows2[i-1]*pows2[1]%mod2; }
    cin >> n;
    for ( int i = 0 ; i < n ; i ++ ) {
        cin >> a[i];
    }
    for ( int y = 0 ; y < n ; y ++ ) {
        for ( int x = 0 ; x < n ; x++ ) {
            rowH1[y] *= pows1[1];
            rowH1[y] += a[y][x] - 'a' +1;
            rowH1[y] %= mod1;

            rowH2[y] *= pows2[1];
            rowH2[y] += a[y][x] - 'a' +1;
            rowH2[y] %= mod2;

        }
    }
    for ( int y = 0 ; y < n ; y ++ ) {
        for ( int x = 0 ; x < n ; x++ ) {

            colH1[x] *= pows1[1];
            colH1[x] += a[y][x] - 'a' +1;
            colH1[x] %= mod1;


            colH2[x] *= pows2[1];
            colH2[x] += a[y][x] - 'a' +1;
            colH2[x] %= mod2;

        }
    }

    long long ans = 0;

    for ( int dx = 0 ; dx < n ; dx ++ ) {
        bool f = 1;
        for ( int i = 0 ; i < n ; i ++ ) {
            if ( rowH1[i] != colH1[(i+dx)%n] || rowH2[i] != colH2[(i+dx)%n] ) { f = 0; }
        }
        if ( f ) { ans += n; }

        for ( int y = 0 ; y < n ; y ++ ) {
            rowH1[y] = ( rowH1[y] - (a[y][dx]-'a'+1)*pows1[n-1]%mod1 + mod1 )%mod1*pows1[1] + (a[y][dx]-'a'+1);
            rowH1[y] %= mod1;

            rowH2[y] = ( rowH2[y] - (a[y][dx]-'a'+1)*pows2[n-1]%mod2 + mod2 )%mod2*pows2[1] + (a[y][dx]-'a'+1);
            rowH2[y] %= mod2;
        }

    }

    cout << ans << "\n";
}


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

using namespace std;

int main()
{
  vector<char> a;
  string s;
  cin >> s;
  for(int i=0; i<s.size(); ++i)
  {
    if (s[i]!='B')
      a.push_back(s[i]); else
    if (!a.empty())
      a.pop_back();
  }
  for(char x:a) cout << x;
  return 0;
}

Measured memory_bytes: 256
// ITP1_4_A:   A / B Problem
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a, b;

	scanf("%d%d", &a, &b);
	printf("%d %d %lf\n", a/b, a%b, (double)a/b);
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <algorithm>
#include <math.h>

using namespace std;

#define ll long long

int main(){
    multimap<ll, ll> mp;
    ll N, A, B, sum = 0;
    cin >> N;
    for(ll i = 0; i < N; i++){
        cin >> A >> B;
        mp.insert(make_pair(B, A));
    }
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        sum += itr->second;
        if(itr->first < sum){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 12800
#define _CRT_SECURE_NO_WARNINGS

#define N (1<<18)
#define MODULO (1000000007)
#define HA1 (2420609)
#define HA2 (19260817)

#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <complex>
using namespace std;

namespace MRAND
{
	class MRNDS
	{
	public:
		int ngf;
		unsigned int lgf;
		MRNDS()
		{
			ngf = HA1*HA2;
			lgf = HA1 - HA2*ngf;
		}
		MRNDS(long long rgf)
		{
			lgf = rgf&((1LL << 32) - 1LL);
			ngf = (rgf >> 31);
			ngf += 2LL * lgf;
			ngf *= HA2;
			lgf += HA1;
		}
		MRNDS operator* (const MRNDS &mrs)const
		{
			MRNDS Res;
			Res.ngf += ngf*mrs.lgf;
			Res.ngf -= mrs.ngf*lgf;
			Res.ngf *= HA1;
			Res.lgf *= HA2;
			return Res;
		}
	}curl, curr;
	inline void InitRand(MRNDS &Lmrs, MRNDS &Rmrs)
	{
		curl = Lmrs;
		curr = Rmrs;
		curl = curl*curr;
		curl.ngf += HA2;
	}
	inline int GetRand()
	{
		curl = curl*curr;
		return (curl.lgf*HA1 - curr.ngf*HA2);
	}
}

long long KissMe(long long xx, long long yy)
{
	if (yy == 0LL)
	{
		return 1LL;
	}
	long long Res = KissMe((xx*xx) % (long long)MODULO, yy >> 1);
	if (yy % 2LL == 1LL)
	{
		Res *= xx;
		Res %= (long long)MODULO;
	}
	return Res;
}

long long fact[N], inv[N];
int h, w, a, b;
long long Ans;

inline long long Ways(int sx, int sy, int fx, int fy)
{
	int ccx = fx - sx, ccy = fy - sy;
	if (ccx < 0 || ccy < 0)
	{
		return 0LL;
	}
	long long Res = fact[ccx + ccy];
	Res *= inv[ccx];
	Res %= (long long)MODULO;
	Res *= inv[ccy];
	Res %= (long long)MODULO;
	return Res;
}

int main()
{
	fact[0] = 1LL;
	for (int i = 1;i < N - 4;i++)
	{
		fact[i] = fact[i - 1] * (long long)i;
		fact[i] %= (long long)MODULO;
	}
	inv[N - 5] = KissMe(fact[N - 5], (long long)MODULO - 2LL);
	for (int i = N - 6;i >= 0;i--)
	{
		inv[i] = inv[i + 1] * (long long)(i + 1LL);
		inv[i] %= (long long)MODULO;
	}
	scanf("%d%d%d%d", &h, &w, &a, &b);
	for (int i = 0;i < h - a;i++)
	{
		Ans += (Ways(0, 0, i, b) - Ways(0, 0, i - 1, b))*Ways(i, b, h - 1, w - 1);
		Ans %= (long long)MODULO;
		if (Ans < 0LL)
		{
			Ans += (long long)MODULO;
		}
	}
	printf("%lld\n", Ans);
	//system("pause");
	return 0;
}


Measured memory_bytes: 4352
X = int(input())

prices = (100, 101, 102, 103, 104, 105)
M = (10000, 10000, 10000, 10000, 10000, 10000)


def restricted_part_sum(a, m, A):
    # 初期化
    N = len(a)
    dp = [[-1 for i in range(A + 1)] for j in range(N + 1)]
    dp[0][0] = 0

    # DP
    for i in range(N):
        for j in range(A + 1):
            if dp[i][j] >= 0:
                dp[i + 1][j] = m[i]
            elif j < a[i] or dp[i + 1][j - a[i]] <= 0:
                dp[i + 1][j] = -1
            else:
                dp[i + 1][j] = dp[i + 1][j - a[i]] - 1
    return dp[N][A] >= 0


if restricted_part_sum(prices, M, X):
    print(1)
else:
    print(0)


Measured memory_bytes: 11672