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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    int h, w;
    cin >> h >> w;
    char c[h][w];
    rep(i, h) rep(j, w) cin >> c[i][j];

    rep(i, h)
    {
        rep(j, w)
        {
            bool flag = 0;
            if (c[i][j] == '.')
                continue;
            rep(k, 4)
            {
                int nx = i + dx[k], ny = j + dy[k];
                if (!(0 <= nx && nx < h && 0 <= ny && ny < w))
                    continue;
                if (c[nx][ny] == '#')
                    flag = 1;
            }
            if (flag == 0)
            {
                OP("No");
                return 0;
            }
        }
    }
    OP("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>

using namespace std;
#define N 1000000

int* Eratosthenes(){
    int* arr = new int[N];

    for(int i = 0; i < N; i++){
        arr[i] = 1;
    }
    for(int i = 2; i < sqrt(N); i++){
        if(arr[i]){
            for(int j = 0; i * (j + 2) < N; j++){
                arr[i *(j + 2)] = 0;
            }
        }
    }

    for(int i = 2; i < N; i++){
        if(arr[i]){
        }
    }

    return arr;
}


int main(){

    long n, p;
    cin >> n >> p;
    int* arr;

    int ans = 1;

    if (n == 1) {
        cout << p << endl;
        return 0;
    } else {
        arr = Eratosthenes();
        for (int i=2; i<=N; i++) {
            if (arr[i]) {
                int count = 0;
                while (p%i == 0) {
                    count++;
                    p /= i;
                }
                if (count/n) {
                    ans *= pow(i, count/n);
                }
            }
            if (p == 1) {
                break;
            }
        }
        cout << ans << endl;

        return 0;
    }
}


Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
	      Scanner sc = new Scanner(System.in);
	      int a = sc.nextInt();
	      int b = sc.nextInt();
	      sc.close();
	      
	      int count = 0;
	      count = count + (a - 1);
	      if(b >= a) {
	    	  	count++;
	      }
	      
	      System.out.println(count);
	      System.exit(0);
	    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<ll,P>;
using PP = pair<P ,P>;
constexpr ll MOD = 998244353;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

template <typename Monoid>
struct SegmentTree{
private:
    using F = function<Monoid(Monoid, Monoid)>;
    int N;
    vector<Monoid> node;
    F f;
    Monoid e;  // identity element

public:
    SegmentTree(){}
    SegmentTree(F f, Monoid e):f(f), e(e){}
    void init(int sz){
        N = 1;
        while(N < sz) N <<= 1;
        node.assign(2*N-1, e);
    }
    void build(vector<Monoid>& v){
        int sz = int(v.size());
        init(sz);
        for(int i=0; i<sz; i++){
            node[i+N-1] = v[i];
        }
        for(int i=N-2; i>=0; i--){
            node[i] = f(node[i*2+1], node[i*2+2]);
        }
    }
    void update(int k, Monoid x){
        k += N-1;
        node[k] = x;
        while(k > 0){
            k = (k-1)/2;
            node[k] = f(node[2*k+1], node[2*k+2]);
        }
    }
    // [a,b)
    Monoid query(int a, int b){return query(a, b, 0, 0, N);}
    Monoid query(int a, int b, int k, int l, int r){
        if(b <= l || r <= a) return e;
        if(a <= l && r <= b) return node[k];
        Monoid vl, vr;
        vl = query(a, b, 2*k+1, l, (l+r)/2);
        vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};

int main(){
    int n, m;
    string s;
    cin >> n >> m >> s;
    SegmentTree<P> dp([](P a, P b){return min(a,b);}, P(IINF,IINF));
    vector<P> tmp(n+1);
    for(int i=0;i<=n;i++){
        tmp[i] = P(IINF, i);
    }
    dp.build(tmp);
    dp.update(n, P(0,n));
    for(int i=n-1;i>=0;i--){
        if(s[i] == '1') continue;
        dp.update(i, P(dp.query(i+1, min(i+m+1,n+1)).first+1,i));
    }
    if(dp.query(0,1).first == IINF){
        cout << -1 << endl;
    }
    else{
        vector<int> ans;
        int now = 0;
        while(now < n){
            int nxt = dp.query(now+1, now+m+1).second;
            ans.emplace_back(nxt - now);
            now = nxt;
        }
        for(int i=0;i<int(ans.size());i++){
            cout << ans[i] << " \n"[i==int(ans.size())-1];
        }
    }
    return 0;
}

Measured memory_bytes: 6776
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod (int)1e9+7
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < n; i++)
#define Rep(i,n) for (int i = n; i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define P pair<int, int>
#define prique priority_queue<P, vector<P>, greater<P>>
struct edge { int to, cost; };
using namespace std;

signed main() {
	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;
}

Measured memory_bytes: 256
X = int(input())
ans = []

for i in range(1, 34):
    for j in range(2, 10):
        if i ** j <= X:
            ans.append(i ** j)
        else:
            break

for i in sorted(ans, reverse=True):
    if i <= X:
        print(i)
        exit()
    else:
        continue

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		String S = sc.next();
		String ans = S;

		int openCount = 0;
		int closeCount = 0;

		int c = 0;

		if(S.charAt(0) == '(') openCount++;
		else closeCount++;

		while(++c < S.length()){
			if(S.charAt(c) == '('){
				if(closeCount > 0){
					for(int i = 0; i < closeCount; i++){
						ans = '(' + ans;
					}
					closeCount = 0;
					openCount = 1;
				}else{
					openCount++;
				}
			}
			else{
				if(openCount > 0){
					openCount--;
				}else{
					closeCount++;
				}
			}
		}

		for(int i = 0; i < openCount; i++){
			ans = ans + ')';
		}
		for(int i = 0; i < closeCount; i++){
			ans = '(' + ans;
		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 23892
#include <stdio.h>
#define N 2000
#define TRUE 1
#define FALSE 0

int solve(int, int);

int A[N], n = 0;

int main(){
  int q = 0;
  int i = 0;
  int m[N];

  /*Input A[N]*/
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    
    scanf("%d",&A[i]);
    
  }

  /*Input m[N]*/
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    
    scanf("%d",&m[i]);
    
  }

  for(i = 0; i < q; i++){
    
    if(solve(0, m[i]) == TRUE)printf("yes\n");
    else printf("no\n");
    
  }
  return 0;
}

int solve(int i, int m){ /* i番目以降の要素を使ってmを作れる -> true */
  int res = 0;
  
  if(m == 0)return TRUE;
  if(i >= n)return FALSE;

  res = solve(i+1, m) || solve(i+1, m-A[i]);
  return res;
}



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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)((x).size()))

typedef long long ll;

const ll mod = 1000000007;
const double pi = 3.1415926535897932384626;

ll powmod(ll a, ll b) {ll res = 1; ll rem = a % mod; for (; b; b >>= 1) {if (b & 1) res = (res * rem) % mod; rem = (rem * rem) % mod;} return res;}

const int N = 8;

int ara[N];
char str[N];

void recur(int i, int t)
{
	if (i == 3) {
		if (t == 7) {
			printf("%d%c%d%c%d%c%d=7\n", ara[1], str[0], ara[2], str[1], ara[3], str[2], ara[4]);
			exit(0);
		}
		else return;
	}

	str[i] = '+';
	recur(i + 1, t + ara[i + 2]);
	str[i] = '-';
	recur(i + 1, t - ara[i + 2]);

	return;
}

int main()
{	
#ifdef hannibal_08
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif
    
	int n = 0;
	int c = 5;
	scanf("%d", &n);

	while (c > 1) {
		ara[--c] = n % 10;
		n /= 10;
	}

	str[3] = '\0';

	recur(0, ara[1]);

	return 0;
}


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

int main()
{
	int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  	
  int k;
  cin >> k;
  cout << arr[k-1];
  return 0;
}

Measured memory_bytes: 256
def main():
    S = input()

    for i, (a, b) in enumerate(zip(S, S[1:]), start=1):
        if a == b:
            print(i, i + 1)
            return

    for i, (a, b, c) in enumerate(zip(S, S[1:], S[2:]), start=1):
        if a == c:
            print(i, i + 2)
            return

    print(-1, -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8988
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.ABC118
{
    class C
    {
        public static void Solve()
        {
            int n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int min = a.Min();
            int nmin = min;
            do
            {
                min = nmin;
                for(int i = 0; i < n; i++)
                {
                    var m = a[i] % min;
                    if(m != 0 && m < nmin)
                    {
                        nmin = m;
                    }
                }                
            }while (min != nmin);

            Console.WriteLine(min);
        }
    }
}
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC118.C.Solve();
        }
    }
}


Measured memory_bytes: 21344
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(int i=1;;i++){
            int a = sc.nextInt();
            if(a==0){
                break;
            }
            System.out.printf("Case %d: %d\n",i,a);
        } 
          sc.close();
    }

}


Measured memory_bytes: 64716
n = int(input())
a = list(map(int, input().split()))
na = sorted(a)
res = 1
ans = 0

if na[0] == 1:
    for i in a:
        if i == res:
            res += 1
        else:
            ans += 1
    print(ans)
else:
    print(-1)

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

int main() {
    string S;
    cin >> S;
    if (S.size() < 3) {
        puts("WA");
        return 0;
    }
    bool ok = true;
    if(S[0] != 'A') ok = false;

    int cnt = 0, f = 0;
    for(int i = 2; i + 1 < S.size(); ++i) {
        if(S[i] == 'C') f = 1;
    }

    for(int i = 0; i < S.size(); ++i) {
        if(isupper(S[i])) cnt++;
    }
    puts(ok and f and cnt == 2? "AC" : "WA");
}

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

int main() {
  while (true) {
    int R0, W0, C, R;
    cin >> R0 >> W0 >> C >> R;

    if (R0 == 0) {
      break;
    }
    
    int x = 0;
    for (; (double)(x * R + R0) / C - W0 < 0.0; x++) {
    }

    cout << x << endl;
  }

  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007

long long inv(long long a){
    long long t = 1;
    while(a > 1){
        t = t * (mod - mod / a) % mod;
        a = mod % a;
    }
    return t;
}

long long comb(long long n, long long k){
    if(k > n-k) k = n-k;
    long long nu = 1, de = 1;
    for(int i = 1; i < k+1; i++){
        nu = nu * (n+1-i)%mod;
        de = de*i % mod;
    }
    return nu*inv(de)%mod;
}

int main(){
    long long x, y;
    long long i = -1,  j = -1;
    cin >> x >> y;

    if((2*x - y) % 3 == 0) i = (2*x-y) / 3; //?????
    if((2*y-x) % 3 == 0) j = (2*y-x) / 3;  //???????

    if(i < 0 || j < 0) cout << "0" << endl; 
    else cout << comb(i+j, j) << endl; //?????
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<int> t(N+1, 0);
    vector<pii> p(N+1, pii(0,0));
    Rep(i, 1, N+1){
        cin >> t[i] >> p[i].fi >> p[i].se;
    }
    REP(i, N){
        int dt = t[i+1] - t[i];
        int dd = abs(p[i+1].fi - p[i].fi) + abs(p[i+1].se - p[i].se);
        if(dt - dd >= 0 && ((dt - dd) % 2) == 0){

        }else{
            pr("No");
            return 0;
        }
    }
    pr("Yes");
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	
	public static void Main(string[] args)
	{
		int[] p = Input().ToInt();
		int n = p[0];
		int k = p[1];
		int[] h = Input().ToInt();
		int r = 0;
		for(int i = 0; i < n; i++)
		{
			if(h[i] >=k)r++;
		}
		Console.WriteLine(r);
	}
	
	public static long GCD(long a, long b)
	{
		if(b == 1) return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		int[] r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
	
}

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

int main() {
    // input
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; ++i) {
        cin >> d[i];
    }

    // solve
    int ans = 0;
    sort(d.begin(), d.end());

    for (int i = 0; i < d.size(); ++i) {
        if (d[i] != d[i + 1]) ans++;
    }

    // output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(R: int, G: int):
    print(G*2-R)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    solve(R, G)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
//
//  main.cpp
//  T2020A

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    string S;
    cin >> S;
    string ans;
    for (int i=0; i<3; i++) {
        ans+=S.at(i);
    }
    cout << ans << endl;
    return 0;
}


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

int main() 
{ 
	ll n,ans=0 ;
	cin>>n;
	if(n%1000 ==0)
    cout<<0;
    else
	cout<<1000-(n%1000);
	//cout<<ans;
	return 0; 
} 


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ")
{ if (!v.size()) puts(""); rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

lint mod_pow(lint a, lint x, int p = 1e9 + 7) {
  lint ret = 1;
  for (lint i  = 1ll << 60; i; i >>= 1) {
    ret *= ret;
    ret %= p;
    if (x & i) { ret *= a; ret %= p; }
  }

  return ret;
}

lint inv(lint n, int p = 1e9 + 7) {
  return mod_pow(n, p - 2);
}

vector<lint> fact(1, 1);
lint Fact(lint n, int p = 1e9 + 7) {
  if (n == 0) return 1;
  if (fact.size() <= n) {
    fact.push_back(Fact(n - 1) * n % p);
  }
  return fact[n];
}

// nCk のmod
lint mod_Combination(lint n, lint k, int p = 1e9 + 7) {
  if (n < k || n < 0 || k < 0) return 0;
  return Fact(n, p) * inv(Fact(k, p), p) % p * inv(Fact(n - k, p), p) % p;
}

signed main() {
  lint h = in(), w = in(), a = in(), b = in();

  lint ans = 0;
  for (int i = b + 1; i <= w; ++i) {
    ans += (mod_Combination(h - a - 1 + i - 1, i - 1) * mod_Combination(a - 1 + w - i, w - i)) % mod;
    ans %= mod;
  }

  cout << ans << endl;
}


Measured memory_bytes: 9588
'use strict'
function main(input) {
  input = input.trim().split('\n')
  const N = Number(input.shift())
  input = input.map(row => row.split(' ').map(n => n - 0)).sort((a, b) => a[1] - b[1])

  let done = 0
  for (let i = 0; i < N; i++) {
    done += input[i][0]
    if (done > input[i][1]) return console.log('No')
  }
  console.log('Yes')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 64624
#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>

int64_t root(int64_t u[], int64_t i)
{
  if (u[i] < 0) return i;
  return u[i] = root(u, u[i]);
}

int64_t size(int64_t u[], int64_t i)
{
  return -u[root(u, i)];
}

int main(void)
{
  int64_t n, m;
  scanf("%" SCNd64 "%" SCNd64, &n, &m);
  int64_t a[m], b[m], ans[m], u[n];
  for (int i = 0; i < n; i++) u[i] = -1;
  for (int i = 0; i < m; i++) {
    scanf("%" SCNd64 "%" SCNd64, &a[i], &b[i]);
    a[i]--;
    b[i]--;
  }
  ans[m - 1] = n * (n - 1) / 2;
  for (int i = m - 1; i > 0; i--) {
    ans[i - 1] = ans[i];
    if (root(u, a[i]) != root(u, b[i])) {
      int64_t x = root(u, a[i]);
      int64_t y = root(u, b[i]);
      if (size(u, a[i]) < size(u, b[i])) {
        int64_t t = x;
        x = y;
        y = t;
      }
      ans[i - 1] -= u[x] * u[y];
      u[x] += u[y];
      u[y] = x;
    }
  }
  for (int i = 0; i < m; i++) {
    printf("%" PRId64 "\n", ans[i]);
  }
}


Measured memory_bytes: 4352
#include <iostream>
#include <unordered_map>
using namespace std;
typedef long long LL;
const int MAXN = 2e5 + 10;
LL nums[MAXN], dp[MAXN];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> nums[i];
        dp[i] = dp[i-1] + nums[i];
    }
    unordered_map<LL, int> table;
    LL ret = 0;
    for (int i = n; i >= 0; i--) {
        ret += table[dp[i]];
        table[dp[i]]++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 11592
from collections import Counter

N=int(input())
A=list(map(int,input().split()))

asum=sum(A)

C=Counter(A)

for i in range(int(input())):
    b,c=list(map(int,input().split()))

    asum=asum+(c-b)*C[b]

    C[c]=C[c]+C[b] if c in C else C[b]
    C[b]=0

    print(asum)

Measured memory_bytes: 93848
#include<iostream>
#include<vector>
#include<string>
#include<cmath>

using namespace std;

void func_A() {

    string s, t;
    cin >> s >> t;

    string temp = t.substr(0, s.size());
    if (s == temp) cout << "Yes";
    else cout << "No";
}

void func_B() {

    long long a, b, c, k;
    cin >> a >> b >> c >> k;

    long long num = 0;
    if (a >= k) {
        cout << k;
        return;
    }
    else {
        k -= a;
        num += a;
    }

    if (b >= k) {
        cout << num;
        return;
    }
    else {
        k -= b;
    }

    cout << num - k;
}


void func_C() {

    int n, m, x;
    cin >> n >> m >> x;


    vector<int> price(n);
    vector<vector<int>> rikai(n, vector<int>(m));

    for (int i = 0; i < n; ++i) {
        cin >> price[i];
        for (int j = 0; j < m; ++j) {
            cin >> rikai[i][j];
        }
    }


    long long max_price = pow(10, 10);
    long long min_price = max_price; //絶対上回らないでかい数字
    //int bit = n; //bit全探索
    for (int bit = 0; bit < (1 << n); ++bit) {

        //bitの1の部分を取り出す
        vector<int> s;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) s.push_back(i);
        }

        //取り出した組み合わせで調べる
        long long temp_price = 0;
        vector<int> temp_rikai(m);
        for (int i = 0; i < s.size(); ++i) {
            int book_num = s[i];
            temp_price += price[book_num];

            for (int j = 0; j < m; ++j) { //理解度上昇
                temp_rikai[j] += rikai[book_num][j];
            }
        }

        //各理解度がx以上かを調べ、そうなら値段を更新できるか調べる
        for (int i = 0; i < m; ++i) {
            if (temp_rikai[i] < x) break;
            if (i == m - 1) { //全ての理解度がx以上
                if (min_price > temp_price) min_price = temp_price;
            }
        }

     }
    
    if (min_price == max_price) cout << -1;
    else cout << min_price;

}

int main() {

    //func_A();
    //func_B();
    func_C();

    return 0;

}

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

int main()
{
	int a, b, c, min;
	cin >> a >> b;
	if (((a + b) % 3 == 0) || (a % 3 == 0) || (b % 3 == 0)) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vec{
    double x, y;
};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
     return false;
}
template<class T>
T min(T a, T b)
{
    if (a < b) return a;
    return b;
}
template<class T>
T max(T a, T b)
{
    if (a > b) return a;
    return b;
}
using namespace std;
int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    int N, K;
    ll sc = 1, sci = 1;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
        // if (i+1 == K){
        //     sci = sc;
        // } else if (i+1 > K) {
        //     sc /=  A[i - K];
        //     cout << sc << endl;
        //     if (sci < sc) cout << "Yes" << endl;
        //     else cout << "No" << endl;
        //     sci = sc;
        // }
    }
    rep(i, N - K){
        if (A[i] < A[i + K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4584
/**
 <Merge Sort>

 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_B
 
 Shunji Lin
 26/01/2016
 **/

#include <cstdio>
#include <vector>

const long int  sentinel = 10e9 + 1; // indicate end of vector
static int comparisons = 0; // number of comparisons

// merge step, sort A in given index boundaries
void merge(std::vector<long int> &A, long int left, long int mid, long int right) {
  int n1 = mid - left + 1; // length of left array, contains [left, mid]
  int n2 = right - mid; // length of right array, contains (mid, right]

  //temporary left, right vectors
  std::vector<long int> L(n1 + 1);
  std::vector<long int> R(n2 + 1);

  for (int i = 0; i < n1; ++i) {
    L[i] = A[left + i]; // populate left vector with [left, mid]
  }
  for (int i = 0; i < n2; ++i) {
    R[i] = A[mid + 1 +  i]; // populate right vector with (mid, right]
  }

  L[n1] =  R[n2] = sentinel; 

  int i = 0, j = 0;

  // merge
  for (int k = left; k <= right; ++k) {
    if (L[i] <= R[j]) {
      A[k] = L[i];
      ++i;
    } else {
      A[k] = R[j];
      ++j;
    }
    ++comparisons; 
  }
}
      
// main merge sort function
void merge_sort(std::vector <long int> &A, long int left, long int right) {
  if (left < right) { // terminate when target indexes of length 1
    int mid = (left + right) / 2;
    merge_sort(A, left, mid);
    merge_sort(A, mid + 1, right);
    merge(A, left, mid, right);
  }
}

int main() {
  int n; // number of elements
  scanf("%d", &n);
  
  std::vector<long int> A(n);

  //populate vector A
  for (int i = 0; i < n; ++i) {
    scanf("%ld", &A[i]);
  }
  
  merge_sort(A, 0, n-1);
  for (int i = 0; i < n - 1; ++i) {
    printf("%ld ", A[i]);
  }
  printf("%ld\n", A[n-1]);
  
  printf("%d\n", comparisons);
}

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

using namespace std;

vector<long long> len(55);
vector<long long> pat(55);

// level nバーガーに関して
// 下からx番目まで食べる時
// パティの値を返す
long long solve(long long n, long long x){
    
    if (x == len[n]) return pat[n];
    long long ans = 0;
    x--;
    
    if (x){
        long long l = min(x,len[n-1]);
        ans += solve(n-1,l);
        x -= l;
    }
    
    if (x){
        ans++;
        x--;
    }
    
    if (x){
        long long l = min(x,len[n-1]);
        ans += solve(n-1,l);
        x -= l;
    }
    
    return ans;
}

int main(){
    long long n, x;
    cin >> n >> x;
    
    len[0] = 1;
    pat[0] = 1;
    
    for (int i = 1; i <= n; i++){
        len[i]= len[i-1]*2+3;
        pat[i] = pat[i-1]*2+1;
    }
    
    cout << solve(n,x) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;

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

        Scanner sc = new Scanner(System.in);

        int N,A;
        int kei =0;
        int sum = 0;

        N = sc.nextInt();
        A = sc.nextInt();

        kei = N * N;

        sum = kei - A;

        System.out.print(sum);

    }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
bitset<10101> B;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	B[0]=1;
	cin>>N;
	FOR(i,N) {
		cin>>x;
		B |= B<<x;
	}
	
	for(i=10000;i>=0;i--) {
		if(i%10==0) continue;
		if(B[i]) return _P("%d\n",i);
	}
	
	_P("0\n");
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
## main

n = gets.strip.to_i
m = gets.strip.to_i

valid = (m >= 0)
max_m = m

n.times do
  i, j = gets.strip.split(' ').map{|s| s.to_i}
  m += i - j

  valid = false if m < 0
  max_m = m if max_m < m
end

max_m = 0 if ! valid
puts max_m

Measured memory_bytes: 6104
s = input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])
for j in range(2):
    for k in range(2):
        for l in range(2):
            sm=a
            if j==0:
                B='+'
                sm+=b
            else:
                B='-'
                sm-=b
            if k==0:
                C='+'
                sm+=c
            else:
                C='-'
                sm-=c
            if l==0:
                D='+'
                sm+=d
            else:
                D='-'
                sm-=d
            if sm==7:
                
                m=str(a)+B+str(b)+C+str(c)+D+str(d)+'=7'
                print(m)
                exit()


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  ll N,K; cin>>N>>K;
  ll inf = pow(10,9)+7;
  ll ans = 0;
  for(ll i=K;i<=N+1;++i){
    ans += (i*N - i*(i-1)/2) - ( i*(i-1)/2 ) + 1;
    ans %= inf;
  }
  cout << ans << "\n";
  
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
    using namespace std;
    
    //                                 (POLICY BASED DS)
    // #include <ext/pb_ds/assoc_container.hpp>
    // #include <ext/pb_ds/tree_policy.hpp>
    // using namespace __gnu_pbds;
    // template<typename T>
    // using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
    // template<typename T>
    // using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
    //                      ( find_by_order( )  ,  order_of_key( ) )
    
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef vector<int> vi;
    typedef vector<long long> vll;
    typedef pair<ll,ll> pll;
     
    const ll mod = 1e9 + 7;
    const ld PI = 3.1415926535897932384626;
    const ld eps = 1e-9;                            
     
    #define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define sidha(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
    #define ulta(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);--i)
    #define stl(container,itr) \
        for(auto itr = container.begin(); itr != container.end(); itr++)
    #define sab(v) v.begin(), v.end()
    #define rall(v) v.rbegin(), v.rend()            
    #define test ll t;cin>>t;while(t--)
    #define sz size()
    #define pb push_back
    #define mp make_pair
    #define fi first
    #define se second
    #define LOG2(X) (63ll - __builtin_clzll(X))
    #define endl '\n'
    #define modinv(x) power(x, mod-2)
    #define ncr(n,r) ( n >= r ? ((((fact[n]*modinv(fact[r]))%mod)*modinv(fact[n-r]))%mod) : (ll)0)
    #define MAX 100005
     
    ll power(ll x, ll y) { 
        ll ans=1;
        x=x%mod;
        while(y>0) { 
            if (y&1) 
                ans=(ans*x)%mod; 
            y=y>>1;
            x=(x*x)%mod; 
        } 
        return ans; 
    }
    
    // vector<ll> adj[MAX];
    // ll visit[MAX];
    // void dfs(ll node){
    //     visit[node]=1;
    //     for(auto i : adj[node]){
    //         if(!visit[i]) dfs(i);
    //     }
    // }
    
    // ll spf[MAX];
    // void sieve(){
    //     sidha(i,1,MAX)  spf[i]=i;
    //     for(ll i=4;i<MAX;i+=2)  spf[i]=2;
    //     for(ll i=3;i*i<=MAX;i++){
    //         if(spf[i]==i){
    //             for(ll j=i*i;j<MAX;j+=i){
    //                 if(spf[j]==j)   spf[j]=i;
    //             }
    //         }
    //     }
    // }

    int main()
    {
        boost;
        string s;
        cin>>s;
        if(s[s.sz-1]=='s'){
            s.pb('e');
            s.pb('s');
        }
        else{
            s.pb('s');
        }
        cout<<s;
        return 0;
    }
    

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

int main(){
  	char s;
  	int cnt[26];
  	
  	rep(i,0,26){
  	    cnt[i] = 0;
  	}
  	
  	while(scanf("%c",&s) != EOF){
  	    
  	    if(s >= 65 && s <= 90){
  	        cnt[((int)s)-65]++;
  	    }
  	    else if(s >= 97 && s <= 122){
  	        cnt[((int)s)-97]++;
  	    }
  	}
  	
  	rep(i,0,26){
  	    cout << (char)(i+97) << " : " << cnt[i] << endl;
  	}
    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int H, W;
    cin >> H >> W;
    int N;
    cin >> N;
    int now = 0;
    int ans[H][W];
    rep2(i, 1, N){
        int A;
        cin >> A;
        rep2(j, now, now+A-1){
            int x = j/W, y = j%W;
            if(x&1) y = W-1-y;
            ans[x][y] = i;
        }
        now += A;
    }
    rep(i, H){
        rep(j, W) cout << ans[i][j] << ' ';
        cout << endl;
    }
}

Measured memory_bytes: 384
N = int(input())
K = int(input())
X = list(map(int, input().split()))
Y = [i for i in range(1, N+1)]
ans = 0

for x in X:
    distance_a = x
    distance_b = abs(K-x)
    if distance_a < distance_b:
        ans += distance_a
    else:
        ans += distance_b
    
print(ans*2)

Measured memory_bytes: 9044
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  LL x,y;
  cin>>x>>y;
  LL cnt = 0;
  if(abs(x)<abs(y)){
    cnt+=x>=0?0:1;
    x=max(x,-x);
    cnt+=abs(y)-abs(x);
    cnt+=y>=0?0:1;
  }else{
    cnt+=x<=0?0:1;
    x=min(x,-x);
    cnt+=abs(x)-abs(y);
    cnt+=y<=0?0:1;
  }
  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <memory>
#include <algorithm>
#include <cstring>

using namespace std;

const int NMAX = 200000+ 4;
int n, a, b, c, d;
char s[NMAX];
bool first[NMAX], second[NMAX];

void visit(bool* visited, int start, int stop, bool smen = false) {
    deque<int> q;
    q.push_back(start);
    bool jumpedOver = false;
    while (!q.empty()) {
        int pos = q[0];
        q.pop_front();
        visited[pos] = true;
        if (pos + 1 <= stop && s[pos + 1] == '.')
            q.push_back(pos + 1);
        if (pos + 2 <= stop && s[pos + 2] == '.') {
            q.push_back(pos + 2);
            if (smen && second[pos + 1])
                jumpedOver = true;
        }
    }
    if (smen && !jumpedOver)
        visited[stop] = false;
}

int main() {
    scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
    a--;
    b--;
    c--;
    d--;
    scanf("%s", s);
    visit(second, b, d);
    if (!second[d]) {
        cout << "No" << endl;
        return 0;
    }

    visit(first, a, c, d < c);
    if (!first[c]) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

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

const ll MOD = 1000000007;

ll powMod(ll n, ll p, ll mod) {
	ll res = 1;
	while (p) {
		if (p & 1) (res *= n) %= mod;
		(n *= n) %= mod;
		p >>= 1;
	}
	return res;
}
ll invMod(ll n, ll mod) {
	return powMod(n, mod - 2, mod);
}

const signed FACT_MAX_N = 2000006;
signed fact[FACT_MAX_N];
signed factInv[FACT_MAX_N];
struct INIT_FACT {
	INIT_FACT() {
		fact[0] = 1;
		for (int i = 1; i < FACT_MAX_N; ++i) fact[i] = (long long)i * fact[i - 1] % MOD;
		factInv[FACT_MAX_N - 1] = powMod(fact[FACT_MAX_N - 1], MOD - 2, MOD);
		for (int i = FACT_MAX_N - 2; i >= 0; --i) factInv[i] = (long long)(i + 1) * factInv[i + 1] % MOD;
	}
} init_fact;

/* n,r<=10^6, query O(1)*/
ll Permutation(int n, int r) {
	if (r == 0) return 1;
	if (n < r) return 0;
	return (long long)fact[n] * factInv[n - r] % MOD;
}
ll Combination(int n, int r) {
	if (r == 0) return 1;
	if (n < r) return 0;
	return (long long)fact[n] * factInv[n - r] % MOD * factInv[r] % MOD;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int h, w;
    cin >> h >> w;
    int a, b;
    cin >> a >> b;
    ll tot = Combination(h+w-2, h-1);
    ll sub = 0;
    for(int i=0; i<b; i++)
    {
        sub = (sub + ((Combination(i+h-a-1, i)* Combination(a+w-i-2, a-1)) % MOD)) % MOD;
    }
    cout << (tot + MOD - sub) % MOD;
    return 0;
}


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

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

    int i,j,flag;
    for(i=s.length()-1;i>=0;i--)
    {
        flag=0;
        if(i%2!=0)
        {
            int mid=(i+1)/2;
            string b="",c="";

            for(j=0;j<mid;j++)
                b=b+s[j];

            for(j=mid;j<i+1;j++)
                c=c+s[j];

            if(b==c)
                flag=1;
        }
        if(i+1==s.length())
            flag=0;

        if(flag==1)
            break;
    }
    cout<<i+1<<endl;

    return 0;
}
/*
    int i,j,k,cnt,flag;

    for(i=1;i<s.length();i++)
    {
        flag=0;
        k=s.length()-i;
        if(k%2==0)
        {
            cnt=0;
            for(j=0;j<k/2;j++)
            {
                if(s[k]==s[j+(k/2)])
                {
                    cnt++;
                }
            }
            if(cnt==k/2)
            {
                flag=1;
                break;
            }
        }
        if(flag==1)
            cout<<k;
    }
    return 0;
}
*/
/*
for(i=0;i<s.length()-i-1;i++)
        {
            if((s.length()-i-1)%2==0)
            {
                for(j=0;j<s.length()/2;j++)
                {
                    if(s[j]!=s[((s.length()-i-1)/2)+1])
                        break;
                }
            }
        }
*/


Measured memory_bytes: 256
# Aizu Problem 0061: Rank Checker
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


points = {}    
while True:
    no, p = [int(_) for _ in input().split(',')]
    if no == p == 0:
        break
    if p not in points:
        points[p] = []
    points[p].append(no)
rank = sorted(list(points.keys()), reverse=True)

while True:
    try:
        team = int(input())
    except EOFError:
        break
    for i in range(len(rank)):
        if team in points[rank[i]]:
            print(i + 1)
            break

Measured memory_bytes: 7724
//g++ -std=gnu++14 a.cpp
//#include <bits/stdc++.h>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>



using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

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

    cout << 2*(M_PI)*N  << endl;

}


Measured memory_bytes: 3736
import java.io.*;

public class Main{
  public static void main(String[] args) {
    try {
      String line;
      int n, a;
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      line = reader.readLine();
      n = Integer.parseInt(line);
      line = reader.readLine();
      a = Integer.parseInt(line);

      if(n%500 > a){
        System.out.println("No");
      }else{
        System.out.println("Yes");
      }
    }
    catch (Exception e) {

    }
  }
}


Measured memory_bytes: 19284
#include <iostream>
using namespace std;
typedef long long ll;
int main(){
	ll n, m, k;
	cin >> n >> m >> k;
	ll A[n], B[m];
	for (ll i = 0; i < n; i++) {
		cin >> A[i];
	}
	for (ll i = 0; i < m; i++) {
		cin >> B[i];
	}
	ll a[n + 1], b[m + 1];
	a[0] = 0; b[0] = 0;
	for (ll i = 1; i <= n; i++) {
		a[i] = a[i - 1] + A[i - 1];
	}
	for (ll i = 1; i <= m; i++) {
		b[i] = b[i - 1] + B[i - 1];
	}
	ll max = 0, j = m;
	for (ll i = 0; i <= n; i++) {
		if (a[i] > k)break;
		while (b[j] > k - a[i]) {
			j--;
		}
		if ((i + j) > max)max = (i + j);
	}
	cout << max;
}

Measured memory_bytes: 9372
#include<bits/stdc++.h>
using namespace std;
int num[100];
int p,n;
long long C(int n,int m)
{
    if(n<m) return 0;
    long long ans=1;
    for(int i=0;i<m;i++) ans=ans*(long long)(n-i)/(long long)(i+1);
    return ans;
}
long long A(int n,int m)
{
    if(n<m) return 0;
    long long ans=1;
    for(int i=0;i<m;i++) ans*=(long long)(n-i);
    return ans;
}
int main(){
 
    int Numz=0;
    int Numo=0;
    cin>>n>>p;
    for(int i=1;i<=n;i++){
        cin>>num[i];
        num[i]%=2;
        if(num[i]==0){
            Numz++;
        }else{
            Numo++;
        }
    }
    long long ans=0;
    if(p==0){
        for(int i=0;i<=Numz;i++){
            long long pos=C(Numz,i);
            for(int j=0;j<=Numo;j+=2){
                long long base=C(Numo,j);
                ans+=(pos*base);
            }
        }
        cout<<ans<<endl;
    }else if(p==1){
        for(int i=0;i<=Numz;i++){
            long long pos=C(Numz,i);
            for(int j=1;j<=Numo;j+=2){
                long long base=C(Numo,j);
                ans+=(pos*base);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, m = [int(x) for x in raw_input().split()]
xyz = [[int(x) for x in raw_input().split()] for _ in range(n)]

sigs = [1, -1]

ans = None

if m == 0:
    print 0
else:
    for xs in sigs:
        for ys in sigs:
            for zs in sigs:
                v = [x * xs + y * ys + z * zs
                    for x, y, z in xyz]
                v.sort()
                tmp = sum(v[-m:])
                ans = max(ans, tmp) if ans is not None else tmp

    print ans


Measured memory_bytes: 2820
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

int gcd(int x, int y) {
  while (y != 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI ans;
  if (n == 3) {
    ans = VI(3);
    ans[0] = 2;
    ans[1] = 5;
    ans[2] = 63;
  } else {
    if (n % 2 == 1) {
      ans.push_back(30000);
    }
    REP(i, 0, 500) {
      if ((int)ans.size() >= n) break;
      REP(j, 2, 30) {
	if (gcd(j, 30) != 1) {
	  ans.push_back(60 * i + j);
	  ans.push_back(60 * i + 60 - j);
	}
      }
      ans.push_back(60 * i + 30);
      ans.push_back(60 * i + 60);
    }
  }
  REP(i, 0, n) {
    cout << ans[i] << (i == n - 1 ? "\n" : " ");
  }
}


Measured memory_bytes: 640
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;

int n,z,w,a[2000],ret;

int main(){
    I(n);
    I(z);
    I(w);
    REP(i,n){I(a[i]);}

    if (n > 1){
        ret = max( abs(a[n-2]-a[n-1]) , abs(a[n-1]-w) );
    } else {
        ret = abs(a[0]-w);
    }
    cout << ret << endl;
}


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

#define fio() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;

const ll mod = 1e9 + 7;
const ll maxn = 1e5 + 6;
const ll N = 1e2 + 2;
const ll inf = 1e12;
const ld eps = 1e-6;

ll n, a[maxn], cnt[maxn], x, ans;

int main() {
	fio();
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		x = x ^ a[i];
		ll tmp = a[i], t = 0;
		while (!(tmp & 1)) {
			t++;
			tmp /= 2;	
		}
		cnt[t]++;
	}
	for (int b = 31; b >= 0; b--) {
		ll p = 1LL << b;
	//	cout << x << " " << p << endl;
		if (x & p) {
			if (cnt[b] < 1) {
				cout << -1 << endl;
				return 0;
			}
			p = p * 2;
			x ^= (p - 1);
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;


int main (int argc, char const *argv[])
{
    int X,Y;
    cin>>X>>Y;
    cout<<X+Y/2<<endl;
    return 0;
}

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

int main(){
  int K,A,B;
  cin >> K >> A >> B;
  
  if (B-(B%K) >= A) {
    cout << "OK" << endl;
  }
  else {
    cout << "NG" << endl;
  }

  return 0;
}

Measured memory_bytes: 3636