akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int a, d, n;
int is_prime[1000010];

int main(){
	fill(is_prime, is_prime + 1000010, 1);
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i*i <= 1000000; i++){
		if(is_prime[i]){
			for (int j = i * 2; j <= 1000000; j += i){
				is_prime[j] = 0;
			}
		}
	}
	while (cin >> a >> d >> n&&a + d + n){
		int co = 0;
		while (n > 0){
			if (is_prime[a + co*d]){
				n--;
				if (n == 0)cout << a + co*d << endl;
			}
			co++;
		}
	}
}

Measured memory_bytes: 5064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 998244353;
#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 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
}

int main() {
  ll n;
  cin >> n;
  map <ll, ll> s1;
  map <ll, ll> s2;
  rep(i, n) {
    ll a;
    cin >> a;
    if (s1.count(i-a)) s1.at(i-a)++;
    else s1[i-a] = 1;
    if (s2.count(i+a)) s2.at(i+a)++;
    else s2[i+a] = 1;
  }
  ll res = 0;
  for (auto p : s1) {
    if (s2.count(p.first)) res += p.second*s2.at(p.first);
  }
  cout << res << endl;
}

Measured memory_bytes: 26540
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通り実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long a = scanner.nextLong(), b = scanner.nextLong();
			int[] x = IntStream.range(0, n).map(i -> scanner.nextInt()).toArray();
			System.out.println(IntStream.range(1, n).mapToLong(i -> Math.min((x[i] - x[i - 1]) * a, b)).sum());
		}
	}
}


Measured memory_bytes: 58904
#include<iostream>
#include<cstdio>
#include<queue>
#include<string>
#include<algorithm>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORS(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FORR(i,n,0)
#define si(n) scanf("%d", &n)
#define sc(s) scanf("%s", s)

using namespace std;
//typedef pair<int, int> P;
typedef pair<unsigned long long int, unsigned long long int> P;

int n;
P tasks[200000];
int main(void){
    si(n);
    rep(i,n) scanf("%llu %llu", &tasks[i].second, &tasks[i].first);

    sort(tasks, tasks+n);

    unsigned long long int t = 0;
    rep(i, n){
        t += tasks[i].second;
        if (t > tasks[i].first){
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");
    return 0;
}



Measured memory_bytes: 3328
import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String args[]){
    int a=0,b=0,i=0,n=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    while(true){
    try{
      String line = reader.readLine();
      String[] splitted = line.split(" ");
      a = Integer.parseInt(splitted[0]);
      b = Integer.parseInt(splitted[1]);
      a++;
      if (b == 0) break;
		}catch(Exception e){
      break;
    }
    for(i = 1; i < a;i++){
      for(n = 0; n < b;n++){
        
        if (i == 1 || n == 0 || n == b-1 || i == a-1) {
          System.out.print("#");
        }else{
          System.out.print(".");
        }
      }
      System.out.print("\r\n");
    }
    System.out.print("\r\n");
  }
	}
}


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

static const int maxn=44;

int DP[45];

int Fibonacci(int n) {
  if (n==0 or n==1) 
    return DP[n]=1;
  
  if (DP[n]!=(-1)) 
    return DP[n];
  
  return DP[n]=Fibonacci(n-1)+Fibonacci(n-2);
}
int main() {
  std::ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  memset(DP,(-1),sizeof(DP));
  Fibonacci(maxn);
  int n;
  cin>>n;
  cout<<DP[n]<<endl;
  return 0;
}


Measured memory_bytes: 3132
q = int(input())


def is_prime(x):
    if x == 1:
        return False
    d = 2
    while d**2 <= x:
        if x % d == 0:
            return False
        d += 1
    else:
        return True

primes = []
for x in range(2, 10**5+1):
    if is_prime(x):
        primes.append(x)
        
A = [0]*(10**5+1)
for prime in primes:
    if is_prime((prime+1)//2):
        A[prime] = 1


S = [0]*(10**5+1)
for i in range(1, 10**5+1):
    S[i] = S[i-1]+A[i]


ans = []
for _ in range(q):
    L, R = map(int, input().split())
    cnt = S[R]-S[L-1]
    ans.append(cnt)

print(*ans, sep='\n')

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

int main(){
  int n, m;  cin >> n >> m;
  int l=0, r=1e5+5;
  int cnt=1;
  rep(i,m){
    int a, b; cin >> a >> b;
    if(b<l || r<a){
      cout << 0 << endl;
      return 0;
    }
    if(l<=a) l = a;
    if(b<=r) r = b;
  }
  int ans = r-l+1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
arrs = [list(map(int,input().split())) for i in range(3)]

score = 0

for i in range(n):
    score += arrs[1][arrs[0][i]-1]
    if i != 0 :
        if arrs[0][i-1]+1 == arrs[0][i]:
            score += arrs[2][arrs[0][i-1]-1]
            
print(score)

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(std::string S){
    string ans = "CODEFESTIVAL2016";
    ll cnt = 0;
    rep(i, 16){
        if(S[i]!= ans[i])
            cnt ++;
    }
    cout << cnt << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
typedef long long int ll;
using namespace std;

ll 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;

int main()
{
  cin>>n;
  int A[n];
  int sum=0;
  int max=0;
  for(int i=0;i<n;i++){
    cin>>A[i];
    sum+=A[i];
    if(A[i]>max)max=A[i];
    }
  if(sum-max>max){cout<< "Yes"<<endl;}else{cout<<"No"<<endl;}
  
  
}


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

int main() {
  int N,M;
  cin >> N >> M;
  int sum = 0;
  int a;
  rep(i, M) {
    cin >> a;
    sum += a;
  }
  cout << max(-1, N-sum) << endl;
  return 0;
}




Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair


void solve(){
 	
 	string s1,s2,s3;
 	queue<int> q[3];
   for(int i=0;i<3;i++){
     string s;cin>>s; 
     for(int j=0;j<s.size();j++){
         q[i].push(s[j]-'a');
     }
   }
 	int pop=0;
 while(1){
    
  if(q[pop].empty()) {cout<<(char)('A'+pop)<<endl; return;} 
  int t=q[pop].front();
  q[pop].pop();
  pop=t;
   
}
 	
}



int main(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  fast
  ll t=1;
 
  while(t--){
  	solve();
  }

return 0;
  
}

Measured memory_bytes: 3568
num = int(input())
count = 0
for i in range(num):
  ab = input().split(" ")
  a = int(ab[0])
  b = int(ab[1])
  if a == b:
    count += 1
    if count >= 3:
      break
  else:
    count = 0
if count >= 3:
  print("Yes")
else:
  print("No")

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

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

int N, M;
int indeg[100010], dp[100010];
vector<int> G[100010];

signed main() {
    cin >> N >> M;
    for(int i=0; i<M; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        indeg[v]++;
    }

    queue<int> que;
    for(int i=0; i<N; i++) {
        if(indeg[i] == 0) que.push(i);
    }

    while(que.size()) {
        int cur = que.front(); que.pop();
        for(auto to : G[cur]) {
            chmax(dp[to], dp[cur] + 1);
            if(--indeg[to] == 0) {
                que.push(to);
            }
        }
    }

    cout << *max_element(dp, dp + N) << endl;
    return 0;
}


Measured memory_bytes: 7296
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

//main.cpp----------------------------


void solve();

ll n;
ll a[100000];
ll b[100100];

int main() {
  cin >> n;
  rep(i, n) cin >> a[i];

  solve();

  return 0;
}

void solve() {

  rep(i, n) {
    b[a[i]] += 1;
    if(a[i]<(n-1)) b[a[i]+1] += 1;
    if(a[i]>0) b[a[i]-1] += 1;
  }
  ll max = -inf;
  rep(i, 100100) {
    if(max<b[i]) max = b[i];
  }

  cout << max << endl;
}

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

int main(){
  string S; cin >> S;
  int d[10];
  int slen=S.size();
  for(int i=0; i<slen; i++){
    d[i]=(int)(S[i]-'0');
  }
  
  long long result=0;
  long long now=0;
  for(int i=0; i<(1<<(slen-1)); i++){
    now=d[0];
    for(int j=0; j<slen-1; j++){
      if(i&(1<<j)){
        result+=now;
        now=d[j+1];
      }else{
        now=now*10+d[j+1];
      }
      if(j==slen-2){
        result+=now;
      }
    }
  }
  if(S.size()==1) result=d[0]; //ここきたない
  cout << result << endl;
}

Measured memory_bytes: 256
def main():
    X, Y, Z, K = map(int, input().split())
    A = sorted(list(map(int, input().split())), reverse=True)
    B = sorted(list(map(int, input().split())), reverse=True)
    C = sorted(list(map(int, input().split())), reverse=True)
    AB = []
    for a in A:
        for b in B:
            AB.append(a + b)
    AB.sort(reverse=True)
    ABC = []
    for i in range(min(K, len(AB))):
        for c in C:
            ABC.append(AB[i] + c)
    ABC.sort(reverse=True)
    for x in ABC[:K]:
        print(x)


main()


Measured memory_bytes: 205536
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
from collections import Counter
def resolve():
    n, p = map(int, input().split())
    S = input()

    if p == 2 or p == 5:
        res = 0
        for i, c in enumerate(S, 1):
            if int(c) % p == 0:
                res += i
        print(res)
        return

    res = 0
    now = 0
    counter = Counter()
    counter[0] = 1
    for i in range(n - 1, -1, -1):
        now = (now + pow(10, n - i - 1, p) * int(S[i])) % p
        res += counter[now]
        counter[now] += 1
    print(res)
resolve()

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

#define mp       make_pair
#define mt	  make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

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

const int INF=1<<29;
const double EPS=1e-9;
const ll MOD = 1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int X;

int check(ll x){
  int cnt = 0;
  while (x > 2){
    cnt++;
    if (x == 4){
      x = 1;
      continue;
    }
    if ((x - 1) % 2 == 0){
      x--;
      x /= 2;

    }else{
      x -= 2;
      x /= 2;
    }
  }
  return cnt;
}
int main(){
  cin >> X;
  ll left = 0;
  ll right = 1LL << 61;
  while (right - left > 1){
    ll med = (right + left) / 2;
    int cnt = check(med);
    //cerr << left << " " << right << " " << cnt << endl;
    if (cnt <= X){
      left = med;
    }else{
      right = med;
    }
  }
  cout << left << endl;
  return 0;
}


Measured memory_bytes: 256
// #include {{{
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <random>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>
// }}}

using namespace std;

// macros {{{
template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

template<typename T>
void PRINT_MATRIX(T mat, size_t nr, size_t nc)
{
    for(size_t r = 0; r < nr; ++r) {
        for(size_t c = 0; c < nc; ++c) {
            cout << mat[r][c] << (c==nc-1 ? "" : " ");
        }
        cout << "\n";
    }
}

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)
// }}}

// types {{{
using ll  = long long;
using ull = unsigned long long;
// }}}

int SX, SY;
int TX, TY;

void solve()
{
    int W = TX - SX;
    int H = TY - SY;

    REP(_, W) {
        cout << "R";
    }
    REP(_, H) {
        cout << "U";
    }
    REP(_, W) {
        cout << "L";
    }
    REP(_, H) {
        cout << "D";
    }

    cout << "L";
    REP(_, H+1) {
        cout << "U";
    }
    REP(_, W+1) {
        cout << "R";
    }
    cout << "D";
    cout << "R";
    REP(_, H+1) {
        cout << "D";
    }
    REP(_, W+1) {
        cout << "L";
    }
    cout << "U";
}

int main()
{
    cin >> SX >> SY >> TX >> TY;

    solve();

    return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    ll a[n], b[n];
    for(int i=0;i<n;i++) cin >> a[i] >> b[i];
    ll prev;
    if(a[n-1] % b[n-1] == 0){
        prev = 0;
    }else{
        prev = b[n-1] - (a[n-1] % b[n-1]);
    }   
    for(int i=n-2;i>=0;i--){
        ll base;
        if(a[i] % b[i] == 0){
            base = 0;
        }else{
            base = b[i] - (a[i] % b[i]);
        } 
        if(base >= prev) prev = base;
        else{
            if((prev - base) % b[i] == 0){
                prev = base + b[i] * ((prev - base) / b[i]);
            }else{
                prev = base + b[i] * (((prev - base) / b[i]) + 1);
            }
        } 
    }
    cout << prev << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define mk make_pair
#define pb push_back
#define eps 1e-12
using namespace std;
const int add=100000;
const int MAXN=2e5+9;
bool visited[MAXN];
vector<int> g[MAXN];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x,y;
		cin>>x>>y;
		g[x].pb(y+add);
		g[y+add].pb(x);
	}
	ll fans=0;
	for(int i=1;i<=100000;i++)
	{
		if(!visited[i])
		{
			if(g[i].size()>=2)
			{
				queue<int> q;
				vector<int> lft;
				vector<int> rgt;
				q.push(i);
				visited[i]=true;
				while(!q.empty())
				{
					int pos=q.front();
					q.pop();
					if(pos<=add)
					{
						lft.pb(pos);
					}
					else
					{
						rgt.pb(pos);
					}
					for(int j=0;j<g[pos].size();j++)
					{
						if(!visited[g[pos][j]])
						{
							q.push(g[pos][j]);
							visited[g[pos][j]]=true;
						}
					}
				}
				ll sz1=lft.size();
				ll sz2=rgt.size();
				ll ans=(sz1*sz2);
				for(int j=0;j<lft.size();j++)
				{
					ll to_minus=g[lft[j]].size();
					ans-=to_minus;		
				}
				fans+=ans;
			}
		}
	}
	cout<<fans<<endl;
	return 0;
}

Measured memory_bytes: 8960
#include<bits/stdc++.h>
typedef long long ll;
const int MOD = 1e9+7, MK=1e6+1, MS = 1e6+1;
char S[MS];
int K, L;
ll ans, F[MK+MS], IF[MK+MS];
inline ll exp(ll b, ll e) {
    ll ret = 1;
    while(e) {
        if(e&1) ret = (ret * b) % MOD;
        b = (b * b) % MOD;
        e /= 2;
    }
    return ret;
}
inline ll nCr(int n, int r) {
    return (((F[n] * IF[r]) % MOD) * IF[n - r]) % MOD;
}
int main() {
    scanf("%d", &K);
    scanf("%s", S);
    L = strlen(S);
    F[0] = IF[0] = 1;
    for(int i=1;i<=K+L;++i) {
        F[i] = (F[i-1] * i) % MOD;
        IF[i] = (IF[i-1] * exp(i, MOD - 2)) % MOD;
    }
    for(int i=0;i<=K;++i) {
        ans = (ans + (((nCr(i + L - 1, L - 1) * exp(25, i)) % MOD) * exp(26, K - i)) % MOD) % MOD;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 35948
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>

using namespace std;

int top[100];

int main(){
    int n,a,b,c;
    cin>>n>>a>>b>>c;
    double cl=c,pr=a;
    for(int i=0;i<n;++i) cin>>top[i];
    sort(top,top+n,greater<int>());
    for(int i=0;i<n;++i){
        if(cl*b>top[i]*pr) break;
        cl +=top[i];pr +=b;
    }
    cout<<floor(cl/pr)<<endl;
    return 0;
}

Measured memory_bytes: 3284
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i ++)
#define pb push_back
#define mp make_pair

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll mod = 2282282287;
const ll power = 49999;

/*
Нас по звукам узнавай:
Ня Кавай, Ня Кавай
Мы орем на весь трамвай:
Ня Кавай
Никогда не забывай:
Ня Кавай, Ня Кавай
Лучше к нам не приставай
Ня Кавай
*/

ll n;

int main()
{
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin >> n;
	if (n < 1200)
	{
		cout << "ABC";
		return 0;
	}
	if (n < 2800)
		cout << "ARC";
	else
		cout << "AGC";

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<vector<int> > square(n, vector<int>(n, -1));
        int y = n/2 + 1;
        int x = n/2;
        square[y][x] = 1;

        for(int i=2; i<=n*n; ++i){
            ++ y;
            ++ x;
            for(;;){
                if(x == n){
                    x = 0;
                    continue;
                }
                if(x == -1){
                    x = n-1;
                    continue;
                }
                if(y == n){
                    y = 0;
                    continue;
                }
                if(square[y][x] != -1){
                    ++ y;
                    -- x;
                    continue;
                }
                break;
            }
            square[y][x] = i;
        }

        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                cout << setw(4) << square[i][j];
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    char b;
    cin >> b;
    if(b == 'A') cout << 'T' << endl;
    else if(b == 'C') cout << 'G' << endl;
    else if(b == 'T') cout << 'A' << endl;
    else cout << 'C' << endl;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  int h[N];
  for(int i=0; i<N;++i){
    cin >> h[i];

  }
  int res=0;
  for(int i=0;i<N;++i){
    if(h[i]>=K){
      ++res;
    }
  }
  cout <<res<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  ll N,D;
  cin >> N >> D;
  ll dis = D*D;
  ll count = 0;
  rep(i,N){
    ll X,Y;
    cin >> X >> Y;
    if(X*X + Y*Y <= dis){
      count ++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3632
use proconio::input;
use std::collections::HashMap;

fn main() {
  input! {
    n: usize,
    sn: [String;n]
  }
  let mut map: HashMap<String, usize> = HashMap::new();
  let mut max = 0;
  for v in sn {
    let mut obj = map.entry(v).or_insert(0);
    *obj += 1;
    max = std::cmp::max(max, *obj);
  }
  
  let mut results: Vec<String> = vec![];
  let keys = map.keys();
  for key in keys {
    if *map.get(key).unwrap() == max {
      results.push(key.to_string());
    }
  }
  
  results.sort_by(|a,b| a.cmp(b));
  println!("{}", results.join("\n"));
}

Measured memory_bytes: 32684
def main():
    N = int(input())
    A_list = list(map(int, input().split()))

    if 0 in set(A_list):
        print(0)
        exit()

    ans = 1
    for i in A_list:
        ans *= i
        if 1000000000000000000 < ans:
            print('-1')
            exit()
    else:
        print(ans)


main()

Measured memory_bytes: 96040
import java.util.*;
import java.text.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int a = in.nextInt();
			String op = in.next();
			if(op.equals("?")) break;
			int b = in.nextInt();
			int ans = 0;
			if(op.equals("+")) ans = a+b;
			else if(op.equals("-")) ans = a-b;
			else if(op.equals("*")) ans = a*b;
			else if(op.equals("/")) ans = a/b;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;

int n;
long long a[400005];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= 3 * n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + (3 * n) + 1);//
	long long ans = 0;
	for (int i = n + 1; i <= 3 * n; i += 2) {
		ans += a[i];
	}
	cout << ans;
}

Measured memory_bytes: 2560
import sys
import heapq
input = sys.stdin.readline
X,Y,Z,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
DD = [i+j for i in A for j in B]
DD.sort()
heap = []
for i in DD[max(len(DD)-3001,0):]:
     for j in C:
         heapq.heappush(heap,-(i+j))
for i in range(K):
    print(-heapq.heappop(heap))
        


Measured memory_bytes: 177056
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};

ll gcd(ll x, ll y){
    if(y == 0) return x;
    else return gcd(y, x % y);
}

int main(){
    int t; cin>>t;
    while(t--){
        ll a, b, c, d; cin>>a>>b>>c>>d;

        if(a < b || d < b){
            cout << "No" << endl;
            continue;
        }

        ll g = gcd(b, d);
        a %= g;

        ll num;
        if((c - a) < 0){
            if((c - a) % g == 0){
                num = (c - a) / g + 1;
            }
            else{
                num = (c - a) / g;
            }
        }
        else{
            num = (c - a) / g + 1;
        }

        ll MIN = a + g * num;

        cout << (b <= MIN ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define maxn 100005
#define NIL -1

int n,m;
vector<int> G[maxn]; //邻接表
int color[maxn]; //编号（可以互相链接的两个节点编号相同）

void dfs(int r,int c) //给节点r分配编号c（深搜实现）（栈）
{
    stack<int> S;
    S.push(r);
    color[r]=c;
    while(!S.empty())
    {
        int u=S.top();S.pop(); //从栈顶取出
        for(int i=0;i<G[u].size();i++)
        {
            int v=G[u][i];
            if(color[v]==NIL) //如果该节点无编号
            {
                color[v]=c; //给其编号
                S.push(v); //压入栈
            }
        }
    }
}

void dfs_(int r,int c) //给节点r分配编号c（深搜实现）（递归）
{
    color[r]=c;
    for(int i=0;i<G[r].size();i++) //注意这里代码于上面的不同
    {
        int v=G[r][i];
        if(color[v]==NIL)
            {
                color[v]=c;
                dfs_(v,c);
            }
    }
}

void bfs(int r,int c) //给节点r分配编号c（广搜实现）
{
    queue<int> S;
    S.push(r);
    color[r]=c;
    while(!S.empty())
    {
        int u=S.front();S.pop(); //从队首取出
        for(int i=0;i<G[u].size();i++)
        {
            int v=G[u][i];
            if(color[v]==NIL)
            {
                color[v]=c;
                S.push(v); //加入队列中
            }
        }
    }
}

void assigncolor()
{
    int id=1;
    memset(color,NIL,sizeof(color)); //这里要记得初始化
    for(int u=0;u<n;u++)
        if(color[u]==NIL)
            dfs_(u,id++); //这里选取了广搜的方式给各个节点编号
}

int main()
{
    int s,t,q;
    cin>>n>>m;
    while(m--)
    {
        cin>>s>>t;
        G[s].push_back(t); //从顶点s向t画边
        G[t].push_back(s); //反过来连边
    }
    assigncolor();
    cin>>q;
    while(q--)
    {
        cin>>s>>t;
        if(color[s]==color[t]) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}


Measured memory_bytes: 11988
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>

using namespace std;

int main(){
int N,D;
int X[10][10];

cin>>N>>D;
for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
        cin>>X[i][j];
    }
}
int cnt=0;
for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
        if(i==j){
            continue;
        }
        float sum=0;
        for(int k=0;k<D;k++){
            sum+=float((X[i][k]-X[j][k])*(X[i][k]-X[j][k]));
        }
        sum=sqrt(sum);
        int s=int(sum);
        if(sum-s>0){
            continue;
        }
        else{
            cnt++;
        }
}

}
cout<<cnt<<endl;
//system("pause");
return 0;
}

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

int main(){
	char c;
	cin >> c;
	if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
		cout << "vowel" << endl;
	}else{
		cout << "consonant" << endl;
	}

}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main(){
  int N, M;
  while(scanf("%d%d", &N, &M) && N+M){
    int s[1000], die[1000];
    rep(i, N) scanf("%d", s+i);
    rep(i, M) scanf("%d", die+i);

    int now = 0;
    rep(i, M){
      now += die[i];
      if(now >= N-1){
	printf("%d\n", i+1);
	break;
      }
      now += s[now];
      if(now >= N-1){
	printf("%d\n", i+1);
	break;
      }
    }
  }
  return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/


int main(){
    fIO

    int n, k;
    cin >> n >> k;

    int a, ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(a >= k) ans++;
    }
    cout << ans;


}








Measured memory_bytes: 256
n,m,c = map(int, input().split())
ans = 0
b = list(map(int,input().split()))
for i in range(n):
    t = c
    a = list(map(int,input().split()))
    for j in range(m):
        t+=a[j]*b[j]
    if t>0:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm> // sort
#include <utility> // pair
#include <cfloat> // DBL_MAX

typedef long long ll;
using namespace std;

int main(){
  ll N,M;
  cin >> N >> M;

  ll ans = 0;

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

  if(M > 2){
    ans += M/4;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}


int main() {
	int a, p;
	cin >> a >> p;
	
	cout << (3*a + p) / 2 << endl;
}

Measured memory_bytes: 256
import math

def prime_number(num):
    if num == 2:
        return 1
    elif num%2 != 0:
        for j in range(3, int(math.sqrt(num))+1, 2):
            if num%j == 0:
                return 0
        return 1
    else:
        return 0

n = int(raw_input())

count = 0
for i in range(n):
    num = int(raw_input())
    if prime_number(num) == 1:
        count += 1

print count
            

Measured memory_bytes: 6816
import java.util.*;
public class Main { 
	final static int maxn=(int)2e5+10;
	static int vis[]=new int [maxn];
	static int a[]=new int [maxn];
	static int b[]=new int [maxn];
	static int f[][]=new int [maxn][3];
 public static void main(String args[])
 {
	 Scanner input=new Scanner(System.in);
     int k,n;
     k=input.nextInt();n=input.nextInt();
     for(int i=1;i<=n;i++)
    	 a[i]=input.nextInt();
     Arrays.sort(a,1,n+1);
     long dis=a[n]-a[1];int alldis=a[n]-a[1];
     int left=a[1];int right=k-a[n];
     for(int i=1;i<=n-1;i++)
     {
    	 int subdis=a[i+1]-a[i];
    	 if(subdis>(left+right))
    		 dis=Math.min(dis, alldis-subdis+(left+right));
     }
     System.out.println(dis);
}
}

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

struct StDtl
{
  int m_nLeft;

  StDtl(int nLeft) :
    m_nLeft(nLeft)
  { }
};

struct StSum
{
  int m_nLeft;
  int m_nRight;
  int m_nArea;

  StSum(int nLeft, int nRight, int nArea) :
    m_nLeft(nLeft), m_nRight(nRight), m_nArea(nArea)
  { }
};

void fnCroSecSet(stack<StDtl> &rskoDtl, vector<StSum> &rvoSum, int &rnTotalArea)
{
  string sCrossSect;
  cin >> sCrossSect;

  for (int i = 0; i < sCrossSect.size(); i++)
  {
    if (sCrossSect[i] == '\\')
    {
      StDtl oDtl(i);
      rskoDtl.push(oDtl);
    }
    else if (sCrossSect[i] == '/')
    {
      if (rskoDtl.size() > 0)
      {
        int nLeft = rskoDtl.top().m_nLeft; rskoDtl.pop();
        int nSum = i - nLeft; 
        rnTotalArea += nSum;

        while (rvoSum.size()  &&
               nLeft < rvoSum.back().m_nLeft  &&
               rvoSum.back().m_nRight < i       )
        {
          nSum += rvoSum.back().m_nArea;
          rvoSum.pop_back();
        }
        StSum oSum(nLeft, i, nSum);
        rvoSum.push_back(oSum);
      }
      else;
    }
  }
}

void  fnCroSecGet(const vector<StSum> &cnrvoSum, int nTotalArea)
{
  cout << nTotalArea << endl;
  cout << cnrvoSum.size();
  if (cnrvoSum.size() > 0)
  {
    cout << " ";
    for (auto itvoSum = begin(cnrvoSum); itvoSum != end(cnrvoSum); ++itvoSum)
    {
      if (itvoSum != begin(cnrvoSum)) cout << " ";
      cout << itvoSum->m_nArea;
    }
  }
  cout << endl;
}

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

  stack<StDtl> skStDtl;
  vector<StSum> voSum;
  int iTtlAra = 0;

  fnCroSecSet(skStDtl, voSum, iTtlAra);
  fnCroSecGet(voSum, iTtlAra);

  return 0;
}

Measured memory_bytes: 3300
import sys

f = sys.stdin

l1 = f.readline().rstrip().split(" ")
l2 = f.readline().rstrip().split(" ")
l3 = f.readline().rstrip().split(" ")

mat = l1 + l2 + l3

f.readline()  #skip N
nums = []
for line in f.readlines():
    nums.append(line.rstrip())


#check
def check(kohos, n1, n2, n3):
    kohos = set(kohos)
    if n1 in kohos:
        if n2 in kohos:
            if n3 in kohos:
                #return True
                print("Yes", end="")
                quit()
    return False


#all patterns..
check(nums, mat[0], mat[1], mat[2])
check(nums, mat[3], mat[4], mat[5])
check(nums, mat[6], mat[7], mat[8])

check(nums, mat[0], mat[3], mat[6])
check(nums, mat[1], mat[4], mat[7])
check(nums, mat[2], mat[5], mat[8])

check(nums, mat[0], mat[4], mat[8])
check(nums, mat[2], mat[4], mat[6])
print("No", end="")


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] MD = Console.ReadLine().Split(' ');
            int M = int.Parse(MD[0]);
            int D = int.Parse(MD[1]);
            int ans = 0;
            for (int m = 1; m <= M; m++)
            {
                for (int d = 1; d <= D; d++)
                {
                    int d1 = d / 10;
                    int d2 = d % 10;
                    if (d1 >= 2 && d2 >= 2 && d1 * d2 == m) ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
s = input()
hs = s[:int((len(s)-1)/2)]
def iskb(s):
    n = len(s)
    k = 1
    for i in range(int((n-1)/2)):
        if s[i] != s[-(i+1)]:
            k = 0
            break
    return k
def iskb2(s):
    n = len(s)
    k = 1
    for i in range(int(n/2)):
        if s[i] != s[-(i+1)]:
            k = 0
            break
    return k

if int((len(s)-1)/2)%2 == 0:
    if iskb(s)+iskb2(hs) == 2:
        print("Yes")
    else:
        print("No")
else:
    if iskb(s)+iskb(hs) == 2:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}

 
int main(){

  ll N,M;
  cin >> N >> M;
  map<ll,ll> X;
  vector<ll> cnt(100001,0);
  vector<ll> can_make(100001,0);

  for(int i=0; i<N; i++){
    ll x;
    cin >> x;
    X[x]++;
    can_make[x%M] -= (X[x]-1) / 2;
    can_make[x%M] += X[x] / 2;
    cnt[x%M]++;
  }

  ll ans = 0;
  for(int i=0; i<M; i++){
    int j = M - i;
    if(j<i)continue;
    if(j==M){
      ans += cnt[0]/2;
      continue;
    }else if(j==i && j+i==M){
      ans += cnt[i]/2;
      continue;
    }

    if(cnt[i] < cnt[j]){
      ans += cnt[i];
      ans += min(can_make[j],(cnt[j]-cnt[i])/2);
    }else{
      ans += cnt[j];
      ans += min(can_make[i],(cnt[i]-cnt[j])/2);
    }
  }

  cout << ans << endl;
}


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

using namespace std;
int main()
{
    int x;
    cin >> x;
    bool dp[x+1] = {false};
    dp[0]=true;
    for(int i=100;i<=x;i++)
    {
        for(int j=0;j<6;j++){
            if(i-(j+100) >= 0)
                if(dp[i-(j+100)])
                    dp[i] = true;
        }
    }
    if(dp[x])
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	while(cin>>n){
		int cnt=0,cnt2=0;
		for(int i=0;i<n;i++){
			int num;
			scanf("%d",&num);
			if(num%4==0) cnt++;
			else if(num%2==0) cnt2++;
		}
		if(cnt2>1) n=n-cnt2+1;
		if(cnt>=n/2) cout<<"Yes\n";
		else cout<<"No\n";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int INF = 1e9;
double temp_start = 100.0;
double temp_end = 0.001; 
int climb_loop = 300000;
double temp;

int main(){
  int seed = 12345;
  mt19937 eng(seed);
  uniform_real_distribution<> uniform_01;

  // input
  int D;
  cin >> D;
  int c[26];
  rep(i,26) cin >> c[i];
  int s[D+1][26];
  rep(i,D) rep(j,26) cin >> s[i+1][j];
  
  // define parameter
  int last[D+1][26];
  int t[D+1];
  rep(i,D+1) rep(j,26) last[i][j] = 0;
  
  // calculate initial content climbing
  int content = 0;
  for(int day = 1; day <= D; day++) {
    int content_after = -INF;
    int best_kind = 0;
    rep(kind,26) {
      int res = content + s[day][kind];
      rep(j,26) {
        if(j == kind) last[day][j] = day;
        else last[day][j] = last[day-1][j];
        res -= c[j] * (day - last[day][j]);
      }
      if(res > content_after) {
        best_kind = kind;
        content_after = res;
      }
    }
    t[day] = best_kind;
    content = content_after;
    rep(j,26) {
      if(j == t[day]) last[day][j] = day;
      else last[day][j] = last[day-1][j];
    }
  }
   
  // simulated annealing
  rep(x,climb_loop) {
    int d = eng() % D + 1;
    int q = eng() % 26;
    int diff = s[d][q] - s[d][t[d]];
    int cur = d;
    while(cur <= D && last[cur][t[d]] == d) {
      diff -= c[t[d]] * (d - last[cur-1][t[d]]);
      last[cur][t[d]] = last[cur-1][t[d]];
      cur++;
    }
    cur = d;
    while(cur <= D && last[cur][q] < d) {
      diff += c[q] * (d - last[cur][d]);
      last[cur][q] = d;
      cur++;
    }
    if(uniform_01(eng) < exp((double)diff/temp)) {
      t[d] = q;
      content += diff;
    } else {
      int day = d;
      while(day <= D && last[day][t[d]] < d) {
        last[day][t[d]] = d;
        day++;
      }
      day = d;
      while(day <= D && last[day][q] == d) {
        last[day][q] = last[day-1][q];
        day++;
      }
    }
  }
  // output
  for(int day = 1; day <= D; day++) cout << t[day]+1 << endl;
  return 0;
}


Measured memory_bytes: 3824
import java.util.Scanner;
import java.awt.geom.Point2D;
import java.text.DecimalFormat;
class Main{
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while(sc.hasNext()){
			DecimalFormat frt = new DecimalFormat("0.0000000");
			Point2D.Double point = new Point2D.Double();
			System.out.println(frt.format(point.distance(sc.nextDouble(),sc.nextDouble(),sc.nextDouble(),sc.nextDouble())));
		}
	}
}

Measured memory_bytes: 28120
//Created Time:2019年12月28日 星期六 20时05分18秒
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
	long long n, a, b; 
	cin >> n >> a >> b;
	if(a > b) swap(a, b);
	if(!(((b - a) & 1))) cout << (b - a) / 2 << endl;
	else {
		long long ans1 = a, ans2 = n - b + 1;
		ans1 += (b - a) / 2;
		ans2 += (b - a) / 2;
		cout << min(ans1, ans2) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
r,c = map(int,raw_input().split())
col_sum=[0]*c
for  i in range(r):
    row=map(int,raw_input().split())
    row.append(sum(row))
    for j in range (c):
        col_sum[j] += row[j]
    print ' '.join(map(str,row))
for i in range(c):
    print col_sum[i],
print sum(col_sum)

Measured memory_bytes: 6436
N = gets.strip
K = gets.to_i
L = N.length

c = ->(m, n){n.times.inject(1){|p, i| p * (m - i)/(i + 1)}}
f = ->(r, k){9**k * c[r, k]}
n = N.chars.map(&:to_i)
ans = L - n.count(&:zero?) >= K ? 1 : 0
k = K
n.each.with_index(1) do |d, i|
  break if k.zero?
  unless d.zero?
    ans += f[L - i, k] + (d - 1)*f[L - i, k - 1]
    k -= 1
  end
end
puts ans

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define int long long
#define MAX 100001
using namespace std;
// KnapSack
int max_value(int N, int W, int*w , int* v)
{
    int dp[N+1][MAX];
    for(int i= 0 ;i<=N ; ++i)
    {
        for(int j = 0 ;j<MAX ; ++j)
        {
            if(j==0){
                dp[i][j] = 0;
                continue;
            }
            if(i==0){
                dp[i][j] = INT_MAX;
                continue;
            }
            dp[i][j] = dp[i-1][j];
            if(j >= v[i-1])
                dp[i][j]  = min(dp[i][j] ,
                                dp[i-1][j-v[i-1]] + w[i-1]);
        }
    }
    for(int j=MAX-1; j>=0 ; --j)
    {
        if(dp[N][j] <=W)
            return j;
    }
} 

int32_t main()
{
    int N,W;
    cin>>N>>W;
    int w[N],v[N];
    for(int i = 0 ;i<N ;++i)
        cin>>w[i]>>v[i];

    cout << max_value(N,W,w,v) <<endl;
    return 0;
}

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

pair<int, int> makeP(int x);

int main() {
    int n;
    cin >> n;
    map<pair<int, int>, long> freq;
    pair<int, int> p;
    rep(i, n) {
        p = makeP(i + 1);
        freq[p]++;
    }
    long ans = 0;
    rep(i, n) {
        p = makeP(i + 1);
        swap(p.first, p.second);
        ans += freq[p];
    }
    cout << ans << endl;
}

pair<int, int> makeP(int x) {
    int a = x % 10;
    int b = 0;
    while(x) {
        b = x;
        x /= 10;
    }
    return make_pair(a, b);
}

Measured memory_bytes: 256
MOD = 10**9+7

def modpow(a:int, p:int)->int:
    # return a**p (mod MOD)
    if p==0: return 1
    if p%2==0:
        half_p = p//2
        half = modpow(a, half_p)
        return half*half % MOD
    else:
        return a * modpow(a, p-1) % MOD
    
def comb(a:int, b:int):
    if b > a-b: return comb(a, a-b)
    mul = 1
    div = 1
    for i in range(b):
        mul *= a-i
        div *= i+1
        mul %= MOD
        div %= MOD
        
    ret = mul * modpow(div, MOD-2) % MOD
    return ret

if __name__ == '__main__':
    N,M = map(int, input().split())
    ans = 1
    
    #  素因数分解
    i=2
    nokori = M
    while i*i <= nokori:
        if nokori%i==0:
            cnt = 0
            while nokori%i==0:
                cnt += 1
                nokori //= i
            ans *= comb(N+cnt-1, N-1)
            ans %= MOD
        i += 1
            
    if nokori != 1:
        ans *= comb(N+1-1, N-1)
        ans %= MOD
        
    print(ans)

Measured memory_bytes: 3064