akhauriyash/Code-Regression huggingface dataset:
/*  ????????????S=0  ?????????H=1  ?????????C=2  ?????????D=3  */

#include <stdio.h>

int main(void)
{
	int n, i, j, rank, card[4][14] = {0};
	char mark;
	
	scanf("%d",&n);
	for(i=0; i<n; i++) {
		scanf(" %c %d",&mark,&rank);
		switch(mark) {
		case 'S':
			card[0][rank] = 1;
			break;
		case 'H':
			card[1][rank] = 1;
			break;
		case 'C':
			card[2][rank] = 1;
			break;
		case 'D':
			card[3][rank] = 1;
			break;
		}
	}
	for (j=0; j<4; j++) {
		for (rank=1; rank<=13; rank++) {
			if(card[j][rank] == 0) {
				switch(j) {
					case 0:
						printf("S %d\n",rank);
						break;
					case 1:
						printf("H %d\n",rank);
						break;
					case 2:
						printf("C %d\n",rank);
						break;
					case 3:
						printf("D %d\n",rank);
						break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>

int main()
{
	int count;
	std::cin >> count;
	int max = 0;
	long sum = 0;
	for (int i = 0; i < count; i++) {
		int tall;
		std::cin >> tall;
		sum += std::max(max - tall, 0);
		max = std::max(tall, max);
	}
	std::cout << sum << std::endl;
	return 0;
}

Measured memory_bytes: 3592
// B - Toll Gates
// https://atcoder.jp/contests/abc094/tasks/abc094_b
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli b, c, h, k, n, m, x, w, ans = 0, count = 0, xd = 0, xa = 0, count2 = 0;
  string s, t;
  cin >> n >> m >> x;
  vi a(m);
  rep(i, 0, m)
  {
    cin >> a[i];
  }
  rep(i, 0, m)
  {
    b = i;
    if (a[i] < x)
    {
      xd++;
    }
    else
    {
      xa++;
    }
  }
  // cout << xd << "  " << xa << endl;
  rep(i, 0, m)
  {
    if (xd <= xa)
    {
      rep(j, 1, n)
      {
        if (a[i] == j && a[i] < x)
          count++;
      }
    }
    else
    {
      rep(j, 1, n)
      {
        if (a[i] == j && a[i] > x)
          count2++;
      }
    }
  }
  cout << max(count, count2) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		while(true){
			input=sc.nextLine().split(" ");
			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);
			if(H==0 && W==0){
				break;
			}
			for(int in1=0;in1<H;in1++){
				for(int in2 =0; in2<W; in2++){
					if(in1==0 || in1==H-1 || in2==0 || in2==W-1){
						System.out.print("#");
						if(in2==W-1){
							System.out.println();
						}
					}else{
						System.out.print(".");
					}
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 33904
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
vector<char> ans(0, 0);

void apply(ll *a, ll *b, char c){
  (*a)++;
  (*b)--;
  ans.push_back(c);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N;
  cin>>N;
  map<char, ll> M;
  cin >> M['A'] >> M['B'] >> M['C'];
  vector<string> S(N, "");
  rep(i, N) cin >> S[i];
  rep(i, N){
    char c1, c2, n1, n2;
    c1 = S[i][0];
    c2 = S[i][1];
    if (i < N-1){
      n1 = S[i+1][0];
      n2 = S[i+1][1];
    }
    if (M[c1] == 0 && M[c2] == 0){
      cout << "No" << endl;
      return 0;
    }
    if (M[c1] == M[c2] && i < N-1){
      if (c1 == n1 || c1 == n2)
        apply(&M[c1], &M[c2], c1);
      else
        apply(&M[c2], &M[c1], c2);
    }
    else if (M[c1] > M[c2])
      apply(&M[c2], &M[c1], c2);
    else
      apply(&M[c1], &M[c2], c1);      
  }
  cout << "Yes" << endl;
  rep(i, N) cout<< ans[i] << endl;
}


Measured memory_bytes: 6632
<?php
$inputs = explode(' ', trim(fgets(STDIN)));
$N = $inputs[0];
$A = $inputs[1];
$B = $inputs[2];
$X = explode(' ', trim(fgets(STDIN)));
$ans = 0;
for($i = 0; $i < $N - 1; $i++){
	$move = abs($X[$i] - $X[$i + 1]);
	if($B < $move * $A) $ans += $B;
	else $ans += ($move * $A);
}
echo $ans;
?>

Measured memory_bytes: 21932
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

int n, x;
int a[120000];

int main() {
	scanf("%d%d", &n, &x);
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d", a + i);
		if (a[i] > x)
			ans += a[i] - x, a[i] = x;
	}
	for (int i = 0; i < n - 1; ++i) {
		ll ov = a[i + 1] + a[i] - x;
		if (ov > 0) {
			ans += ov;
			a[i + 1] -= ov;
		}
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

struct UnionFind {
    vector<int> par;
    vector<int> rnk;

    UnionFind(int n) {
        par.assign(n, 0);
        rnk.assign(n, 1);
        for(int i=0; i<n; i++) {
            par[i] = i;
        }
    }

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

    int find(int x) {
        if(par[x] == x) return x;
        return par[x] = find(par[x]);
    }

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

    int size(int x) {
        return rnk[find(x)];
    }
};

signed main() {
    int N, M, K;
    cin >> N >> M >> K;
    UnionFind fr(100050);
    vi res(N+1, 0);
    rep(i, M) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        fr.unite(A, B);
        res[A]--; res[B]--;
    }

    
    rep(i, N) {
        res[i] += fr.size(i)-1;
    }

    rep(i, K) {
        int C, D;
        cin >> C >> D;
        C--; D--;
        if(fr.same(C, D)) {
            res[C]--; res[D]--;
        }
    }

    rep(i, N) {
        cout << res[i] << " ";
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int main(){
  int n; cin >> n;
  string s; cin >> s;
  int cnt_l = 0, cnt_r = 0;

  string ans = s;
  rep(i, n){
    if(s[i] == '('){
      cnt_l++;
      while (cnt_r > 0) {
        ans.insert(0, "(");
        cnt_r--;
      }
    }
    else{
      if(cnt_l > 0) cnt_l--;
      else cnt_r++;
    }
  }
  while (cnt_r > 0) {
    ans.insert(0, "(");
    cnt_r--;
  }

  while (cnt_l > 0) {
    ans.pb(')');
    cnt_l--;
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


#define PI 3.1415926535897

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

	string s, t;
	vector<int> c1(26, 0), c2(26, 0);
	cin >> s >> t;
	for (auto ch : s) c1[ch - 'a']++;
	for (auto ch : t) c2[ch - 'a']++;
	sort(c1.begin(), c1.end());
	sort(c2.begin(), c2.end());

	if (c1 == c2) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 916
#include<stdio.h>
int main(){
  int a,b,i,j;
  char ki[101][101]={0};
  while(1){
    scanf("%d %d",&a,&b);
    if(a == 0 && b == 0) break;
    for(i=0;i<a;i++){
      scanf("%s",ki[i]);
    }
    i=j=0;
    for(;;){
      if(ki[i][j] == '>'){
	ki[i][j] = 1;
	j++;
      }
      else if(ki[i][j] == '<'){
	ki[i][j] = 1;
	j--;
      }
      else if(ki[i][j] == '^'){
	ki[i][j] = 1;
	i--;
      }
      else if(ki[i][j] == 'v'){
	ki[i][j] = 1;
	i++;
      }
      if(ki[i][j] == '.'){
	printf("%d %d\n",j,i);
	break;
      }
      if(ki[i][j] == 1){
	printf("LOOP\n");
	break;
      }
    }
  }
  return 0;
}

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

const int N = 330000;

int a[N];

vector<int> dp[N];

void insert(vector<int> &lhs, const vector<int> &rhs) {
	for (int x : rhs) lhs.push_back(x);
	sort(lhs.begin(), lhs.end());
	reverse(lhs.begin(), lhs.end());
	lhs.resize(2);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n; int m = 1 << n;
	for (int i = 0; i < m; i++) cin >> a[i];
	for (int i = 0; i < m; i++) dp[i].push_back(a[i]);
	for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (j & (1 << i)) insert(dp[j], dp[j ^ (1 << i)]);
	int ans = 0;
	for (int i = 1; i < m; i++) {
		ans = max(ans, dp[i][0] + dp[i][1]);
		cout << ans << "\n";
	}
	return 0;
}



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

using namespace std;
#define pii pair<int,int>
#define ll long long 

const int N = 2e5+10;
int vis[N],prm[N],cnt;
void get(){
	int n = 2e5;
	for(int i=2;i<=n;++i){
		if(vis[i]==0)
			prm[cnt++] = i;
		for(int j=0;j<cnt;++j){
			if(i*prm[j]>n)
				break;
			vis[i*prm[j]] = 1;
			if(i%prm[j] == 0)
				break;
		}
	}
}

int main(){
	get();
	int x;
	cin >> x;
	for(int i=0;i<cnt;++i){
		if(prm[i]>=x){
			cout << prm[i];
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535;

int h[100000];
int a[100000];
int b[100000];

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

    vector<vector<int>> to(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    int ans = 0;
    rep(i, n) {
        bool is_good = true;
        int height = h[i];
        rep(j, to[i].size()) {
            if (h[to[i].at(j)] >= height) {
                is_good = false;
                break;
            }
        }
        if (is_good) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8728
#include <cstdio>
#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 <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back

int pos(char c){
  c-='0';
  if(c%3==0)return 3;
  if(c%3==2)return 2;
  return 1;
}

main(){
  string str;
  while(cin>>str){
    if(str=="#")break;
    int ans=1000000;
    int r,l,c;
    r=0,l=0,c=0;//c==1 r ,2 l
    int tans=0;
    rep(i,str.size()){
      //cout<<l<<" "<<r<<" "<<tans<<endl;
      int n=pos(str[i]);
      if(c==0){
	r=n;
	c=1;
	continue;
      }
      if(c==1){
	if(n<=r){
	  l=n;
	  c=2;
	}else{
	  r=n;
	  c=1;
	  ++tans;
	}
      }else{
	if(l<=n){
	  r=n;
	  c=1;
	}else{
	  l=n;
	  c=2;
	  ++tans;
	}
      }
    }
    //cout<<l<<" "<<r<<" "<<tans<<endl;
    //cout<<endl;
    ans=min(ans,tans);

    r=0,l=0,c=0,tans=0;
    rep(i,str.size()){
      //cout<<l<<" "<<r<<" "<<tans<<endl;
      int n=pos(str[i]);
      if(c==0){
	l=n;
	c=2;
	continue;
      }
      if(c==1){
	if(n<=r){
	  l=n;
	  c=2;
	}else{
	  r=n;
	  c=1;
	  ++tans;
	}
      }else{
	if(l<=n){
	  r=n;
	  c=1;
	}else{
	  l=n;
	  c=2;
	  ++tans;
	}
      }
    }
    //cout<<l<<" "<<r<<" "<<tans<<endl;
    ans=min(tans,ans);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1140
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList< ArrayList<int[]>> people = new ArrayList<ArrayList<int[]>>();

        for(int i = 0; i < N; i++){
            int A = sc.nextInt();
            ArrayList<int[]> say = new ArrayList<int[]>();
            for(int j = 0; j < A; j++){
                say.add(new int[]{sc.nextInt() - 1, sc.nextInt()});
            }
            people.add(say);
        }

        boolean[] honest = new boolean[N];
        int max = Integer.MIN_VALUE;

        for (int i = 0; i < (Math.pow(2 ,N)); i++) {
            Arrays.fill(honest, false);
            int count = 0;

            for (int j = 0; j < N; j++) {
                if ((1 & i >> j) == 1){
                    honest[j] = true;
                    count++;
                }
            }

            boolean flag = true;
            for(int j = 0; j < N; j++){
                if(honest[j]){
                    for(int k = 0; k < people.get(j).size(); k++){
                        if(people.get(j).get(k)[1] == 1 && !honest[ people.get(j).get(k)[0] ])
                            flag = false;
                        if(people.get(j).get(k)[1] == 0 && honest[ people.get(j).get(k)[0] ])
                            flag = false;
                    }
                }
            }
            if(flag)max = Math.max(max, count);
        }
        System.out.println(max);
    }
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vvi g(n+1);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vi dist(n+1, -1);
  queue<int> que;
  vi ans(n+1);
  dist[1] = 0;
  que.push(1);
  while(!que.empty()){
    int v = que.front();
    que.pop();
    for(auto nv : g[v]){
      if(dist[nv] != -1) continue;
      dist[nv] = dist[v] + 1;
      que.push(nv);
      ans[nv] = v;
    }
  }
  cout << "Yes" << endl;
  for(int i=2; i<=n; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 10592
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }

void solve()
{
	ll a,b;
	cin>>a>>b;
	cout<<(a+b)%24;
	
	return;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

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

int main()
{
	int i,j,n,m,a,b,e[501][501],c[501],student;
	queue<int> Q;
	
	while(1)
	{
	   scanf("%d",&n);
	   scanf("%d",&m);
	   if(n==0) break;
	   for(i=0;i<=n;i++)
	   {
	      for(j=0;j<=n;j++)
		  {
		     e[i][j]=0;
		  }
		  c[i]=0;
	   }
	   for(i=0;i<=m-1;i++)
	   {
	      scanf("%d%d",&a,&b);
		  e[a][b]=e[b][a]=1;
	   }
	   c[1]=1;
	   student=0;
	   for(i=2;i<=n;i++)
	   {
	   	   if(e[1][i]==1)
		   {
		   	   student++;
			   Q.push(i);
			   c[i]=1;
		   }
	   }
	   while(Q.empty()!=1)
	   {
	   	   j=Q.front();
		   Q.pop();
		   for(i=2;i<=n;i++)
		   {
		      if(e[j][i]==1 && c[i]==0)
			  {
			  	  student++;
				  c[i]=1;
			  }
		   }
	   }
	   printf("%d\n",student);
	}
	return 0;
}

Measured memory_bytes: 4128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  long long a,b;
  cin >> a >> b;
  if(a%2==1){
    rep(i,b){
      long long y=i+1;
      cout << y << " " << a-i << endl; 
    }
  }
  else{
    long long y;
    if(a%4==0)y=a/2;
    else y=a/2-1;
    rep(i,min(b,a/4)){
      cout << i+1 << " " << y-i << endl;
    }
    if(b-a/4<=0)return 0;
    else{
      long long t=(b-a/4)*2;
      rep(i,b-a/4){
        cout << y+i+1 << " " << y-i+1+t << endl;
      }
    }
  }
}


Measured memory_bytes: 3644
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);

int main(){
  int N;
  cin >> N;
  int X[N], Y[N];
  rep(i, N){
    int a;
    cin >> a;
    X[i] = a; Y[i] = a;
  }
  sort(Y, Y+N);
  int med = Y[(N+1)/2];
  rep(i, N){
    if(X[i]<med) cout << med << endl;
    else cout << Y[(N-1)/2] << endl;
  }
      
  
}

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

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("b.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int N, D;
    cin >> N >> D;

    int X[10][10];

    rep(i, N)
    {
        rep(j, D)
        {
            cin >> X[i][j];
        }
    }

    int cnt = 0;

    rep(i, N)
    {
        for (int j = i+1; j < N; j++)
        {
            int dis = 0;
            rep(k, D)
            {
                dis += std::pow(X[j][k] - X[i][k], 2);
            }
            //cout << i << " " << j << " " << dis << endl;
            rep(m, dis+1)
            {
                if (dis == m*m)
                {
                    cnt++;
                }
            }
        }
    }

    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
import std.array, std.stdio, std.conv, std.string, std.math, std.random, std.range,std.functional;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.comparison;


void main()
{
    int[] input = readln().split.to!(int[]);
    int N = input[0];
    int K = input[1];
    auto wList = iota(N).map!(a=>readln().strip.to!int).array();

    int maxWight = wList.reduce!"a>b?a:b";
    writeln(search(maxWight, maxWight*N, K, wList));
}
int search(int min, int max, int k, int[] list)
{
    if(max-min==1)
    {
        if(fun(min, k, list))
        {
            return min;
        }else{
            return max;
        }
    }

    int p = min+(max-min)/2;
    if(fun(p, k, list))
    {
        return search(min, p, k, list);
    }else{
        return search(p, max, k, list);
    }
}
bool fun(int p, int k, int[] list)
{
    int ck=1;
    int cp;
    foreach(e; list)
    {
        if(cp + e <= p)
        {
            cp += e;
        }else if(ck < k){
            ck++;
            cp = e;
        }else{
            return false;
        }
    }
    return true;
}

sizediff_t minIndex(alias pred="a<b", R) (R list)
    if(isForwardRange!R && !isInfinite!R && is(typeof(binaryFun!pred(list.front, list.front))))
{
    assert(!list.empty);
    typeof(list.front) min = list.front;
    sizediff_t minPos;
    sizediff_t curPos;
    for(list.popFront(); !list.empty; list.popFront())
    {
        curPos++;

        if(binaryFun!pred(list.front, min))
        {
            min = list.front;
            minPos = curPos;
        }
    }
    return minPos;
}



Measured memory_bytes: 3728
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>

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

#define INF 1000000000

using namespace std;

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

    REP(i, N) {
        string str;
        cin >> str;

        if (str == "Y") {
            cout << "Four" << endl;
            return 0;
        }
    }

    cout << "Three" << endl;

    return 0;
}


Measured memory_bytes: 256
// 1000000000000001でz11文字 -> i文字目はたかだか26種類（たかだかじゃねぇよ）
// -> で、全探索は無理なので数式でやる
// 世の中にABCの三文字しかないときに長さ3文字を作ろうとしたときにできる文字列を小さい順に並べたとき（早い話がABCから3つ取るpermutation）、全部で27通りであり、
// 左から数えて「1文字目がAなるのは前半の1/3(1~9)」「Bは次の1/3(10~18)」「Cは最後の1/3（19~27）」
// 2文字目がAなるのはそれぞれ「前半1/3の中の前半1/3」「次の1/3の前半1/3」「最後の1/3の前半1/3」となる
// これをなんか愚直に範囲を狭めてやろうとしたら無限にバグったのでポンコツ
// これを数式でやるのがポイント
// 26で割ったあまりをどんどこしていく感じ
// ゆうてなんかよくわからんかったのですげぇ雑にアドホックにやった

package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	alphabets := []string{"z", "a"}
	for len(alphabets) < 26 {
		t := alphabets[len(alphabets)-1]
		ts := string(t[0] + 1)
		alphabets = append(alphabets, ts)
	}
	x := N
	ans := []string{}
	for x > 0 {
		ans = append(ans, alphabets[x%26])
		x--
		x /= 26
	}
	for i := len(ans) - 1; i >= 0; i-- {
		fmt.Printf("%s", ans[i])
	}
	fmt.Println()
}


Measured memory_bytes: 1844
#include <stdio.h>

long long int fuctorial(long long int n);

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

	printf("%lld\n", fuctorial(n));

	return 0;
}

long long int fuctorial(long long int n){
	if(n == 1) return 1;
	else return (fuctorial(n-1) * n);
}

Measured memory_bytes: 0
def main():
  def dfs(x):
    m=x//2
    if m not in dp or dp[m]>dp[x]+abs(2*m-x)*d+a:
      dp[m]=dp[x]+abs(2*m-x)*d+a
      dfs(m)
    m=0--x//2
    if m not in dp or dp[m]>dp[x]+abs(2*m-x)*d+a:
      dp[m]=dp[x]+abs(2*m-x)*d+a
      dfs(m)
    m=x//3
    if m not in dp or dp[m]>dp[x]+abs(3*m-x)*d+b:
      dp[m]=dp[x]+abs(3*m-x)*d+b
      dfs(m)
    m=0--x//3
    if m not in dp or dp[m]>dp[x]+abs(3*m-x)*d+b:
      dp[m]=dp[x]+abs(3*m-x)*d+b
      dfs(m)
    m=x//5
    if m not in dp or dp[m]>dp[x]+abs(5*m-x)*d+c:
      dp[m]=dp[x]+abs(5*m-x)*d+c
      dfs(m)
    m=0--x//5
    if m not in dp or dp[m]>dp[x]+abs(5*m-x)*d+c:
      dp[m]=dp[x]+abs(5*m-x)*d+c
      dfs(m)
  def solve():
    dp[n]=0
    dfs(n)
    return min(dp[i]+abs(i)*d for i in dp)
  for _ in range(int(input())):
    n,a,b,c,d=map(int,input().split())
    dp={}
    print(solve())
if __name__ == "__main__":
  main()


Measured memory_bytes: 103428
import java.util.*;
 
class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int K = sc.nextInt();
 
    for (;A>=B && K>0; K--){
      B += B;
    }
    
    for (;B>=C && K>0; K--){
      C += C;
    }
    
    if(A<B && B<C)
      System.out.println("Yes");
    else
      System.out.println("No");
    
    sc.close();
  }
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int n = Integer.parseInt(line);
        String result="";
        if(n < 1000) {
            result="ABC";
        } else {
            result = "ABD";
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 21076
#include<iostream>
#define debug(x) std::cout<<x<<std::endl;
#define fori(i,a,z) for(i=a;i<=z;i++)
int main(){
  int i=0,N=0,T=0,c[1001],t[1001];
  std::cin>>N>>T;
  int fmax = N;
  for(i=1;i<=fmax;i++){
    std::cin>>c[i]>>t[i];
    if(t[i]>T){
      i--;
      fmax--;
    }
  }
  if(i==1){
    debug("TLE");
      return 0;
  }
  int cmin = c[1];
  fori(i,1,fmax){
    if(c[i]<cmin) cmin=c[i];
  }
  
  debug(cmin);

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  int maxi=0,mini=10e9,baf;
  for(int i=0;i<n;i++){
    cin >> baf;
    mini=min(mini,baf);
    maxi=max(maxi,baf);
  }
  cout << maxi-mini << endl;
  return 0;
}

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

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)

#ifdef _DEBUG
ifstream ifs("input.txt");
#define input ifs
#else
#define input cin
#endif
#define DEBUG(x) cout<<#x<<": "<<x<<endl

int N, K, ans = 0;
int A[100010];
vector<int> G[100010];

int dfs(int v){
    int res = 0;
    for(int p : G[v]) res = max(res, dfs(p));
    if(v == 1) return 0;
    if(res == K-1){
        if(A[v] != 1) ans++;
        return 0;
    }
    return res+1;
}

int main(){
    input >> N >> K;
    int dist;
    REP(i,1,N+1){
        input >> A[i];
        if(i == 1 && A[i] != 1) ans++;
        if(i != 1) G[A[i]].push_back(i);
    }
    dfs(1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10752
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int solve(string s) {
	int ans = 0, n = s.size();
	for (int i = 1; i < n; i++) {
		if (s[i - 1] == s[i]) {
			ans++;
			s[i] = s[i] == '0' ? '1' : '0';
		}
	}

	return ans;
}

int reverseSolve(string s) {
	int ans = 0, n = s.size();

	for (int i = n - 1; i > 0; i--) {
		if (s[i - 1] == s[i]) {
			ans++;
			s[i - 1] = s[i - 1] == '0' ? '1' : '0';
		}
	}

	return ans;
}

// 10
// 01

// 00
// 11

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

	string s;
	cin >> s;

	int scoreA = solve(s);
	int scoreB = reverseSolve(s);
	int ans = min(scoreA, scoreB);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
import math


def main():
    N, K = map(int, input().split())
    print((max(0, N - K + 1) + sum(
        max(0, N - (math.ceil(K * 0.5 ** i)) + 1) * 0.5 ** i
        - max(0, N - (math.ceil(K * 0.5 ** (i - 1))) + 1) * 0.5 ** i
        for i in range(1, int(math.log2(K)) + 1 + 1))) / N)
    return


main()


Measured memory_bytes: 3188
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

//Criba de Eratostenes
vector<bool> marcaje(200, true); 
vector<int> primes;

void sieve() { //Ejecutar al principio del programa
	marcaje[0] = marcaje[1] = 0;
	for (int i = 2; i < marcaje.size(); i++)
		if (marcaje[i]) {
			for (int j = i*i; j < marcaje.size(); j += i) 
				marcaje[j] = 0;
			primes.push_back(i);
		}
}

vector<int> primeFactors(int N) { 
	vector<int> factors; 
	int PF_idx = 0, PF = primes[PF_idx];
	while (PF_idx < primes.size() && PF*PF <= N) {
		while (N % PF == 0) {
			N /= PF;factors.push_back(PF);
		}PF = primes[++PF_idx];
	}
	if (N != 1) factors.push_back(N); 
	return factors; 
}

bool res() {
	int m,d;
	cin >> m >> d;
	if (!cin) return false;

	ll sol = 0;

	for (int i = 1; i <= m; ++i) {
		vi facts = primeFactors(i);

		//KNAP
		set<int> s, sig;
		for (int j = 0; j < facts.size(); ++j) {
			s.insert(1);
			for (auto it = s.begin(); it != s.end(); ++it) {
				sig.insert(*it * facts[j]);
			}
			s = sig;
		}

		s.erase(i);

		for (auto it = s.begin(); it != s.end(); ++it) {
			if (*it > 9 || *it < 2) continue;
			if (i / *it > 9) continue;
			int dact = *it * 10 + (i / *it);
			if (dact <= d) {
				//cout << i << ' ' << dact << '\n';
				++sol;
			}
		}
	}

	cout << sol << '\n';

	return true;
}

int main() {
	sieve();
	while (res()) {}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

def rot(S, N):
  S = S.lower()
  enc = ""
  for char in list(S):
    ASCII = ord(char)
    num = ASCII - 97
    num = (num + N) % 26
    ASCII = num + 97
    enc += chr(ASCII)
  enc = enc.upper()
  return enc

print(rot(S, N))


Measured memory_bytes: 41324
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int long long i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll m[100001];

int main(){
    ll n;
    cin>>n;
    rep(i,100001){m[i]=0;}
    
    rep(i,n){
        ll x;
        cin>>x;
        m[x]++;
    }
    
    ll ans=0;
    
    for(int i=0;i<100001;i++){
        if(m[i]>=1){
            ans+=(m[i]-1);
        }
    }
    
    if(ans%2){
        ans++;
    }
    if(n-ans>=1){
    cout<<n-ans<<endl;
    }
    
    
return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    scanf("%d", &i);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    scanf("%lld", &i);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////

int main()
{
    string S, T;
    io >> S >> T;
    int ans = 0;
    for (size_t i = 0; i < S.size(); i++)
    {
        if (S[i] != T[i]) ++ans;
    }
    io << ans << BR;
}

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

using namespace std;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << b * (c/a) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
    }
    
    vector<pair<int, int>> ab(M);
    for(int i = 0; i < M; i++){
        ab[i] = make_pair(a[i], b[i]);
    }
    sort(ab.begin(), ab.end());
    
    int cnt1 = upper_bound(ab.begin(), ab.end(), make_pair(1, N))
                - lower_bound(ab.begin(), ab.end(), make_pair(1, 2));
    for(int i = 0; i < cnt1; i++){
        int cnt2 = upper_bound(ab.begin(), ab.end(), make_pair(ab[i].second, N))
                    - lower_bound(ab.begin(), ab.end(), make_pair(ab[i].second, N));
        if(cnt2){
            cout << "POSSIBLE\n";
            return 0;
        }
    }
    
    cout << "IMPOSSIBLE\n";
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int N,K;
    cin>>N>>K;
    string str;
    cin>>str;
    int total=0;
    for(int i=0;i<N-1;i++){
        if(str[i]==str[i+1])
            total++;
    }
    cout<<min(N-1,total+(2*K));
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include<algorithm>
#include<string>
using namespace std;

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

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;


}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
using namespace std;

struct Data{
	int cost,p;
	Data(){}
	Data(int _cost,int _p){
		cost=_cost; p=_p;
	}
	bool operator<(const Data &a)const{
		return cost>a.cost;
	}
};

struct Way{
	int to,cost;
	Way(){}
	Way(int _to,int _cost){
		to=_to; cost=_cost;
	}
};

int main(){
	int N,K,Type,A,B,E;
	while(cin>>N>>K,N||K){
		vector<Way> way[100];
		for(int i=0;i<K;i++){
			cin>>Type;
			if(Type==1){
				cin>>A>>B>>E; A--; B--;
				way[A].push_back(Way(B,E)); way[B].push_back(Way(A,E));
			}
			else{
				cin>>A>>B; A--; B--;
				priority_queue<Data> q; q.push(Data(0,A));
				Data q_c;
				bool memo[100]={};
				int ans=-1;
				while(!q.empty()){
					q_c = q.top(); q.pop();
					if(memo[q_c.p]) continue;
					memo[q_c.p] = true;
					if(q_c.p==B){
						ans = q_c.cost;
					}
					for(int i=0;i<way[q_c.p].size();i++){
						q.push(Data(q_c.cost+way[q_c.p][i].cost,way[q_c.p][i].to));
					}
				}
				printf("%d\n",ans);
			}
		}
	}
    return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int homework[5] = {0} ; //{ day , Japanese , Math , maxJapanesePage , maxMathPage }
    int freeday = 0 ;
    for ( int i = 0 ; i < 5 ; i++ )
    {
        cin >> homework[i] ;
    }
    freeday = homework[0] - max( ceil( (double)homework[1]/homework[3] ) , ceil( (double)homework[2]/homework[4] ) ) ;
    cout << freeday << endl ;

    return 0 ;
}

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

int main() {
  long long N,W;
  cin >> N >> W;
  vector<vector<long long>> V(N,vector<long long>(2,0));
  for (long long i = 0; i < N; i++)
    cin >> V.at(i).at(0) >> V.at(i).at(1);
  
  long long count = 0;
  vector<vector<long long>> D(N + 1,vector<long long>(W + 1,0));
  for (long long j = 1; j < N + 1; j++) {
    for (long long k = 1; k < W + 1; k++) {
      if (k - V.at(j - 1).at(0) >= 0)
        D.at(j).at(k) = max(D.at(j - 1).at(k),D.at(j - 1).at(k - V.at(j - 1).at(0)) + V.at(j - 1).at(1));
      else
        D.at(j).at(k) = D.at(j - 1).at(k);
      count = max(D.at(j).at(k),count);
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 82984
X, K, D = map(int, input().split())

new_X = abs(X) % D
new_K = K - abs(X) // D

if new_K <= 0:
    answer = abs(X) - K*D
else:
    if new_K % 2 == 0:
        answer = new_X
    else:
        answer = abs(new_X - D)
        
print(answer)


Measured memory_bytes: 9140
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
typedef long long ll;

int main() {
	string s, t; cin >> s >> t;
	int ans = 10000;
	for (int i = 0; i <= (int)s.size() - (int)t.size(); i++) {
		int cnt = 0;
		string l = s.substr(i, (int)t.size());
		for (int j = 0; j < (int)t.size(); j++) {
			if (l.at(j) != t.at(j)) cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, q;
ll a[100010];

int main() {
    cin >> n >> q;
    rep(i, n) cin >> a[i];
    rep(i, q) {
        ll x; cin >> x;
        int r = 0;
        ll cnt = 0;
        ll sum = 0;
        for (int l = 0; l < n; l++) {
            while (r < n && sum + a[r] <= x) {
                sum += a[r];
                r++;
            }
            cnt += r - l;
            if (r == l) r++;
            else sum -= a[l];
        }
        cout << cnt << endl;
    }
}



Measured memory_bytes: 3896
let n, a, b, c = Scanf.scanf " %d %s %s %s" @@ fun a b c d -> a, b, c, d
let ans = ref 0
let _ = String.iteri (fun i x -> ans := !ans + List.(length @@ sort_uniq compare [x; b.[i]; c.[i]]) - 1) a; Printf.printf "%d\n" !ans

Measured memory_bytes: 384
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}

	int D;
	std::cin >> D;

	std::cout << "Christmas";
	for (int i = 25; i > D; --i) {
		std::cout << " Eve";
	}
	std::cout << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

ll n;

bool poss( ll x ){
	if( x == 1 ) return false;
	ll s = x;
	while( n%s == 0 ){
		s *= x;
	}
	s /= x;
	return (n/s)%x == 1;
}

int main(){
	cin >> n;
	ll ans = 0;
	ll t = n-1;
	for( ll i = 1; i*i <= t; ++i ){
		if( t%i == 0 ){
			if( i*i == t ) ans += 1;
			else ans += 2;
		}
	}
	// 約数の 1 のぶん
	ans -= 1;
	for( ll k = 2; k*k <= n; ++k ){
		if( n%k == 0 ){
			if( poss(k) ) ++ans;
		}
	}
	// 約数の n のぶん
	ans += 1;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define V 10000
#define eb emplace_back
#define ef emplace_front
vector<int> adl[V];
vector<int> rev[V];
deque<int> s;
bool vis[V];
int col[V], v, e;

void dfs(int v) {
	if (vis[v]) return;
	vis[v] = true;
	for (int ng: adl[v]) 
		dfs(ng);
	s.ef(v);
}

void color(int v, int c) {
	if (col[v] != -1) return;
	col[v] = c;
	for (int ng: rev[v])
		color(ng, c);
}

int scc() {
	for (int i = 0; i < v; i++)
		dfs(i);
	for (int v: s)
		color(v, v);
}

int main() {
	scanf("%d%d", &v, &e);
	memset(col, -1, sizeof col);
	for (int i = 0; i < e; i++) {
		int p, q; scanf("%d%d", &p, &q);
		adl[p].eb(q); rev[q].eb(p);
	}

	scc();
	int nQ; scanf("%d", &nQ);
	while (nQ--) {
		int p, q; scanf("%d%d", &p, &q);
		printf("%d\n", col[p] == col[q]);
	}
}


Measured memory_bytes: 4932
import java.util.Scanner;
class Main{

	public void solve(){
    Scanner sc=new Scanner(System.in);
		
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		
		if(a < b){
			if(b < c){
				System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		}else{
		    System.out.println("No");
		}
	}


	
	public static void main(String[] args){
        Main obj =new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17316
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
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();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    string S;
    cin >> S;
    int L=S.length();
    int num=0;
    for(int i=0;i<L-1;++i){
        if(S[i]!=S[i+1]){
            ++num;
        }
    }
    cout << num;
    }

Measured memory_bytes: 512
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let mut s = read::<String>();
    let p = read::<String>();
    let t = s.clone();

    s.push_str(&t);
    yn(s.contains(&p));
}



Measured memory_bytes: 5032
#include<bits/stdc++.h>
using namespace std;
int n,m,a[100005],ans,maxn;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=2;i<=n;i++){
		if(a[i]<=a[i-1]){
			maxn++;
		}else{
			ans=max(ans,maxn);
			maxn=0;
		}
	}
	ans=max(ans,maxn);
	cout<<ans;
}

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

int main()
{
    int n,l;
    cin>>n>>l;///n>=2

    if(1<=1-l&&1-l<=n)
        cout<<n*(l-1)+n*(n+1)/2;

    else if(l>0)
        cout<<n*(l-1)+n*(n+1)/2-l;

    else if(n+l<1)
        cout<<n*(l-1)+n*(n+1)/2-(n+l-1);

    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000007
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;


int main()
{
int x,y,z;
cin>>x>>y>>z;

cout<<(x-z)/(y+z)<<endl;

 return 0;
}


Measured memory_bytes: 3524