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

template<typename T> vector<int> z_algorithm(const int len, const T& in) {
  vector<int> res(len, 0);
  int c = 0;
  for (int i = 1; i < len; ++i) {
    if (i + res[i - c] < c + res[c]) {
      res[i] = res[i - c];
    } else {
      int j = max(0, c + res[c] - i);
      while (i + j < len && in[j] == in[i + j]) j++;
      res[i] = j;
      c = i;
    }
  }
  res[0] = len;
  return res;
}

template<typename T> vector<int> z_algorithm(const T& in) {
  return z_algorithm((int) in.size(), in);
}

template<typename T> vector<int> z_algorithm(const T& in_first, const T& in_second) {
  T combined = T();
  combined.append(in_first);
  combined.append({'?'});
  combined.append(in_second);
  int n = (int) in_first.size(), m = (int) in_second.size();
  vector<int> v = z_algorithm(n + m + 1, combined);
  vector<int> res(m);
  for (int i = 0; i < m; i++) {
    res[i] = min(n, v[i + n + 1]);
  }
  return res;
}

class UnionFind {
private:
  int siz;
  vector<int> a;

public:
  UnionFind(int x) : siz(x), a(x, -1) {}

  int root(int x) {
    return a[x] < 0 ? x : a[x] = root(a[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    siz--;
    if (a[x] > a[y]) swap(x, y);
    a[x] += a[y];
    a[y] =x;
    return true;
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  int size(int x) {
    return -a[root(x)];
  }
  
  int conneted_component() {
  	return siz;
  }
};

signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  string s, t;
  cin >> s >> t;
  int n = (int) s.size(), m = (int) t.size();
  s.append(s);
  s.append(s);
  while ((int) t.size() * 2 > (int) s.size()) s.append(s);
  vector<int> v = z_algorithm(t, s);
  UnionFind uf(n);
  for (int i = 0; i < n; i++) {
    if (v[i] == m && v[i + m] == m) {
      if (!uf.unite(i, (i + m) % n)) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] == m) ans = max(ans, uf.size(i));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 24412
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int, int> P;

int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}


int calc(int p, int q, int a, int n, int d,int num, int prod) {
  if (p == 0) return 1;
  if (num == n) return 0;
  int res = 0;
  int g = gcd(p, q);
  p /= g; q /= g;
  for (int i = d; prod*i <= a; i++) {
    if (p*i - q < 0) continue;
    if (p*i -q*(n-num) > 0) break;
    res += calc(p*i-q, i*q, a, n, i, num+1, prod*i);
  }
  return res;
}

int main() {
  while (true) {
    int p, q, a, n;
    scanf("%d%d%d%d", &p, &q, &a, &n);
    if (p == 0 and q == 0 and a == 0 and n == 0) break;

    printf("%d\n", calc(p, q, a, n, 1, 0, 1));
  }
}

Measured memory_bytes: 1172
#include "bits/stdc++.h"
using namespace std;
// #define endl '\n'
// #define double long double
#define int long long
int MOD = 1000 * 1000 * 1000 + 7;
// int MOD = 998244353;

int pw(int a, int b) {
	if (b == 0) return 1;
	if (b == 1) return a;
	int h = pw(a, b/2);
	int an = (h * h) % MOD;
	if (b % 2 == 0) return an;
	return (a * an) % MOD;
}

signed main() {
	
	int n, k;
	cin >> n >> k;
	
	int seq[k+1];
	
	for (int i=1; i<=k; i++) {
		seq[i] = pw(k / i, n); 
	}
	
	for (int i=k; i>=1; i--) {
		// remove all multiples
		for (int j=2*i; j<=k; j+=i) {
			seq[i] -= seq[j];
		}
	}
	
	int ans = 0;
	for (int i=1; i<=k; i++) {
		ans += (seq[i] * i) % MOD;
		ans %= MOD;
	}
	
	cout << ans << endl;
	
}


Measured memory_bytes: 4364
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')

# input macro
def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())
def join(s):
    return ''.join(s)

###########

n=i()
x=ii()
l=i()
q=i()
a,b=[0]*q,[0]*q
for j in range(q):
    aa,bb=ii()
    a[j],b[j]=min(aa,bb)-1,max(aa,bb)-1
table=[[0 for i in range(n)] for j in range(32)]


for k in range(n):
    table[0][k]=bisect.bisect_right(x,x[k]+l)-1
for j in range(1,32):
    for k in range(n):
        table[j][k]=table[j-1][table[j-1][k]]
for j in range(q):
    day=0
    cur=a[j]
    for k in reversed(range(32)):
        if table[k][cur]<b[j]:
            day+=2**k
            cur=table[k][cur]
    print day+1


Measured memory_bytes: 43756
import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
H, W, N = map(int, input().split())
ys = [0] * (H + 1)
xs = [0] * (W + 1)
a = []
base = 10 ** 6
for i in range(N):
  y, x = map(int, input().split())
  ys[y] += 1
  xs[x] += 1
  a.append((y, x))
sy = sorted(ys[1: ])
sx = sorted(xs[1: ])
#print(sy, sx)
def check(k):
  res = 0
  for y, x in a:
    res -= (ys[y] + xs[x]) == k
    res += (ys[y] + xs[x]) > k

  #print(res, k)
  for y in sy:
    i = bl(sx, k - y)
    res += W - i
    #print(W - i, y, k, res)
  return res > 0

ok = 0
ng = N + 1
while ng - ok > 1:
  m = (ok + ng) // 2
  if check(m): ok = m
  else: ng = m
print(ok)

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n;
  cin >> n;
  st stn = to_string(n);
  ll fx = 0;
  vrep(i, stn) fx += i - '0';
  cout << (n % fx == 0 ? "Yes" : "No") << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;
int main() {
	cin>>n;
	ll i=1,s=0,c=0;
	while(n/i>=10){
		s+=n/i%10;
		i*=10;
		c++;
	}
	s+=n/i;c++;
	cout<<max((n/i-1)+9*(c-1), s);
	return 0;
}

Measured memory_bytes: 256
X, Y, Z, K = gets.split(" ").map(&:to_i)
A = gets.split(" ").map(&:to_i)
B = gets.split(" ").map(&:to_i)
C = gets.split(" ").map(&:to_i)

AB = []
A.each do |a|
  B.each do |b|
    AB << a+b
  end
end

AB.sort!.reverse!
AB = AB[0...K]
ABC = []
AB.each do |ab|
  C.each do |c|
    ABC << ab + c
  end
end
ABC.sort!.reverse!
K.times do |i|
  puts ABC[i]
end


Measured memory_bytes: 70000
#include<iostream>
using namespace std;
typedef long long ll;

ll calc_pow(ll x, ll y) {
    ll z = 1;
    while (y > 0) {
        if ((y & 1) == 1) z *= x;
        x *= x;
        y /= 2;
    }
    return z;
}

int main() {
    ll N, P;
    cin >> N >> P;
    ll ans = 1;
    for (ll i = 2; i * i <= P; i++) {
        ll count = 0, tmp = P;
        bool is_ok = true;
        while (tmp > 0 && count < N) {
            if (tmp % i != 0) {
                is_ok = false;
                break;
            }
            tmp /= i;
            count++;
        }
        if (is_ok) ans = max(ans, i);
    }
    if (N == 1) ans = P;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main (void) {
    int N;
    cin >> N;
    vector<int> p(N);
    for ( int i=0; i<N; i++ )
        cin >> p.at(i);

    int ans = 0;
    for ( int i=0; i<N-1; i++ ) {
        if ( p.at(i) == i + 1 ) {
            ans++;
            swap(p.at(i), p.at(i+1));
        }
    }
    /* 最後だけは前の要素と swap する */
    if ( p.at(N-1) == N ) {
        ans++;
        swap(p.at(N-2), p.at(N-1));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3748
import java.util.Scanner;

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

    int input = scan.nextInt();

    int cases = 1;

    while(input>0) {
      int[][] arr = new int[input][input];
      int x=0,y=0;
      int count = 1;
      boolean mode = false;
      while(x<input&&y<input) {
        arr[x][y] = count;

        if(mode) {
          x--;  y++;
        }else {
          y--;  x++;
        }

        if(x>=input) {
          x--;  y++;  y++;
          mode = !mode;
        }else if(y>=input) {
          y--;  x++;  x++;
          mode = !mode;
        }

        if(x<0) {
          x++;
          mode = !mode;
        }else if(y<0) {
          y++;
          mode = !mode;
        }

        count++;
      }

      System.out.println("Case "+cases+":");

      for(int i = 0; i < input; i++) {
        for(int j = 0; j < input; j++) {
          System.out.printf("%3d",arr[j][i]);
        }
        System.out.println();
      }

      input = scan.nextInt();
      cases++;
    }
  }
}

Measured memory_bytes: 26180
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int Y = sc.nextInt();

    int[] x = new int[N];
    int[] y = new int[M];

    for (int i = 0; i < N; i++) {
      x[i] = sc.nextInt();
    }

    for (int i = 0; i < M; i++) {
      y[i] = sc.nextInt();
    }

    sc.close();

    Arrays.sort(x);

    Arrays.sort(y);

    String result = "War";

    for (int i = -100; i <= 100; i++) {

      if (x[N - 1] < i && i <= y[0] && X < i && i <= Y) {
        result = "No War";
        break;
      }

    }

    System.out.println(result);
 
  }

}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int const nax = 2e6 + 10;
const int mod=1000000007;//
void plusle (int &a, int b) {
    if (( a += b) >= mod ) a -= mod ;
}
void minun (int &a, int b) {
    if ((a -= b) < 0) a += mod ;
}
int add (int a, int b) {
    return (( a += b ) >= mod ) ? a - mod  : a;
}
int sub (int a, int b) {
    return (( a -= b) < 0) ? a + mod : a;
}
int mul (int a, int b) {
    return 1LL * a * b % mod;
}
int power (int a, int b) {
    int res = 1;
    for (; b > 0 ; b >>= 1 , a = mul(a, a))
        if (b & 1) res = mul(res, a);
    return res ;
}

const int Mx = 2e6 + 10;
int fac[Mx], invf[Mx] ;
void prefact () {
    fac[0] = 1 ;
    for (int i = 1 ; i < Mx ; i ++) {
        fac[i] = mul(fac[i - 1], i);
    }
    invf[Mx - 1] = power (fac[Mx - 1] ,  mod - 2 );
    for (int i = Mx - 2 ; i >= 0 ; i --) {
        invf[i] = mul(invf[i + 1], i + 1);
    }
}

int ncr (int N, int R) {
    if (R > N) return 0;
    if (R == 0 || R == N) return 1;
    return mul (fac[N], mul(invf[N - R], invf[R]));
}


int k;
char s[nax];

int main () {
    prefact();
    scanf("%d", &k);

    scanf("%s", s + 1);

    int n = strlen(s + 1);


    int ans = 0;
    for (int i = 0 ; i <= k ; ++ i) {
        plusle(ans, mul(ncr(n + k, i), power(25, i)));
    }

    printf("%d\n", ans);
}


Measured memory_bytes: 20440
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i > 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  int N; cin >> N;
  int h[N];
  REP(i, N) cin >> h[i];

  int cost[N];
  REP(i, N) cost[i] = INF;
  cost[0] = 0;

  int a;
  REP(i, N-1) {
    a = cost[i] + abs(h[i] - h[i+1]);
    if (a < cost[i+1]) cost[i+1] = a;

    if (i < N - 2) {
      a = cost[i] + abs(h[i] - h[i+2]);
      if (a < cost[i+2]) cost[i+2] = a;
    }
  }

  cout << cost[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
a = [input() for i in range(N)]
a = list(map(int, a))

i = 1
count = 0
Flag = False
while count < N:
    i = a[i-1]
    count += 1
    if i == 2:
        Flag = True
        break

if Flag:
    print(count)
else:
    print(-1)

Measured memory_bytes: 13480
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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 n;
  cin >> n;
  vector<int> v(n);
  rep (i, n) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  int ans, tmp = INF;
  rep (i, n) {
    if (tmp != v[i]) {
      ans++;
      tmp = v[i];
    }
  }
  P(ans);

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    n++;
    int d = 0;
    while(n){
        d++;
        n >>= 1;
    }
    cout << d-1 << "\n";
    return 0;
}



Measured memory_bytes: 3204
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    x = II()
    if x==3 or x==5 or x==7: print('YES')
    else: print('NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import heapq
n,m = map(lambda x: int(x), input().split())
a = list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a)

for _ in range(m):
    max = heapq.heappop(a)
    heapq.heappush(a,(-1)*(-max//2))
print(-sum(a))


Measured memory_bytes: 14252
/**
 *   created: 09 June 2019  14:03:36
**/
#include<bits/stdc++.h>
using namespace std;

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

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	// cin>>tt;
	while(tt--){
		int n,l;
		cin>>n>>l;
		vi v(n);
		int sum = 0,num=INF;
		int sn = 1;
		rep(i,0,n){
			sum += l+i;
			
			if(num>abs(l+i)){
				num = min(num,abs(l+i));
				if(l+i<0)
					sn = -1;
				else
					sn =1;
			}
		}
		// trace2(sum,num);
		cout<<sum-num*sn;
	}	
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#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>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define MT make_tuple
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	LL N, M;
	cin >> N >> M;

	LL ret = 0;
	LL tmp;

	tmp = min(N, M / 2);
	ret += tmp;
	N -= tmp;
	M -= 2 * tmp;

	tmp = max(0LL, M / 4);
	ret += tmp;

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
a = []
b = []
for i in range(N):
    tmp1, tmp2 = map(int, input().split())
    a.append(tmp1)
    b.append(tmp2)
count = 0
ls_l = [i for i in range(N) if a[i] > b[i]]
ls_m = [i for i in range(N) if a[i] == b[i]]
ls_s = [i for i in range(N) if a[i] < b[i]]

flg = 1
if len(ls_l) > 1:
    ls_l2 = [(b[i],i) for i in ls_l]
    ls_l2.sort()
    idx = ls_l2[0][1]
    count = sum(a)-b[idx]
elif len(ls_m) == N:
    count = 0
else:
    for idx in ls_m:
        count += a[idx]
    
    for idx in ls_s:
        count += a[idx]
    
    if flg==1:
        for idx in ls_l:
            count += a[idx]-b[idx]
print(count)


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

using namespace std;

template< class T >
struct DecomposableSearchingStructure
{
  struct DecomposableSearchingProblem
  {
    T structure;
    int length;

    DecomposableSearchingProblem(T t, int l) : structure(t), length(l) {}

    DecomposableSearchingProblem operator+(const DecomposableSearchingProblem &p)
    {
      return (DecomposableSearchingProblem(structure + p.structure, length + p.length));
    }
  };

  vector< DecomposableSearchingProblem > vs;

  DecomposableSearchingStructure() {}

  void add(const T &st)
  {
    vs.emplace_back(DecomposableSearchingProblem(st, 1));
    while(vs.size() > 1 && vs[vs.size() - 2].length == vs[vs.size() - 1].length) {
      DecomposableSearchingProblem renew(vs[vs.size() - 2] + vs[vs.size() - 1]);
      vs.pop_back(), vs.pop_back();
      vs.push_back(renew);
    }
  }

  size_t size()
  {
    return (vs.size());
  }

  T &operator[](int k)
  {
    return (vs[k].structure);
  }
};

struct Vector
{
  int top;
  vector< int > vs;

  Vector() : top(0) {}

  Vector(int v) : top(0)
  {
    vs.push_back(v);
  }

  int size() const
  {
    return ((int) vs.size() - top);
  }
};

Vector operator+(const Vector &a, const Vector &b)
{
  Vector ret;
  int x = 0, y = 0;
  while(x < a.size() || y < b.size()) {
    if(y == b.size() || (x != a.size() && a.vs[x] < b.vs[y])) {
      ret.vs.push_back(a.vs[x++]);
    } else {
      ret.vs.push_back(b.vs[y++]);
    }
  }
  return (ret);
}

int main()
{
  char S[16];
  int K;

  DecomposableSearchingStructure< Vector > dss;
  while(scanf("%s", S), S[2] != 'd') {
    if(S[0] == 'i') {
      scanf("%d", &K);
      dss.add(Vector(K));
    } else {
      pair< int, int > ret = {-1, -1};
      for(int i = 0; i < dss.size(); i++) {
        auto &p = dss[i];
        if(p.size()) ret = max(ret, {p.vs[p.size() - 1], i});
      }
      printf("%d\n", ret.first);
      ++dss[ret.second].top;
    }
  }
}

Measured memory_bytes: 14948
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;
const ll mod=998244353;

int main(){
    int h,w,m;cin>>h>>w>>m;
    vpii r(h+1),c(w+1);
    set<pair<int,int>> bomb;
    int a,b,tmp;
    rep(i,m){
        cin>>a>>b;
        tmp=r[a].first;
        r[a]=mp(tmp+1,a);
        tmp=c[b].first;
        c[b]=mp(tmp+1,b);
        bomb.insert(mp(a,b));
    }
    sort(all(r));reverse(all(r));
    sort(all(c));reverse(all(c));
    vin rmax,cmax;
    int ans=0;
    tmp=r[0].first;
    ans+=tmp;
    rep(i,h+1){
        if(r[i].first==tmp)rmax.push_back(r[i].second);
        else break;
    }
    tmp=c[0].first;
    ans+=tmp;
    rep(i,w+1){
        if(c[i].first==tmp)cmax.push_back(c[i].second);
        else break;
    }
    ans--;
    bool res=false;
    rep(i,rmax.size()){
        rep(j,cmax.size()){
            if(!bomb.count(mp(rmax[i],cmax[j]))){
                ans++;
                res=true;
                break;
            }
        }
        if(res)break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 26196
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cerr <<  #x << " = " << x << endl

int main(int qtd, char* nome[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	int k;
	cin >> k;
	vector<ll> a;
	for(int i=1; i<10; i++)
		a.push_back(i);
	for(int i=0; a.size() < k; i++){
		int d = a[i] % 10ll;
		if(d > 0)
			a.push_back(10ll*a[i]+d-1);
		a.push_back(10ll*a[i]+d);
		if(d < 9)
			a.push_back(10ll*a[i]+d+1);
	}
	cout << a[k-1] << endl;
	
	return 0;
}

Measured memory_bytes: 4212
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	int W,H,N;
	scanf("%d %d %d",&W,&H,&N);
	int l = 0;
	int r = W;
	int u = H;
	int d = 0;

	for(int i=0;i<N;i++){
		int x,y,a;
		scanf("%d %d %d",&x,&y,&a);
		if(a==1){
			l = max(l,x);
		}else if(a==2){
			r = min(r,x);
		}else if(a==3){
			d = max(d,y);
		}else if(a==4){
			u = min(u,y);
		}
	}

	if(r<l||u<d){
		printf("0\n");
	}else{
		printf("%d\n",(r-l)*(u-d));
	}

	return 0;
}

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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int ans = 0;
  vector<int> cosin(5);
  for (int i = 0; i < 5; i++) {
    cin >> cosin[i];
  }
  int min = 999999;
  do {
    ans = 0;
    for (int i = 0; i < 4; i++) {
      ans += cosin[i];
      if (ans % 10 != 0) {
        ans += (10 - ans % 10);
      }
    }
    ans += cosin[4];
    if (ans < min) {
      min = ans;
    }
  } while (next_permutation(cosin.begin(), cosin.end()));
  cout << min << endl;
}


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

int main()
{
  int n;
  cin >> n;
  double bunbo = 0.;
  rep (i, n) {
    double a;
    cin >> a;
    bunbo += 1 / a;
  }
  cout << std::fixed;
  cout << setprecision(7) << 1 / bunbo << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC068B
{
    class Program
    {
        static void Main(string[] args)
        {
            int maxnum = 1;
            int maxcount = 0;
            int N = int.Parse(Console.ReadLine());
            for(int i = 1; i <= N; i++){
                int count = 0;
                int now = i;
                while(now % 2 == 0){
                    now /= 2; count++;                    
                }                
                if(maxcount < count) {
                        maxcount = count;
                        maxnum = i;
                }
            }
            Console.WriteLine("{0}", maxnum);
        }
    }
}


Measured memory_bytes: 13268
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define range(i,a,b) for(int i=a; i<(int)(b); i++)
#define rep(i,b) range(i,0,b)

typedef int Capacity;
struct Edge {
    int src, dst;
    Capacity cap;
    Edge(int src_, int dst_, int cap_) :
        src(src_), dst(dst_), cap(cap_) { }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<int> Array;
typedef vector<Array> Matrix;

int const inf = 1e9;

template<class Capacity = int> struct FordFulkerson {
    typedef vector<vector<Capacity>> Matrix;
    size_t n;
    Matrix cap, flow;
    vector<bool> vis;
    Capacity res;
    vector<vector<int>> g;
    FordFulkerson(const int s, const int t, const Graph &graph) :
        n(graph.size()), cap(n, Array(n)), flow(n, Array(n)), res(0), g(n) {
        rep(i,n)rep(j,graph[i].size()){
            int u = graph[i][j].src, v = graph[i][j].dst;
            cap[u][v] = flow[u][v] = graph[i][j].cap;
        }
        rep(i,n)rep(j,n) if(cap[i][j]) g[i].emplace_back(j), g[j].emplace_back(i);
        Capacity f = -1;
        while(f) vis.assign(n,false), res += (f = augment(s,t,inf));
        rep(i,n)rep(j,n) flow[i][j] -= cap[i][j];
    }
    Capacity augment(const int v, const int t, Capacity lim){
        vis[v] = true;
        if(v == t) return lim;
        for(const int &i : g[v]){
            if(vis[i] || cap[v][i] == 0) continue;
            Capacity f = augment(i, t, min(lim, cap[v][i]));
            cap[v][i] -= f, cap[i][v] += f;
            if(f) return f;
        }
        return 0;
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    Graph g(N);
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        g[a].emplace_back(a,b,c);
    }
    cout << FordFulkerson<>(0,N-1,g).res << endl;
}

Measured memory_bytes: 1352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 998244353;

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

Measured memory_bytes: 256
s=input().rstrip()
n=len(s)
sf,sm,sl=s[:int((n-1)/2)],s[int((n-1)/2)],s[int((n+1)/2):]
 
if s==s[::-1] and sf==sf[::-1] and sl==sl[::-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
using namespace std;
int main()
{
	string h;
	cin>>h;
	
	deque<char>s;
	for (int i=0;i<sz(h);i++)  s.pb(h[i]);
	
	int q;
	cin>>q;
	int zzz=0;
	for (int i=0;i<q;i++)
	{
		int h;
		cin>>h;
		if (h==2)
		{
			int x;
			char y;
			cin>>x>>y;
			
			if ((x==1 && !zzz) || (x==2 && zzz))  s.push_front(y);
			else  s.pb(y);
		}
		else  zzz=1-zzz;
	}
	
	if (zzz)  reverse(all(s)); 
	for (int i=0;i<sz(s);i++)  cout<<s[i];
	re 0;
}

Measured memory_bytes: 896
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 main() {
	solve(NewScanner())
}

func solve(s *Scanner) {
	wtr := bufio.NewWriter(os.Stdout)
	N, R := s.nextInt(), s.nextInt()
	reduced := 100 * (10 - N)
	if reduced <= 0 {
		reduced = 0
	}
	ans := R + reduced
	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}

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
}


Measured memory_bytes: 640
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
 
int n;
string s[N];
map <string, int> d;
set <string> ans;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();   
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> s[i], d[s[i]]++;
	int maxi = 0;
	for(int i = 1; i <= n; i++) maxi = max(maxi, d[s[i]]);
	for(int i = 1; i <= n; i++)
		if(maxi == d[s[i]])
			ans.insert(s[i]);
	for(auto to : ans) cout << to << endl; 
}                                

Measured memory_bytes: 34816
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int K = int.Parse(str[1]);
		int Q = int.Parse(str[2]);
		int[]F = new int[N];
		for(var i=0;i<Q;i++){
			int a1 = int.Parse(Console.ReadLine());
			F[a1-1]++;
		}
		for(var i=0;i<N;i++){
			int a = K-Q+F[i];
			if(a<=0){
				Console.WriteLine("No");
			} else {
				Console.WriteLine("Yes");
			}
		}
	}
}


Measured memory_bytes: 15708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int a,b,c,x,y;
  	long long ans,ans1=0,ans2=0;
  	cin>>a>>b>>c>>x>>y;
  
  	if(a+b<2*c){
		cout<<a*x+b*y<<endl;
      	return 0;
    }else{
          if(x>y){
			ans1+=c*2*y+a*(x-y);
            ans2+=c*2*x;
          }else{
			ans1+=c*2*x+b*(y-x);
            ans2+=c*2*y;
          }
      		ans=min(ans1,ans2);
    }
  	
  	cout<<ans<<endl;
}
    

Measured memory_bytes: 256
def resolve():
    n = int(input())
    ans = 10 ** 9
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            f = max(len(str(i)), len(str(n // i)))
            if f < ans:
                ans = f
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 39152
#include <stdio.h>
#include <string.h>
int main(void) {
  char s[10], t[10], u[10];
  int a, b;
  scanf("%s %s", s, t);
  scanf("%d %d", &a, &b);
  scanf("%s", u);
  if (strcmp(s, u) == 0)
    printf("%d %d\n", a - 1, b);
  else
    printf("%d %d\n", a, b - 1);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

vector<int> to[100005];

int main(){
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--,b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int> dist(n,-1);
    vector<int> prev(n);
    queue<int> q;
    dist[0]=0;
    q.push(0);
    while(!q.empty()){
        int v = q.front();q.pop();
        for(int u:to[v]){
            if(dist[u]!=-1)continue;
            dist[u]=dist[v]+1;
            prev[u]=v;
            q.push(u);
        }
    }
    cout << "Yes" << endl;
    rep(i,n){
        if(i==0)continue;
        cout << prev[i]+1 << endl;
    }
}

Measured memory_bytes: 10584
from math import gcd
n=int(input())
answer = 0
a = []

for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            a.append(i)
            a.append(j)
            a.append(k)
            ans = a[0]
            for l in range(1,3):
                ans = gcd(ans, a[l])
            answer+=ans
            a=[]
print(answer)

Measured memory_bytes: 68284
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int s, w;
    cin >> s >> w;

    if (s <= w) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }

    return 0;
}


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

int main()
{
    int h,w,i,j;
    while(true){
        cin >> h >> w;
        if(h ==0 && w == 0)
            break;
        for(i = 0; i < h ;i++){
            for(j = 0; j < w; j++)
                cout << '#';
            cout << '\n';
        }
        cout << endl;
    }
}

Measured memory_bytes: 1152
#include <stdio.h>
 
int main(void) {
	int s[10000];
	int n,y;
	n=0;
	while(1){
		scanf("%d",&s[n]);
		if(s[n]==0){
			break;
		};
		n++;
	}
	for(y=0;y<n;y++){
		printf("Case %d: %d\n",y+1,s[y]);
	}
	return 0;
}


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

using namespace std;

bool sosuu(int x){
    for(int i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return true;
}

int main(){
    int X;
    cin >> X;
    for(int i=X;;i++){
        if(sosuu(i)){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
//Problem link - https://atcoder.jp/contests/dp/tasks/dp_d

#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define INF 0x3f3f3f3f
#define mod 1000000007

int main()
{
	fast;
	ll N,W;
	cin>>N>>W;
	ll v[N+1];
	ll wt[N+1];
	for(ll i=1;i<=N;i++)
		cin>>wt[i]>>v[i];
	ll dp[N+1][W+1];
	for(ll i=0;i<=N;i++)
	{
		for(ll w=0;w<=W;w++)
		{
			if(i==0 || w==0)
				dp[i][w]=0;
			else if(w-wt[i]>=0)
				dp[i][w]=max(dp[i-1][w],v[i]+dp[i-1][w-wt[i]]);
			else
				dp[i][w]=dp[i-1][w];
		}
	}
	cout<<dp[N][W];
	return 0;
}

Measured memory_bytes: 79232
import java.util.Scanner;

public class Main {

    private final static String YES = "Yes";
    private final static String NO = "No";

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

        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        int[] array = { a, b, c };

        boolean inputOK = false;

        for (int i : array) {
            if (0 <= i && i <= 100) {
                inputOK = true;
            }
        }

        if (inputOK) {
            if (a < b && a < c) {
                System.out.println(b < c ? YES : NO);
            } else if (a < c && b < c) {
                System.out.println(a < b ? YES : NO);
            } else {
                System.out.println(NO);
            }
        }

    }
}



Measured memory_bytes: 26248
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    LL n;
    LL x;
    cin >> n >> x;
    vector<LL> m(n);
    for(LL i=0; i<n; i++){
        cin >> m[i];
        x-=m[i];
    }

    sort(m.begin(), m.end());
    while(x>=m[0]){
        x-=m[0];
        n++;
    }

    cout << n << endl;

    return 0;
}


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

const int maxn = 100005;

typedef long long ll;
ll dp[maxn];

ll mod = 1e9+7;
ll pot( ll b, ll e ){
    ll ret = 1, a = b;
    while( e ){
        if( e & 1 )
            ret = (ret * a)%mod;
        e >>= 1;
        a = (a*a)%mod;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm

    ll n, k;
    cin >> n >> k;

    for( int i = k; i >= 1; i-- ){
        ll x = k/i;
        dp[i] = pot(x, n);
        for( int j = 2*i; j <= k; j += i )
            dp[i] = (dp[i] - dp[j] + mod)%mod;
    }

    ll sol = 0;
    for( int i = 1; i <= k; i++ )
        sol = (sol + i * dp[i])%mod;

    cout << sol << "\n";
    return 0;
}


Measured memory_bytes: 4396
N = int(input())
S = input()
alphabet = 'ZABCDEFGHIJKLMNOPQRSTUVWXY'
alphabet_num = {st: num for num, st in enumerate(alphabet)}
alphabet_list = [st for st in alphabet]

for s in S:
  num = (alphabet_num[s] + N) % 26
  print(alphabet_list[num], end='')

Measured memory_bytes: 4468
#include <stdio.h>

int score[5], ans = 0;

int main(void) {
	scanf("%d%d%d%d%d", &score[0], &score[1], &score[2], &score[3], &score[4]);
	
	for (int i = 0; i < 5; ++i) {
		if (score[i] < 40) { ans += 40; }
		else { ans += score[i]; }
	}

	printf("%d\n", ans / 5);
	return 0;
}

Measured memory_bytes: 2600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	static int n;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		if (n == m)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

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

int main() {

  vector<double> yama;
  double input;

  while( cin >> input ) {

    yama.push_back(input);

  }

  sort( yama.begin(), yama.end() );

  cout << yama[ yama.size()-1 ] - yama[ 0 ] << endl;

  return 0;

}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  int M = 0;
  cin >> M;
  int maxn = 100100;
  vector<bool> n;
  n.resize(maxn,1);
  
  for(int i = 2; i < maxn; i++){
    if(n[i]){
      if(M <= i){
        cout << i;
        return 0;
      }
    }
    for(int j=i; j<maxn; j += i){
      n[j] = 0;
    }
  }
  return 0;
}

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,k;cin>>h>>w>>k;
    vector<vector<bool>> c(h,vector<bool>(w));
    rep(i,h)rep(j,w){
      char ch;cin>>ch;
      if(ch=='#')c[i][j]=1;
      else c[i][j]=0;
    }
    int cnt = 0;
    for(int i = 0;i <(1<<h); i++){
      bitset<6> s(i);
      for(int j = 0;j <(1<<w);j++){
        bitset<6> t(j);
        int tmp=0;
        rep(l,h){
          rep(m,w){
            if(c[l][m] && !s.test(l) && !t.test(m))tmp++;
          }
        }
        if(tmp==k)cnt++;
      }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3656
from fractions import gcd
N, M = map(int, input().split())
a = list(map(int, input().split()))
k = a[0]
for i in range(1, N):
    k = (a[i]*k) // gcd(a[i], k)
    if k > M*2:
        print(0)
        exit(0)
    k = int(k)
ans = (M - (k // 2)) // k

if M >= (k // 2):
    flag = True
    for i in range(N):
        if (k // a[i]) % 2 == 0:
            print(0)
            exit(0)
    if flag:
        ans += 1

print(int(ans))


Measured memory_bytes: 16284
#!/usr/bin/env python3

def main():
    s = int(input())
    se = {s}
    for i in range(10 ** 6):
        s = next(s)
        if s in se:
            print(i + 2)
            return
        se.add(s)

def next(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1

main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  cin>>s;
  if(s.size() == 2){
    if(s[0] == s[1])puts("1 2");
    else puts("-1 -1");
  }
  else {
    for(int l = 0; l + 2 < s.size(); ++l){
      int r = l + 2;
      if(s[l] == s[l + 1] || s[l] == s[l + 2] || s[l + 1] == s[l + 2]){
        cout<<l + 1 <<" " << l+3<<endl;
        return 0;
      }
    }
    puts("-1 -1");
  }
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
 
struct SegmentTree {
 
    long long sum[1 << 18];
    long long lazy[1 << 18];
    int size;
 
    void init(int size) {
        this->size = 1 << (int)ceil(log2(size));
    }
 
    void propagate(int k) {
        if (lazy[k]) {
            sum[k] += lazy[k];
            if (k < size - 1) {
                lazy[k * 2 + 1] += lazy[k] / 2;
                lazy[k * 2 + 2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }
 
    void add(int a, int b, int v, int k, int l, int r) {
        if (b <= l || r <= a) {
            propagate(k);
            return;
        }
        if (a <= l && r <= b) {
            lazy[k] += v * (r - l);
            propagate(k);
            return;
        }
        propagate(k);
        add(a, b, v, k * 2 + 1, l, (l + r) / 2);
        add(a, b, v, k * 2 + 2, (l + r) / 2, r);
        sum[k] = sum[k * 2 + 1] + sum[k * 2 + 2];
    }
 
    void add(int a, int b, int v) {
        add(a, b, v, 0, 0, size);
    }
 
    long long get(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a) {
            return 0;
        }
        if (a <= l && r <= b) {
            propagate(k);
            return sum[k];
        }
        propagate(k);
        long long vl = get(a, b, k * 2 + 1, l, (l + r) / 2);
        long long vr = get(a, b, k * 2 + 2, (l + r) / 2, r);
        return vl + vr;
    }
 
    long long get(int a, int b) {
        return get(a, b, 0, 0, size);
    }
} st;
 
int main() {
    int n, q;
    cin >> n >> q;
    st.init(n);
    while (q--) {
        int i, s, t, x;
        cin >> i >> s >> t;
        --s;
        if (i) {
            cout << st.get(s, t) << endl;
        } else {
            cin >> x;
            st.add(s, t, x);
        }
    }
    return 0;
}


Measured memory_bytes: 6432
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,a,b;
  cin>>k>>a>>b;
  int f=1;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0)
    {  f=0;
    break;}
  }
  if(f==0)
    cout<<"OK"<<'\n';
  else
    cout<<"NG"<<'\n';
}
    

Measured memory_bytes: 3588
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T& a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U>& p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector< T > &v) { rep(i, v.size()) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "c.cpp"

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

  set<string> s;
  rep(i, n) {
    string t;
    cin >> t;
    s.insert(t);
  }

  cout << s.size() << el;
}


Measured memory_bytes: 19200
n = int(input())
l = list(map(int, input().split()))
def memo(n) :
    me = [0]*(n)
    global l
    me[0] = 0
    me[1] = abs(l[0] - l[1])
    def f(n) :
        for i in range(2, n) :
            me[i] = min([me[i - 2] + abs(l[i - 2] - l[i]),me[i - 1] + abs(l[i - 1] - l[i])])
        return me[n-1]
    return f(n)
print(memo(n))


Measured memory_bytes: 13908
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var abc = lines[0].split(' ');
 var a = Number(abc[0]);
 var b = Number(abc[1]);
 var c = Number(abc[2]);
 var i = 0;
 var count = 0;

 while(true){
   if(a%2 == 1 || b%2 == 1 || c%2 == 1){
     break;
   }
   var tmpa = b/2 + c/2;
   
   var tmpb = a/2 + c/2;
   
   var tmpc = b/2 + a/2;

   if(tmpa == a && tmpb == b && tmpc == c){
     console.log("-1");
     count++;
     break;
   }
   
   
   a = tmpa;
   b = tmpb;
   c = tmpc;
   
   i++;
   
 }

 if(count == 0){
 console.log(i);
}
});


Measured memory_bytes: 9548