akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define true 1
#define false 0
typedef struct{
  char kind;
  int num;
} data;
int N;
int isStable(data *,data *);
void BubbleSort(data *,int);
void SelectionSort(data *,int);

int main()
{
  int i; 
  data *in, *B, *S;
  
  scanf("%d",&N);
  in = (data *)malloc(N * sizeof(data));
  B = (data *)malloc(N * sizeof(data));
  S = (data *)malloc(N * sizeof(data));

  for(i = 0 ; i < N ; i++){
    scanf(" %c%d",&in[i].kind,&in[i].num);
    B[i] = in[i];
    S[i] = in[i]; }

  BubbleSort(B ,N); 
  SelectionSort(S, N);

  for(i = 0 ; i < N-1 ; i++) printf("%c%d ",B[i].kind,B[i].num);
  printf("%c%d\n",B[N-1].kind,B[N-1].num);
  if(isStable(in,B) == true) printf("Stable\n");
  else printf("Not stable\n");

  for(i = 0 ; i < N-1 ; i++) printf("%c%d ",S[i].kind,S[i].num);
  printf("%c%d\n",S[N-1].kind,S[N-1].num);
  if(isStable(in,S) == true) printf("Stable\n");
  else printf("Not stable\n");

  free(in);
  free(B);
  free(S);
  
  return 0;
}

int isStable(data *in,data *out){
  int i, j, a, b;

  for(i = 0 ; i < N-1 ; i++){
    for(j = i+1 ; j < N-1 ; j++){ 
      for(a = 0 ; a < N-1 ; a++){
	for(b = a+1 ; b < N-1 ; b++){
	  if(in[i].num == in[j].num && in[i].num == out[b].num && in[j].num == out[a].num){
	    if(in[i].kind == out[b].kind && in[j].kind == out[a].kind) return false; }
	}
      }
    }
  }
  
  return true;
}

void BubbleSort(data *C,int N){
  int i, j, num;
  char kind;
  
  for(i = 0 ; i < N-1 ; i++){
    for(j = N-1 ; j >= i+1 ; j--){
      if(C[j].num < C[j-1].num){
	num = C[j].num;
	C[j].num = C[j-1].num;
	C[j-1].num = num;
	kind = C[j].kind;
	C[j].kind = C[j-1].kind;
	C[j-1].kind = kind; }
    }
  }
      
}

void SelectionSort(data *C,int N){
  int i, j, minj, for_change_num;
  char for_change_kind;
  
  for(i = 0 ; i < N-1 ; i++){
    minj = i;
    for(j = i ; j <= N-1 ; j++){
      if(C[j].num < C[minj].num) minj = j; }
    for_change_num = C[i].num;
    C[i].num = C[minj].num;
    C[minj].num = for_change_num;
    for_change_kind = C[i].kind;
    C[i].kind = C[minj].kind;
    C[minj].kind = for_change_kind;
  }

}



Measured memory_bytes: 2144
n=int(input())
ans=0
n_len=len(str(n))-1



for i in range(1,n+1):
    #print("i:",i)
    if i%10==0:
        continue
    tmp=str(i)
    tmp=tmp[-1]+tmp[0]
    check=0
    if int(tmp)<=n:
        check+=1
    if tmp[0]==tmp[-1]:
        check+=1
    
    for j in range(1,n_len):
        
        cal_min=int(tmp[0]+"0"*j+tmp[-1])
        cal_max=int(tmp[0]+"9"*j+tmp[-1])
        #print("cal:",cal_min,",",cal_max)
        if cal_min>n:
            continue
        if cal_max<=n:
            check+=10**j
            continue
        cal_n=str(n)[1:-1]
        check+=int(cal_n)+1
        if int(str(n)[-1])<int(tmp[-1]):
            check-=1
    #print("check:",check)
    ans+=check
print(ans)

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

const ll mod = 998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);

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

  mint ans = 0;
  mint col = M;
  for (int x = N - 1; x >= 0; x--) {
    mint now = col;
    now *= c(N - 1, x);
    if ( x <= K) ans += now;
    col *= M - 1;
  }

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


Measured memory_bytes: 6236
using System;

class Problem {
    public static void Main() {
        var inp = "";
        while ((inp = Console.ReadLine()) != "-") {
            var n = int.Parse(Console.ReadLine());
            for (var i = 0; i < n; i++) {
            	var h = int.Parse(Console.ReadLine());
            	var s = inp.Substring(0, h);
            	inp = inp.Remove(0, h) + s;
            }
            Console.WriteLine(inp);
        }
    }
}


Measured memory_bytes: 8864
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m,d = inpl()
cnt = n-d
if d > 0: cnt *= 2
print(cnt/pow(n,2)*(m-1))

Measured memory_bytes: 77220
#include <stdio.h>
#include <iostream>

int main() {
	int x1, x2, x3, x4;
	int y1, y2, y3, y4;
 
	std::cin >> x1;
	std::cin >> y1; 
	std::cin >> x2; 
	std::cin >> y2;
 
	int dis_x, dis_y;
	dis_x = x1 - x2;
	dis_y = y1 - y2;
 
	x3 = x2 + dis_y;
	y3 = y2 - dis_x;
	x4 = x1 + dis_y;
	y4 = y1 - dis_x;
 
	std::cout << x3 << " "
		<< y3 << " "
		<< x4 << " "
		<< y4 << " "
		<< std::endl;
 
	return 0;
}

Measured memory_bytes: 256
n = int(input())

scores = [int(input()) for _ in range(n)]

scores.sort()
sum_scores = sum(scores)

if sum_scores % 10 == 0:
    for score in scores:
        if score % 10:
            print(sum_scores - score)
            exit()
else:
    print(sum_scores)
    exit()

print(0)

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

int main() {
  
  int a;
  int b;
  int c;
  int d;
  int e;
  
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cin >> e;
  
  cout << ( c * 60 + d ) - ( a * 60 + b ) - e << endl;
}


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

int main() {
    string a,b,c;
    cin >> a >> b >> c;

    char ac = a[0] -0x20;
    char bc = b[0] -0x20;
    char cc = c[0] -0x20;
    cout << ac << bc << cc << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef long long ll;
typedef pair<ll,ll> P;
const int INF=INT_MAX / 3;
const ll LINF=LLONG_MAX / 3LL;
#define CONST 1000000007
#define EPS (1e-8)
#define PB push_back
#define MP make_pair
#define sz(a) ((int)(a).size())
#define reps(i,n,m) for(int i=(n);i<int(m);i++)
#define rep(i,n) reps(i,0,n)
#define SORT(a) sort((a).begin(),(a).end())
ll mod(ll a,ll m){return (a%m+m)%m;}
int dx[9]={0,1,0,-1,1,1,-1,-1,0},dy[9]={1,0,-1,0,1,-1,1,-1,0};

typedef vector<int> VI;
typedef vector<VI> VVI;

struct unionFind {
  VI par, rank;
  int n;
  void init(int x) {
    n = x;
    par.resize(n);
    rank.resize(n);
    rep(i,n) {
      par[i] = i;
      rank[i] = 0;
    }
  }
  int root (int x) {
    if (par[x] == x) {
      return x;
    }
    return par[x] = root(par[x]);
  }
  bool same (int x, int y) {
    return root(x) == root(y);
  }
  void unite (int x, int y) {
    x = root(x);
    y = root(y);
    if (x==y) return;
    if(rank[x]<rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }
  int treeNum () {
    set<int> s;
    rep(i,n) {
      s.insert(root(i));
    }
    return s.size();
  }
};


ll n, k, l;
int main(){
  unionFind road;
  cin >> n >> k >> l;
  road.init(n);
  rep(i,k){
    int p,q;
    cin >> p >> q;
    p--;q--;
    road.unite(p, q);
  }

  unionFind rail;
  rail.init(n);
  rep(i, l) {
    int p,q;
    cin >> p >> q;
    p--;q--;
    rail.unite(p, q);
  }

  map<P, int> mp;
  rep(i, n) {
    mp[P(road.root(i), rail.root(i))] += 1;
  }

  rep(i, n) {
    if(i!=0) cout<<" ";
    cout << mp[P(road.root(i), rail.root(i))];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 15104
import java.io.*;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {
  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    Runtime.getRuntime().addShutdownHook(new Thread(() -> out.close()));
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));

    int N = sc.nextInt();
    int[] buttons = new int[N+1];
    buttons[0] = -1;
    for (int i = 1; i <= N; i++) {
      buttons[i] = sc.nextInt();
    }

    int next = 1;
    int ans = 0;
    while (true){
      ans++;
      int polled = buttons[next];

      if (polled==2){
        break;
      }else if (polled==0){
        ans = -1;
        break;
      }

      buttons[next] = 0;
      next = polled;
    }

    out.println(ans);
    out.close();
  }

  /*          
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


Measured memory_bytes: 41508
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(System.out);
        int N = scan.nextInt();
        for (int t = 1; t <= N; t++) {
            int ans = solve(t);
            out.println(ans);
        }
        out.flush();
        out.close();
    }
    private int solve(int t) {
        int ans = 0;
        for (int x = 1; x * x <= t; x++) {
            int remain1 = t - x * x;
            if (remain1 < 0) {
                continue;
            }
            for (int y = x; y * y <= remain1; y++) {
                int remain2 = remain1 - y * y - x * y;
                if (remain2 < 0) {
                    continue;
                }
                for (int z = y; z * z <= remain2; z++) {
                    if (remain2 % z != 0) {
                        continue;
                    }
                    int w = remain2 / z;
                    if (x + y + z != w) {
                        continue;
                    }
                    if (x == y && y == z) {
                        ans += 1;
                        continue;
                    }
                    if (x == y || x == z || y == z) {
                        ans += 3;
                        continue;
                    }
                    ans += 6;
                }
            }
        }
        return ans;
    }
}


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

int n, t = 0;
vector<vector<int> > G(110);
pair<int, int> toki[110];
bool vis[110];

void dfs(int v)
{
    if(vis[v]) return;
    t++;
    toki[v].first = t;
    vis[v] = true;
    rep(i, G[v].size())
    {
        if(vis[G[v][i]]) continue;
        dfs(G[v][i]);
    }
    t++;
    toki[v].second = t;
    return;
}

int main(void)
{
    cin >> n;
    rep(i, n) vis[i] = false;
    rep(i, n)
    {
        int t, k;
        cin >> t >> k;
        t--;
        rep(j, k)
        {
            int v;
            cin >> v;
            v--;
            G[t].push_back(v);
        }
    }
    rep(i, n)
    {
        dfs(i);
    } 
    rep(i, n)
    {
        cout << i+1 << " " << toki[i].first << " " << toki[i].second << endl;
    }
    return 0;
}


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

bool judge(char a,char b) {
  int x = (a - '0')*10 + (b - '0');
  if ((1 <= x) && (x <= 12)) {
    return true;
  }
  else {
    return false;
  }
}
 
int main() {
  string S;
  cin >> S;
  bool a = judge(S.at(0),S.at(1));
  bool b = judge(S.at(2),S.at(3));
  if (a && b) {
    cout << "AMBIGUOUS" << endl;
  }
  else if (!a && !b) {
    cout << "NA" << endl;
  }
  else if (a && !b) {
    cout << "MMYY" << endl;
  }
  else {
    cout << "YYMM" << endl;
  }
}
  
      
     
  
  


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

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

    int n, x;

    while (1) {
        cin >> n >> x;
        if (n == 0 && x == 0) {
            break ;
        }
        int count = 0;
        for (int i = 1; i < n + 1; i++) {
            for (int j = i + 1; j < n + 1; j++) {
                for (int k = j + 1; k < n + 1; k++) {
                    if (i + j + k == x) {
                        count++;
                    }
                }
            }
        }
        cout << count << '\n';
    }

    return 0;
}


Measured memory_bytes: 3212
#include <iostream>
using namespace std;
int main(void){
    string s;
    int x;
    cin >> s;
    cin >> x;
    int i=0;
    while(x>0){
        if(s[i]=='1'){
            x--;
        }else{
            cout << s[i] << endl;
            break;
        }
        i++;
    }
    if(x==0){
        cout << '1' << endl;
    }
}


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

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


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

#define fi first
#define se second

const int N = 3030;
const long long mod = 1e9 + 7;

using namespace std;

int n;
int m;
int a[N];
int s[N];
char c[N];
int d[N][N];

void add(int &x, int y)
{
        x += y;
        if(x >= mod){
                x -= mod;
        }
}

int main()
{
        ios_base::sync_with_stdio(0);

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

        cin >> n >> m;
        for(int i = 1; i <= n; i++){
                cin >> c[i];
                a[i] = i;
                s[i] = s[i - 1] + c[i] - '0';
        }
        for(int i = 1; i <= m; i++){
                int x, y;
                cin >> x >> y;
                a[x] = max(a[x], y);
        }
        for(int i = 1; i <= n; i++){
                a[i] = max(a[i], a[i - 1]);
        }
        d[n][0] = d[n][1] = 1;
        for(int i = n - 1; i >= 1; i--){
                int to_add = s[a[i + 1]] - s[a[i]];
                int lim = min(n - to_add, a[i] - i + 1);
                for(int j = 0; j <= lim; j++){
                        if(j > 0){
                                add(d[i][j], d[i + 1][j - 1 + to_add]);
                        }
                        if(j < a[i] - i + 1){
                                add(d[i][j], d[i + 1][j + to_add]);
                        }
                }
        }
        cout << d[1][s[a[1]]] << "\n";
}


Measured memory_bytes: 34048
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%lld\n",n)
#define PRF(f) printf("%.10lf\n",f)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
typedef long long int ll;
int cmp(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}
int main(void){
  int n,c,k,t[100000],sum=0,ans=0;
  ll x;
  scanf("%d%d%d",&n,&c,&k);
  FOR(n)scanf("%d",&t[i]);
  qsort(t,n,sizeof(int),cmp);
  x=(long long int)(t[0]+k);
  ans++;
  FOR(n){
    if(x>=t[i] && sum<c) sum++;
    else{
      ans++;
      x=(long long int)(t[i]+k);
      sum=1;
    }
  }
  PRN(ans);
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  double t,x;
  cin>>t>>x;
  cout<<fixed<<setprecision(6)<<t/x<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a=0,b=0,c=0,d=0,e=0,f=0,i=0,j=0,m1=0,m2=0;
  int a1[999999],a2[999999],a3[999999];

  cin>>a>>b;
  for(i=0;i<b;i++){
    cin>>a1[i];
    m1+=a1[i];
  }
  if(m1>=a) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
  


Measured memory_bytes: 2688
////////
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long LL;
void guan() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls (rt<<1)
#define rs (rt<<1|1)
#define F first
#define S second
#define mst(x,a) memset(x,a,sizeof(x))
#define Pr pair<int,int>
#define Prl pair<LL, LL>
#define Prd pair<double, double>
#define root 1,cnum,1
#define For(i,b,c) for(int i=b;i<=c;i++)
#define lowbit(x) (x&(-x))
const int maxn = 200020;
const LL mod = 998244353;
const LL mod2 = mod - 1;
const int INF = 0x7FFFFFFF;
const LL LINF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const LL maxx = 1LL<<61;
const double eps = 1e-8;
//*********
 
int n, m, q, k;
char s[maxn];
inline int read() { 
    mst(s, 0);
    return
    cin >> s
?1:0; }

void solve() {
    int ok = 1;
    if(s[0] != 'A') ok = 0;
    int cnt = 0;
    for(int i = 0;i < strlen(s);i++) {
        if(s[i] == 'A' || s[i] == 'C') continue;
        if('A' <= s[i] && s[i] <= 'Z') ok = 0;
    }
    for(int i = 2;i < strlen(s) - 1;i++) {
        if(s[i] == 'C') cnt++;
    }
    if(cnt != 1) ok = 0;
    if(ok) cout << "AC" << endl;
    else cout << "WA" << endl;
}

int main() {
    guan();
    int t = 1;
    //cin >> t;
    int Cas = 1;
    while(t--) {
        while(read())
            //cout << "Case #" << Cas++ << ": " << endl;
            solve();
    }
    //cin >> t;
    return 0;
}


Measured memory_bytes: 512
n=int(input())
l=1
c=1
while(1):
    c+=26**l
    if n/c<1:
        c-=26**l
        break
    else:
        l+=1

S = list('abcdefghijklmnopqrstuvwxyz')
tmp_n=n-c
tmp=0
tmp_ans=[]
for i in range(l):
    tmp = (tmp_n)//26**((l-1)-i)
    tmp_n -= tmp*26**(l-1-i)
    tmp_ans.append(S[tmp])
print("".join(tmp_ans))

Measured memory_bytes: 9200
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>
#include <cmath>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


int main() {
	int N;
	cin >> N;
	cout << 800 * N - (N/15)*200;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int w , h , x , y , z ;
	while ( 1 )
	{
		cin >> h >> w ;
		z = 1 ;
		if ( w == 0 && h == 0 ) break ;
	while ( z <= h ){
		for ( x = 1 ; x <= w ; x ++ )
			cout << "#" ;
			z ++ ;
			cout << endl;
	}
	cout << endl;
}
}

Measured memory_bytes: 1152
import java.util.*;
import java.lang.*;

class Mod{
    static final long MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(1000000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long adds(long... ar){
        long ans=0;
        for(long x:ar) ans = Mod.add(ans, x);
        return ans;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long mults(long... ar){
        long ans=1;
        for(long x:ar) ans = Mod.mult(ans, x);
        return ans;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }
    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

}

public class Main {
    static long firstDifBit(int x, int y){
        int z = x^y;
        for(int i=0; i<30; i++) if((z & (1<<i))!=0) return i;
        return -1;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for(int i=0; i<N; i++){
            for(int j=i+1; j<N; j++){
                System.out.print(1+firstDifBit(i,j));
                if(j==N-1) System.out.println();
                else System.out.print(" ");
            }
        }
    }
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	string s,t;
	std::cin >> s >> t;
	std::vector<std::vector<int>> counts(26,std::vector<int>{}), countt(26,std::vector<int>{});
	for (size_t i = 0; i < s.size(); i++) {
		counts[s[i]-'a'].push_back(i);
		countt[t[i]-'a'].push_back(i);
	}
	sort(counts.begin(), counts.end());
	sort(countt.begin(), countt.end());

	for (size_t i = 0; i < counts.size(); i++) {
		if (counts != countt) {
			std::cout << "No" << '\n';
			return 0;
		}
	}

	std::cout << "Yes" << '\n';
	//
	// for (size_t i = 0; i < counts.size(); i++) {
	// 	if (counts[i].size() == 0) {
	// 		continue;
	// 	}
	// 	for (size_t j = 0; j < counts[i].size(); j++) {
	// 		std::cout << counts[i][j] << ' ';
	// 	}
	// 	std::cout << '\n';
	// }
	// for (size_t i = 0; i < countt.size(); i++) {
	// 	if (countt[i].size() == 0) {
	// 		continue;
	// 	}
	// 	for (size_t j = 0; j < countt[i].size(); j++) {
	// 		std::cout << countt[i][j] << ' ';
	// 	}
	// 	std::cout << '\n';
	// }
	return 0;
}


Measured memory_bytes: 3080
import java.util.*;

class Main{


    private static int solver(int[] w, int[] v, int n, int max){
        
        int[][] dp = new int[n + 1][max + 1];
        for(int[] row: dp) Arrays.fill(row, 0);


        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= max; j++){

                if(w[i-1] <= j) { 
                    int emptyCapacity = j - w[i-1]; 
                    dp[i][j] = Math.max(dp[i-1][j], v[i-1] + dp[i-1][emptyCapacity]);
                     
                } else { 
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
        
        return dp[n][max];
    }  


    // space optimized version, weight is the dimension to dp   
    private static long solverOneDimension(int[] w, int[] v, int n, int max){
        
        long[] dp = new long[max + 1];
        dp[0] = 0;

        for(int i = 1; i <= n ;i++){

            int value = v[i - 1];
            int weight = w[i - 1];

            for(int weight_already = max - weight; weight_already >= 0; --weight_already) {
                
                    dp[weight_already+weight] = Math.max(dp[weight_already+weight], dp[weight_already] + value);
                }
        }

        return dp[max];

        // for(int i=0; i<dp.length; i++){
        //     System.out.print(dp[i] + " ");
        // }
        // System.out.println();
        // long answer = 0;
        // for(int i = 0; i <= max; i++) {
        //     answer = Math.max(answer, dp[i]);
        // }        


        // return answer;
    }



    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(); // number of items
        int max = in.nextInt(); // max weight
        int[] w = new int[n];
        int[] v = new int[n];
        
        for(int i = 0; i < n; i++){
            w[i] = in.nextInt();
            v[i] = in.nextInt();
        }
        System.out.println(solverOneDimension(w, v, n, max));
        
    }
}


Measured memory_bytes: 22228
// Problem : C - XYZ Triplets
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 100005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub uppper_bound
using namespace std;
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		int cnt = 0;
		for(int j=1;j<=(int)sqrt(i);j++)
			for(int k=1;k<=(int)sqrt(i);k++)
			{
				int b = j+k;
				int c = j*j + k*k+j*k -i;
				int d = (b*b)-(4*c);
				if(d < 0)
					continue;
				int x = sqrt(d);
				if(x*x != d)
					continue;
				int r = (x-b);
				int s = (-x-b);
				if((r%2 || r <= 0) and (s%2 || s <=0))
					continue;
				// cout << r <<" "<<j<<" "<< k <<" "<< i <<"\n";
				cnt++;
				
			}	
			cout << cnt <<"\n";
		}
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int s;cin>>s;
    vector<int> num;
    int ans=0;
    num.push_back(s);
	while(1){
        if(s%2==0){
            s = s/2;
        } else{
            s = 3*s+1;
        }
        ans++;
        num.push_back(s);
    
        if(count(num.begin(),num.end(),s) == 2){
            cout << ans+1 << endl;
            return 0;
        }
        
 
    }
}

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

using namespace std;

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2437&lang=jp
typedef long long ll;
#define INF 1<<30
const int mod = 1e9 + 7;
int dp[55][55][55][55];
int Sum;
int Na, Nt, Ng, Nc;
map<string, int> mp;
vector<vector<string>> ms;

vector<string> split(const string& str, char c) {
	vector<string> ret;
	stringstream ss(str);
	string item;
	while (getline(ss, item, c)) {
		if (!item.empty())ret.push_back(item);
	}
	return ret;
}

void decryp(const string& key, vector<string>& dec,int& _sum) {
	int len = (int)ms[mp[key]].size();
	for (int i = 1; i < len;i++) {
		if (ms[mp[key]][i][0] == '[') {
			dec.push_back(ms[mp[key]][i]);
			_sum++;
			if (_sum > Sum)return;
		}
		else {
			decryp(ms[mp[key]][i], dec, _sum);
			if (_sum > Sum)return;
		}
	}
	return;
}
int solve(int na, int nt, int ng, int nc, int inc, const vector<string>& dec) {
	if (inc == Sum) {

		return ((na == Na) && (nt == Nt) && (nc == Nc) && (ng == Ng));
	}
	int& res = dp[na][nt][ng][nc];
	if (res != -1)return res;
	res = 0;
	int L = dec[inc].length();
	for (int at = 1; at < L - 1;at++) {
		if (dec[inc][at] == 'A' && na < Na) {
			(res += solve(na + 1, nt, ng, nc, inc + 1, dec)) %= mod;
		}
		else if (dec[inc][at] == 'T' && nt < Nt) {
			(res += solve(na, nt + 1, ng, nc, inc + 1, dec)) %= mod;
		}
		else if (dec[inc][at] == 'G' && ng < Ng) {
			(res += solve(na, nt, ng + 1, nc, inc + 1, dec)) %= mod;
		}
		else if (dec[inc][at] == 'C' && nc < Nc) {
			(res += solve(na, nt, ng, nc + 1, inc + 1, dec)) %= mod;
		}
	}
	return res;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	cin >> Na >> Nt >> Ng >> Nc;
	int _m; cin >> _m;
	Sum = Na + Nt + Ng + Nc;
	cin.ignore();
	vector<string> ni(_m);
	string First;
	int idx = 0;
	for (int i = 0; i < _m;i++) {
		string temp;
		getline(cin, temp);
		ni[i] = temp;
		auto sp = split(ni[i],' ');
		string f = sp[0].substr(0, sp[0].length() - 1);
		if (i == 0)First = f;
		mp[f] = idx; idx++;
		ms.push_back(sp);
	}

	vector<string> dec;
	int _sum = 0;
	decryp(First, dec,_sum);
	if (_sum != Sum) { cout << 0 << endl; return 0; }

	for (int i = 0; i < 55; i++)for (int j = 0; j < 55;j++)for (int k = 0; k < 55;k++) for (int l = 0; l < 55;l++) {
		dp[i][j][k][l] = -1;
	}
	cout << solve(0, 0, 0, 0, 0, dec) << endl;
	return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;

int main()
{
    int a, b, k; cin >> a >> b >> k;
    set<int> st;
    for (int i = 0; i < k && i <= b - a; i++) {
        st.insert(a+i);
        st.insert(b-i);
    }
    for (auto& e: st) {
        cout << e << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;
 
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;
 
 
const int mod=1000000007;
//const int mod=998244353;

 
 

 
int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r,p;
    cin >> n;
    vll v(1e5+1);
    b=0;
    for(int i=0; i<n; i++){
        cin >> a;
        v[a]++;
        b+=a;
    }
    cin >> q;
    for(int i=0; i<q; i++){
        cin >> c >> d;
        b-=v[c]*c;
        b+=v[c]*d;
        v[d]+=v[c];
        v[c]=0;
        cout << b << el;
    }
    return 0;
}


Measured memory_bytes: 3984
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define T int t = 0; cin >> t; while(t--)
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef long double lld;
const ll mod = 1e9 + 7;
const ll mx = 2e6 + 5;

void input(){
   int n, r;cin >> n >> r;
   cout << ((n >= 10) ? r : (r + (100 * (10 - n))) )<< endl;

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

Measured memory_bytes: 256
def north(d):
    d[0], d[1], d[5], d[4] = d[1], d[5], d[4], d[0]


def west(d):
    d[0], d[2], d[5], d[3] = d[2], d[5], d[3], d[0]


def east(d):
    d[0], d[3], d[5], d[2] = d[3], d[5], d[2], d[0]


def south(d):
    d[0], d[4], d[5], d[1] = d[4], d[5], d[1], d[0]


F = {'N': north, 'W': west, 'E': east, 'S': south}
d, os = list(map(int, input().split())), input()
for o in os:
    F[o](d)
print(d[0])

Measured memory_bytes: 7796
using System;

public class Hello
{
	public static int MOD = 1000000007;
	public static void Main()
	{
		string[] line = Console.ReadLine().Trim().Split(' ');
		var n = int.Parse(line[0]);
		var m = int.Parse(line[1]);
		var a = new bool[100001];
		for (int i = 0; i < m; i++)
		{
			var w = int.Parse(Console.ReadLine().Trim()) - 1;
			a[w] = true;
		}
		var dp = new long[n + 1];
		dp[0] = 1;
		dp[1] = a[0]? 0 : 1;
		for (int i = 2; i < n+1; i++)
		{
			if (a[i - 1] && a[i - 1]) dp[i] = 0;
			else if (a[i - 1])  dp[i] = dp[i - 2];
			else  dp[i] = dp[i - 1] + dp[i - 2];
			dp[i] %= MOD;
		}
		Console.WriteLine(dp[n]);
	}
}

Measured memory_bytes: 13792
def main():
    n=int(input())
    a=list(map(int,input().split()))
    l1=[0]*61
    for i in a:
        j=list(reversed(bin(i)[2:]))
        for k in range(len(j)):
            if j[k]=="1":
                l1[k]+=1
    l0=[n-i for i in l1]
    ans=0
    mod=10**9+7
    for i in range(len(l1)):
        ans=(ans+l0[i]*l1[i]*pow(2,i,mod))%mod
    print(ans)
main()


Measured memory_bytes: 122808
#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
#define mp make_pair
//manip
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power_mod(T a, T b) {return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
template<class T> T power(T a, T b) {return b ? power(a * a, b / 2) * (b % 2 ? a : 1) : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i_, n) cout << a[i_] << " "; cout << endl
#define out(a) cout << a << endl
#define outv(v) rep(i, SZ(v)) cout << v[i] << " "; cout << endl
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always
//ctrl + command + e -> 変数一括変更



int main() {
    
    
   
    int n, e, r; cin >> n >> e >> r;
    int table[n]; fill_n(table, n, inf); //rからの距離
    table[r] = 0;
    vector<vector<pii> > edge(n);
    rep(i, e) {
        int s, t, d; cin >> s >> t >> d;
        edge[s].eb(t, d);
    }
    
    int cnt = 0;
    while (1) {
        int update = 0;
        rep(from, n) {
            if (table[from] == inf) continue;
            rep(j, SZ(edge[from])) {
                int to = edge[from][j].F;
                int cost = edge[from][j].S;
                
                if (table[to] > table[from] + cost) {
                    update = 1;
                    table[to] = table[from] + cost;
                }
            }
        }
        if (update == 0) break;
        cnt++;
        if (cnt == n) {
            out("NEGATIVE CYCLE");
            return 0;
        }
    }
    
    
    rep(i, n) {
        if (table[i] == inf) out("INF");
        else out(table[i]);
    }
        
        
    
    
    
}



Measured memory_bytes: 3156
S = int(input())


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7  # 出力の制限
N = 10**5
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


if S < 3:
    print(0)
else:
    k = S // 3
    ans = 0
    s = S
    for i in range(1, k+1):
        s -= 3
        ans += cmb(s+(i-1), i-1, mod)
        ans %= mod
    print(ans)


Measured memory_bytes: 21296
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(ll i = a; i < (n); ++i)
#define repD(i, a, n) for(ll i = a; i > (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (long long) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
// #define mp make_pair
#define pb push_back
// #define endl "\n"
#define MAXN 5000000
const long double PI = 3.141592653589793238462643383;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<double> vd;
typedef vector<pii> vii;
int Ceil(int a, int b){
    if(a%b==0) return a/b;
    else return (a/b)+1;
}
ll p=1000000007;
float E = 0.00000000000001;
ll power(ll x, ll y){
    if(y==0){
        return 1;
    }
    if(y%2==0){
        ll q=power(x,y/2);
        q=q%p;
        return (q*q)%p;
    }
    ll q=power(x,y/2);
    q=q%p;
    return ((x%p)*((q*q)%p))%p; 
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}  

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a); 
}
long long int mod(long long int a, long long int b) {
    long long int ret = a%b; return ret>=0? ret: ret+b; 
}


long long int rec(long long int num, vector <long long int> &dp){
        if(num == 1)
            return 0;
        if(dp[num] != -1)
            return dp[num];
        else if(num%2)
            dp[num] = 1 + rec(3*num + 1, dp);
        else
            dp[num] = 1 + rec(num/2, dp);
        return dp[num];
    }
int getKth(int lo, int hi, int k) {
        vector <long long int> dp(10000, -1);
        vector < pair<long long int, long long int> > vec(hi - lo + 1);
        dp[0] = 0;
        dp[1] = 0;
        for(int i = lo ; i <= hi ; i++){
            vec[i - lo].first = rec(i, dp);
            vec[i - lo].second = i;
        }
        sort(vec.begin(), vec.end());
            // for(auto x:vec)
            //     cout<<x.second<<" ";
        return vec[k-1].second;
    }

int main(){

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

    int t;
    // cin>>t;
    t = 1;
    while(t--){
            int a,b,c,k;
            cin>>a>>b>>c>>k;
            int sum = 0;
            sum += min(k, a);
            k -= min(k, a);
            // cout<<sum;
            // cout<<k;
            if(k > 0)
                k -= min(k, b);
            // cout<<sum;
            if(k > 0){
                // cout<<"Y";
                sum -= min(k, c);
                k -= min(k, c);
            }
            cout<<sum;
        }   
        return 0;
    }

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

int main() {
  ios::sync_with_stdio(false);
  int N, T;
  cin >> N >> T;
  vector<int> V(N);
  for (int i = 0; i < N; i++) cin >> V.at(i);
  V.push_back(INT_MAX);

  long ans = 0;
  for (int i = 0; i < N; i++) ans += min(T, V.at(i + 1) - V.at(i));
  cout << ans << "\n";
}

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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int hmax=0;
  int n;
  cin >> n;
  int ans = 0;
  rep(i,n) {
    int h = 0;
    cin >> h;
    hmax = max(hmax, h);
    if(h == hmax) ans++;
  }
  cout << ans << endl;
}

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

using namespace std ;

const int MAX = 2e5 + 10 ;

long long sum[MAX] ;
int n , d;
long long a ;
vector< pair<long long , long long> >vp ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>d>>a ;
	for(int i = 0 ; i < n ; ++i)
	{
		long long x , y ;
		cin>>x>>y ;
		vp.emplace_back(x , y) ;
	}
	vp.push_back({0 , 0}) ;
	sort(vp.begin() , vp.end()) ;
	long long ans = 0ll ;
	for(int i = 1 ; i <= n ; ++i)
	{
		sum[i] += sum[i-1ll] ;
		if(sum[i] >= vp[i].second)
			continue ;
		long long pos = vp[i].first + d + d ;
		long long val = vp[i].second - sum[i] ;
		val = (val + a - 1ll) / a ;
		ans += val ;
		val = val * a ;
		sum[i] += val ;
		int l = i , r = n ;
		int cur = i ;
		while(l <= r)
		{
			int mid = (l + r) >> 1 ;
			if(vp[mid].first <= pos)
				cur = mid , l = mid+1 ;
			else
				r = mid-1 ;
		}
		sum[cur+1] -= val ;
	}
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 6512
#include<iostream>
#include<string>
#include <vector>
#include <algorithm> 
#include <list>

using namespace std;

int main(){
 int k,a,b;
 int d = 0;
 cin >>k>>a>>b;
 for(int i = a;i<=b;i++){
   if(i%k == 0){
     d = 1;
     break;
   }
 }
 if(d==0) cout<<"NG";
 else cout<<"OK";
}

Measured memory_bytes: 3132
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
lli gcd(lli a, lli b) {
	return b == 0 ? a : gcd(b, a % b);
}
void solve() {
	lli n;
	cin >> n;
	lli ret = 0;
	for (lli i = 1; i <= n; i++) {
		for (lli j = 1; j <= n; j++) {
			for (lli k = 1; k <= n; k++) {
				ret += gcd(i, gcd(j, k));
			}
		}
	}
	cout << ret << endl;
}
int main()
{
	zanj0();
	solve();
	return 0;
}

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

using namespace std;

int main()
{
    long long int t, i, j, k;
    cin >> t;
    long long int ans = 0;
    if (t >= 500)
    {
        long long int diff = (t / 500);
        t = t - diff * 500;
        ans += diff * 1000;
    }
    if(t>=5)
    {
        long long int diff = t / 5;
        ans += (diff * 5);
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    bool fi=true;
    long long n,x,mi,tr=0;
    scanf("%lld",&n);
    while(n--){
        scanf("%lld",&x);
        if(fi){
            mi=x;
            tr++;
            fi=false;
        }
        else{
            if(x<mi){
                mi=x;
                tr++;
            }
            else continue;
        }
    }
    printf("%lld",tr);
}


Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int A,B;
  scanf("%d%d",&A,&B);
  for(int i=1;i<=3;i++){
    if((A*B*i)%2==1){
      printf("Yes\n");
      break;
    }else{
      if(i==3){
        printf("No\n");
        break;
      }
    }
    
  }
  return 0;
}

Measured memory_bytes: 128
def factorize_factorial(n):
    # 階乗の素因数分解
    e = [0] * 101
    for k in range(2, n + 1):
        divisor = 2
        cnt = 0
        while k % divisor == 0:
            k //= divisor
            cnt += 1
        if cnt > 0:
            e[divisor] += cnt

        divisor = 3
        while k > 1:
            cnt = 0
            while k % divisor == 0:
                k //= divisor
                cnt += 1
            if cnt > 0:
                e[divisor] += cnt
            divisor += 2
    return e


def count(k, e):
    # 素因数分解テーブルからべき数k以上の要素数を求める
    return len(tuple(filter(lambda x: x >= k, e)))


def main():
    n = int(input())
    e = factorize_factorial(n)

    ans = 0
    ans += count(75 - 1, e)
    ans += count(25 - 1, e) * (count(3 - 1, e) - 1)
    ans += count(15 - 1, e) * (count(5 - 1, e) - 1)
    ans += count(5 - 1, e) * (count(5 - 1, e) - 1) * (count(3 - 1, e) - 2) // 2

    print(ans)


if __name__ == '__main__':
    main()


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

int main(void){
  	int M,N;
	cin >> M >> N;
	int result=0;
	
    int gusu=0,kisu=0;
    if( M != 0 ){
	    gusu = M * (M - 1)/ 2;
    }
  	if( N != 0 ){
	    kisu = N * (N - 1)/ 2;
    }
    result = gusu + kisu;
  	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256