akhauriyash/Code-Regression huggingface dataset:
def f(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1

def solver(v):
    ary = []
    for i in range(10**6):
        if i == 0:
            ary.append(v)
        else:
            v = f(ary[-1])
            if v in ary:
                return i+1
            else:
                ary.append(v)

s = int(input())
print(solver(s))


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int sum;
	int sum1,sum2;
	sum1=a*b;
	sum2=c*d;
	if(sum1>sum2){
		sum=sum1;
	}
	else{
		sum=sum2;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    vector<long long> solve(vector<long long>& S, vector<long long>& T, vector<long long>& W, vector<long long>& D) {
        for (auto& x : S) {
            x <<= 1;
        }
        for (auto& x : T) {
            x <<= 1;
        }
        for (auto& x : W) {
            x <<= 1;
        }
        for (auto& x : D) {
            x <<= 1;
        }

        vector<long long> X;
        int n = W.size();
        int m = D.size();
        for (int i = 0; i < n; ++i) {
            X.push_back(W[i]);
            X.push_back(W[i] - (S[i] - 1));
            X.push_back(W[i] - (T[i] - 1));
        }
        for (auto x : D) {
            X.push_back(-x);
        }
        sort(X.begin(), X.end());
        X.erase(unique(X.begin(), X.end()), X.end());
        auto index = [&](int x) {
            return lower_bound(X.begin(), X.end(), x) - X.begin();
        };

        int N = X.size();
        vector<vector<long long>> add(N + 1);
        vector<vector<long long>> remove(N + 1);
        for (int i = 0; i < n; ++i) {
            long long r = W[i] - (S[i] - 1);
            long long l = W[i] - (T[i] - 1);
            // cout << i << ": " << l << " " << r << " " << W[i] << endl;
            l = index(l);
            r = index(r);
            add[l].push_back(W[i]);
            remove[r + 1].push_back(W[i]);
        }

        const long long INF = 1LL << 60;
        vector<long long> mins(N + 1, INF);

        multiset<long long> M;
        for (int i = 0; i < N; ++i) {
            for (auto x : add[i]) {
                M.insert(x);
            }
            for (auto x : remove[i]) {
                auto it = M.find(x);
                M.erase(it);
            }
            if (!M.empty()) {
                // cout << i << " " << X[i] << " " << *M.begin() << endl;
                mins[i] = *M.begin();
            }
        }

        vector<long long> res(m, -1);
        for (int i = 0; i < m; ++i) {
            auto x = -D[i];
            x = index(x);
            // cout << x << "::: " << X[x] << " " << mins[x] << endl;
            if (mins[x] < INF) {
                res[i] = mins[x] / 2;
            }
        }
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, q;
    cin >> n >> q;
    vector<long long> S(n);
    vector<long long> T(n);
    vector<long long> X(n);
    for (int i = 0; i < n; ++i) {
        cin >> S[i] >> T[i] >> X[i];
    }

    vector<long long> D(q);
    for (int i = 0; i < q; ++i) {
        cin >> D[i];
    }
    Solution sol;
    auto res = sol.solve(S, T, X, D);
    for (auto r : res) {
        cout << r << "\n";
    }
    return 0;
}

Measured memory_bytes: 79080
from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    l[0]=0
    l[1]=0
    prime=[2]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0
    
    for i in range(3,limit+1,2):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r


def solve():
    n=inp()
    if n>=30:
        print("Yes")
    else:
        print("No")
    


for _ in range(1):
    solve()
    


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

#define 	pi 				3.1415926536
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(int i = a ; i < b ; i++)
#define     repn(i, a, b)   for(int i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define 	F 				first
#define 	S 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define 	vi 				vector<int>
#define     pii              pair<int, int>
#define     pll             pair<long long int, long long int>
#define     vll             vector<long long int>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;


/*############################# DSU ##############################*/
vi parent(1e5), Size(1e5), Rank(1e5);

void make_set(int v){
    parent[v]=v;
    Size[v] = 1;
    // Rank[v] = 0;
}
 
int find_set(int v){
	return (parent[v]==v) ?  v : parent[v] = find_set(parent[v]);
}
 
void union_sets(int a, int b){
	a = find_set(a);
	b = find_set(b);
	if(a != b){
        if(Size[a] < Size[b])
            swap(a, b);
        // if(Rank[a] < Rank[b])
        //     swap(a, b);
		parent[b] = a;
        Size[a] += Size[b];
        // if(Rank[a] == Rank[b])
        //     Rank[a]++;
    }
}
/*############################# DSU ##############################*/


bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }

bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }

unsigned int logn(unsigned int n, unsigned int r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }

ll pw2[32];
void cal(){ pw2[0] = 1; rep(i, 1, 32)pw2[i] = 2*pw2[i-1]; }

/* ################################################################ */

void solve()
{
    int k, a, b;
    cin>>k>>a>>b;
    if(a/k==b/k && (a%k&&b%k)){
        cout<<"NG\n";return;
    }
    cout<<"OK\n";return;
}


int main()
{
    // boost;
    cal();
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

Measured memory_bytes: 4492
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

typedef long long ll;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)

int main(){
    ll A,B,C;
    cin >> A >> B >> C;
    if(A == B && B == C){
        cout << "No" << endl;
    }else if(A == B ||B == C||A == C){
        cout << "Yes" << endl;
    }else{cout << "No" << endl;}

    return 0;

}

Measured memory_bytes: 256
/*In the name of Allah*/
#include <bits/stdc++.h>
using namespace std;
#define inf 1000000111
#define MAX 505
#define mod 1000000007
#define ll long long
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a,b;
	cin>>a>>b;
	cout<<max(a*b,max(a-b,a+b));

	return 0;
}


Measured memory_bytes: 256
n = int(input())
v = [int(i) for i in input().split()]
odd = [[0,i] for i in range(10**5+1)]
even = [[0,i] for i in range(10**5+1)]
for i in v[0:n-1:2]:
    odd[i][0] += 1
for i in v[1:n:2]:
    even[i][0] += 1
odd.sort(reverse=True)
even.sort(reverse=True)
if odd[0][1] != even[0][1]:
    ans = n//2 - odd[0][0] + n//2 - even[0][0]
else:
    ans=min(n//2-odd[0][0]+n//2-even[1][0],n//2-odd[1][0]+n//2-even[0][0])
print(ans)

Measured memory_bytes: 34232
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,k,ans=0;
signed main(){
	cin>>n>>k;
	for(int i=k+1;i<=n;i++){
		ans+=n-(n/i*k+min(n%i,max(0ll,min(n%i,k-1))));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n, y = map(int, input().split()) # n枚y円

for i in range(n+1):
    for j in range(n+1-i):
        if (y - 10000 * i - 5000 * j - 1000 * (n-i-j)) == 0:
            print(i, j, n-i-j)
            exit()

print(-1, -1, -1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
 
using namespace std;
LL p = 1000000007ll;
 
LL dsum(LL x)
{
  if(x<10) return x;
  else return dsum(x/10) + x%10;
}
 
int main(void)
{
  LL k;
  cin >> k;
  LL tmp = 1;
  LL diff = 1;
  REP(i,k) {
    cout << tmp << endl;
    if(1.0*(tmp+diff)/dsum(tmp+diff) > diff) diff*=10;
    tmp += diff;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    double d,t,s;
    cin>>d>>t>>s;
    double nw=d/s;
    if((t-nw)>=0)
    {
        cout<<"Yes\n";
    }
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3736
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void){
  int x,a,b;
  cin >> x >> a >> b;
  if (a>=b) cout << "delicious" << endl;
  else if (b-a<=x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstring>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x,y,mn=1e18;
    cin>>x>>y;
    for (ll i=x;i<=y;i++){
        for (ll j=i+1;j<=y;j++){
            mn=min((i%2019*j%2019)%2019,mn);
            if (j==i+1+2019)
                break;
        }
        if (i==x+2019)
                break;
    }
    cout<<mn<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
    int h,w;
    while(1){
        cin >> h >> w;
        for(int i=0; i<h; i++){//heiht
            for(int j=0; j<w; j++){//width
                if(i%2!=0 && j%2!=0){
                    cout << "#";
                }else if(i%2==0 && j%2==0){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        if(h==0&&w==0){
            return 0;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3060
N = int(input())
A = [
    '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',
]
res = []
while N > 0:
    a = (N - 1) % 26
    N = (N - 1) // 26
    res.append(A[a])
res.reverse()
print(''.join(res))

Measured memory_bytes: 9144
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        long c = scanner.nextLong();
        long d = scanner.nextLong();
        long e = scanner.nextLong();
        long min = Math.min(a,Math.min(b, Math.min(c,Math.min(d,e))));
        System.out.println((long)(Math.ceil((double)n/min) + 4));
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define F first
#define S second
#define endl "\n"
#define MOD (lli)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
#define DEBUG if(0) cout << "aqui" << endl;
#define PI 2 * acos(0.0)
typedef pair<int,int> ii;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

int n;
string s;
vector<int> vec;

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

  for(int i='A';i<='Z';i++) vec.push_back(i-'A');

  cin >> n;
  cin >> s;

  for(int i=0;i<sz(s);i++){
    s[i] = ((s[i]+n-'A')%(sz(vec)) + 'A');
  }

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
vll f, g;

ll dfs(int n, ll X){
    ll ret = 0LL;

    if(n == 0){
        ret = (X <= 0 ? 0:1);
    }
    else if(X <= 1 + f[n - 1]){
        ret = dfs(n - 1, X - 1);
    }
    else {
        ret = g[n - 1] + 1 + dfs(n - 1, X - 2 - f[n - 1]);
    }

    return ret;
}

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

    int n; cin >> n;
    ll X; cin >> X;

    f = g = vll(n+1);
    {
        f[0] = g[0] = 1;
        rep(i, 1, n+1){
            f[i] = 3 + 2 * f[i-1];
            g[i] = 1 + 2 * g[i-1];
        }
    }

    cout << dfs(n, X) << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
s = nin(n)
s.sort()
ans = sum(s)

if ans % 10 == 0:
    flag = True
    for i in range(n):
        if s[i] % 10 != 0:
            flag = False
            ans -= s[i]
            break
    if flag:
        ans = 0

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
string s,t,d;
cin>>s>>t;
string c=s;
int l=s.size() ,f=0,p=1;
for(int j=0 ; j<l ; j++){
    for (int i=0 ;i<l;i++){
        d[(i+1)%l]=s[i];
    }
    for(int k=0 ; k<l ; k++){
        if(d[k]!=t[k]){
            f=1;
            break;
        }
    }
    if(f==1){
        for(int a=0 ;a<l;a++){
            s[a]=d[a];
        }
        f=0;
    }
    else{
        p=0;
        break;
    }
}
if( p==0 || c==t  ) cout<<"Yes";
else cout<<"No";
return 0;
}

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

string s;

int main(){
  cin >> s;
  if(s[0]=='7' || s[1]=='7' || s[2]=='7'){cout << "Yes";}
  else{cout << "No";}
  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; ++i) cin >> A[i];
    int box[N];
    for(int i = 0; i < N; ++i) box[i] = 0;
    
    int ball = 0;
    for(int i = N-1; i >= N/2; --i) {
        if(A[i] != 0) { box[i] = 1; ++ball; }
    }

    for(int i = N/2 - 1; i >= 0; --i) {
        int cnt = 0;
        for(int j = i; j < N; j += i + 1 ) {
            if(box[j] != 0) ++cnt;
        }
        if(cnt%2 != A[i]) {
            box[i] = 1; ++ball;
        } 
    }

    cout << ball << endl;
    bool flag = false;
    for(int i = 0; i < N; ++i) {
        if(box[i] != 0) {
            cout << i + 1 << " "; flag = true;
        }
    }
    if(flag) cout << endl;
    return 0;
}

Measured memory_bytes: 2432
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        String s = reader.next();
        if (s.equals("abc") ||
            s.equals("acb") ||
            s.equals("bac") ||
            s.equals("bca") ||
            s.equals("cab") ||
            s.equals("cba")) System.out.println("Yes");
        else System.out.println("No");
    }

    // Read Class
    static class FS {
        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() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); 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 int nextInt() {
            return (int)nextLong();
        }
        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();
            }
        }
    }
}



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

int main() {
  int N,M,X;
  cin >> N >>M>>X;
vector<int>A(N),B(M),C(N+1);
  for(int i=0;i<M;i++){
    cin>>B[i];
    A[B[i]]++;
  }
  C[0]=0;
  for(int i=1;i<N+1;i++){
    C[i]=C[i-1];
    if(A[i]==1){
      C[i]++;
    }
  }
  

  cout << min(abs(C[0]-C[X]),abs(C[N]-C[X])) <<endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define INF (1<<29)

int n,m,R;
int d[201][201];
int r[9];
int a,b,c;
int res;
bool used[9];

void dfs(int c,int las,int dist){
	if(c==R+1){
		if(res>dist) res=dist;
		return;
	}
	for(int i=1;i<=R;i++) if(!used[i]){
		used[i]=true;
		if(las==-1) dfs(c+1,i,0);
		else dfs(c+1,i,dist+d[r[las]][r[i]]);
		used[i]=false;
	}
}

int main(){
	cin >> n >> m >> R;
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(i!=j) d[i][j]=INF;
	for(int i=1;i<=R;i++) cin >> r[i];
	for(int i=1;i<=m;i++){
		cin >> a >> b >> c;
		if(d[a][b]>c) d[a][b]=d[b][a]=c;
	}
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				if(d[i][j]>d[i][k]+d[k][j]) d[i][j]=d[i][k]+d[k][j];
	res=INF;
	dfs(1,-1,0);
	cout << res << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){

    ll h,w; cin >> h >> w;
    if(h%3 == 0 || w%3 == 0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = min(h,w);
    ll a,b,c;
    for(ll i = 0; i <= h; i++){
        int W  = w/2;
        a = i*w;
        b = (h-i)*W;
        c = (h-i)*(w-W);
        chmin(ans,max(a,max(b,c))-min(a,min(b,c)));
    }
    for(ll i = 0; i <= w; i++){
        int H  = h/2;
        a = i*h;
        b = (w-i)*H;
        c = (w-i)*(h-H);
        chmin(ans,max(a,max(b,c))-min(a,min(b,c)));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
MAX = 200000
INF = 10 ** 10
cnt = 0


def merge(A, left, mid, right):
    global cnt
    L = A[left:mid] + [INF]
    R = A[mid:right] + [INF]
    i = j = 0
    for k  in range(left , right):
        if L[i] <= R[j]:
          A[k] = L[i]
          i +=  1
        else:
          A[k] = R[j]
          j +=  1
          cnt += mid - left - i
    return cnt

def mergeSort(A, left, right):
  if left+1 < right:
    mid = (left + right)//2
    v1 = mergeSort(A, left, mid)
    v2 = mergeSort(A, mid, right)
    v3 = merge(A, left, mid, right)
    return v1 + v2 + v3
  else:
      return 0

n = int(input())
A =[int(x) for x in input().split()]
mergeSort(A, 0, n)
print(cnt)




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

Measured memory_bytes: 1816
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
ll solve(ll n, ll a[], ll b[]){
	ll dp[n + 1];
	dp[0] = 0;
	for (ll i = 1; i <= n; i++){
		dp[i] = 0;
		for (ll j = 0; j < 4; j++){
			if (i - a[j] >= 0) dp[i] = max(dp[i], dp[i - a[j]] + b[j]);
		}
	}
	return dp[n];
}
int main(){
	ll n, a[4], b[4];
	scanf("%lld", &n);
	for (ll i = 0; i < 3; i++) scanf("%lld", &a[i]);
	for (ll i = 0; i < 3; i++) scanf("%lld", &b[i]);
	a[3] = 1;
	b[3] = 1;
	ll t = solve(n, a, b);
	printf("%lld\n", solve(t, b, a));
}

Measured memory_bytes: 195456
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min(a*b,c)<<endl;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
vector<int> A;
vector<bool> can_use;
int match[10] = {0,2,5,5,4,5,6,3,7,6};
int rev_match[10];
void chmax(int &a, int b){if(a<b) a=b;}


void input(){
    fast_io();
    cin >> N >> M;
    can_use.assign(10,false);
    for (int i = 0; i < M; i++)
    {
        int a; cin >> a;
        A.push_back(a);
        can_use[match[a]] = true;
    }

    for (int i = 0; i < M; i++)
    {
        chmax(rev_match[match[A[i]]],A[i]);
    }
}

bool change_st(string s, string t){
    if(s.length()>t.length()) return false;
    if(s.length()==t.length()){
        for (int i = 0; i < s.length(); i++)
        {
            // if(rev_match[s[i]-'0']>rev_match[t[i]-'0']) return false;
            // if(rev_match[s[i]-'0']<rev_match[t[i]-'0']) return true;
            if(s[i]>t[i]) return false;
            if(s[i]<t[i]) return true;
        }
    }
    return true;
}

string memo[11000];
string keta(int n){
    if(n==0) return "";
    if(n<0) return "0";
    if(memo[n].length()>0) return memo[n];
    string ret;
    for (int i = 1; i < 10; i++)
    {
        if(can_use[i]){
            string v = to_string(rev_match[i])+keta(n-i);
            if(v.back()=='0') continue;
            if(change_st(ret,v)) ret = v;
        }
    }
    if(ret.length()==0) return "0";
    return memo[n] = ret;    
}

int solve(){
    // use.length()が求める整数の桁数を表し、各桁が使うマッチの数を表している。
    // string use = keta(N);

    string ans = keta(N);
    // for (int i = 0; i < use.length(); i++)
    // {
    //     ans += to_string(rev_match[use[i]-'0']);
    // }
    // sort(ans.begin(),ans.end());
    // reverse(ans.begin(),ans.end());    
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 30428
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool f_u,f_l;//0=amb,1=YY
  
  //upper
  int sum=((s[0]-'0')*10)+(s[1]-'0');
  if(sum>12||sum<1){f_u=1;}
  else{f_u=0;}
  
  //lower
  sum=((s[2]-'0')*10)+(s[3]-'0');
  if(sum>12||sum<1){f_l=1;}
  else{f_l=0;}
  
  if(f_u==0&&f_l==0){cout << "AMBIGUOUS" << endl;}
  if(f_u==1&&f_l==0){cout << "YYMM" << endl;}
  if(f_u==0&&f_l==1){cout << "MMYY" << endl;}
  if(f_u==1&&f_l==1){cout << "NA" << endl;}
  
  return 0;
}


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

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int ans = 0;
    if (K <= A) ans = K;
    else if (K <= A + B) ans = A;
    else {
        ans = A - (K - A - B);
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;
int main()
{
  cout<<fixed<<setprecision(10);
  string database = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int N;
  string S;
  cin >> N;
  cin >> S;
  for(int i=0; i<S.size(); ++i){
    for(int j=0; j<database.size(); ++j){
      if(S[i]==database[j]) {
        S[i]=database[(j+N)%database.size()];
        break;
      }
    }
  }
  cout << S << endl;
}


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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<int> graph[10005];
vector<bool> used(10005);
vector<int> vec;
void dfs(int p) {
  used[p] = true;
  for(auto e: graph[p]) {
    if (!used[e]) {
      dfs(e);
    }
  }
  vec.push_back(p);
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  rep(i, n-1) {
    int a, b; cin >> a >> b;
    a--; b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  dfs(0);
  vector<int> c(n);
  rep(i, n) {
    cin >> c[i];
  }
  sort(c.begin(), c.end());
  ll ans = 0;
  rep(i, n-1) {
    ans += c[i];
  }
  vector<int> ret(n);
  rep(i, n) {
    ret[vec[i]] = c[i];
  }
  cout << ans << endl;
  rep(i, n) {
    cout << ret[i] << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int a, b; cin >> a >> b;
	if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) puts("Possible");
	else puts("Impossible");
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
edge = [[] for _ in range(N + M + 1)]
for i in range(N):
    i += M + 1
    k, *L = map(int, input().split())
    for l in L:
        edge[i].append(l)
        edge[l].append(i)

# pair[1,2,3,...,M] : 言語
# pair[M+1, M+2, ... M+N] : 人、こいつらが同じグラフ上にあればOK
pair = [-1] * (N + M + 1)

cnt = 1
for i in range(1, N + M + 1):
    if pair[-1] == -1:
        node = [i]
        pair[i] = cnt
        while node:
            s = node.pop()
            for t in edge[s]:
                if pair[t] == -1:
                    pair[t] = cnt
                    node.append(t)
        cnt += 1

tmp = pair[M + 1]
ans = "YES" if all(tmp == i for i in pair[M + 1:]) else "NO"
print(ans)


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

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

Measured memory_bytes: 3664
import java.util.Scanner;

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

        int N = scanner.nextInt();
        String S = scanner.next();

        if (S.length() % 2 != 0) {
            System.out.println("No");
            return;
        }

        String first = S.substring(0, S.length() / 2);
        String second = S.substring(S.length() / 2);

        if (first.equals(second)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 35804
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> fruits = new ArrayList<>();
        for (int i = 0; i < n; i++) fruits.add(sc.nextInt());
        Collections.sort(fruits);
        
        int sum = 0;
        for (int i = 0; i < k; i++) sum += fruits.get(i);

        System.out.println(sum);
    }
}

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

s = list(str(input()))

set_ = set(["A", "C", "G", "T"])

ans = 0
count = 0
for i in range(len(s)):
    if s[i] in set_:
        count += 1
    else:
        ans = max(ans, count)
        count = 0

ans = max(ans, count)

print(ans)


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if((a != b && a != c && b != c) || (a == b && a == c && b == c)) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0 ;
}


Measured memory_bytes: 256
/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define rep(i, n) for (int(i) = (0); (i) < (n); ++(i))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x

void prep()

{
	ios_base::sync_with_stdio(0);

	cin.tie(0);

	cout.tie(0);

	/*#ifndef ONLINE_JUDGE

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

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

#endif*/
}

int main()

{
	prep();
	int n;
	cin >> n;
	if (n % 1000)
	{
		cout << 1000 - (n % 1000);
	}
	else
	{
		cout << 0 << endl;
	}

	return 0;
}


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

int main()
{
    vector<int> v(10);
    for(int i=0;i<10;i++) cin >> v[i];
    sort(v.rbegin(),v.rend());
    for(int i=0;i<3;i++) cout << v[i] << endl;
    return 0;
}


Measured memory_bytes: 3076
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    const cost = A.reduce((m,n)=>m+n);
    
    console.log(Math.max(N - cost, -1));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); i++)
#define RFOR(i, a, b)  for(int i = (a); i > (b); i--)
#define rep(i, n)	   for(int i = 0; i < (n); i++)
#define all(c)		   begin(c), end(c)
#define rall(c)		   rbegin(c), rend(c)
#define foritr(itr, c) for(auto itr = begin(c); itr != end(c); itr++)
#define SZ(a)		   ((ll) a.size())

typedef long long int		   ll;
typedef long long unsigned int llu;

void solve(vector <string> s) {
	printf("%c%c%c", s[0].front() - 32, s[1].front() - 32, s[2].front() - 32);
}

int main() {
	vector <string> s(3 - 1 + 1);
	for(int i = 0; i <= 3 - 1; i++) {
		cin >> s[i];
	}
	solve(s);
	return 0;
}


Measured memory_bytes: 256
N, H = map(int, input().split())
A = list()
B = list()
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
A.sort(reverse = True)
B.sort(reverse = True)
cnt = 0
b = 0
while(H > 0 and b<=N-1 and cnt==b):
  cnt += 1
  if(B[b]>A[0]):
    H -= B[b]
    b += 1
if(H <= 0):
  print(b)
else:
  print(b +(H-1)//A[0]+1)

Measured memory_bytes: 11296
#include <iostream>
#include <stack>

std::stack<int> s;

int main() {
    int n;
    while (std::cin >> n) {
        if (n == 0) {
            std::cout << s.top() << std::endl;
            s.pop();
        } else {
            s.push(n);
        }
    }
    return 0;
}



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

int main()
{
	long N;
	cin >> N;
	int min = 12;
	for (int i = 1; i <= sqrt(N) + 1; i++) {
		if (N % i == 0) {
            int M = N / i;
			int n = 0;
			while (M != 0) {
				M = M / 10;
				n++;
			}
			min = n;
		}
	}
    cout << min << endl;
}


Measured memory_bytes: 764
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int i;
	int a, b, c;
	int d, e;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	a = atoi(ch);
	ch = strtok(NULL, " ");
	b = atoi(ch);
	ch = strtok(NULL, " ");
	c = atoi(ch);

	d = a % b;

	for(i = 0; i < b; i += 1) {
		e = (d * i) % b;
		if(e == c) {
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");

	return 0;
}


Measured memory_bytes: 2024
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    int n; cin >> n;
    int a[2][n];
    rep(i, 2) rep(j, n) cin >> a[i][j];
    rrep(i, 1, n) a[0][i] += a[0][i - 1];
    a[1][0] += a[0][0];
    rrep(i, 1, n) a[1][i] += max(a[0][i], a[1][i - 1]);
    //rep(i, 2) {rep(j, n) cout << a[i][j] << " "; cout << endl;}
    cout << a[1][n - 1] << endl;
    
}


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

int main() {
	int l, a, b, c, d, f = 0,  h = 0;
	cin >> l >> a >> b >> c >> d;
	while (true) {
		if (a <= 0) {
			break;
		}
		a = a - c;
		f = f + 1;
	}
	while (true) {
		if (b <= 0) {
			break;
		}
		b = b - d;
		h= h + 1;
	}
	if(f<h){
		cout<<l-h<<endl;
	}
	else{
		cout<<l-f<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#pragma warning (disable: 4996)
using namespace std;

long long N;
long long dp[2009];
long long mod = 1000000007;

int main() {
	cin >> N;
	dp[0] = 1;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= i - 3; j++) {
			dp[i] += dp[j];
			dp[i] %= mod;
		}
	}
	cout << dp[N] << endl;
	return 0;
}

Measured memory_bytes: 3604
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# import collections # queue
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    w,a,b = map(int,input().split())
    ans = 0
    if a<b:
        ans = b - (a + w)
    else:
        ans = a - (b + w)
    print(max(0,ans))
    return

if __name__=='__main__':
    main()


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

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

    vector <int> ans(4);

    rep(i, n) {
        string s;
        cin >> s;

        if (s == "AC")
            ans.at(0)++;
        else if(s == "WA")
            ans.at(1)++;
        else if(s=="TLE")
            ans.at(2)++;
        else
            ans.at(3)++;
    }

    cout << "AC x " << ans.at(0) << endl;
    cout << "WA x " << ans.at(1) << endl;
    cout << "TLE x " << ans.at(2) << endl;
    cout << "RE x " << ans.at(3) << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N, M, C; cin >> N >> M >> C;
  vector<int> B(M); cin >> B;

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    int x = 0;
    for (int j = 0; j < M; ++j) {
      int a; cin >> a;
      x += a * B[j];
    }
    if (x + C > 0) ++cnt;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-14

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

int main(){
	//全て奇数のパターンを数える
	int N;
	int A[10000];
	int even=0;
	cin >> N;
	rep(i,N){
		cin >> A[i];
		if(A[i]%2==0){
			even++;
		}
	}
	cout << pow(3,N)-pow(2,even) << endl;
	return 0;
}

Measured memory_bytes: 256
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
from collections import defaultdict
H,W,N = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]

dic = defaultdict(int)
for a,b in AB:
    for dh in range(3):
        for dw in range(3):
            if 0 < a-dh <= H-2 and 0 < b-dw <= W-2:
                dic[(a-dh,b-dw)] += 1

Ans = [0]*10
total = 0
for v in dic.values():
    Ans[v] += 1
    total += 1

Ans[0] = (H-2)*(W-2) - total

for ans in Ans:
    print(ans)


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

using namespace std;

int main()
{
    int n , a=0 , b=0 , t;
    vector<int> v;
    cin>> n ;
    for(int i = 0 ; i < n ; i++)
    {
        cin>> t;
        v.push_back(t);
    }
    sort(v.rbegin(), v.rend());
    for(int i = 0 ; i < n;i++)
    {
        if(i&1)b+=v[i];
        else a+=v[i];
    }
        cout<<a-b;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;
typedef long long LL;

const int MOD = 1e9+7;
void solve(){
    int n;
    cin>>n;
    vector<vector<LL>> table(n,vector<LL>(2,0));
    for(int i=0;i<n;i++){
        cin>>table[i][0]>>table[i][1];
    }
    auto comp=[](vector<LL> &a,vector<LL> &b){
        if((a[0]+a[1])  != (b[0]+b[1])) return (a[0]+a[1]) < (b[0]+b[1]);
        return a[0]<b[0];
    };
    sort(table.begin(),table.end(),comp);
    int cnt = 1;
    auto maxe = table[0][0]+table[0][1];
    for(int i = 1;i<n;i++){
        auto s = table[i][0]-table[i][1];
        auto e = table[i][0]+table[i][1];
        if(s<maxe) continue;
        maxe = e;
        cnt++;
    }
    cout<<cnt<<endl;
}

int main(){
    int T = 1;
    while(T--){
        solve();
    }
    return 0;
}

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

using namespace std;

int H[100000];
int h[100000];

int main() {

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

	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> H[i];
	}
	for (int i = n - 2; i >= 0; --i) {
		if (H[i] >= H[i + 1]) {
			h[i] = h[i + 1] + 1;
		}
	}
	sort(h, h + n);
	cout << h[n - 1] << '\n';
	return 0;
}

Measured memory_bytes: 1024
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int X = sc.nextInt();
		
		int min = X - K + 1;
		int max = X + K -1;
		LinkedList<Integer> ansList = new LinkedList<Integer>();
		
		for(int i = min; i <= X; i++) {
			ansList.add(i);
		}
		
		for(int i = X + 1; i <= max; i++) {
			ansList.add(i);
		}
		
		for(int i = 0; i < ansList.size() ; i++ ) {
			if ( i > 0 ) {
				System.out.print(" ");
			}
			System.out.print(ansList.get(i));
		}

		sc.close();
	}
}


Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

using PQ = priority_queue<ll, vector<ll>, greater<ll>>;

signed main() {
  ios::sync_with_stdio(false);
  ll n, k, q;
  cin >> n >> k >> q;
  vector<ll> a(n);
  vector<ll> b(n);
  REP(i, n) cin >> a[i];
  REP(i, n) b[i] = a[i];
  PQ p;
  PQ s;
  sort(all(b));
  ll ans = 1e9;
  REP(i, n - k + 1) {
    if(i > 0 && b[i-1] == b[i]) continue;
    p = PQ();
    s = PQ();
    REP(j, n) {
      if(a[j] < b[i]) {
        while(p.size() >= k) {
          s.push(p.top());
          p.pop();
        }
        p = PQ();
      }
      else {
        p.push(a[j]);
      }
    }
    while(p.size() >= k) {
      s.push(p.top());
      p.pop();
    }
    REP(j, q - 1) {
      if(s.size() == 0) break;
      s.pop();
    }
    if(s.size() == 0) continue;
 
    ans = min(ans, s.top() - b[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384