akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)

const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
char f[8][8];

inline bool inner(int x, int y) { return 0<=x && x<8 && 0<=y && y<8; }

int kount(int cx, int cy, char me, char ene) {
    if(f[cx][cy]!='.') return 0;
    int c = 0;
    rep(d, 8) {
        int x = cx+dx[d], y = cy+dy[d], t = 0;
        while(inner(x, y) && f[x][y]==ene) x+=dx[d], y+=dy[d], t++;
        if(inner(x, y) && f[x][y]==me) c += t;
    }
    return c;
}

void flip(int cx, int cy, char me, char ene) {
    if(f[cx][cy]!='.') return ;
    f[cx][cy] = me;
    rep(d, 8) {
        int x = cx+dx[d], y = cy+dy[d];
        while(inner(x, y) && f[x][y]==ene) x+=dx[d], y+=dy[d];
        if(inner(x, y) && f[x][y]==me) {
            int tx=cx, ty=cy;
            while(tx!=x || ty!=y) {
                f[tx][ty] = me;
                tx+=dx[d], ty+=dy[d];
            }
        }
    }
}

int main() {
    rep(i, 8) rep(j, 8) scanf(" %c", f[i]+j);
    int a, b;
    do {
        a = 0;
        rep(i, 8) rep(j, 8) a = max(a, kount(i, j, 'o', 'x'));
        if(a) rep(i, 8) rep(j, 8) if(kount(i, j, 'o', 'x')==a) {
            flip(i, j, 'o', 'x');
            a = -1;
        }
        b = 0;
        rep(i, 8) rep(j, 8) b = max(b, kount(i, j, 'x', 'o'));
        if(b) rep(i, 8) rep(j, 8) if(kount(7-i, 7-j, 'x', 'o')==b) {
            flip(7-i, 7-j, 'x', 'o');
            b = -1;
        }
    } while(a || b);
    rep(i, 8) {
        rep(j, 8) putchar(f[i][j]);
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 0
//cool
#include <iostream>
#include <fstream>
#include <set>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long int lli;
typedef int ll;
#define lp(i, wwww) for(int i=0; i<wwww; i++)
#define lp2(i, a, b) for(int i=a; i<b; i++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define clean(a, b) memset(a, b, sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pb push_back

string s;
vector<int>v;

ll main(){
	IOS;
	cin >> s;
	for (int i=0; i<4; i++) v.push_back(int(s[i]));
	sort(&v[0], &v[4]);
	if (v[0]==v[1] && v[2]==v[3] && v[2]!=v[1]) {
	   cout << "Yes";
       return 0;
    }
	cout << "No";
}
		


Measured memory_bytes: 256
def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers}


A, B, K = map(int, input().split(' '))

a_dividers = get_dividers(A)
b_dividers = get_dividers(B)
ab_dividers = sorted(a_dividers & b_dividers)
print(ab_dividers[-K])


Measured memory_bytes: 3060
//
//  main.cpp
//  C - Write and Erase
//
//  Created by wenhan on 2017/9/9.
//  Copyright © 2017年 wenhan. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
int a[100005];
int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1, a+1+n);
    int s=1;
    int t=0;
    for(int i=1;i<n;i++)
        if(a[i]==a[i+1])
            s++;
        else
        {
            if(s%2==1)
                t++;
            s=1;
        }
    if(s%2==1)
        t++;
    printf("%d\n",t);
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    rep(i, n) { int a; cin >> a; mp[a]++; }
    int tmp = SZ(mp); // out(tmp);
    vector<pii> a;
    for (auto e : mp) { a.eb(e.S, e.F); }
    sort(all(a));
    int ans = 0;
    rep(i, tmp - k) ans += a[i].F;
    out(ans);
    
}



Measured memory_bytes: 11764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)


//0-index ?????????????????¶?????°?????????(????????????) verified AOJ DSL_2_G, (((CODEFESTIVAL2015-D)))
template<class T>
class lazySegmentTree{
private:
    vector<T> dat;
    vector<T> lazy;
    int _size;  //the number of leaves
    T _init;
    
public:
    lazySegmentTree( vector<T> vec, T init = numeric_limits<T>::max() ): _init(init){
        int size = vec.size();
        if(size==0)return ;
        
        _size = 1;
        while(_size<size)_size*=2;
        dat.resize(_size*2);
        rep(i,vec.size())dat[i+_size] = vec[i];
        lazy.resize(_size*2,_init);
    }
    
    
    void eval(int num, int l, int r){
        if(lazy[num]==0) return ;
        dat[num] += lazy[num];
        
        if(r-l>1){  //?????§?????????
            lazy[num*2] += lazy[num]/2;
            lazy[num*2+1] += lazy[num]/2;
        }
        lazy[num] = 0;
    }
    
    
    
    T update(int s, int t, T x, int num=1, int l=0, int r=-1){
        if(r==-1)r =_size;
        
        eval(num,l,r);
        
        if(r<=s || t<=l) return _init ;   //????±??????????
        if(s<=l && r<=t){
            lazy[num] += x * (r-l);
            eval(num,l,r);
        }
        else{
            update(s, t, x, num*2, l, (l+r)/2);
            update(s, t, x, num*2+1, (l+r)/2, r);
            dat[num] = dat[num*2] + dat[num*2+1];
        }
        return dat[num];
    }
    
    
    T find(int s, int t, int num=1, int l=0, int r=-1){
        if(r==-1)r = _size;
        
        eval(num,l,r);
        
        
        if(r<=s || t<=l) return _init;  //????±??????????
        if(s<=l && r<=t) return dat[num];
        else{
            return find(s, t, num*2, l, (l+r)/2) + find(s, t, num*2+1, (l+r)/2, r);
        }
    }
    
    int size(){ return _size; }
};

signed main(){
    int n,q;
    cin>>n>>q;
    
    lazySegmentTree<int> seg(vector<int>(n,0), 0);
    
    rep(i,q){
        int type,s,t,x;
        cin>>type;
        if(type==0){
            cin>>s>>t>>x;
            s--;
            seg.update(s,t,x);
        }else{
            cin>>s>>t;
            s--;
            cout<<seg.find(s,t)<<endl;
        }
    }
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);

    int a,b;
    vector<vi> e(N);
    Rep(i,N-1){
        Scd2(a,b);
        a--,b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    vi id(N,-1);
    stack<int> s;
    id[0] = 0;
    s.push(0);
    while(s.size()){
        int from = s.top();
        s.pop();
        int idd = (id[from]+1)%2;
        for( int to : e[from] ){
            if( id[to] == -1 ){
                id[to] = idd;
                s.push(to);
            }
        }
    }

    int t1 = 1;
    int t2 = 2;
    int t3 = 3;
    vi cnt(2);
    Rep(i,N){
        cnt[id[i]]++;
    }
    vi ans(N);
    if( cnt[0] <= N/3 ){
        Rep(i,N){
            if( id[i] == 0 ) ans[i] = t3, t3 += 3;
            else if( t2 <= N ) ans[i] = t2, t2+= 3;
            else if( t1 <= N ) ans[i] = t1, t1+=3;
            else ans[i] = t3, t3+=3;
        }
    }else if( cnt[1] <= N/3 ){
        Rep(i,N){
            if( id[i] == 1 ) ans[i] = t3, t3 += 3;
            else if( t2 <= N ) ans[i] = t2, t2+= 3;
            else if( t1 <= N ) ans[i] = t1, t1+=3;
            else ans[i] = t3, t3+=3;
        }
    }else{
        Rep(i,N){
            if( id[i] == 0 && t1 <= N ) ans[i] = t1, t1 += 3;
            else if( id[i] == 1 && t2 <= N ) ans[i] = t2, t2+= 3;
            else ans[i] = t3, t3+=3;
        }
    }

    Rep(i,N){
        printf ("%d%s", ans[i], i==N-1?"\n":" " );
    }

    return 0;
}



Measured memory_bytes: 15220
import os
import heapq
import sys,threading
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

sys.setrecursionlimit(10 ** 5)
threading.stack_size(2**27)


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


"""def pw(a,b):
    result=1
    while(b>0):
        if(b%2==1): result*=a
        a*=a
        b//=2
    return result"""


def inpt():
    return [int(k) for k in input().split()]


def main():
    n=int(input())
    ar=inpt()
    sm=0
    ans=0
    md=10**9+7
    for i in range(n-1):
        sm+=ar[i]
        temp=(sm%md * ar[i+1]%md)%md
        ans=(ans+temp)%md
    print(ans)






BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()
    #threading.Thread(target=main).start()


Measured memory_bytes: 96292
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N = I()
ans = 0
A,B = [],[]
for i in range(N):
    a,b = MI()
    A.append(a)
    B.append(b)

if A == B:
    print(0)
    exit()

s = sum(B)
m = s
for i in range(N):
    if A[i] > B[i]:
        m = min(m,B[i])

print(s-m)


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

const int MAX_N = 110;
int n;
string s[MAX_N], x;
int t[MAX_N];

void solve()
{
	int ans = 0;
	bool seen = false;
	for(int i=0;i<n;++i){
		if(s[i] == x) seen = true;
		else if(seen) ans+=t[i];
	}
	cout<<ans;
}

int main()
{
	cin >> n;
	for(int i=0;i<n;++i) cin >> s[i] >> t[i]; 
	cin >> x;
	solve();
	return 0;
}

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

using namespace std;

#define pb            push_back
#define mp            make_pair
#define po            pop_back
#define fi            first
#define se            second
#define mxn           100005
#define ll            long long int
#define ldb           long double
#define fr(i,a,b,k)   for(int i=a ; i<b ; i+=k)
#define frr(i,a,b,k)  for(int i=a ; i>b ; i-=k)
#define all(v)        v.begin(),v.end()
#define endl          "\n"
#define deg(x)        cout<<endl<<#x<<" = "<<(x)<<endl;
#define casep(x)      cout<<"Case #"<<(x)<<": ";
#define fast          ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

typedef pair<ll,ll> pp;
typedef vector<ll> vi;
typedef vector<pp> vpp;
typedef vector<vi> vvi;

const int inf = INT_MAX;

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b){ return __gcd(a,b);}
ll lcm(ll a,ll b){return a*b/__gcd(a,b);}
vector<vector<ll>> adj;
vector<bool> vis;


void solve(ll test){

    ll n;
    cin >> n;
    ll a[n];
    fr(i,0,n,1)cin >> a[i];

    ll ans = 0;
    fr(i,0,n,1){
        fr(j,i+1,n,1){
            if(a[i] == a[j])continue;
            ll sum = a[i]+a[j];
            fr(k,j+1,n,1){
                if(a[k] == a[i] || a[k] == a[j])continue;
                ll sum1 = a[k]+a[i];
                ll sum2 = a[k]+a[j];
                if(a[k] < sum && sum1 > a[j] && sum2 > a[i]){
                    // cout << i+1 << " " << j+1 << " " << k+1 << endl;
                    ans++;
                }
            }
        }
    }

    cout << ans;

}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        solve(i);
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3656
#include<cstdio>
using namespace std;
main()
{
    double w,h,x,y;
    scanf("%lf%lf%lf%lf",&w,&h,&x,&y);
    printf("%lf ",w*h/2.0);
    if(w/2==x&&h/2==y)puts("1");
    else puts("0");
}

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

int main() {
	int ans = 0;
	int N;
	cin >> N;
	vector<int> a;
	for (int i = 0; i < N; i++) {
		int t;
		cin >> t;
		a.push_back(t-1);
	}
	for (int i = 0; i < a.size(); i++) {
		if (i == a[a[i]]) {
			ans++;
		}
	}
	cout << ans/2 << endl;
	return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        final int H = sc.nextInt();
        final int N = sc.nextInt();
        int A[] = sc.nextIntArray(N);
        int accum = 0;
        for (int i = 0; i < N; i++)
            accum += A[i];
        if (accum < H)
            out.println("No");
        else
            out.println("Yes");
        out.flush();
    }
}

// FastScanner start
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int[] nextIntArray(int n) {
        int arr[] = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }
        return arr;
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}
// FastScanner end

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

int main(){
  string s;
  cin >> s;
  int kekka = 0;
  for(int i = 0;i < s.size();i++){
    if(s.at(i) == '2'){
      kekka++;
    }
  }
  cout << kekka << endl;
}

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

int main(){
    int H, W; cin >> H >> W;
    const vector<int> dx = {1, 0, -1,  0, 1, -1, -1,  1};
    const vector<int> dy = {0, 1,  0, -1, 1,  1, -1, -1};
    vector<string> board(H);
    for (int i = 0; i < H; i++) {
        cin >> board.at(i);
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (board.at(i).at(j) == '#') { continue; }

            int num = 0;
            for (int d = 0; d < 8; d++) {
                const int ni = i + dx.at(d);
                const int nj = j + dy.at(d);

                if (ni < 0 || H <= ni) { continue; }
                if (nj < 0 || W <= nj) { continue; }
                if (board.at(ni).at(nj) == '#') {
                    num++;
                }
            }

            board.at(i).at(j) = char(num + '0');
        }
    }

    for (int i = 0; i < H; i++) {
        cout << board.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
ll mod=1000000007;
#define vl vector<ll>
#define pl pair<ll,ll>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,b) for(ll i=0;i<b;i++)
#define RFOR(i,a,b) for(ll i=b-1;i>=a;i--)
#define rsort(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;
set<string>s;

ll n,k;
ll T[100000];
ll check(ll P){
    ll i=0;
    rep(j,k){
        ll s=0;
        while(s+T[i]<=P){
         s+=T[i];
         i++;
         if(i==n)return n;
        }
    }
    return i;
}
ll solve(){
    ll left=0;
    ll right=100000*10000;
    ll mid;
    while(right-left>1){
        mid=(left+right)/2;
        ll v=check(mid);
        if(v>=n)right=mid;
        else left=mid;
    }
    return right;
}
int main(){
    cin>>n>>k;
    rep(i,n)cin>>T[i];
    ll ans=solve();
    cout<<ans<<endl;
}


Measured memory_bytes: 3884
package main

import (
	"fmt"
)

func main() {
	var a,b,k int
	fmt.Scan(&a,&b,&k)
	
	cnt := 0
	for i := 100; i > 0; i-- {
		if a % i == 0 && b % i == 0 {
			cnt++
			if cnt == k {
				fmt.Println(i)
				break
			}
		}
	}

}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#define NMAX 100001

using namespace std;

int N, M;
vector<int> a;
int dp[NMAX];
int finish[NMAX];
int isOK[NMAX];

long long int fdp(long int i){
  if(finish[i]>0){
    return dp[i];
  }else{
    if(isOK[i]==1){
      finish[i]=1;
      dp[i]=0;
      return dp[i];
    }else if(i==0||i==1){
      finish[i]=1;
      dp[i]=1;
      return dp[i];
    }else{
      finish[i]=1;
      dp[i]=(fdp(i-1)+fdp(i-2))%1000000007;
      return dp[i];
    }
  }
}

int main(void){
  cin >> N >> M;
  for(int i=0;i<M;i++){
    long int tmp;
    cin >> tmp;
    isOK[tmp]=1;
  }
  cout << fdp(N);
  return 0;
}


Measured memory_bytes: 4480
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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


















int main(){
    ll n, m;
    cin >> n >> m;
    vector<bool> f(n, false);
    vector<ll> c(n, 0);
    REP(i, m){
        ll p;
        string s;
        cin >> p >> s;
        p--;
        if(s == "AC"){
            f[p] = true;
        }
        else{
            if(!f[p]){
                c[p]++;
            }
        }
    }
    ll cnt1 = 0, cnt2 = 0;
    REP(i, n){
        cnt1 += f[i];
        if(f[i]) cnt2 += c[i];
    }
    cout << cnt1 << " " << cnt2 << endl;
}

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

using namespace std;

int s;

int main(){

    cin >> s;
    if (s < 1200){
        cout << "ABC" << endl;
    } 
    
    else if(1200 <= s && s < 2800){
        cout << "ARC" << endl;
    }
    else{
        cout << "AGC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<functional>
using namespace std;

int main(){
    string s;
    cin>>s;
    int i;
    i=s.length()-3;
    while(s.substr(0,i/2)!=s.substr(i/2+1,i/2)){
        //cout<<s.substr(0,i/2)<<endl;
        //cout<<s.substr(i/2+1,i)<<endl;
        //cout<<endl;
        i-=2;
    }
    cout<<i+1<<endl;
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

// 考えついた方針は合ってたけど実装が浮かばなかった
func main() {
	H := nextInt()
	W := nextInt()
	S := make([]string, H)
	// 周囲1マスずつを定義
	dxy := [][]int{{1, 0}, {0, 1}, {-1, 0}, {0, -1}, {1, 1}, {-1, 1}, {-1, -1}, {1, -1}}
	// ans := make([][]int, H)
	// for i := 0; i < H; i++ {
	// 	ans[i] = make([]int, W)
	// }
	for i := 0; i < H; i++ {
		S[i] = nextLine()
	}
	Srune := make([][]rune, H)
	for i := 0; i < H; i++ {
		Srune[i] = []rune(S[i])
	}
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if Srune[i][j] == '#' {
				continue
			}
			var num int
			for d := 0; d < len(dxy); d++ {
				n := []int{j, i}
				n[0] = j + dxy[d][0]
				n[1] = i + dxy[d][1]
				if n[0] < 0 || W <= n[0] || n[1] < 0 || H <= n[1] {
					continue
				}
				if Srune[n[1]][n[0]] == '#' {
					num++
				}
			}
			Srune[i][j] = rune(num + '0')
		}
	}
	for i := 0; i < H; i++ {
		fmt.Println(string(Srune[i]))
	}
}

func searchMine([]int) {

}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


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

struct edge{
  int to, color;
};

void coloring(vector<vector<edge> > &E, int r, int p, int c){
  int color = 1;
  for(int i = 0; i < E[r].size(); i++){
    if(E[r][i].to == p) continue;
    if(E[r][i].color == 0){
      if(color == c) color++;
      E[r][i].color = color;
      int tmp = E[r][i].to;
      for(int j = 0; j < E[tmp].size(); j++){
        if(E[tmp][j].to == r){
          if(E[tmp][j].color == 0){
            E[tmp][j].color = color;
          }
        }
      }
      color++;
    }
    int j = E[r][i].to;
    coloring(E, j, r, E[r][i].color);
  }
}

int main(){
  int N;
  cin >> N;
  vector<vector<edge> > E(N+1);
  vector<pair<int, int> > outE;
  for(int i = 0; i < N-1; i++){
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    edge tmpE1 = {tmp2, 0};
    edge tmpE2 = {tmp1, 0};
    outE.push_back(make_pair(tmp1, tmp2));
    E[tmp1].push_back(tmpE1);
    E[tmp2].push_back(tmpE2);
  }
  int numC = 0, r = 0;
  // for(int i = 0; i < E.size()-1; i++){
  //   for(int j = 0; j < E[i+1].size(); j++){
  //     cout << i+1 << " " << E[i+1][j].to << " " << E[i+1][j].color << endl;
  //   }
  // }
  for(int i = 0; i < N-1; i++){
    int tmpC = E[i+1].size();
    // cout << "sizeE = " << tmpC << endl;
    if(numC < tmpC){
      numC = tmpC;
      r = i+1;
    }
  }
  coloring(E, r, 0, 0);
  // cout << r << endl;
  cout << numC << endl;
  for(int i = 0; i < N-1; i++){
    // cout << outE[i].first << " " << outE[i].second << endl;
    // cout << "size = " <<  E[outE[i].first].size() << endl;
    for(int j = 0; j < E[outE[i].first].size(); j++){
      if(E[outE[i].first][j].to == outE[i].second){
        cout << E[outE[i].first][j].color << endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 8568
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
template <class T>
int upb(V<T> &v, const T &x) { return upper_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    ll d;
    cin >> d;
    int res = 0;
    for (int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d) {
            res++;
        }
    }
    cout << res << newl;
}

Measured memory_bytes: 3648
n=int(input())
if n%2 == 1:
	print("0")
else:
	k = n//2
	cnt = 1
	ans = 0
	while True:
		if k//(5**cnt) >= 1:
			ans += k//(5**cnt)
			cnt += 1
		else:
			break
	print(ans)

Measured memory_bytes: 2940
/*
* @Author: Samson
* @Date:   2018-05-03 22:37:33
* @Last Modified by:   Samson
* @Last Modified time: 2018-05-03 22:44:49
*/
//   @URL : 
#include<bits/stdc++.h>
#include<algorithm>
#include <cstdlib>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int MAXN = 1e5+10;

int a[25],q,m,n;

int fun(int i,int m)
{
	if(m == 0)	return 1;
	if(i > n)	return 0;
	return (fun(i+1,m) || fun(i+1,m-a[i]));
}

int main(void)
{
	ios::sync_with_stdio(false); 
	//cin.tie(0);
	cin>>n;
	for(int i = 1; i <= n; ++i)
		cin>>a[i];
	cin>>q;
	while(q--)
	{
		cin>>m;
		if(fun(0,m))
			cout<<"yes\n";
		else
			cout<<"no\n";
	}
	return 0;
}


Measured memory_bytes: 3136
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

    vector<int> A(N);
    for (int i = 0; i < N; i++)cin >> A[i];

    int ans = 0;
    for (int i = 1; i <= 100; i++) {
        int sum = 0;
        bool good = true;
        for (int j = 0; j < N; j++) {
            sum += A[j];
            sum -= i;
            if (sum < 0) good = false;
        }
        if(good) ans = i;
    }

    cout << ans << endl;

}












Measured memory_bytes: 3084
N = int(input())

p = input().split(' ')
ans = 0
for i in range(N):
    if int(p[i]) == i+1:
        if not(i==N-1) and not(p[i+1] ==i+1):
            rrr = p[i]
            p[i] = p[i+1]
            p[i+1] = rrr
            ans +=1
        else:
            rrr = p[i]
            p[i]=p[i-1]
            p[i-1] =rrr
            ans +=1

print(ans)
#print(p)


Measured memory_bytes: 10420
K = int(input())
N = 50

print(N)
br = (K-1)//50
pos = K-50*br
ans_list = list(range(br,br+50))
for i in range(pos,N):
    ans_list[i] -= 1*pos
for i in range(0,pos):
    ans_list[i] = ans_list[i]+N-(1*pos)+1

print(" ".join(map(str,ans_list)))

Measured memory_bytes: 3316
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#include <bitset>

using namespace std;
typedef long long ll;

int main(){
    int N;
    
    while(1){
        cin >> N;
        
        if(!N)break;
        
        int q[100][24] = {0};
        int d[100] = {0};
        
        for(int i=0; i<N; ++i){
            int t;
            cin >> d[i] >> t;
            for(int j=0; j<d[i]; ++j){
                cin >> q[i][(j + d[i] - t)%d[i]];
            }
        }
        
        const int M = 2*2*2*2*3*3*5*7*11;
        ll sum[M] = {0};
        ll sum13[13] = {0};
        ll sum17[17] = {0};
        ll sum19[19] = {0};
        ll sum23[23] = {0};
        
        for(int i=0; i<N; ++i){
            switch(d[i]){
                case 13:for(int j=0; j<13; ++j){sum13[j] += q[i][j];}break;
                case 17:for(int j=0; j<17; ++j){sum17[j] += q[i][j];}break;
                case 19:for(int j=0; j<19; ++j){sum19[j] += q[i][j];}break;
                case 23:for(int j=0; j<23; ++j){sum23[j] += q[i][j];}break;
                default:{
                    int cnt=0;
                    while(cnt != M){
                        for(int j=0; j<d[i]; ++j){
                            sum[cnt] += q[i][j];
                            ++cnt;
                        }
                    }
                }break;
            }
        }
        ll maxSum = 0, maxSum13 = 0, maxSum17 = 0, maxSum19 = 0, maxSum23 = 0;
        for(int j=0; j<13; ++j){maxSum13 = max(maxSum13, sum13[j]);}
        for(int j=0; j<17; ++j){maxSum17 = max(maxSum17, sum17[j]);}
        for(int j=0; j<19; ++j){maxSum19 = max(maxSum19, sum19[j]);}
        for(int j=0; j<23; ++j){maxSum23 = max(maxSum23, sum23[j]);}
        for(int j=0; j<M; ++j){maxSum = max(maxSum, sum[j]);}
        
        cout << (maxSum + maxSum13 + maxSum17 + maxSum19 + maxSum23) << endl;
    }
    return 0;
}

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


class AtCoder:
    def main(self):
        N = int(input())
        S = input().rstrip()

        if N%2 == 0:
            middle = N//2
            if S[:middle] == S[middle:]:
                print('Yes')
            else:
                print('No')
        else:
            print('No')


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 38256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);
double to_deg(double rad);
double distance(int xi, int yi, int xj, int yj);

//main function
int main() {
    long long A = llin(), B = llin();
    llout(lllcm(A, B));
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

/*
    int型の最大公約数
*/

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    int型の最小公倍数
*/

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    long long型の最大公約数
*/

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    long long型の最小公倍数
*/

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    int型の昇順用比較関数
*/

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

/*
    int型の降順用比較関数
*/

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

/*
    弧度法を度数法に
*/

double to_deg(double rad) {
    return rad * 180.0 / (atan(1.0) * 4.0);
}

double distance(int xi, int yi, int xj, int yj) {
    return hypot(xj - xi, yj - yi);
}


Measured memory_bytes: 128
# https://atcoder.jp/contests/abc063/tasks/arc075_b
# 問題文あなたが散歩していると、突然 N 体の魔物が出現しました。
# それぞれの魔物は 体力 という値を持ち、i 体目の魔物の出現時の体力は hi です。
# 体力が 0以下となった魔物は直ちに消滅します。
# 幸い、あなたは熟練の魔法使いであり、爆発を引き起こして魔物を攻撃できます。
# 一回の爆発では、以下のように魔物の体力を減らすことができます。
# 生存している魔物を一体選び、その魔物を中心に爆発を引き起こす。
# 爆発の中心となる魔物の体力は A 減り、
# その他の魔物の体力はそれぞれ B 減る。
# ここで、A と B はあらかじめ定まった値であり、A>B である。
# すべての魔物を消し去るためには、最小で何回の爆発を引き起こす必要があるでしょうか？
# 制約入力値はすべて整数である。
# 1≤N≤10^5
# 1≤B<A≤10^9
# 1≤hi≤10^9

# N A B
# h1
# h2
# :
# hN

# 4 5 3
# 8
# 7
# 4
# 2

# 2

# 2 10 4
# 20
# 20

# 4

# 5 2 1
# 900000000
# 900000000
# 1000000000
# 1000000000
# 1000000000

# 800000000

N, A, B = gets.split.map(&:to_i)
H = []
N.times { H << gets.to_i }

A_B = A - B

class Integer
  def able?
    counter = self
    bself = B * self
    b2 = - bself + A_B - 1
    H.each do |value|
      next if value <= bself
      counter -= ((value + b2)/(A_B))
      break if counter < 0
    end
    counter >= 0
  end
end

# T回で倒しきれるか？ を二分探索
# ng = 0, ok = h.max
ng = 0
ok = 10**9
mid = 0
while (ok - ng) > 1
  mid = (ng + ok)/2
  if mid.able?
    ok = mid
  else
    ng = mid
  end
end
puts ok

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

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

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

public class Main {
  public static void main( String[] args ) {
	  int a,b,x,y,z;
      Scanner scan = new Scanner(System.in);

   a = scan.nextInt();
   b = scan.nextInt();
   
   x = a + b;
   y = a - b;
   z = a * b;
   
int values[] = {x, y, z};
int max      = values[0];
for (int index = 1; index < values.length; index ++) {
	 max = Math.max(max, values[index]);
     }
	  System.out.println ( max );
  }
}


Measured memory_bytes: 21844
import collections
N, K = [int(i) for i in input().split()]

# Kで割ってvalue余る数が1以上key以下にいくつあるか
d = collections.defaultdict(int)
for i in range(1, N + 1):
    d[i % K] += 1

ans = 0
for a in range(K):
    b = (K - a) % K
    c = (K - a) % K
    if (b + c) % K:
        continue
    ans += d[a] * d[b] * d[c]
print(ans)

Measured memory_bytes: 50800
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
int main(void){
    int saidai = 0;
    int N;
    cin >> N;
    vector<string> s(N);
    for (int i = 0; i < N; i++) cin >> s[i];
    int M;
    cin >> M;
    vector<string> t(M);
    for (int i = 0; i < M; i++) cin >> t[i];
    for (int i = 0; i < N; i++) {
        string a = s.at(i);
        int c = 0;
        for (int i = 0; i < N; i++) {
            if (a == s.at(i)) c++;
        }
        for (int i = 0; i < M; i++) {
            if (a == t.at(i)) c--;
        }
        if (saidai < c) saidai = c;
    }
    cout << saidai << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}


int main(){
	int n,q;
	cin >> n >> q;
	vector<int> line(n);
	foreach(i,line)cin>>i;
	sort(all(line));
	rep(i,q){
		int l,r;
		cin >> l >> r;
		cout << upper_bound(all(line),r) - lower_bound(all(line),l) << endl;
	}
	return 0;
}



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

#define pi 3.141592654
#define fix(n) cout << fixed << setprecision(n)

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)

#define si(d)  scanf("%d",&d)
#define sll(d) scanf("%lld",&d)
#define pin(d) printf("%d\n",d)
#define pln(d) printf("%lld\n",d)
#define nl 	   printf("\n")

#define ll long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define vi vector<int>
#define pii pair<int,int> 
#define piii pair<pair<int,int>,int> 

#define chalne_de continue
int mod=1000000007;
const int N = 1000005;

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	int n;
	cin >> n ;
	int a[n+1];
	ll sum = 0;
	rep(i,0,n)
	{
		cin >> a[i];
		sum += a[i];
	}
	sort(a,a+n);
	if ( sum % 10)
	{
		cout << sum;
	}
	else
	{
		for ( int i =0; i < n; i++)
		{
			if ( (sum - a[i])%10)
			{
				cout << sum - a[i];
				return 0;
			}
		}
		cout << 0 ;
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

typedef pair<double,int> dmp;
int n;
double A[40005],B[40005],C[40005];

int inv[40005];

int N;
int bit[160005];


void inc(int x){
	for(int i=x;i<=N;i+=(i&(-i)))bit[i]++;
}

int sum(int x){
	int res=0;
	for(int i=x;i>0;i-=(i&(-i)))res+=bit[i];
	return res;
}

double solve(){
	vector<dmp> pa;
	rep(i,n)pa.push_back(dmp(B[i]/A[i],i));
	sort(pa.begin(),pa.end(),greater<dmp>());
	rep(i,n){
		inv[pa[i].sec]=i;
		//printf("%d -> %d\n",i,pa[i].sec);
	}
	
	int hn = n*(n-1)/4;
	if(n*(n-1)%4)hn++; 
	//hn++;
	double l=-16e12,r=16e12;
	rep(k,100){
		double m=(l+r)/2;
		vector<dmp> np;
		rep(i,n){
			np.push_back(dmp((C[i]-B[i]*m)/A[i],i));
		}
		sort(np.begin(),np.end());
		memset(bit,0,sizeof(bit));
		
		int s=0;
		rep(i,n){
			int no=inv[np[i].sec];
			s += sum(no+1);
			inc(no+1);
		}
		//printf("%d %lf\n",s,m);
		if(s<hn)l=m;
		else r=m;
	}
	return l;
}


int main(void){
	scanf("%d",&n);
	N=1;
	while(N<=n+5)N*=2;
	rep(i,n){
		scanf("%lf%lf%lf",&A[i],&B[i],&C[i]);
	}
	double ay=solve();
	rep(i,n){
		swap(A[i],B[i]);
	}
	double ax=solve();
	printf("%.10f %.10f\n",ax,ay);
	return 0;
}






Measured memory_bytes: 4296
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
using namespace std;

unsigned long long int gcd(unsigned long long int x, unsigned long long int y)
{
	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

unsigned long long int lcm(unsigned long long int x, unsigned  long long int y) {

	return (x / gcd(x, y))*y;
}
int main()
{
	int n;
	cin >> n;
	unsigned long long int a = 1, b;
	while (cin >> b) {
		a = lcm(a, b);
	}
	cout << a;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a;
  cin >> n >> a;

  if ( n % 500 >= 0 && n % 500 <= a) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    string s, t;

    while(cin >> s >> t)
    {
		for(i = 0; i < s.size(); i++)
		{
			if(s[i] != t[i]) break;
		}

		if(s.size() == i) cout << "Yes" << endl;
		else cout << "No" << endl;
    }


}




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

int main(){
	int h,w;	cin>>h>>w;
	char tile[h+2][w+2];
	for(int i=0;i<h+2;i++){
		for(int j=0;j<w+2;j++){
			tile[i][j]='@';
		}
	}

	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++)cin>>tile[i][j];
	}
	for(int i=1;i<=h;i++){
		for(int k=0;k<2;k++){
			for(int j=1;j<=w;j++){
				cout<<tile[i][j];
			}
			cout<<endl;
		}
	}
	cout<<endl;

cout<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,i,tmp=0,max=0;
	char s[101];
	scanf("%d %s",&n,s);
	for(i=0;i<n;i++){
		if(s[i]=='I')tmp++;
		if(s[i]=='D')tmp--;
		if(max<tmp)max=tmp;
	}
	printf("%d\n",max);
}

Measured memory_bytes: 128
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
cnt = 0
for i in T:
    m = 0
    S.append(i)
    while i != S[m]:
        m+=1
    if m != n:
        cnt+=1
    S.pop()
print(cnt)


Measured memory_bytes: 6544
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
  if max(p[i-1],p[i],p[i+1])!=p[i] and min(p[i-1],p[i],p[i+1])!=p[i]:
    ans+=1
print(ans)

Measured memory_bytes: 3060