akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N;
	cin >> N;
	LL ans = 0;
	for(LL n = 1;n <= N;n++){
		LL temp = n;
		LL b = N / n;
		temp *= b;
		temp *= (b + 1);
		temp /= 2;
		ans += temp;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
const int N = 100010, MOD = 1e9 + 7;
int a[N],n,pla[N],x,y;
typedef long long ll;
ll jc[N],inv[N];
ll power(ll a,int b) {
  ll res = 1;
  while (b) {
    if (b&1) (res *= a) %= MOD;
    (a *= a) %= MOD;
    b >>= 1;
  }
  return res;
}
ll comb(int a,int b) {
  if (a < 0 || b < 0 || a < b) return 0;
  return jc[a] * inv[b] % MOD * inv[a-b] % MOD;
}
int main() {
  scanf("%d",&n);
  for (int i = 1 ; i <= n + 1 ; ++ i) {
    scanf("%d",&a[i]);
    if (!pla[a[i]]) pla[a[i]] = i;
    else x = pla[a[i]], y = i;
  }
  jc[0] = 1;
  for (int i = 1 ; i <= n + 1 ; ++ i)
    jc[i] = 1ll * jc[i-1] * i % MOD;
  inv[n+1] = power(jc[n+1],MOD-2);
  for (int i = n ; i >= 0 ; -- i)
    inv[i] = 1ll * inv[i+1] * (i+1) % MOD;
  for (int i = 1 ; i <= n + 1 ; ++ i)
    printf("%lld\n",(comb(n+1,i) - comb(x - 1 + n + 1 - y,i-1) + MOD) % MOD);
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    string s; cin>>s;
    ll n=s.size();
    set<char> st;
    rep(i,n){
        st.insert(s[i]);
    }
    bool ok=false;
    vector<ll> a(4,0);
    if(st.size()==4) ok=true;
    if(st.size()==2){
        for(auto x:st){
            if(x=='N') a[0]++;
            if(x=='S') a[1]++;
            if(x=='E') a[2]++;
            if(x=='W') a[3]++;
        }
        if(a[0]>0 && a[1]>0 && a[2]==0 && a[3]==0) ok=true;
        if(a[2]>0 && a[3]>0 && a[0]==0 && a[1]==0) ok=true;
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
struct fastio { fastio () { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } _io;
template<class T, class U> bool chmax(T& a, const U &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> bool chmin(T& a, const U &b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	int a;
	std::cin >> a;
	std::cout << a + a * a + a * a * a << '\n';
	return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<stack>
#define ll long long
using namespace std;

#define Get_Abs(a) ((a) >= 0 ? (a) : -(a))
#define Get_Max(a, b) ((a) > (b) ? (a) : (b))
#define Get_Min(a, b) ((a) < (b) ? (a) : (b))
#define Get_Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
#define Get_Limit(a, b, c) ((a) = ((a) > (c)) ? (c) : (((a) < (b)) ? (b) : (a)))

int main()
{
	ll a, b, c, d, x, y;
	ll Ans;
	cin >> a >> b >> c >> d;
	Ans = Get_Max(a * c, a * d);
	Ans = Get_Max(Ans, b * c);
	Ans = Get_Max(Ans, b * d);
	cout << Ans;
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string.h>

using namespace std;

bool isSafe(int i, int j, int k, int n){
    return i>=0 && j>=0 && k>=0 && i<n && j<n&&k<n;
}

int main(){
    int n;
    cin>>n;
    int arr[n];
    //now scan the array
    int a=0; int b=0; int c = 0;
    for(int i=0; i<n; i++){
        cin>>arr[i];
        if(arr[i]==1)a++;
        else if(arr[i]==2)b++;
        else c++;
    }
    //given that n<=500
    //create the DP

    double dp[n+1][n+1][n+1];

    // memset(dp, 0, sizeof(dp));

    //now loop through the elements
    //i for c, j for b, and k for a
    for(int i=0; i<=c; i++){
        for(int j=0; j<=b+c; j++){
            for(int k=0; k<=a+b+c; k++){
                dp[k][j][i]=0;
                if(i+j+k>0){
                    double factor = i+j+k;
                    if(isSafe(k-1, j, i, n+1)){
                        dp[k][j][i]+=k*dp[k-1][j][i];
                    }
                    if(isSafe(k+1, j-1, i, n+1)){
                        dp[k][j][i]+=j*dp[k+1][j-1][i];
                    }
                    if(isSafe(k, j+1, i-1, n+1)){
                        dp[k][j][i]+=i*dp[k][j+1][i-1];
                    }
                    dp[k][j][i]+=n;
                    dp[k][j][i]=(double)dp[k][j][i]/(double)(i+j+k);
                }
            }
        }
    }
    printf("%0.14f\n",dp[a][b][c]);
}

Measured memory_bytes: 213248
#include <stdio.h>
#include <math.h>

int calc_max_sum(long a, long b){
    long long inte = sqrt(a * b);
    if((inte + 1) * inte < a * b){
        return inte * 2 + 1;
    }else if(inte * inte <= a * b){
        return inte * 2;
    }
}

bool is_square_number(long s){
    long inte = long(sqrt(s));
    if(inte * inte == s){
        return true;
    }else{
        return false;
    }
}

void answer(long long a, long long b){
    long long ans = calc_max_sum(a, b) - 1;

    ans -= 1;

    if(is_square_number(a * b)){
        ans -= 1;
        if (a == b){
            ans = (a - 1) * 2;
        }
    }


    printf("%lld\n", ans);
}


int main(void){
    int n;
    scanf("%d", &n);

    for(int i = 0; i < n; i++){
        long long a, b;
        scanf("%lld", &a);
        scanf("%lld", &b);
        answer(a, b);
    }
}


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

int main() {

	//入力
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	int ans = 0; //答えとなる山の数
	int maxheight = 0; //今までで最も高い山の高さ

	//今見ている山
	for (int i = 0; i < N; i++) {
		if (maxheight <= H[i]) {
			ans++;
			maxheight = H[i];
		}
	}

	cout << ans << endl;
}

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

int main() {
    string S;
    cin >> S;
    int N = S.length();
    for (int i = N - 2; i >= 0; i--) {
        string temp = S.substr(0, i);
        if (temp.substr(0, i / 2) == temp.substr(i / 2)) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt(); //n個後の文字
		char[] s = stdIn.next().toCharArray(); //文字列S
		if(n==0) {
			System.out.println(s);
			System.exit(0);
		}
		
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < s.length; j++) {
				if(s[j] == 'Z') {
					s[j] ='A';
				}else {
				
					s[j]++;
				}
			
			}
		}	
		for(char a: s) {
			System.out.print(a);
		}
	}

}


Measured memory_bytes: 26140
#include <stdio.h>
#include <stdlib.h>
#define INFTY 2000000000;
void merge(int *,int,int,int);
void mergeSort(int *,int,int);
int n, count = 0, *L, *R;
/*countは比較回数をカウントする。*/
int main()
{
  int *S, i;

  scanf("%d",&n);
  S = (int *)malloc(n * sizeof(int));

  for(i = 0 ; i < n ; i++) scanf("%d",&S[i]);

  mergeSort(S, 0, n);

  for(i = 0 ; i < n-1 ; i++) printf("%d ",S[i]);
  printf("%d\n",S[n-1]);
  printf("%d\n",count);

  free(S);
  free(L);
  free(R);
  
  return 0;
}

void merge(int *A, int left , int mid, int right)
{
  int n1, n2, i, j, k; 
  n1 = mid - left;
  n2 = right - mid;

  L = (int *)malloc((n1 + 1) * sizeof(int));
  R = (int *)malloc((n2 + 1) * sizeof(int));

  for(i = 0 ; i < n1 ; i++) L[i] = A[left+i]; 
  for(i = 0 ; i < n2 ; i++) R[i] = A[mid+i];

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

  i = 0;
  j = 0;

  for(k = left ; k < right ; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
      count++; }
    else{
      A[k] = R[j];
      j++;
      count++; } 
  }

} 

void mergeSort(int *A, int left, int right)
{
  int mid;
  
  if(left + 1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right); }

}


Measured memory_bytes: 64100
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>

using namespace std;

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

    for(unsigned int bit = 0; bit < (1 << 3); bit++){
        vector <string> opp(3, "+");
        for(unsigned int i = 0; i < 3; i++) {
            if(bit & (1 << i)) opp[i] = "-";
        }

        int result = atoi(str_input.substr(0, 1).c_str());
        for(unsigned int k = 1; k < 4; k++){
            if(opp[k-1] == "+") result += atoi(str_input.substr(k,1).c_str());
            else result -= atoi((str_input.substr(k, 1).c_str()));
        }

        if(result == 7) {
            string output = str_input[0] + opp[0] + str_input[1] + opp[1] + str_input[2] + opp[2] + str_input[3] + "=7";
            cout << output << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef pair<int,int>P;
int main(){
	vector<P>V;
	int w,h,n,x,y,ans=0,mx,my;
	cin>>w>>h>>n;
	for(int i=0;i<n;i++){
		cin>>x>>y;
		V.push_back(P(x,y));
	}
	for(int i=0;i<n-1;i++){
		mx=V[i].first-V[i+1].first;
		my=V[i].second-V[i+1].second;
		if(mx>0 && my>0)
			ans-=min(mx,my);
		else if(mx<0 && my<0)
			ans+=max(mx,my);
		if(mx<0)
		ans-=mx;
		else
		ans+=mx;
		if(my<0)
		ans-=my;
		else
		ans+=my;
	}
	cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 1212
n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

ans = -1e10
for i in range(1, 2**10):
    d = [0 for _ in range(n)]
    pi = 0
    for j in range(10):
        if (1 << j) & i:
            for k in range(n):
                d[k] += f[k][j]
    ans = max(ans, sum(map(lambda k: p[k][d[k]], range(n))))

print(ans)

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

int gcd(int x,int y){
    return (x % y)? gcd(y, x % y) : y;
}
int main() {
    int n, a, sum; cin >> n;
    sum = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int o = 1; o <= n; o++){
                a = gcd(gcd(i , j) , o);

                sum = sum + a;
            }
        }
    }
    cout << sum << endl;
    return 0;

}

Measured memory_bytes: 3608
import sys

N = int(input())
tasks = []
lines = sys.stdin.readlines()
for line in lines:
    temp = [int(i) for i in line.split()]
    #tasks.append((temp[0], temp[1] - temp[0], temp[1]))
    tasks.append(tuple(temp))

time = 0
tasks.sort(key=(lambda x: x[1]))

for t in tasks:
    time += t[0]
    if time > t[1]:
        print('No')
        sys.exit(0)
print('Yes')


Measured memory_bytes: 46252
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;


int main(){
	string s, t; int a, b;
	cin >> s >> t;
	cin >> a >> b;
	string u;
	cin >> u;
	if (u == s) a--;
	if (u == t) b--;
	cout << a << " " << b << endl;
	return 0;
}


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

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

int main()
{
    int n, k, ans = 0;
    scanf("%d %d", &n, &k);

    for (int i = 0; i < n; i++) {
        int num;
        scanf("%d", &num);

        if (num >= k)
            ans++;
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(s: str):
    ret = ''
    for c in s:
        if c == 'B':
            if len(ret) > 0:
                ret = ret[:-1]
        else:
            ret += c
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define mp make_pair
#define ll long long
#define pb push_back

void solve()
{

  ll n;
  cin>>n;
  vector<ll>v(n);

  ll i;
  ll sum  = 0;
  for(i=0;i<n;i++){cin>>v[i]; sum = sum + v[i];}

  ll hell = 1e9+7;


  ll ans = 0;
  for(i=0;i<n;i++)
  {
      sum = sum - v[i];
      
      ll val = sum;
      val = val%hell;

      ans = (ans + (val * v[i])%hell)%hell;
  }
  cout<<ans;


  return;
}

int main()
{

  int t = 1;
  //cin>>t;

  while(t--)
    solve();

  return 0;
}


Measured memory_bytes: 4748
#!/usr/bin/env python3
import sys
import itertools

def solve(ABCD: str):
    A, B, C, D = map(int,ABCD)
    bit_list = list(itertools.product(["+","-"], repeat=3))
    for bit in bit_list:
        a=A
        if bit[0] == "+":
            a+=B
        else:
            a-=B        
        if bit[1] == "+":
            a+=C
        else:
            a-=C        
        if bit[2] == "+":
            a+=D
        else:
            a-=D    
        if a == 7:
            print("{}{}{}{}{}{}{}=7".format(A,bit[0],B,bit[1],C,bit[2],D))
            break 

    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
def solve(n):
  res = 0
  while(n != 1):
    if n%2 == 0:
      res += 1
      n /= 2
    else:
      break
  return res

n = int(input())

ans = 1
ans_max = 0
for i in range(1, n+1):
  cnt = solve(i)
  if cnt > ans_max:
    ans_max = cnt
    ans = i
print(ans)

Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = (m); i < (n); i++)
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  rep(i,0,N) cin >> vec[i];
  vector<int> bin;
  rep(i,0,N){
    int cnt = 0;
	while(!(vec[i]&(1<<0))){
      vec[i]/=2;
      cnt++;
    }
    bin.push_back(cnt);
  }
  sort(bin.begin(), bin.end());
  rep(i,0,N/2){
    if ((bin[i]+bin[N-i-1])<2){
      cout <<"No\n";
      return 0;
    }
  }
  cout << "Yes\n";
}

Measured memory_bytes: 1276
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  long long int N,M,MOD=10E8 + 7,res=0,xsum=0,ysum=0,x[100001],y[100001];
  cin >> N >> M;
  REP(i,N)cin >> x[i];
  REP(i,M)cin >> y[i];
  REP(i,N){
    xsum = (xsum - x[i]*(N-i-1)+i*x[i] + MOD) % MOD;
  }
  REP(i,M){
    ysum = (ysum -y[i]*(M-i-1)+i*y[i] + MOD) % MOD;
  }
  res = (xsum * ysum) % MOD;
  cout << res << endl;
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 1792
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1e6 + 6, mod = (int) 0;
int deg[N];
int main() {
	int n, m;
	cin >> n >> m;
	while (m--) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		deg[u] ^= 1;
		deg[v] ^= 1;
	}
	int res = 0;
	for (int j = 0; j < n; ++j) res += deg[j];
	if (res > 0) {
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
	}
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b; cin >> a >> b;
  int ans = 0;
  bool check = true;
  for(int i=1; i<=1009; i++){
    int x = i*0.08;
  	int y = i*0.10;
    if(x==a && y==b){
      ans = i;
      check = false;
      break;
    }
  }
  if(check) cout << -1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(_, _, x, y) = sc.nextLine().split(" ").map(_.toInt)
    val xMax = sc.nextLine.split(" ").map(_.toInt).max
    val yMin = sc.nextLine.split(" ").map(_.toInt).min

    if (xMax >= y) println("War")
    else if (yMin <= x) println("War")
    else {
      if (xMax >= yMin) println("War")
      else println("No War")
    }
  }

}


Measured memory_bytes: 27332
#include<iostream>
using namespace std;
int main(){
	long long N;
	cin >> N;
	long long sum=0;
	long long tmp=0;
	long long ans=1000000000000;
	
	for(long long i=1; i*i<N+1; i++){
		if(N%i==0){
			tmp = N/i;
			sum = (i-1)+(tmp-1);
		}
		if(ans>sum){
			ans = sum;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  double x, ans;
  ans = 0;
  string u;
  for(int i=0;i<n;i++){
    cin >> x >> u;
    if(u == "JPY"){
      ans += x;
    }else{
      ans += x * 380000.;
    }
  }

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

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979
#define MAXI 7500000

//.size()はunsigned int　0-1をするとオーバーフローする
 
using namespace std;
typedef long long int ll;
typedef pair< long long int , long long int> P;

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

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

struct edge{long long int to;
long long int cost;};

 
int main(void){

	int n;
	string s[101];
	int p[101];

	cin>>n;

	vector< pair< pair<string,int> ,int> > pa(n);

	FOR(i,1,n){
		cin>>s[i]>>p[i];
		pa[i-1].first.first=s[i];
		pa[i-1].first.second=-p[i];
		pa[i-1].second=i;
	}

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

	FOR(i,0,n-1){
		cout<<pa[i].second<<endl;
	}

}



Measured memory_bytes: 256
from subprocess import*
with open('A.py','w')as f:
    f.write('a,b=map(int,input().split())\n')
    for i in range(-100,101):
        f.write('if a==%d:\n'%i)
        for j in range(-100,101):
            f.write('    if b==%d:print(%d)\n'%(j,max(i+j,i-j,i*j)))
call(('python3','A.py'))

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

int main() {
    int N;
    cin >> N;
    int ans=0;
    rep(i,N) {
        int l,r;
        cin >> l >> r;
        ans += r-l+1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;

//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int N;
  string S;
  string R = "";
  cin >> N >> S;
  for(int i = 0 ; i < S.length(); i++){
  	if(char(S[i] + N) > char('Z')){
  		R += char(S[i] + N - 'Z' + 'A' -1);
  	}
  	else{
  		R += char(S[i] + N);
  	}
  }
  cout << R << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long n;
long long ans;
long long k;
int main()
{
	cin>>n;
	k=n/11;
	ans=k*2;
	k=n%11;
	if(1<=k&&k<=6)
	{
		ans++;
	}
	else if(7<=k)ans+=2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/*created by tanishk gupta*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef vector<int> VI;
typedef long long int ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll MOD=1e9+7;
const ll mod=1e9+7;
//const llint MOD;
const int N=(int)(2*1e5+10);
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll add(ll a,ll b){return ((a%MOD)+(b%MOD))%MOD;}
ll mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
ll sub(ll a,ll b){return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll binpow(ll x, ll y){ll z = 1;while(y){if(y & 1) z = mul(z, x);x = mul(x, x);y >>= 1;}return z;}
int inv(int x){return binpow(x, MOD - 2);}
int divide(int x, int y){return mul(x, inv(y));}
//int fact[N];
//void precalc(){fact[0] = 1;for(int i = 1; i < N; i++)fact[i] = mul(fact[i - 1], i);}
//int C(int n, int k){return divide(fact[n], mul(fact[k], fact[n - k]));}
//bool prime[N];
//void sieve() {for(int i=2;i<N;i++) {prime[i]=true;}for (int p=2; p*p<=N; p++){if (prime[p] == true){for (int i=p*p; i<=N; i += p)prime[i] = false;}}}
ll legendpow(ll n, ll p){ll total = 0;while (n){n /= p;total += n;}return total;}

//head==================================================================================


int main()
{ IOS;
int n;
cin>>n;
int ans=360/__gcd(360,n);
cout<<ans;
}


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

int main() {
    int D, G;
    cin >> D >> G;
    G /= 100;
    vector<int> P(D), C(D);
    for(int i = 0; i < D; ++i) {
        cin >> P[i] >> C[i];
        C[i] /= 100;
    }
    auto rec = [&](auto &&rec, int d, int score, int cnt, int mask) -> int {
        if(d == D) {
            int i = D - 1;
            while(mask & (1 << i)) --i;
            if(i >= 0) {
                int n = P[i];
                while(n-- && score < G) {
                    score +=  i + 1;
                    ++cnt;
                }
            }
            if(score >= G) return cnt;
            else return 1e9;
        }
        int nscore = score + (d + 1) * P[d] + C[d];
        int ncnt = cnt + P[d];
        int nmask = mask | (1 << d);
        return min(rec(rec, d + 1, score, cnt, mask), rec(rec, d + 1, nscore, ncnt, nmask));
    };
    cout << rec(rec, 0, 0, 0, 0) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int main() {
  int n; cin >>n;
  vector<int> a(n),b(n),c(n);
  rep(i, n) cin >>a.at(i); rep(i, n) cin >>b.at(i); rep(i, n) cin >>c.at(i);
  sort(all(a)); sort(all(c));
  ll res = 0;
  rep(i, n){
    int x = lower_bound(all(a), b[i]) - a.begin();
    int y = c.end() - upper_bound(all(c), b[i]);
    res += (ll)x * (ll)y;
  }
  cout <<res <<endl;
}


Measured memory_bytes: 1536
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		String str;
		int[] listA = new int[26];

		//hasNext()??§?¬?????????????????????¨?????????????????????????????£??????????????£?????????

		while(sc.hasNext()){

			//1???????????????????°??????????????????????
			String SS = sc.nextLine();
			str = SS.toLowerCase();

			//
			for(int i = 0;i < str.length();i++){
				char c = str.charAt(i);

				//???????????£?????????????????\??????
				if(Character.isLetter(c)){
					listA[c - 'a']++;
				}
			}
		}
		//sc.close();

		for(int i = 0; i < listA.length; i++){
			System.out.println((char)( 'a' + i ) + " : " + listA[i]);
		}
	}
}

Measured memory_bytes: 26020
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdint>
#include <utility>
#include <tuple>
#include <map>    
#include <queue> 
#include <set>  
#include <stack> 
#include <deque>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset>

using namespace std;

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

	int count = 0;
	for (int i = 1; i <= N; i++) {
		if (i >= 1 && i <= 9) {
			count++;
		}
		else if (i >= 100 && i <= 999) {
			count++;
		}
		else if (i >= 10000 && i <= 99999) {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl;exit(0);}else return;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	ll N,ans = 0; cin >> N;
	V<ll> a(N), b(N);
	REP(i, N) cin >> a[i];
	REP(i, N) cin >> b[i];
	for (int k = 28; 0 <= k; --k) {
		V<ll> c = a,d = b;
		for (auto& u : c) u %= (1 << (k + 1));
		for (auto& u : d) u %= (1 << (k + 1));
		sort(ALL(d));
		ll sum = 0;
		REP(i,N){
			sum += lower_bound(ALL(d), 2 * (1 << k) - c[i]) - lower_bound(ALL(d), 1 * (1 << k) - c[i]);
			sum += lower_bound(ALL(d), 4 * (1 << k) - c[i]) - lower_bound(ALL(d), 3 * (1 << k) - c[i]);
			sum %= 2;
		}
		ans += sum*(1 << k);
	}
	cout << ans << endl;
	return 0;
}



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

public class Main {
	static int c=0, H[];
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		H=new int[2000000];
		
		PrintWriter out= new PrintWriter(System.out);
		while(true) {
			String odr=in.next();
			if(odr.equals("end"))break;
			if(odr.equals("insert")) {
				int k=Integer.parseInt(in.next());
				insert(k);
			}
			else if(odr.equals("extract")) {
				out.println(remove());
			}
		}
		out.flush();
	}
	
	static void insert(int k){
		c++;
		H[c]=k;
		
		int i=c/2,s=c;
		while(i>0) {
			if(H[i]>H[s])break;
			int t=H[i];
			H[i]=H[s]; H[s]=t;
			s=i; i/=2;
		}
	}
	
	static int remove() {
		int max=H[1];
		H[1]=H[c];
		c--;
		maxHeapify(1);
		return max;
	}
	
	static void maxHeapify(int i) {
		if(i*2>c)return;
		
		int max=H[i], u=-1;
		if(H[i*2]>max) {
			max=H[i*2];
			u=i*2;
		}
		if(i*2+1<=c && H[i*2+1]>max) {
			max=H[i*2+1];
			u=i*2+1;
		}
		
		if(u!=-1) {
			int t=H[i];
			H[i]=H[u];
			H[u]=t;
			maxHeapify(u);
		}
	}

}



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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//template end



int main(){
   int a,b; scanf("%d%d",&a,&b);
   string s,t;
   rep(i,0,b)s+=(char)(a+'0');
   rep(i,0,a)t+=(char)(b+'0');
   cout<<min(s,t)<<endl;
   return 0;
}

Measured memory_bytes: 256
#define ONLINE_JUDGE
#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cmath>
#include <iterator>
#include <map>
#include <set>
#ifndef ONLINE_JUDGE
#include <prettyprint/prettyprint.hpp>
#endif

#define FOR(i, n) for(int i = 0; i < n; ++i)
#define TEST int T; std::cin >> T; while(T--)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vll = std::vector<ll>;
using vull = std::vector<ull>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	ifstream fin("in.txt");
	ofstream fout("out.txt");
	auto cinbuf = cin.rdbuf(fin.rdbuf());    // save and redirect
	auto coutbuf = cout.rdbuf(fout.rdbuf()); // save and redirect
#endif	
	int N, W;
	cin >> N >> W;

	vector<pair<int, ull>> objects(N);

	for(auto& e : objects) {
		cin >> e.first >> e.second;
	}

	ull dp[N + 1][W + 1]; // One extra state for 0 capacity and no objects.

	// Initialize state.
	for(int i = 0; i <= W; ++i) {
		dp[0][i] = 0;
	}
	for(int i = 0; i <= N; ++i) {
		dp[i][0] = 0;
	}

	for(int j = 1; j <= W; ++j) {
		for(int i = 1; i <= N; ++i) {
			// Can we add this to our knapsack?
			int w = objects[i - 1].first;
			ull v = objects[i - 1].second;
			dp[i][j] = dp[i - 1][j];
			if(w <= j) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - w] + v);
			}
		}
	}

	cout << dp[N][W] << endl;
#ifndef ONLINE_JUDGE
	cin.rdbuf(cinbuf);    // restore
	cout.rdbuf(coutbuf); // restore
#endif	
}


Measured memory_bytes: 79232
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k, temp, j;
    cin>>n>>k;
    ll a[n + 1], i;
    for(i = 1; i <= n; i++) {
    	cin>>a[i];
    }
    vector<ll> mini(n + 1, -1);
    mini[1] = 0;
    if(k == 0) {
    	cout<<"1\n";
    	return 0;
    }
    ll cur = 1;
    vector<ll> recur;
    for(i = a[1]; ; i = a[i]) {
    	ll jump = i;
    	// cout<<i<<" "<<mini[i]<<endl;
    	if(mini[jump] == -1) {
    		mini[jump] = cur;
    		if(cur == k) {
    			cout<<jump<<"\n";
    			return 0;
    		}
    	}
    	else {
    		k = k - mini[jump];
    		temp = jump;
    		j = a[jump];
    		recur.pb(jump);
    		for(; j != temp; j = a[j]) {
    			recur.pb(j);
    		}
    		break;
    	}
    	cur++;
    }
    ll len = recur.size();
    k = k % len;
    cout<<recur[k]<<"\n";
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt=0;
    for(int i=1; i<n; i++){
        if(s.at(i) == 'E') cnt++;
    }  
    vector<int> change(n);
    change.at(0) = cnt;
    for(int i=1; i<n; i++){
        change.at(i) = change.at(i-1);
        if(s.at(i-1) == 'W') change.at(i)++;
        if(s.at(i) == 'E') change.at(i)--;
    }
    int ans=change.at(0);
    for(int i=0; i<n; i++){
        ans = min(ans, change.at(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4724
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        s = s.replaceAll("eraser", "0");
        s = s.replaceAll("erase", "0");
        s = s.replaceAll("dreamer", "0");
        s = s.replaceAll("dream", "0");
        s = s.replaceAll("0", "");
        if (s.length()== 0){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }

}

Measured memory_bytes: 29108
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    for(int i=1;i<=10000;i++){
      int a=sc.nextInt();
      if(a==0) break;
      System.out.println("Case "+i+": "+a);
    }
  }
}



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

const int INF = pow(2, 31) - 1;
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)

template <class T1, class T2, class Pred = less<T2> >
struct sort_pair_second {
  bool operator()(const pair<T1, T2>&left, const pair<T1, T2>&right) {
    Pred p;
    return p(left.second, right.second);
  }
};
int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, long long> > vec(M);
  vector<long long> Y(M);
  REP(i, M) {
    cin >> vec[i].first >> vec[i].second;
    Y[i] = vec[i].second;
  }
  sort(vec.begin(), vec.end(), sort_pair_second<int, long long>());
  vector<int> p_count(N, 1);
  map<long long, string> ans;
  REP(i, M) {
    ostringstream sout1, sout2;
    sout1 << setfill('0') << setw(6) << vec[i].first;
    sout2 << setfill('0') << setw(6) << p_count[vec[i].first-1];

    string s = sout1.str() + sout2.str();
    ans.insert(make_pair(vec[i].second, s));
    p_count[vec[i].first-1]++;
  }
  REP(i, M) {
    cout << ans.at(Y[i]) << endl;
  }
  return 0;
}


Measured memory_bytes: 15232
#include <iostream>

using namespace std;

int calc_gcd(int a, int b);

int main(void)
{
    int sum_lim;

    cin >> sum_lim;

    int sum = 0;

    for(int i = 1; i <= sum_lim; i++){
        for(int j = 1; j <= sum_lim; j++){
            for(int k = 1; k <= sum_lim; k++){
                sum += calc_gcd(calc_gcd(i, j), k);
            }
        }
    }

    cout << sum << endl;

    return 0;
}

int calc_gcd(int a, int b)
{
    int c = a % b;

    if(c == 0){
        return b;
    }

    return calc_gcd(b, c);
}

Measured memory_bytes: 3636
R1 = [35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0]
R2 = [71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0]
B = %w[AAA AA A B C D E]
$<.each do |l|
  t1, t2 = l.split.map(&:to_f)
  r1 = R1.find_index {|t| t1 < t }
  r2 = R2.find_index {|t| t2 < t }
  puts r1 && r2 ? B[[r1, r2].max] : 'NA'
end

Measured memory_bytes: 8616
#include <stdio.h>

int main(void){
	int N,T;
	scanf("%d %d",&N,&T);
	
	int c[N],t[N];
	int i,j,count;
	for(i=0;i<N;++i){
		scanf("%d %d",&c[i],&t[i]);
	}
	/*for(i=0;i<N;++i){		//入力チェック
			printf("c[%d]=%d t[%d]=%d\n",i,c[i],i,t[i]);
	}*/
	j=0,count=0;
	for(i=0;i<N;++i){
		if(t[i]<=T) {
			c[j]=c[i];
			j++;
			count++;
		}
	}
	
	if(count==0) {
		printf("TLE\n");
		return 0;
	}else {

		/*for(j=0;j<count;++j){		//チェック
				printf("c[%d]=%d\n",j,c[j]);
		}*/
		
		int min=c[0];
		for(j=0;j<count;++j){
			if(c[j]<=min) min=c[j];
		}
		
		printf("%d\n",min);
		
		
		return 0;
	}
}

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

int main(){
   int x,y;
   cin >> x >> y;
   int f = 0;
   for (int i = 0; i <= x;i++)
   {
   if(i*2+(x-i)*4==y)
   {
       f = 1;
       break;
   }
   }

    if(!f)
    {

        cout << "No" << endl;
    }else
    {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n, d, a = MI()
    hp = []
    for _ in range(n):
        x, h = MI()
        heappush(hp, (x, 1, h))
    p = 0
    ans = 0
    while hp:
        x, op, h = heappop(hp)
        if op:
            h -= p
            if h > 0:
                ad = (h + a - 1) // a
                ans += ad
                p += ad * a
                heappush(hp, (x + 2 * d + 1, 0, ad * a))
        else:
            p -= h

    print(ans)

main()


Measured memory_bytes: 35688
//
// Created by David Sarpong on 5/30/20.
//

#include <iostream>
#include <iomanip>
using namespace std;

int main(int argc, char** argv) {
    int N, K;
    cin >> N >> K;

    double expected[N];
    for (int i = 0; i < N; i++) {
        int p;
        cin >> p;

        expected[i] = (p + 1.0)/2;
    }

    double maxSum = -1.0;
    double sum = 0.0;
    for (int i = 0; i < N; i++) {
        sum += expected[i];

        if (i >= K) {
            sum -= expected[i - K];
        }

        maxSum = max(maxSum, sum);
    }

    cout << setprecision(9) << maxSum << "\n";

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

int main() {
  int n,m; cin >> n >> m;
  vector<pair<int,int>> x(n);
  rep(i,n) cin >> x[i].first >> x[i].second;
  sort(ALL(x));
  ll ans = 0;
  int c = 0;
  for(auto [f,s] : x) {
    if(c+s >= m) {
      ans += (m-c) * (ll)f;
      break;
    }
    ans += f*(ll)s;
    c += s;
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 4012
<?php

while (true) {
    fscanf(STDIN, '%s', $m);
    if (feof(STDIN)) {
        break;
    }
    $m = str_split($m);
    for ($i = 0; $i < 7; $i += 3) {
        if ($m[$i] !== 's' && $m[$i] === $m[$i + 1] && $m[$i + 1] === $m[$i + 2]) {
            echo $m[$i] . PHP_EOL;
            continue 2;
        }
    }
    for ($i = 0; $i < 3; $i++) {
        if ($m[$i] !== 's' && $m[$i] === $m[$i + 3] && $m[$i + 3] === $m[$i + 6]) {
            echo $m[$i] . PHP_EOL;
            continue 2;
        }
    }
    if ($m[0] !== 's' && $m[0] === $m[4] && $m[4] === $m[8]) {
        echo $m[0] . PHP_EOL;
        continue;
    }
    if ($m[2] !== 's' && $m[2] === $m[4] && $m[4] === $m[6]) {
        echo $m[2] . PHP_EOL;
        continue;
    }
    echo 'd' . PHP_EOL;
}

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

int main()
{
	int N;

	cin >> N;

	if (N<=999) {
		cout << "ABC" << endl;
	}

	else {
		cout << "ABD" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    string s;
    cin>>s;
    int n=s.size();
    int cnt=0;
    if('A'>=s[0]) ++cnt;
    FOR(i,1,n){
        if(s[i-1]>=s[i]) ++cnt;
    }
    cout<<cnt<<endl;
    return 0;
}


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

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int s, n, a[100005];
vector<pair<int, int> > v;

int main(void) {
    cin >> n;
    rep(i, 0, n) scanf("%d", &a[i]);
    sort(a, a+n);
    swap(a[1], a[n-1]);

    s = a[0];
 
    rep(i, 1, n) {
        int x, y;
        if (i==n-1 || a[i+1]<0) {
            x = max(s, a[i]);
            y = min(s, a[i]);
        } else {
            x = min(s, a[i]);
            y = max(s, a[i]);
        }
        s = x - y;
        v.pb(mp(x, y));
    }
    

    cout << s << endl;
    for (int i=0; i<(int)v.size(); i++) printf("%d %d\n", v[i].first, v[i].second);

	return 0;
}


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

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
  int a,b,c;
  cin>>a>>b>>c;
  int ans=0;
  reep(i,a,b+1){
    if(c%i==0) ans++;
  }
  cout<<ans<<endl;
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int a,b,c,i,d=0;
    
    scanf("%d%d%d",&a,&b,&c);
    
    for(i=0;i<b-a+1;i++){ 
    
    if (c%(a+i)==0)
    d++;
}
  
  printf("%d\n",d);
  
  return(0);
  
}


Measured memory_bytes: 2112