akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

const ll C_MAX = (ll)1e18;

int main()
{
	ll N;
	ll ret = 1;

	cin >> N;
	vector<ll> vec(N);
	rep(i, N)
	{
		cin >> vec.at(i);
	}

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

	rep(i, N)
	{
		if (vec.at(i) == 0)
		{
			ret = 0;
			break;
		}
		
		if (C_MAX / vec.at(i) < ret)
		{
			ret = -1;
			break;
		}
		else
		{
			ret *= vec.at(i);
		}


	}

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

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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

ll mpow(ll x, ll n){
  if(n == 0)
    return 1;
 
  if(n % 2 == 0)
    return mpow(x * x, n / 2);
  else
    return x * mpow(x, n - 1);
}


int main(){
  cout << setprecision(10);
  ll N, K;
  cin >> N >> K;
  int max_digit = 50;
  map<int, ll> m;
  for(int i = 0; i <= max_digit; i++){
    m[i] = 0;
  }

  for(int i = 0; i < N; i++){
    ll A;
    cin >> A;
    int index = 0;
    while(A > 0){
      m[index] += A%2;
      A /= 2;
      index++;
    }
  }

  for(ll i = max_digit; i >= 0; i--){
    if(K < mpow(2, i)) continue;

    if(m[i] > N-m[i]){
      // 1の方が多い場合は0にする方がとく
      // f[i] = m[i]になる 
    } else if(m[i] < N-m[i]){
      // 0の方が多い場合は1にする
      // f[i] = N - m[i] になる
      // Kが減る
      m[i] = N - m[i];
      K = K - mpow(2,i);
    } 
  }

  ll ans = 0;
  for(ll i = 0; i < m.size(); i++){
    ans += m[i] * mpow(2,i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? LLONG_MAX : INT_MAX;
const int MOD = 1000000007LL;
const long double EPS = 1e-8;

signed main() {
	int n, m;
	cin >> n >> m;
	int x[n], y[m];
	rep (i, n) cin >> x[i];
	rep (i, m) cin >> y[i];
	int prev = 0, next = 0;
	range (i, 1, n) prev = ((prev + (x[n - i] * (n - i)) % MOD) % MOD - (MOD + (x[i - 1] * (n - i)) % MOD)) % MOD;
	range (i, 1, m) next = ((next + (y[m - i] * (m - i)) % MOD) % MOD - (MOD + (y[i - 1] * (m - i)) % MOD)) % MOD;
	cout << prev * next % MOD << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
typedef vector<string> vs;
bool later(string a, string b) {
	for (int i = 0; i < a.size(); i++) {
		if ((int)a[i] < (int)b[i])return true;
		if ((int)a[i] > (int)b[i])return false;
	}
	return false;
}

int main() {
	int n, l;
	cin >> n >> l;
	vs s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s.begin(), s.end(), later);
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>

int main(){
  long long K;
  std::cin >> K;
  std::queue<long long> que;
  for(int i = 1 ; i < 10 ; i++){
    que.push(i);
  }
  
  long long resa = 1;
  for(long long i = 0 ; i < K ; i++){
    resa = que.front();
    que.pop();
    if(resa % 10 != 0){
      que.push(10 * resa + resa % 10 - 1);
    }
    que.push(10 * resa + resa % 10 );
    if(resa % 10 != 9){
      que.push(10 * resa + resa % 10 + 1);
    }
  }
  std::cout << resa << std::endl;
  return 0;
}


Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {

        var line = Console.ReadLine().Split(' ').Select(p => double.Parse(p)).ToArray();
        double W = line[0];
        double H = line[1];
        double x = line[2];
        double y = line[3];

        Console.WriteLine(W * H / 2);

        if(W / 2 == x && H / 2 == y)
        {
            Console.WriteLine(1);
        }
        else
        {
            Console.WriteLine(0);
        }
    }

}


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

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,m;
	cin>>n>>m;
	cout<<(m-1)*(n-1);
	return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    X, Y, Z = map(int, readline().split())

    print(Z, X, Y)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61908
#include<stdio.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MOD=1e9+7,MAX=1e6;
static inline char CH()
{
  static char buf[100000],*ptr1=buf,*ptr2=buf;
  return ptr1==ptr2&&(ptr2=(ptr1=buf)+fread(buf,1,100000,stdin),ptr1==ptr2)?EOF:*ptr1++;
}
static inline int IN(void)
{
  int x=0,f=0,c=CH();while(c<48||c>57){f^=c==45,c=CH();}
  while(c>47&&c<58){x=x*10+c-48,c=CH();}return f?-x:x;
}
typedef struct{int SPF[1000001];int Primes[78498];int sz;}Template;
Template P;
static inline int MPow(int a,int b){return b?1l*MPow(1l*a*a%MOD,b>>1)*(b&1?a:1)%MOD:1;}
static inline void ready(void)
{
  *P.SPF=1,*P.Primes=2,P.sz=1;
  rep(i,MAX/2)P.SPF[2*(i+1)]=2,P.SPF[2*(i+1)-1]=2*(i+1)-1;
  rep(i,MAX/2-1)
  {
    int x=2*(i+1)+1;if(P.SPF[x]==x){P.Primes[P.sz++]=x;}
    rep(j,P.sz){if(P.Primes[j]<=P.SPF[x]&&x*P.Primes[j]<=MAX)P.SPF[x*P.Primes[j]]=P.Primes[j];else break;}
  }
}
int main(void)
{
  int N=IN(),A=0,factor=0,invsum=0,lcm=1,x=0,box[1000001]={0};ready();
  rep(i,N)
  {
    A=IN();invsum=(invsum+1l*MPow(A,MOD-2))%MOD;
    while(A>1)
    {
      factor=P.SPF[A];x=0;
      while(A%factor==0)A/=factor,x++;
      if(box[factor]<x)box[factor]=x; 
    }
  }
  rep(i,P.sz){if(box[P.Primes[i]])lcm=1l*lcm*MPow(P.Primes[i],box[P.Primes[i]])%MOD;}
  return printf("%ld\n",1l*lcm*invsum%MOD),0;
}

Measured memory_bytes: 9776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;


int main() {
    int n; cin >> n;
    int a[n];
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    int now = a[0]-1;
    int cnt = 0;
    for(int i = 0;i < n;i++){
        cnt++;
        if(now == 1){
            cout << cnt;
            return 0;
        }else{
            now = a[now]-1;
        }
    }
    cout << -1;
}




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

string s;
int a = 700;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> s;
	for(int i=0; i<s.size(); ++i)
		if(s[i] == 'o') a += 100;
	cout << a << "\n";
}

Measured memory_bytes: 256
import java.util.*;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        
        int ans = 0;
        for (int i = 0; i < 2; i++) {
            if ( A > B ) {
                ans += A;
                A--;
            } else {
                ans += B;
                B--;
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ll long long
#define int long long
#define mod 1000000007
#define DEBUG cout<<"Hello1\n";
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))
#define deb(...) debug(#__VA_ARGS__, __VA_ARGS__);
const int N = 1e6 + 5;
const ll inf = LLONG_MAX;
using namespace std;

template<typename T> void debug(string s, T x) {cout << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cout << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}
template<class T>
void print_container(T &container) {
	for (auto &t : container) {
		cout << t << " ";
	}
	cout << endl;
}

int n;
void solve() {
	cin >> n;

	int x = 0;

	while (x < n) {
		x += 1000;
	}
	cout << x - n << endl;
}

int32_t main() {
	IOS;

	solve();
}



Measured memory_bytes: 3632
SIZE=300000; MOD=998244353 #ここを変更する

inv = [0]*(SIZE+1)# inv[j] = j^{-1} mod MOD
fac = [0]*(SIZE+1)# inv[j] = j! mod MOD
finv = [0]*(SIZE+1)# inv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE+1):
    inv[i] = MOD -(MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD

def choose(n,r): # nCk mod MOD の計算
    if r < 0 or r > n or n < 0:
        return 0
    else:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    

n,a,b,k = [int(i) for i in input().split()]
ans=0
for i in range(n+1):
    if (k-i*a)%b == 0:
        ans = (ans + choose(n,i)*choose(n,(k-i*a)//b)%MOD)%MOD
print(ans)




Measured memory_bytes: 47984
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n,a[200100],dl[400100],head,tail;
	head=100010;
	tail=head-1;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);	
		if(i&1) dl[++tail]=a[i];
		else dl[--head]=a[i];
	}
	if(n&1) for(int i=tail;i>=head;i--) printf("%d ",dl[i]);
	else for(int i=head;i<=tail;i++) printf("%d ",dl[i]);
	return 0;
} 

Measured memory_bytes: 4352
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict(list)
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    s = input()
    for i in range(0,len(s),2):
        #print(s[i:i+2])
        if s[i:i+2] == 'hi':
            pass
        else:
            print('No')
            exit()
    print('Yes')
if __name__ == '__main__':
  main()


Measured memory_bytes: 2940
/**
Bismillahir Rahmanir Rahim
!~~~~~~~~~~~~!
|Naimul Islam|
!~~~~~~~~~~~~!
*/
#include<bits/stdc++.h>

using namespace std;

typedef     unsigned long long  ull;
typedef     long long           ll;

#define     CS(x)        cout << "Case " << x << ": ";

#define in() ( { int a ; scanf("%d",&a); a; } )     //int x= in()

#define     PI           (acos(-1))
#define     sq(x)          ((x) * (x))
#define     mod          (1000000007)
#define     EPS          1e-9
#define     inf          1 << 30

#define     eb           emplace_back
#define     mp           make_pair
#define     SZ(_n)       (int)_n.size()
#define     ALL(_n)      _n.begin(), _n.end()
#define     Clear(a,b)   memset(a,b,sizeof(a))

#define     sp           ' '
#define     endl         "\n"
#define     nl           cout << endl
#define     r0           return 0

#define     Check(x)     cout << #x << " is " << x <<endl;
#define     precision(n) cout << fixed << setprecision(n);
#define     dbg          cout << "KHELA HOBE" << endl;
#define     doura      ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
	doura;
    string s, t;
    cin >> s >> t;
    cout << t+s << endl;



    r0;
}















Measured memory_bytes: 256
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

int main(){
	int N;
	cin >> N;

	string ans = "APPROVED";

	int A;
	for (int i=0; i<N; i++) {
		cin >> A;
		if (A % 2 == 1) continue;

		if (A % 3 != 0 && A % 5 != 0) {
			ans = "DENIED";
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import deque
n,k = map(int,input().split())
l = list(map(int,input().split()))

que = deque(l[:k])
for i in range(n-k):
    p = que.popleft()
    que.append(l[k+i])
    if p < l[k+i]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 95372
#!/usr/bin/env python3
def main():
  # import bisect
  # from collections import Counter
  # from collections import defaultdict
  # from collections import deque
  # from copy import deepcopy
  # from fractions import gcd
  # from heapq import heappop,heappush
  # from itertools import accumulate
  # from itertools import combinations
  # from itertools import permutations
  # from itertools import product
  # from math import ceil,floor, pi
  import sys
  sys.setrecursionlimit(10**6)
  readline = sys.stdin.readline
  ints = lambda: map(int, readline().split())
  floats = lambda: map(float, readline().split())
  pyes = lambda: print("Yes")
  pno = lambda: print("No")
  lli = lambda I, J: [[0] * J for _ in range(I)]
  mod = 10**9+7

  n,m = ints()
  a = list(ints())
  sm = sum(a) / 4 / m
  x = len([i for i in a if i >= sm])
  if x < m:
    pno()
  else:
    pyes()

if __name__ == '__main__':
  main()


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

#define endl '\n'

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

    int n;
    cin >> n;
    long long res = 0;
    for(int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        res += r - l + 1;
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int a, b;
    int n;
    cin >> n;
    vector<int>p(n),q(n);
    rep(i,n)cin >> p[i];
    rep(i,n)cin >> q[i];
    vector<int> id(n);
    iota(id.begin(),id.end(),1);
    int k = 0;
    do{
        if(id == p)a = k;
        if(id == q)b = k;
        k++;
    }while(next_permutation(id.begin(),id.end()));
    cout << abs(a-b) << endl;
}


Measured memory_bytes: 256
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
#import math
#n=int(input())
#li=input().split()
#S=input()

lis=list(map(int,input().split()))
ans=0
if lis[0]>lis[1]:
    ans+=lis[0]
    lis[0]-=1
else:
    ans+=lis[1]
    lis[1]-=1

if lis[0]>lis[1]:
    ans+=lis[0]
else:
    ans+=lis[1]

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

int main(){
  int w,d;
  int f[10],s[10],c[10],ans=0,p;
  while(1){
    for(int i=0;i<10;i++){
      f[i]=s[i]=c[i]=0;
    }
    ans=0;
    p=0;
    cin>>w>>d;
    if(w==0 && d==0) break;
    rep(i,w){
      cin>>f[i];
    }
    rep(i,d){
      cin>>s[i];
    }
    
    for(int i=0;i<w;i++){
      int r,l;
      l=0;r=d;
      sort(f,f+w,greater<int>());sort(s,s+d,greater<int>());
      while(l<r){
	
	int m=(l+r)/2;
	if(s[m]==f[i]){ans+=f[i];f[i]=s[m]=(BIG+p);p++;break;}
	else if(s[m]>f[i]) l=m+1;
	else r=m;
      }
      if(f[i]<BIG) ans+=f[i];
    }
    for(int i=0;i<d;i++){
      if(s[i]<BIG) ans+=s[i];
    }
    cout<<ans<<endl;
    
    /*for(int i=0;i<5;i++){
    cout<<f[i]<<" "<<s[i]<<endl;
    }*/
  }
  return 0;
}



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

int main() {
    int a, b;
    double x, y, val;
    cin >> a >> b;

    x = (double)(a + b) / 2.0;

    y = modf(x, &val);

    if (y >= 0.5) {
        val = val + 1.0;
    } else {
        val = val;
    }

    cout << val << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# CGL_4_C: Convex Polygon Convex Cut


def cut(ps, p0, p1):
    polygon = []
    for p2, p3 in zip(ps, ps[1:] + [ps[0]]):
        if cross(p0, p1, p0, p2) >= 0:
            polygon.append(p2)
        if intersect(p0, p1, p2, p3):
            p = intersect_point(p0, p1, p2, p3)
            if not same(p, p2):
                polygon.append(p)

    return polygon


def intersect(p0, p1, p2, p3):
    if cross(p0, p1, p0, p2) >= 0 and cross(p0, p1, p0, p3) < 0:
        return True
    elif cross(p0, p1, p0, p2) <= 0 and cross(p0, p1, p0, p3) > 0:
        return True

    return False


def same(p0, p1):
    x0, y0 = p0
    x1, y1 = p1
    return abs(x0 - x1) < 1e-10 and abs(y0 - y1) < 1e-10


def intersect_point(p0, p1, p2, p3):
    d1 = abs(cross(p0, p1, p0, p2))
    d2 = abs(cross(p0, p1, p0, p3))
    t = d1 / (d1 + d2)
    x2, y2 = p2
    x3, y3 = p3
    return x2 + (x3 - x2) * t, y2 + (y3 - y2) * t


def area(ps):
    """Calculate area of a polygon.

    >>> area([(0, 0), (2, 2), (-1, 1)])
    2.0
    >>> area([])
    0.0
    >>> area([(0, 0)])
    0.0
    >>> area([(0, 0), (1, 0)])
    0.0
    """
    area = 0.0

    if ps:
        for p0, p1 in zip(ps, ps[1:]+[ps[0]]):
            area += cross((0, 0), p0, p0, p1)
    return area / 2


def cross(p0, p1, p2, p3):
    x0, y0 = p0
    x1, y1 = p1
    x2, y2 = p2
    x3, y3 = p3
    return (x1-x0)*(y3-y2) - (x3-x2)*(y1-y0)


def run():
    n = int(input())
    ps = []

    for _ in range(n):
        x, y = [int(i) for i in input().split()]
        ps.append((x, y))

    q = int(input())

    for _ in range(q):
        x1, y1, x2, y2 = [int(i) for i in input().split()]
        print("{:.10f}".format(area(cut(ps, (x1, y1), (x2, y2)))))


if __name__ == '__main__':
    run()



Measured memory_bytes: 5664
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner file = new Scanner(System.in);
      	String s = file.next(), t = file.next();
      	System.out.println(s.equals(t.substring(0, t.length() - 1)) ? "Yes" : "No");
      	file.close();
    }
}


Measured memory_bytes: 35712
class UseTime
  def initialize login
    @login = login
    @logout = -1
    @pc_num = 1
  end
  attr_accessor :login, :logout, :pc_num
end

def main
  loop do
    pc_num,student_num = gets.chomp.split(' ').map(&:to_i)
    break if (pc_num|student_num) == 0

    log_num = gets.chomp.to_i

    log_list = Array.new(student_num + 1).map{Array.new()}
    log_num.times do
      time,pc,student,action = gets.chomp.split(' ').map(&:to_i)
      case action
      when 1
        if log_list[student].size == 0 \
          or log_list[student][-1].logout != -1
          log_list[student] << UseTime.new(time)
          next
        end
        log_list[student][-1].pc_num += 1
      when 0
        log_list[student][-1].pc_num -= 1
        if log_list[student][-1].pc_num == 0
          log_list[student][-1].logout = time
        end
      end
    end

    question_num = gets.chomp.to_i
    question_num.times do
      start_time,end_time,student = gets.chomp.split(' ').map(&:to_i)

      total = 0
      log_list[student].each do |record|
        if record.logout < start_time or record.login > end_time
          next
        end

        tmp_start = record.login
        if record.login < start_time
          tmp_start = start_time
        end

        tmp_end = record.logout
        if record.logout > end_time
          tmp_end = end_time
        end
        total += tmp_end - tmp_start
      end
      puts total
    end
  end
end

main

Measured memory_bytes: 7060
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;

int main(void) {
    ll N, M, X;
    cin >> N >> M >> X;
    vector<ll> C(N);
    vector<vector<ll>> A(N, vector<ll>(M));
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    int bitN = 1;
    for (int i = 0; i < N; i++) {
        bitN *= 2;
    }

    vector<vector<ll>> dp(bitN+1, vector<ll>(M+1));

    for (int n = 1; n < bitN+1; n++) {
        for (int b = 0; b < N; b++) {
            // フラグが立っているビットを探して
            // そのフラグを消して足す
            if (n & (1<<b)) {
                for (int m = 0; m < M; m++) {
                    dp[n][m] += dp[(n & ~(1<<b))][m] + A[b][m];
                }
                dp[n][M] += dp[(n & ~(1<<b))][M] + C[b];
                break;
            }
        }
    }
    ll minmon = INF;
    for (int n = 0; n < bitN+1; n++) {
        for (int m = 0; m < M; m++) {
            if (dp[n][m] < X) break;
            if (m == M-1) {
                minmon = min(minmon, dp[n][M]);
            }
        }
    }
    if (minmon == INF) {
        cout << -1 << endl;
    } else {
        cout << minmon << endl;
    }

    return 0;
}



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

const string YES = "Yes";
const string NO = "No";

void solve(long long X, long long Y)
{
    if (Y & 1)
    {
        cout << NO << endl;
        return;
    }
    Y >>= 1;
    if (X <= Y && Y <= 2 * X)
        cout << YES << endl;
    else
        cout << NO << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long X;
    scanf("%lld", &X);
    long long Y;
    scanf("%lld", &Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 3768
N = int(input())
S = str(input())
ans = [0] * len(S)

alpha2num = lambda c: ord(c) - ord('A') + 1
num2alpha = lambda c: chr(c+64)

for i in range(len(S)):
  alpha = S[i]
  num = alpha2num(alpha)#アルファベットを数字に置き換え
  num += N
  if num > 26:
    num -= 26
  ans[i] = num2alpha(num)#数字をアルファベットに戻す

for i in range(len(S)):
  print(ans[i], end = "")

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class a, int N, class T>
void fillArray(a(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
int a[105];
int num[105];
void solve() {
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        ++num[a[i]];
    }
    bool start = false;
    int first = 0, last = 0;
    reps(i, n - 1) {
        if (start && num[i] > 0 && num[i - 1] == 0 || start && num[i] > 0 && num[i] < 2) {
            cout << "Impossible" << endn;
            return;
        }
        if (!start && num[i] > 0) {
            first = i;
            start = true;
        }
        if (num[i] > 0) last = i;
    }

    if (last % 2 == 1 && num[first] == 2 && first == (last + 2 - 1) / 2 ||
        last % 2 == 0 && num[first] == 1 && first == (last + 2 - 1) / 2) cout << "Possible" << endn;
    else cout << "Impossible" << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
 
sum=0
for i in range(N):
    if B[i]<=A[i]:
        sum+=B[i]
    else:
        sum+=A[i]
        B[i]-=A[i]
        sum+=min(A[i+1],B[i])
        A[i+1]-=min(B[i],A[i+1])
print(sum)

Measured memory_bytes: 19244
fun main(args: Array<String>) {
  val (n, m) = readLine()!!.split(" ").map(String::toLong)
  val ans = when {
    n == 1L && m == 1L -> 1
    n == 1L -> (m - 2)
    m == 1L -> (n - 2)
    else -> (n - 2) * (m - 2)
  }
  println(ans)
}

Measured memory_bytes: 38064
N = int(input())
X = input()

n1 = X.count("1")
Xn = int(X, 2)

Xms = (Xn % (n1 - 1)) if n1 > 1 else 0
Xml = Xn % (n1 + 1)

p2s = [1]
p2l = [1]
s2 = 1
l2 = 1
for i in range(N - 1):
    s2 = (s2 * 2) % (n1 - 1) if n1 > 1 else 0
    l2 = (l2 * 2) % (n1 + 1)
    p2s.append(s2)
    p2l.append(l2)


def f(n):
    if n == 0:
        return 0
    return f(n % bin(n).count("1")) + 1


for i in range(N):
    cnt = 0
    p2 = 2 ** (N - i - 1)
    Xim = 0

    if X[i] == "1" and n1 == 1:
        print(cnt)
    elif X[i] == "1":
        print(f((Xms - p2s[-i - 1]) % (n1 - 1)) + 1)
    else:
        print(f((Xml + p2l[-i - 1]) % (n1 + 1)) + 1)



Measured memory_bytes: 100600
import itertools
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]
ans = 0
for A in itertools.combinations_with_replacement(range(1, M+1), N):
  score = 0
  for i in range(Q):
    a = abcd[i][0]
    b = abcd[i][1]
    c = abcd[i][2]
    d = abcd[i][3]
    if A[b-1]-A[a-1] == c:
      score += d
  ans = max(ans,score)
print(ans)


Measured memory_bytes: 9196
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[100010], h[100010];

signed main() {
    int N; cin >> N;
    fill(dp, dp + N + 1, INF);
    dp[0] = 0;
    for(int i=0; i<N; i++) {
        cin >> h[i];
    }

    for(int i=0; i<N; i++) {
        for(int k=1; k<=2; k++) {
            if(i + k >= N) continue;
            chmin(dp[i+k], dp[i] + abs(h[i] - h[i+k]));
        }
    }
    cout << dp[N-1] << endl;
    return 0;
}


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

int main() {
  
  int N,i;
  double S;
  cin >> N;
  i = 0;
  S = 0.0;
    
  while(i < N){
    double A;
    cin >> A;
    S += (1/A);
    i++;
  }
  cout << 1/S << endl;
}
    

Measured memory_bytes: 256
#include <stdio.h>
#include <memory.h>
struct data{
	int n,s,w[10],pen;
};
int main(void){
	struct data d[50],tmp;
	int t,p,r,tid,pid,time,i,j;
	char m[10];
	while(scanf("%d %d %d",&t,&p,&r),t){
		memset(d,0,sizeof(d));
		for(i=0;i<t;i++)
			d[i].n=i+1;
		while(r--){
			scanf("%d %d %d %s",&tid,&pid,&time,m);
			if(m[0]=='C'){
				d[tid-1].s++;
				d[tid-1].pen+=d[tid-1].w[pid-1]*1200+time;
			}
			else if(m[0]=='W')
				d[tid-1].w[pid-1]++;
		}
		for(i=0;i<t-1;i++){
			for(j=t-1;j>i;j--){
				if(d[j-1].s<d[j].s||(d[j-1].s==d[j].s&&d[j-1].pen>d[j].pen)){
					tmp=d[j];
					d[j]=d[j-1];
					d[j-1]=tmp;
				}
			}
		}
		for(i=0;i<t;i++)
			printf("%d %d %d\n",d[i].n,d[i].s,d[i].pen);
	}
	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  int a[n][n-1];
  int tta;
  rep(i,n){
    rep(j,n-1){
      cin >> tta;
      tta--;
      a[i][j]=tta;
    }
  }
  int ans=0;
  int v[n]; //iから今出ている辺
  int ind[n]; //各個人の試合がどこまで進んだかのindex
  rep(i,n) ind[i]=0;
  rep(i,n) v[i]=-1;
  queue<int> tmp;
  rep(i,n){
    int to=a[i][ind[i]];
    ind[i]++;
    v[i]=to;
    if(v[to]==i){
      tmp.push(to);
      tmp.push(i);
      //      cout << to << " " << i << endl;
    }    
  }
  ans++;
  if(tmp.empty()){
    bool nom_end=true;
    rep(i,n){
      if(ind[i]!=n-1) nom_end=false;
    }
    if(!nom_end){
      cout<< -1 << endl;
    }
    else cout << ans << endl;
    return 0;
  }
  while(1){
    queue<int> ttmp;
    int si=tmp.size();
    rep(i,si){
      int k=tmp.front();tmp.pop();
      if(ind[k]==n-1) continue;
      int to=a[k][ind[k]];
      //      cout << k  <<" next go to " << to<<endl;
      //      cout << "aiteha " << v[to] << " ni" << endl;
      ind[k]++;
      v[k]=to;
      //      cout << v[to] << " " << k << endl;
      if(v[to]==k){
	ttmp.push(to);
	ttmp.push(k);
	//	cout << v[to] << " " << k << endl; 
      }    
    }
    ans++;
    //    cout << " " << endl;
    if(ttmp.empty()){
      bool nom_end=true;
      rep(i,n){
	if(ind[i]!=n-1) nom_end=false;
      }
      if(!nom_end){
	cout<< -1 << endl;
      }
      else cout << ans-1 << endl;
      return 0;
    }
    while(!ttmp.empty()){      
      tmp.push(ttmp.front());
      ttmp.pop();
    }
  }
  


  
  return 0;
    

}


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

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

using boost::multiprecision::cpp_int;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  cpp_int a, b;
  cin >> a >> b;

  cout << (a > b ? "GREATER" : (a == b ? "EQUAL" : "LESS")) << endl;
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int main(){
    int a,c,b;
    cin>>a>>b>>c;
    if(a==b) cout<<c<<endl;
    else if(b==c) cout<<a<<endl;
    else if(a==c) cout<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	boolean dd(int a, int b, int c, int d){
		int p, q;
		String s = "";
		String t = "";
		for(int i=0;i<4;i++){
			if(i==0) p = a+b;
			else if(i==1) p = a-b;
			else if(i==2) p = b-a;
			else p = a*b;
			for(int j=0;j<4;j++){
				if(j==0) q = c+d;
				else if(j==1) q = c-d;
				else if(j==2) q = d-c;
				else q = c*d;
				
				if(p+q==10 || p-q==10 || q-p==10 || p*q==10){
					if(i==0) s = "( " + a + " + " + b + " )";
					else if(i==1) s = "( " + a + " - " + b + " )";
					else if(i==2) s = "( " + b + " - " + a + " )";
					else s = "( " + a + " * " + b + " )";
					
					if(j==0) t = "( " + c + " + " + d + " )";
					else if(j==1) t = "( " + c + " - " + d + " )";
					else if(j==2) t = "( " + d + " - " + c + " )";
					else t = "( " + c + " * " + d + " )";
					
					if(p+q==10) s = s + " + " + t;
					else if(p-q==10) s = s + " - " + t;
					else if(q-p==10) s = t + " - " + s;
					else s = s + " * " + t;
					
					System.out.println(s);
					return true;
				}
			}
		}
		return false;
	} 
	
	boolean st(int a, int b, int c, int d){
		int p, q;
		String s = "";
		for(int i=0;i<4;i++){
			if(i==0) p = a+b;
			else if(i==1) p = a-b;
			else if(i==2) p = b-a;
			else p = a*b;
			for(int j=0;j<4;j++){
				if(j==0) q = c+p;
				else if(j==1) q = c-p;
				else if(j==2) q = p-c;
				else q = c*p;
				
				if(d+q==10 || d-q==10 || q-d==10 || d*q==10){
					if(i==0) s = "( " + a + " + " + b + " )";
					else if(i==1) s = "( " + a + " - " + b + " )";
					else if(i==2) s = "( " + b + " - " + a + " )";
					else s = "( " + a + " * " + b + " )";
					
					if(j==0) s = "( " + c + " + " + s + " )";
					else if(j==1) s = "( " + c + " - " + s + " )";
					else if(j==2) s = "( " + s + " - " + c + " )";
					else s = "( " + c + " * " + s + " )";
					
					if(d+q==10) s = "( " + d + " + " + s + " )";
					else if(d-q==10) s = "( " + d + " - " + s + " )";
					else if(q-d==10) s = "( " + s + " - " + d + " )";
					else s = "( " + d + " * " + s + " )";
					
					System.out.println(s);
					return true;
				}
			}	
		}
		return false;
	}
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int[] n = new int[4];
			for(int i=0;i<4;i++) n[i] = sc.nextInt();
			if(n[0]==0 && n[1]==0 && n[2]==0 && n[3]==0) break;
			
			boolean flag = false;
			for(int i=0;i<4;i++){
				for(int j=0;j<4;j++){
					if(i!=j){
						for(int k=0;k<4;k++){
							if(i!=k && j!=k){
								for(int r=0;r<4;r++){
									if(i!=r && j!=r && k!=r){
										if(dd(n[i],n[j],n[k],n[r])==true || st(n[i],n[j],n[k],n[r])==true){
											flag = true;
											i=4;
											j=4;
											k=4;
											r=4;
										}
									}
								}
							}
						}
					}
				}
			}
			if(flag==false) System.out.println(0);
		}
	}
	
	
	public static void main(String[] args) {
		new Main().solve();
	}	
}

Measured memory_bytes: 19740
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(void)
{
    double q, x, eq;
    while(scanf("%lf",&q),q>0)
    {
        x = q/2;
        eq = q*0.00001;
        while(fabs(x*x*x-q) >= eq)
            x -= (x*x*x-q)/(3*x*x);
        printf("%f\n", x);
    }
    return 0;
}


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

int main(){
ll n;
cin>>n;
ll a[n+1],b[n+1]={0};
ll ans=0,curr=1;
for(int i=0;i<n;i++){
cin>>a[i];
if(a[i]==curr){
curr++;}
else{
ans++;}
}

if(ans==n){
cout<<-1<<endl;}
else{

cout<<ans<<endl;}
}

Measured memory_bytes: 3328
#![allow(non_snake_case)]
use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let K: usize = read();
    let mut vec: Vec<i64> = (0..N).map(|_| read()).collect();
    let MOD = 10_i64.pow(9) + 7;
    vec.sort();
    if vec.iter().all(|&x| x < 0) && K % 2 == 1 {
        vec.reverse();
        let mut tmp: i64 = 1;
        for &i in &vec[0..K] {
            tmp *= i as i64;
            tmp %= MOD;
        }
        println!("{}", tmp + MOD);
        return;
    }
    let mut negatives: Vec<i64> = vec
        .iter()
        .filter(|&x| x < &0)
        .copied()
        .map(|x| -x)
        .collect();
    let mut positives: Vec<i64> = vec.iter().filter(|&x| x >= &0).copied().collect();
    negatives.sort();
    positives.sort();
    let mut ans_vec: Vec<i64> = vec![];
    while ans_vec.len() != K {
        if positives.is_empty() {
            let v = negatives.pop().unwrap();
            ans_vec.push(-v);
            continue;
        }
        if negatives.len() < 2 {
            let v = positives.pop().unwrap();
            ans_vec.push(v);
            continue;
        }
        if K - ans_vec.len() == 1 {
            let v = positives.pop().unwrap();
            ans_vec.push(v);
            continue;
        }
        if positives.len() == 1 && K - ans_vec.len() >= 2 {
            let v1 = negatives.pop().unwrap();
            let v2 = negatives.pop().unwrap();
            ans_vec.push(-v1);
            ans_vec.push(-v2);
            continue;
        }
        let neg = negatives[negatives.len() - 1] * negatives[negatives.len() - 2];
        let pos = positives[positives.len() - 1] * positives[positives.len() - 2];
        if pos > neg {
            let v = positives.pop().unwrap();
            ans_vec.push(v);
        } else {
            let v1 = negatives.pop().unwrap();
            let v2 = negatives.pop().unwrap();
            ans_vec.push(-v1);
            ans_vec.push(-v2);
        }
    }
    let mut ans: i64 = 1;
    for v in ans_vec {
        ans *= v;
        ans %= MOD;
    }
    if ans < 0 {
        ans += MOD;
    }
    println!("{}", ans)
}


Measured memory_bytes: 7620
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) {
	if (b == 0) return a;
	else return GCD(b, a % b); 
}
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }
template<class T>
inline T upper(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	if (s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3624
from bisect import bisect
N = int(input())
*A, = map(int, input().split())
B = {}
for a in A:
    B[a] = B.get(a, 0) + 1
R = sorted(B.items())
C = []; D = []
for k, v in sorted(B.items()):
    C.append(k)
    D.append(v)
M = len(C)
j = 0
ans = 0
for i in range(M-1, -1, -1):
    if D[i] == 0:
        continue
    a = C[i]
    b = 2**a.bit_length()
    j = bisect(C, b-a-1)
    if j < M and C[j] == b-a:
        if i == j:
            c = D[i]//2
        else:
            c = min(D[i], D[j])
        ans += c
        D[i] -= c; D[j] -= c
print(ans)

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;



template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

int main(){
    int N; cin >> N;
    ll m = INF;
    int count = 0;
    ll res = 0ll;

    rp(i, 0, N) {
        ll a; cin >> a;
        if(a < 0) count ++;
        a = abs(a);
        chmin(m, a);
        res += a;
    }
    if(count % 2) res -= 2 * m;
    cout << res << endl;
    return 0;
}

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

int main(void){
  int Q,A,qq[4],aa[4],Hit,Blow,num;


  while(1){

    num = 1000;
    Hit = Blow = 0;

  cin >> Q >> A;
  if( Q == 0 && A == 0 ) break;

  for( int i = 0 ; i < 4 ; i++ ){

    qq[i] = Q / num % 10;
    aa[i] = A / num % 10;
    num/=10;

  }

  for( int i = 0 ; i < 4 ; i++ ){
    for( int j = 0 ; j < 4 ; j++ ){

      if( qq[i] == aa[j] && i == j ) Hit++;
      else if( qq[i] == aa[j] && i != j ) Blow++;

    }
  }

  cout << Hit << " " << Blow << endl;

  }

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll a, b;
	char c;
	cin >> a >> c >> b;
	
	if( c == '+' ) cout << a + b << endl;
	else if( c == '-' ) cout << a - b << endl;
	
	return 0;
}


Measured memory_bytes: 3508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
vector<int>v[maxn];
priority_queue<int>q;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int a,b;
    for(int i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        v[a].push_back(b);
    }
    int ans=0;
    for(int i=1;i<=m;i++){
        for(auto c:v[i]) q.push(c);
        if(!q.empty()){
            ans+=q.top();
            q.pop();
        }
    }
    printf("%d\n",ans);
}


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


int main(){

	string s, t;
	cin >> s >> t;
	vector<int> start(26, -1), goal(26, -1);
	string ans = "Yes";
	for(int i = 0; i < (int)s.size(); i++)
	{
		int a, b;
		a = s[i] - 'a';
		b = t[i] - 'a';
		if(start[a] != -1 || goal[b] != -1){
			if(start[a] != b || goal[b] != a) ans = "No";
		}
		else
		{
			start[a] = b;
			goal[b] = a;
		}		
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
 
int main(){
  int N;
  cin >> N;
  if(N < 1200) cout << "ABC" << endl;
  else if(N < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  }

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

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
using ll  = long long;

int mypow(int a, ll n){
  int ans = 1;
  while(n){
    if(n&1) ans *= a;
    a *= a;
    n = n >> 1;
  }
  return ans;
}

signed main(){
  int n;
  while(cin >> n, n){
    string ans;
    int cur = 0; // k-1桁までの数
    int k = 2; // 桁数
    int a, b = -1;
    
    // 桁数kを決定してから最上位の桁aを決定する
    while(1){
      int tmp = 81*(mypow(2,k-1)-1); // k桁の場合の数
      if(cur + tmp < n){
	cur += tmp;
	k++;
	continue; // k桁ではないのでk+1桁か調べる
      }
      
      tmp /= 9; // 最上位がiだった時の場合の数
      FOR(i,1,10){
	if(cur < n and n <= cur + tmp){
	  a = i;
	  break;
	}else{
	  cur += tmp;
	}
      }
      break;
    }
    ans += to_string(a);

    // k-1桁目を決める
    while(k-1 > 0){
      if(b == -1){ // もう1つの数が未定
	int tmpa = mypow(2,k-2); // この桁がaでないとき
	int tmpb = 9 * mypow(2,k-2) - 9; // この桁がaのとき
	FOR(i,0,10){
	  int tmp; // k-1桁目がiのときの場合の数
	  if(a == i) tmp = tmpb;
	  else tmp = tmpa;
	  if(cur < n and n <= cur + tmp){
	    if(a != i)
	      b = i;
	    break;
	  }else
	    cur += tmp;
	}
	if(b == -1) ans += to_string(a);
	else{
	  ans += to_string(b);
	  if(a > b) swap(a,b);
	}
      }else{
	// 二進数みたいな感じ
	if(n <= cur + mypow(2,k-2)) ans += to_string(a);
	else{
	  cur += mypow(2,k-2);
	  ans += to_string(b);
	}
      }
      k--;
    }
    cout << ans << endl;
  } 
}


Measured memory_bytes: 3216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String msg = "Good";

		for (int i = 0; i < 3; i++) {
			if (s.substring(i, i + 1).equals(s.substring(i + 1, i + 2))) {
				msg = "Bad";
			}
		}

		System.out.println(msg);

	}
}


Measured memory_bytes: 20180
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
ll digit(ll x){ll c=0;while(x>0){x=x/10;c++;}return c;}
// for (ll i = 0; i < n; i++) {
// sort(.begin(), .end());
int main(){
  ll n;
  str s, ans="Good";
  cin >> s;
  for (ll i = 0; i < 3; i++) {
    if (s[i] == s[i+1]) {
      ans = "Bad";
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

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

int N;
// maxIndex[i]: B[j] >= A[i]なる最大のj(1-indexed，存在しないときは0)
int A[40001], B[40001], maxIndex[40001];

int main(){
    while(std::cin >> N, N){
        FOR(i, 1, N+1){
            std::cin >> A[i];
        }
        std::sort(A+1, A+N+1, std::greater<int>());

        FOR(i, 1, N+1){
            std::cin >> B[i];
        }
        std::sort(B+1, B+N+1, std::greater<int>());

        for(int i=1,j=0;i<=N;i++){
            while(j+1<=N&&B[j+1]>=A[i]){j += 1;}
            maxIndex[i] = j;
            // printf("%d: %d\n", i, maxIndex[i]);
        }

        int a_win = 0, b_win = 0;
        FOR(i, 1, N+1){
            if(maxIndex[i] - b_win > 0){ // bが勝つ
                // puts("B won");
                b_win += 1;
            }else{ // aが勝つ
                // puts("A won");
                a_win += 1;
            }

            if(a_win > (a_win+b_win) / 2){break;}
        }

        if(a_win+b_win == N){
            puts("NA");
        }else{
            printf("%d\n", a_win+b_win);
        }
    }
}

Measured memory_bytes: 1624