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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
pair<ll, ll> normalize(ll A, ll B) {
  if (A == 0 && B == 0) return {0, 0};
  if (A == 0 && B != 0) { return {0, 1}; }
  if (A != 0 && B == 0) { return {1, 0}; }
  ll g = gcd(abs(A), abs(B));
  A /= g;
  B /= g;
  if (B < 0) { A *= -1; B *= -1; }
  return {A, B};
}

const ll MOD = 1000000007;
const int MAX_N = 212345;
ll two[MAX_N];

int main2() {
  int N = nextInt();

  map< pair<ll, ll>, ll > count;
  REP(i, N) {
    ll A = nextLong();
    ll B = nextLong();
    auto v = normalize(A, B);
    ++count[v];
  }

  ll ans = 1;

  for (auto item : count) {
    auto v1 = item.first;
    auto v2 = normalize(-v1.second, v1.first);

    if (count[v2] == 0) {
      ans *= two[item.second];
      ans %= MOD;
    } else if (v1 < v2) {
      ans *= (1 + two[count[v1]] - 1 + two[count[v2]] - 1 + MOD) % MOD;
      ans %= MOD;
    }
  }

  if (count[{0, 0}] > 0) {
    ans += count[{0, 0}];
    ans %= MOD;
  }

  ans = (ans - 1 + MOD) % MOD;

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

int main() {
  two[0] = 1;
  REP(i, MAX_N-1) two[i+1] = (two[i] * 2) % MOD;
#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 30184
#include<iostream>
#include<iomanip>

using namespace std;

int main()
{
	int H, W;

	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if ((i + j) % 2 == 0) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << "\n";
		}
		cout << "\n";
	}
}

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

#define fi first
#define se second

int M;
bool ng_flg;
typedef pair<int,char> pic;

long long inv(long long n) {
	if(!n) ng_flg = true;
	long long res = 1;
	for(int i = 0; i < 16; i++) {
		if((M-2) & (1 << i))
			res = (res * n) % M;
		n = (n*n) % M;
	}
	return res;
}

long long solve(string s) {
//	cout << s << endl;
	vector<pic> ops;
	vector<long long> nums;
	ops.push_back(pic(-1,'x'));
	for(int i = 0; i < s.size();) {
		if(s[i] == '(') {
			int pa = 1;
			int b = i++;
			while(pa) {
				if(s[i] == '(') pa++;
				if(s[i] == ')') pa--;
				i++;
			}
			nums.push_back(solve(string(s.begin()+b+1, s.begin() + i-1)));
		}
		else if('0' <= s[i] && s[i] <= '9') {
			long long tmp = 0;
			while('0' <= s[i] && s[i] <= '9') {
				tmp *= 10;
				tmp += s[i] - '0';
				i++;
			}
			nums.push_back(tmp);
		}
		else {
			long long p;
			switch(s[i]) {
				case '+' : p = 0; break;
				case '-' : p = 0; break;
				case '*' : p = 1; break;
				case '/' : p = 1; break;
				default  : p = -1;
			}
			ops.push_back(pic(p ,s[i]));
			i++;

			while(ops.size() > 1) {
				pic op0, op1;
				op0 = ops[ops.size()-1];
				op1 = ops[ops.size()-2];
				if(op1.fi < op0.fi) {
					break;
				}
				long long a, b, c;
				b = nums.back(); nums.pop_back();
				a = nums.back(); nums.pop_back();
				ops.pop_back(); ops.pop_back();
				ops.push_back(op0);
				switch(op1.se) {
					case '+' : c = (a + b + M) % M; break;
					case '-' : c = (a - b + M) % M; break;
					case '*' : c = (a * b + M) % M; break;
					case '/' : c = (a * inv(b) + M) % M; break;
					default  : c = 0;
				}
				nums.push_back(c);
			}
		}
	}

	while(ops.size() > 1) {
		pic op;
		op = ops.back(); ops.pop_back();
		long long a, b, c;
		b = nums.back(); nums.pop_back();
		a = nums.back(); nums.pop_back();
		switch(op.se) {
			case '+' : c = (a + b + M) % M; break;
			case '-' : c = (a - b + M) % M; break;
			case '*' : c = (a * b + M) % M; break;
			case '/' : c = (a * inv(b) + M) % M; break;
			default  : c = 0;
		}
		nums.push_back(c);
	}
	return nums.back();
}

int main() {
	while(cin >> M, M) {
		ng_flg = false;
		string in, exp = "";
		getline(cin, in);
		for(int i = 0; i < in.size(); i++) {
			if(in[i] != ':' && in[i] != ' ')
				exp += in[i];
		}
		long long res = solve(exp);
		if(ng_flg)
			cout << "NG" << endl;
		else
			cout << exp << " = " << res << " (mod " << M << ")" << endl;
	}
}

Measured memory_bytes: 1372
line = input()
a, b = line.split(" ")
a = int(a)
b = int(b)
flag = 0

# num_a = int(a / 0.08)

# if int(num_a * 0.1) == b:
#     print(num_a)
# else:
#     print("-1")

flag = 0
for i in range(1,1251):
    if int(i * 0.08) == a:
        if int(i * 0.1) == b:
            print(i)
            flag = 1
            break
if flag == 0:
    print("-1")

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

int main() {
  int n, l = 0;
  string s;
  cin >> n >> s;
  vector<int> w(n), e(n);

  for (int i = 1; i < n; i++) {
    if (s[i - 1] == 'W')
      w[i] = w[i - 1] + 1;
    else
      w[i] = w[i - 1];
  }

  for (int i = n - 2; i > -1; i--) {
    if (s[i + 1] == 'E')
      e[i] = e[i + 1] + 1;
    else
      e[i] = e[i + 1];
  }

  int c = 3000000;
  for (int i = 0; i < n; i++) {
    if (c > w[i] + e[i]) c = w[i] + e[i];
  }

  cout << c << endl;
}

Measured memory_bytes: 3076
def run():
    n = int(input())
    data = []
    for _ in range(n):
        data.append(list(map(int, input().split())))

    for d in data:
        _data = d[:]
        mx = max(_data)
        _data.remove(mx)
        if mx**2 == sum([x**2 for x in _data]):
            print('YES')
        else:
            print('NO')
        

if __name__ == '__main__':
    run()




Measured memory_bytes: 5760
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  int N,K,X,Y, res;
  cin >> N >> K >> X >> Y;

  if (N >= K+1){
    res = (X*K) + (N-K)*Y;
  }
  else{
    res = (X*N);
  }

  cout << res << endl;

  return 0;
}


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

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

		// 入力値の取得
		int N = sc.nextInt();
		int[] R = new int[N];
		for (int i = 0; i < N; i++) {
			R[i] = sc.nextInt();
		}
		
		// 消費する体力の総和の計算
		PriorityQueue<Integer> pq = new PriorityQueue<> ();
		for (int i = 1; i <= 100; i++) {
			int sum = 0;
			for (int j = 0; j < N; j++) {
				sum += Math.pow(R[j]-i, 2);
			}
			pq.add(sum);
		}
		
		// 結果の出力
		System.out.println(pq.poll());

		sc.close();
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <tuple>
#include <list>
#include <deque>
#include <stack>
#include <complex>
#include <functional>
#include <regex>
#include <map>

using namespace std;

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

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

using ll = long long;
using ld = long double;
using ull = unsigned long long;

const int PI = acos(-1);
const int INF = numeric_limits<int>::infinity() / 2;
const ll INFLL = numeric_limits<ll>::infinity() / 2;

int N;
char buf[3];
map<char, int> CNT;

ll count(const string& s, int pos, int cnt) {
  if (cnt == 3) {
    ll t = 1;
    rep(i, 3) t *= CNT[buf[i]];
    return t;
  }

  if (pos >= s.length())
    return 0;

  buf[cnt] = s[pos];
  ll ans = count(s, pos + 1, cnt + 1);
  ans += count(s, pos + 1, cnt);
  return ans;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  rep(i, N) {
    string s; cin >> s;
    CNT[s[0]]++;
  }
  cout << count("MARCH", 0, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
int n, l;
int main() {
  cin>>n>>l;
  vector<string> ss;
  for (int i = 0; i < n; ++i) {
  	string s;
    cin>>s;
    ss.push_back(s);
  }
  sort(ss.begin(), ss.end());
  string ans="";
  for (int i = 0; i < n; ++i) {
  	ans += ss[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
        "fmt"
)

func solution(a, b int, s string) string {
        if s[a] != '-' {
                return "No"
        }
        for i := 0; i < a+b+1; i++ {
                if i == a {
                        continue
                }
                n := s[i] - '0'
                if 0 > n || n > 9 {
                        return "No"
                }
        }
        return "Yes"
}

func main() {
        var a, b int
        var s string
        fmt.Scan(&a, &b, &s)
        fmt.Println(solution(a, b, s))
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;
bool isRate[8];

signed main() {
  int n;
  std::cin >> n;
  int overCnt = 0;
  REP(i, n) {
    int a = read();
    if (a >= 3200)
      overCnt++;
    else
      isRate[a / 400] = true;
  }
  int ans = 0;
  REP(i, 8)
  if (isRate[i])
    ans++;
  print(max(ans, (int)1), 2);
  print(ans + overCnt);
}


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

int main(){
  string S;
  cin>>S;
  if(S[0]!=S[1] &&S[1]!=S[2] &&S[2]!=S[0]){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
import java.awt.Point;
import java.util.Scanner;

public class Main {
    final double EPS = 1.0e-10;
    final int INF = 1 << 28;
    final double pi = Math.pow(Math.E, 1.1447298858494);

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Line[] ls = new Line[n];
        for (int i = 0; i < n; i++) {
            Point p1 = new Point(sc.nextInt(), sc.nextInt());
            Point p2 = new Point(sc.nextInt(), sc.nextInt());
            ls[i] = new Line(p1, p2);
        }
        if (n > 5100)
            System.out.printf("%.9f\n", 0.);
        else if (n > 2550) {
            System.out.printf("%.9f\n", 1.);
        } else {
            double min = Double.POSITIVE_INFINITY;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    min = Math.min(min, ls[i].minDistance(ls[j]));
                }
            }
            System.out.printf("%.9f\n", min);
        }

    }

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

class Line {
    public Point p1;
    public Point p2;

    Line(Point p1, Point p2) {
        this.p1 = p1;
        this.p2 = p2;
    }

    public double length() {
        return Math.sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y)
                * (p1.y - p2.y));
    }

    public double ip(Line l) {
        Point q1 = l.p1;
        Point q2 = l.p2;
        return (p2.x - p1.x) * (q2.x - q1.x) + (p2.y - p1.y) * (q2.y - q1.y);
    }

    public double ep(Line l) {
        Point q1 = l.p1;
        Point q2 = l.p2;
        return (p2.x - p1.x) * (q2.y - q1.y) - (p2.y - p1.y) * (q2.x - q1.x);
    }

    public double disToPoint(Point q1) {
        Line p1q1 = new Line(p1, q1);
        double ip1 = p1q1.ip(this);
        double ip2 = this.ip(this);
        if (ip1 <= 0)
            return p1q1.length();
        else if (0 < ip1 && ip1 < ip2) {
            double d2 = ip1 / this.length();
            double size = p1q1.length();
            return Math.sqrt(size * size - d2 * d2);
        } else {
            Line p2q1 = new Line(p2, q1);
            return p2q1.length();
        }
    }

    public boolean isCross(Line q1q2) {
        Point q1 = q1q2.p1;
        Point q2 = q1q2.p2;
        Line p1q1 = new Line(p1, q1);
        Line p1q2 = new Line(p1, q2);
        Line q1p1 = new Line(q1, p1);
        Line q1p2 = new Line(q1, p2);
        if (this.ep(p1q1) * this.ep(p1q2) < 0
                && q1q2.ep(q1p1) * q1q2.ep(q1p2) < 0)
            return true;
        else
            return false;
    }

    public double minDistance(Line q1q2) {
        if (this.isCross(q1q2))
            return 0;
        double ans = Double.MAX_VALUE;
        Point q1 = q1q2.p1;
        Point q2 = q1q2.p2;
        ans = Math.min(ans, this.disToPoint(q1));
        ans = Math.min(ans, this.disToPoint(q2));
        ans = Math.min(ans, q1q2.disToPoint(p1));
        ans = Math.min(ans, q1q2.disToPoint(p2));
        return ans;
    }

    public String toString() {
        return p1 + "=>" + p2;
    }
}

Measured memory_bytes: 17000
#include <iostream>

int getDevideTimes(int number);

int main(int argc, char const *argv[]) {

    int N;
    std::cin >> N;

    int max_devide_times = 0;
    int max_devide_times_number = 1;
    for(int i = 1 ; i <= N ; i++ )
    {
        int number = i;
        int devide_times = getDevideTimes(number);
        if(devide_times > max_devide_times)
        {
            max_devide_times = devide_times;
            max_devide_times_number = number;
        }
    }

    std::cout << max_devide_times_number << '\n';

    return 0;
}

int getDevideTimes(int number)
{
    int devide_times = 0;
    while(number % 2 == 0 && number != 0)
    {
        number /= 2;
        devide_times++;
    }
    return devide_times;
}


Measured memory_bytes: 256
// @samraj2k #2ksr 
//Not showoff, but solid.
//Not handsome, but likeable.
//Not intelligent, but hardworking.
//Not with good speaking skills, but great thoughts.
//This is me.
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define see(x) cout << (#x) << " is " << (x) << endl
#define see2(x,y) cout << (#x) <<" "<<(#y)<< " are " << (x) <<" "<<(y)<< endl
#define samraj2k ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

int main()
{  
  samraj2k;
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)  cin>>arr[i];
  int dp[n];
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
  }
  cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG 0
#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
 
lli abs2(lli a){
	if(a>=0)return a;
	else return -a;
}

lli calc(lli a,lli b){
	if(a%b==0)return b;
	return calc(b,a%b);
}
 
int main(){
	lli n,k;
	cin>>n>>k;

	lli cnt1=0,cnt2=0;
	lli ans1=0,ans2=0;

	//(a%k,b%k,c%k)=(0,0,0)となる個数は何個?
	for(lli i=1;i<=n;i++){
		if(i%k==0){
			cnt1++;
		}
	}
	ans1 = cnt1*cnt1*cnt1;

	//(a%k,b%k,c%k)=(k/2,k/2,k/2)となる個数は何個?
	if(k%2==0){
		for(lli i=1;i<=n;i++){
			if(i%k==k/2){
				cnt2++;
			}
		}
		ans2 = cnt2*cnt2*cnt2;
	}

	cout<<ans1+ans2<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
 
#define  ff         first
#define  ss         second
#define  pb         push_back
#define  all(x)     (x).begin(), (x).end()
#define  rep(i,a,b) for(int i=a ; i<b ; ++i)
#define  deb(x)     cout << #x << " - " << x << "\n";
#define  IOS        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  D2(x)      cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]\n"; 
#define  D2p(x)	    cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << "\n";
#define  ps(x,y)    fixed<<setprecision(y)<<x
 
#define PI 3.141592653589793238462643383279502884L
// const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 4e4 + 10;

 
int main() {
    IOS;
    ll MOD = 2019;
    string s; cin >> s;
    map<ll,ll>mp;
    ll suf = 0,pot = 1;
    mp[suf]++;
    ll ans = 0;
    for(ll i=s.size()-1;i>=0;--i){
        ll dig = s[i] - '0';
        suf = (suf + dig * pot) % MOD;
        pot = (10 * pot) % MOD;
        ans += mp[suf];
        mp[suf]++;
    }
    cout << ans;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N, X; cin >> N >> X;
    vector<i64> A(N);
    REP(i, N) cin >> A[i];

    i64 cnt = 0;
    REP(i, N - 1) {
        if (A[i] + A[i + 1] <= X) continue;
        i64 d = (A[i] + A[i + 1] - X);
        cnt += d;
        A[i + 1] -= d;
        chmax(A[i + 1], (i64)0);
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1024
n,k=map(int,input().split())
lr=[]
for i in range(k):
  l_,r_=map(int,input().split())
  lr.append([l_,r_])
mod=998244353


#dp[i]=0からi-1マスからiのマスへ行く総数
dp=[0]*(n+1)
sumdp=[0]*(n+1)
#初期条件：マス0に最初いるので１通り
dp[1]=1
sumdp[1]=1
#dp漸化式
for i in range(2,n+1):
  for l,r in lr:
    if i>l:
      if i<=r:
        dp[i]=(dp[i]+sumdp[i-l])%mod
      else:
        dp[i]=(dp[i]+sumdp[i-l]-sumdp[i-r-1])%mod
  sumdp[i]=(sumdp[i-1]+dp[i])%mod
  
  
print(dp[n]%mod)

    



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

int n;
string s;

int main() {
    cin >> n >> s;
    int left = 0, right = 0;
    int prefix = 0, suffix = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == '(') {
            left++;
        } else {
            right++;
        }
        if (left < right) {
            prefix++;
            left++;
        }
    }
    suffix = left - right;
    cout << string(prefix, '(') + s + string(suffix, ')');
}

Measured memory_bytes: 256
n = 1
x = 1
while n!=0 or x!=0:
	n,x = [int(i) for i in input().split()]
	if n!=0 or x!=0:
		list = [int(i) for i in range(1,n+1)]
		count = 0
		for i in range (1,n-1):
			for j in range(i+1,n):
				for k in range(j+1,n+1):
					if (i + j + k) == x:
						count += 1
		print(count)

Measured memory_bytes: 7628
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
signed main(){
  int n;
  while(cin>>n,n){
    int w,h;
    cin>>w>>h;
    int x[n],y[n];
    for(int i=0;i<n;i++) cin>>x[i]>>y[i];
    int s,t;
    cin>>s>>t;
    int ans=0;
    set<P> sp;
    for(int i=0;i<n;i++) sp.insert(P(x[i]-1,y[i]-1));
    for(int i=0;i+s<=w;i++){
      for(int j=0;j+t<=h;j++){
	int tmp=0;
	for(int k=0;k<s;k++)
	  for(int l=0;l<t;l++)
	    tmp+=sp.count(P(i+k,j+l));
	ans=max(ans,tmp);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3124
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

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

    vector<string> ans;
    int leng = s.length();

    for(int i=0;i<s.size();i++){
        for(int j=i;j<s.size() && j<i+5;j++){
            ans.push_back(s.substr(i, j-i+1));
        }
    }

    sort(ans.begin(), ans.end());
    ans.erase( unique(ans.begin(), ans.end()), ans.end() );

    cout << ans[k-1] << endl;
    return 0;
}

Measured memory_bytes: 1660
// https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_c
// https://atcoder.jp/contests/abc073/tasks/abc073_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

struct UnionFind {
    vector<int> par; // 親の番号
    UnionFind(int size) : par(size, -1) {}
    // xとyの木を併合
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (par[y] < par[x])
                swap(x, y);
            par[x] += par[y];
            par[y] = x;
            return true;
        } else {
            return false;
        }
    }
    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) { return root(x) == root(y); }
    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); }
    // 頂点 v が属するグループと同じグループに属する頂点数を得る
    int size(int x) { return -par[root(x)]; }
};
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, K, L;
    cin >> N >> M;
    UnionFind uf(N + M);
    REP(i, N) {
        cin >> K;
        REP(j, K) {
            cin >> L;
            uf.unite(L - 1, M + i);
        }
    }
    bool flag = true;
    REP(i, N - 1) {
        if (!uf.same(M + i, M + i + 1)) {
            flag = false;
            break;
        }
    }

    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main(){

        ios::sync_with_stdio(false);
        cin.tie(0);

	vector<int> arr(3);
	
	cin>>arr[1]>>arr[2]>>arr[0];

	for(int i=0;i<3;i++){
		cout<<arr[i];
		if(i!=2) cout<<" ";
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int main()
{
	int n,m=1;scanf("%d",&n);while(m<n)m<<=1;
	if(m==n){puts("No");return 0;}
	puts("Yes");
	printf("%d %d\n",1,n+2);printf("%d %d\n",n+2,3);
	printf("%d %d\n",3,n+1);printf("%d %d\n",n+1,2);
	printf("%d %d\n",2,n+3);
	for(int i=4;i<n;i+=2)
	{
		printf("%d %d\n",i,n+1);printf("%d %d\n",i,n+i+1);
		printf("%d %d\n",i+1,n+1);printf("%d %d\n",n+i,i+1);
	}
	if(!(n&1)){for(int i=2;i<n;++i)if((n^i^1)<n){printf("%d %d\n",n,i);printf("%d %d\n",n+n,n^i^1);break;}}
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, sum = 0; cin >> n;
    vi t(n);
    rep(i, n){ cin >> t[i]; sum += t[i]; }
    ll m; cin >> m;
    rep(i, m){
        ll p, x; cin >> p >> x; p--;
        cout << sum-t[p]+x << endl;
    }
}

Measured memory_bytes: 256
A,B = map(int,input().split())
import math
q = 0
for i in range(math.ceil(12.5*A),int(12.5*(A+1))):
    if 10*B <= i < 10*(B+1):
        q = i
        break
if q != 0:
    print(i)
else:
    print(-1)

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 100000000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P>> vec;
// vector<vector<int>> data(3, vector<int>(4));

vector<vector<ll>> dp(1LL << 18, vector<ll>(51, INF));

void solve(long long N, std::vector<long long> A, std::vector<long long> B) {
    dp[0][0] = 0;
    rep(i, 1LL << N) {
        ll b = __builtin_popcount(i);
        rep(j, 51) {
            ll c = 0;
            rep(k, N) {
                if (!((1LL << k) & i)) {
                    if (abs(k - b) % 2 == 0) {
                        if (j <= A[k]) {
                            dp[i | (1LL << k)][A[k]] = min(dp[i | (1LL << k)][A[k]], dp[i][j] + abs(k - c));
                            // if ((i | (1LL << k)) == 1 && dp[i | (1LL << k)][A[k]] < INF)
                            // cout << A[k] << " " << dp[i | (1LL << k)][A[k]] << endl;
                        }
                    } else {
                        if (j <= B[k]) {
                            dp[i | (1LL << k)][B[k]] = min(dp[i | (1LL << k)][B[k]], dp[i][j] + abs(k - c));
                            // if ((i | (1LL << k)) == 2 && dp[i | (1LL << k)][B[k]] < INF)
                            //     cout << B[k] << " " << dp[i | (1LL << k)][B[k]] << endl;
                        }
                    }

                } else {
                    c++;
                }
            }
        }
    }
    ll res = INF;
    rep(i, 51) {
        res = min(res, dp[(1LL << N) - 1][i]);
        // cout << i << " " << dp[(1LL << N) - 1][i] << endl;
    }
    if (res >= INF)
        cout << "-1" << endl;
    else
        cout << res << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    std::vector<long long> B(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 114944
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun power(x: Int, n: Int): Int = when {
    n == 0 -> 1
    n == 2 -> (x * x)
    n % 2 == 1 -> (power(x, n - 1) * x)
    else -> {
        val tmp = power(x, n / 2)
        tmp * tmp
    }
}

fun main() {
    val (h, w, k) = readIntList()
    val grid = Array(h + 2) { Array(w + 2) { ' ' } }
    for (i in 1..h) {
        val row = readLine()!!
        for (j in row.indices) {
            grid[i][j + 1] = row[j]
        }
    }

    var res = 0
    for (i in 0 until (power(2, h))) {
        for (j in 0 until (power(2, w))) {
//            println("$i $j start")
            var num = 0
            for (m in 1..h) {
                for (l in 1..w) {
//                    println("${i shr (m - 1) and 1 == 1} ${j shr (l - 1) and 1 == 1}")
                    when {
                        ((i shr (m - 1) and 1) == 1) || ((j shr (l - 1) and 1) == 1) -> {
                            // 赤
//                            println("$m, $l は赤")
                        }
                        else -> {
                            // 白か黒
                            if (grid[m][l] == '#') {
                                num += 1
                            }
//                            println("$m, $l は${grid[m][l]}")
                        }
                    }
                }
            }

            if (num == k) {
//                println("num : $num")
                res += 1
            }
        }
    }
    println(res)
}


Measured memory_bytes: 37336
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 a, b;
  cin >> a >> b;
  if (1 < a - b)
    cout << a * 2 - 1 << endl;
  else if (1 < b - a)
    cout << b * 2 - 1 << endl;
  else
    cout << a + b << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}

int min (int a, int b) {
  return a<b ? a:b;
}

int main(){
  int elaps=0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n+1;
  while (head != tail){
    u=dequeue();
    c=min(q,u.t);
    u.t -= c;
    elaps += c;
    if(u.t>0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  
  return 0;
}



Measured memory_bytes: 11888
from collections import Counter
n=int(input())
V=list(map(int,input().split()))

even=[(0,0)]+sorted(Counter(V[::2]).items(), key=lambda x:x[1])
odd=[(0,0)]+sorted(Counter(V[1::2]).items(), key=lambda x:x[1])

if even[-1][0]==odd[-1][0]:
    if even[-2][1]>odd[-2][1]:even=even[-2][0];odd=odd[-1][0]
    else:even=even[-1][0];odd=odd[-2][0]
else:even=even[-1][0];odd=odd[-1][0]

cnt=0
for i,j in enumerate(V):
    if i%2==0 and j!=even:cnt +=1
    elif i%2==1 and j!=odd:cnt +=1

print(cnt)

Measured memory_bytes: 20700
#include <iostream>

using namespace std;

bool isEasy(char arr[], int n);

int main()
{
  char S[100], tmp;
  int n = 0;
  
  while(cin >> tmp)
  {
      S[n] = tmp;
      ++n;
  }
  
  if(isEasy(S, n)) cout << "Yes";
  else cout << "No";
  
  return 0;
}

bool isEasy(char arr[], int n)
{
  for(int i = 0; i < n; ++i)
  {
      if(i % 2 == 0 && arr[i] == 'L') return 0;
      if(i % 2 != 0 && arr[i] == 'R') return 0;
  }
  return 1;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	int n = readln.chomp.to!int;
	long[] as = readln.chomp.split.map!(to!long).array;
	
	as.sort!("a < b")();
	
	int x = 0;
	long s = 0;
	for(int i = 0; i < n - 1; i ++){
		s += as[i];
		if(s * 2 < as[i + 1]){
			x = i + 1;
			}
		debug writeln(i, " ", s, " ", x);
		}
	
	(n - x).writeln;
	}

Measured memory_bytes: 4428
from collections import defaultdict

def unplanned_queries():
	n, m = map(int, raw_input().split(" "))
	a = []
	for i in range(m):
		a.append(map(int, raw_input().split(" ")))
	dic = defaultdict(int)
	for i in range(m):
		dic[a[i][0]] += 1
		dic[a[i][1]] += 1
	for key,value in dic.iteritems():
		if value%2!=0:
			print "NO"
			return
	print "YES"


if __name__ == "__main__":
	unplanned_queries()

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

#define REP(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) REP(i, 0, n)
#define ALL(v) begin(v), end(v)

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

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

	vector<int> a(n);
	for(auto &e : a) cin >> e;

	vector<int> cnt(n, 0);
	rep(i, m) {
		int b;
		cin >> b;

		rep(j, n) {
			if(a[j] <= b) {
				++cnt[j];
				break;
			}
		}
	}

	cout << max_element(ALL(cnt)) - cnt.begin() + 1 << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1204
from math import sqrt
n=int(input())
x=[]
y=[]
for _ in range(n):
  a,b=map(int,input().split())
  x.append(a)
  y.append(b)

dist=0

for i in range(n-1):
  for j in range(i+1,n):
    d=(x[i]-x[j])**2+(y[i]-y[j])**2
    dist+=sqrt(d)
print(dist*2/n)

Measured memory_bytes: 38256
require 'pp'
n = gets.to_i
s = {}
n.times do
  ss = gets.chomp
  s[ss].nil? ? s[ss] = 1 : s[ss] += 1
end

sss = s.sort_by{|x|x[1]}

a = sss[-1][1]
hoge = s.to_a.select{|x|x[1] == a}
puts hoge.map{|x|x[0]}.sort.join("\n")



Measured memory_bytes: 51728
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y ==0 :
        return y
    else:
        while x%y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z 

def lcm(m,n):
    return int(m*n/gcd(m,n))

m,n = input().split()
m = int(m)
n = int(n)

print(lcm(m,n))

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

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)

const int INF = 100000000;

using namespace std;


int main() {
	int s[3];
	rep(i, 0, 3)cin >> s[i];
	int minn = INF;
	rep(i, 0, 2) {
		rep(j, i+1, 3) {
			minn = min(minn, s[i] + s[j]);
		}
	}
	cout << minn << endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
bool second_greater(const pii& left, const pii& right) {
    return left.second > right.second;
}
#endif


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

    ll N;  cin >> N;

    ll h, n, w;
    bool found = false;
    for (ll i = 1; i < 3501; i++) {
        for (ll j = 1; j < 3501; j++) {            
            ll a = i * j * N;
            ll b = 4 * i*j - N * j - N * i;
            if (b > 0 && a%b == 0) {
                h = i; n = j; w = a / b;
                found = true;
                break;
            }
        }
        if (found) break;
    }

    cout << h << " " << n << " " << w << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=305;
const int mo=1000000007;
int n,S1,S2;
int a[N*2],used[N*2];
int f[2][N][N];
int main(){
	scanf("%d",&n); S2=n;
	For(i,1,2*n) scanf("%d",&a[i]);
	For(i,1,n){
		if (a[i*2]==-1)	swap(a[i*2],a[i*2-1]);
		if (a[i*2-1]!=-1) used[a[i*2]]=used[a[i*2-1]]=1,--S2;
		else if (a[i*2]!=-1) used[a[i*2]]=-1;
		else ++S1;
	}
	f[0][0][0]=1;
	For(i,1,n*2) if (used[i]!=1){
		For(j,0,S2) For(k,0,S2) f[1][j][k]=0;
		if (!used[i]){
			For(j,0,S2) For(k,0,S2){
				f[1][j+1][k]=(f[1][j+1][k]+f[0][j][k])%mo;
				f[1][j][k+1]=(f[1][j][k+1]+f[0][j][k])%mo;
				if (k) f[1][j][k-1]=(f[1][j][k-1]+f[0][j][k])%mo;
			}
		}
		else{
			For(j,0,S2) For(k,0,S2){
				f[1][j][k+1]=(f[1][j][k+1]+f[0][j][k])%mo;
				if (j) f[1][j-1][k]=(f[1][j-1][k]+1ll*j*f[0][j][k])%mo;
			}
		}
		For(j,0,S2) For(k,0,S2)
			f[0][j][k]=f[1][j][k];
	}
	int ans=f[0][0][0];
	For(i,1,S1) ans=1ll*ans*i%mo;
	printf("%d",ans);
}

Measured memory_bytes: 1024
import sys
n = int(input())
INF = 10*n
dp = [INF]*(n+1)
dp[0] = 0
for i in range(1, n+1):
    tmp = dp[i-1] + 1
    for j in range(10):
        if i-6**j<0:
            break
        tmp = min(tmp, dp[i-6**j] + 1)
    for j in range(10):
        if i-9**j<0:
            break
        tmp = min(tmp, dp[i-9**j] + 1)
    dp[i] = tmp
print(dp[n])

Measured memory_bytes: 42732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 2147483647;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);
const ll LLMAX = 9223372036854775805;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    map<ll,ll> m;
    ll ans = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        m[a[i]]++;
        ans += a[i];
    }
    int q;
    cin >> q;
    vector<ll> b(q),c(q);
    for(int i=0;i<q;i++){
        cin >> b[i] >> c[i];
    }
    for(int i=0;i<q;i++){
        ll x = m[b[i]];
        m[b[i]] = 0;
        m[c[i]] += x;
        ans = ans - x*b[i] + x*c[i];
        cout << ans << endl;
    }
}

Measured memory_bytes: 11372
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> 
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

int main(){
    int N,A,B;cin>>N>>A>>B;
    if(N==1){
        cout<<"Hello World"<<endl;
        return 0;
    }else{
        cout<<A+B<<endl;
        return 0;
    }
}

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

int main() {
	int n, d;
	cin >> n >> d;
	int x[20][20];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j)continue;
			int dist = 0;
			for (int k = 0; k < d; k++) {
				int l = x[i][k] - x[j][k];
				dist += l * l;
			}
			for (int s = 0; s <= dist; s++) {
				if (s * s == dist) res++;
			}
		}
	}
	cout << res / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10, inf = 1e9 ;
int tr[N<<1][2],a[N],book[N];
int n,ans=0,M;

void build(int n) {
	memset(tr,38,sizeof(tr));
	for(M=1;M<=n+1;M<<=1);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),book[a[i]]=i,tr[M+i][i&1]=a[i];
	for(int i=M-1;i>=1;i--)
		for(int k=0;k<2;k++)
			tr[i][k]=min(tr[i<<1][k],tr[i<<1|1][k]);
}


struct Node {
	int l,r,st,L,R;
	bool operator < (const Node &rhs) const {
		return a[L]>a[rhs.L];
	}
};

priority_queue<Node> q;

int Q(int s,int t,int st,int ans=inf) {
	for(s=s+M-1,t=t+M+1;s^t^1;s>>=1,t>>=1) {
		if(~s&1) ans=min(ans,tr[s^1][st]);
		if(t&1) ans=min(ans,tr[t^1][st]);
	}
	return ans;
}

inline void A(int l,int r,int st) {
	if(l>r) return ;
	int s=book[Q(l,r,st)],t=book[Q(s,r,st^1)];
	tr[s+M][st]=inf,tr[t+M][st^1]=inf;
	q.push((Node){l,r,st,s,t});
}

main() {
	cin>>n;
	build(n);
	A(1,n,1);
	while(!q.empty()) {
		Node u=q.top();
		q.pop();
		printf("%d %d ",a[u.L],a[u.R]);
		A(u.l,u.L-1,u.st);A(u.R+1,u.r,u.st);A(u.L+1,u.R-1,u.st^1);
	}
}

Measured memory_bytes: 8948
// Youtube解説AC
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
// const ll INF = 1000000000000000000LL;

const int A = 1000005;

 ll gcd(ll a,ll b){
     if(a<b) swap(a,b);
     bool have_mod =true;
     while(have_mod){
         ll mod = a % b;
         if(mod == 0 ) have_mod = false;
         a = b;
         b = mod;
     }
     return a;
 }

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> c(A);
  rep(i,n) {
    cin >> a[i];
    c[a[i]]++;
  }
 
  bool pairwise = true;
  for (int i = 2; i < A; i++) {
    int cnt = 0;
    for (int j = i; j < A; j += i) {
      cnt += c[j];
    }
    if (cnt > 1) pairwise = false;
  }
 
  if (pairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
 
  int g = 0;
  rep(i,n) g = gcd(g,a[i]);
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }
 
  cout << "not coprime" << endl;
  return 0;
}

Measured memory_bytes: 11156
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (int32_t i = 0; i <= 25; i++)
		for (int32_t j = 0; j <= 25; j++)
	{
			if (4 * i + 7 * j == N) {
				out << "Yes" << endl;
				return 0;
		}
	}
	out << "No" << endl;

	return 0;
}
#endif


Measured memory_bytes: 256
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()

    res = []
    for i in range(1, n + 1):
        for j in range(1 + i, n + 1):
            if i + j == n + (n % 2 == 0):
                continue
            res.append((i, j))

    print(len(res))
    for r in res:
        print(*r)


main()


Measured memory_bytes: 3996
//解説AC
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int n;
    ll sum=0;
    cin>>n;
    vi a(n);
    rep(i,n){
        cin>>a[i];
        sum^=a[i];
    }
    rep(i,n){
        cout<<(sum^a[i])<<" ";
    }
    cout<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 3960
#include<iostream>
#include<deque>

using namespace std;

int main()
{
	deque<int> vec;

	int q;
	cin >> q;

	int comand1, comand2, comand3;
	for (int i = 1; i <= q; i++) {
		cin >> comand1 >> comand2;

		switch (comand1)
		{
		case 0:
			cin >> comand3;

			if (comand2 == 0) {
				vec.push_front(comand3);
			}
			else {
				vec.push_back(comand3);
			}

			break;
		case 1:
			cout << vec[comand2] << endl;
			break;
		case 2:
			if (comand2 == 0) {
				vec.pop_front();
			}
			else {
				vec.pop_back();
			}

			break;
		}
	}

	return 0;
}


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

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

  bool ans = false;
  for (int i = 0; i < s.size(); i ++) {
    if (s == t) {
      ans = true;
      break;
    }
    s = s.back() + s.substr(0, s.size() - 1);
  }

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main( void )
{
    int a = 0;
    int b = 0;
    int Sum = 0;
    int i = 0;
 
    while( scanf( "%d %d", &a, &b ) != EOF )
    {
 
        Sum = a + b;
 
        for( i = 0 ; Sum != 0 ; i ++ ) Sum /= 10;
 
        printf( "%d\n", i );
    }
 
    return 0;
}

Measured memory_bytes: 0
l,r = map(int,input().split())

ls = []

for i in range(l,r+1):
    ls.append(int(int(i)%2019))

    if len(ls)==1050:
        break
ls = sorted(ls)

ans = ls[0]*ls[1]

for i in range(len(ls)-1):
    for j in range(i+1,len(ls)):
        ans = min(ans,(ls[i]*ls[j])%(2019))

print(ans)

Measured memory_bytes: 39664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  int n,b[110],idx[110],ans[110];
  bool vis[110]={},f;
  cin>>n;
  Fr(i,n){cin>>b[i];idx[i]=i;}
  iFr(i,n){
    iFr(j,n){
      f=1;
      if(!vis[j]&&b[j]==idx[j]){
        ans[i]=b[j];
        for(int k=j+1;k<=n;k++) idx[k]--;
        vis[j]=1;f=0;
        break;
      }
    }
    if(f){
      cout<<-1<<endl;
      return 0;
    }
  }
  Fr(i,n) cout<<ans[i]<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * @Author oreid
 * @Release 04/12/2016
 */
public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        long a = scanner.nextLong();
        long b =  scanner.nextLong();
        long x =  scanner.nextLong();
        long cnt = 0;
        scanner.close();


        cnt = numDivs(a ,b ,x);


        System.out.print(cnt);

    }

    public static long numDivs(long a, long b, long x) {
        long fDiv = a%x == 0 ? a : a + (x - a%x);
        long lDiv = b%x == 0 ? b : b - b%x;
        return (lDiv - fDiv)/x + 1;
    }
}


Measured memory_bytes: 9812