akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long

using namespace std;
int mod = 1e9+7;
int fac[200005];
int ifac[200005];

int power(int x,int y)
{
    if(y==0)
        return 1;
    int tmp = power(x,y/2);
    if(y&1)
        return ((tmp*tmp)%mod * x)%mod;
    else
        return (tmp*tmp)%mod;
}

int C(int k,int n)
{
    int ans = fac[n];
    ans *= ifac[k];
    ans %= mod;
    ans *= ifac[n-k];
    ans %= mod;

    return ans;
}

signed main()
{
    int h,w,a,b;
    cin>>h>>w>>a>>b;

    fac[0] = 1;
    for(int i=1;i<=200000;i++)
        fac[i] = (fac[i-1] * i) % mod;

    //cout<<fac[7];
    //cout<<power(3,7);

    ifac[200000] = power(fac[200000],mod-2);
    for(int i = 200000 - 1;i>=0;i--)
        ifac[i] = (ifac[i+1] * (i+1)) % mod;


    int ans = 0;
    for(int i=b+1;i<=w;i++)
    {
        ans += (C(i-1,i+h-a-2) * C(a-1,w+a-i-1))%mod;
        ans %= mod;
    }

    cout<<ans;

}


Measured memory_bytes: 3328
import java.util.Scanner;
 
public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    String str = scanner.next();
	int[] number = new int[str.length()];
    int n = 0;
    
    for(int i = 0; i < str.length(); i++){
      number[i] = Integer.parseInt(""+str.charAt(i));
      n += number[i];
    }
    
    if((Integer.parseInt(str) % n) == 0){
     System.out.println("Yes"); 
    }
    else{
     System.out.println("No");
    }
    scanner.close();
  }
}

Measured memory_bytes: 22608
s = gets
k = gets.to_i

n = 0
while s[n] == "1"
  n += 1
end

#nは1が何文字続くか
if n == 0
  puts s[0]
else
  one = "1"
  other = s[n]
  if k <= n
    puts "1"
  else
    puts other
  end
end

Measured memory_bytes: 1788
import java.util.Scanner;

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

		while(sc.hasNext()) {
			int inputNum1 = sc.nextInt();
			int inputNum2 = sc.nextInt();

			if(inputNum1 < inputNum2) {
				System.out.println(inputNum1+" "+inputNum2);
			}
			else if(inputNum1 > inputNum2) {
				System.out.println(inputNum2+" "+inputNum1);
			}
			else if(inputNum1 == inputNum2 && !(inputNum1 == 0 && inputNum2 == 0)) {
				System.out.println(inputNum1+" "+inputNum2);
			}
			else if(inputNum1 == 0 && inputNum2 == 0) {
				break;
			}
		 }

	}
}

Measured memory_bytes: 35924
#include <stdio.h>
#include <string.h>
#include <iostream>

using namespace std;

bool m[111][111];
bool k[111][111];

int h,w;
int all;

int xs[11111];
int ys[11111];

int main()
{
	all = 0;
	scanf("%d %d",&w,&h);
	h += 2;
	w += 2;
	for(int i = 0; i < h; i++)
	{
		for(int ii = 0; ii < w; ii++)
		{
			m[i][ii] = false;
			k[i][ii] = false;
		}
	}
	for(int i = 1; i < h - 1; i++) 
	{
		for(int ii = 1; ii < w - 1; ii++)
		{
			int q;
			scanf("%d",&q);
			if(q == 1)
			{
				m[i][ii] = true;
			}
		}
	}
	xs[0] = 0;
	ys[0] = 0;
	int sn = 1;
	k[0][0] = true;
	while(sn > 0)
	{
		int x = xs[sn - 1];
		int y = ys[sn - 1];
		sn--;
		int nx[6];
		int ny[6];
		nx[0] = x - 1;
		ny[0] = y;
		nx[1] = x + 1;
		ny[1] = y;
		nx[2] = x;
		ny[2] = y - 1;
		nx[3] = x;
		ny[3] = y + 1;
		if(y % 2 == 0)
		{
			nx[4] = x - 1;
			ny[4] = y - 1;
			nx[5] = x - 1;
			ny[5] = y + 1;
		}
		else
		{
			nx[4] = x + 1;
			ny[4] = y - 1;
			nx[5] = x + 1;
			ny[5] = y + 1;
		}
		for(int i = 0; i < 6; i++)
		{
			if(nx[i] >= 0 && ny[i] >= 0 && nx[i] < w && ny[i] < h)
			{
				if(m[ny[i]][nx[i]])
				{
					all++;
				}
				else
				{
					if(!k[ny[i]][nx[i]])
					{
						xs[sn] = nx[i];
						ys[sn] = ny[i];
						k[ny[i]][nx[i]] = true;
						sn++;
					}
				}
			}
		}
	}
	printf("%d\n",all);
	return 0;
}

Measured memory_bytes: 1236
// I can't tell you what it really is,
// I can only tell you what it feels like.
#include "bits/stdc++.h"
using namespace std;
#define int long long
const int N = 4e5 + 2;

string str;
int n, k;
vector<int> vv;

map<vector<int>, int> dp[1000][2];

int go(int id, bool f, vector<int> &vv) {
	{
		int ans = 0;
		for (auto it: vv) ans += it;
		if (ans > k) return 0;
	}
	if (id == n) {
		int ans = 0;
		for (auto it: vv) ans += it;
		// cout << ans << '\n';
		return ans == k;
	}
	if (dp[id][f].count(vv)) return dp[id][f][vv];
	int ans = 0;
	for (int i = 0; i < 10; ++i) {
		if (f == false && str[id]-'0' < i) break;
		if (i) vv[i]++;			
		ans += go(id+1, f|(i<(str[id]-'0')), vv);
		if (i) vv[i]--;
	}
	return dp[id][f][vv] = ans;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> str >> k;
	n = str.size();
	vector<int> ok(10);
  cout << go(0,0,ok);
  return 0;
}
// 1). Try forming/rearranging the equations if any
// 2). If problem asks to count, try counting in reverse(it can be easier sometimes)

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int R, C;
string s[202];

int dp[2][1<<16];

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> R >> C;
  rep(i, R) cin >> s[i];

  memset(dp, -1, sizeof(dp));

  int *cur = dp[0], *next = dp[1];
  cur[0] = 0;
  rep(i, R) rep(j, C) {
    rep(bit, 1<<16) next[bit] = -1;
    rep(bit, 1<<C) {
      if(cur[bit] == -1) continue;
      //rep(bit, C) cout<<(int)(bit&(1<<C));
      //cout<<endl;

      int idx = __builtin_popcountll(bit&((1<<j)-1));
      //cout<<idx<<" "<<j<<" "<<C<<endl;

      if(idx+C-j > (int)s[i].size()) { // empty
	chmax(next[bit&~(1<<j)], cur[bit]);
      }

      if(idx < (int)s[i].size()) { // char
	//cout<<s[i]<<endl;
	int same = 0;
	if(j > 0 && ((bit>>(j-1))&1)) { // left
	  if(idx > 0 && s[i][idx] == s[i][idx-1]) same += 2;
	}

	if(i > 0 && ((bit>>j)&1)) { // above
	  int sz = s[i-1].size();
	  int above = __builtin_popcountll(bit>>j);
	  //cout<<sz<<" "<<above<<endl;
	  //cout<<s[i-1]<<endl;
	  if(sz >= above && s[i][idx] == s[i-1][sz-above]) same += 2;
	}

	//cout<<same<<endl;
	chmax(next[bit|1<<j], cur[bit]+same);
      }
    }
    swap(cur, next);
  }

  int ans = 0;
  rep(bit, 1<<C) chmax(ans, cur[bit]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4232
a,b,c,d,e,f = map(int,input().split())
waters,sugars = [],[]
ans_w = 0
ans_s = 0
ans_d = 0

for i in range(0,f//100+1):
    for j in range(0,f//100+1):
        w = 100*a*i + 100*b*j
        if w < f:
            waters.append(w)

for i in range(0,f+1):
    for j in range(0,f+1):
        s = c*i + d*j
        if s < f:
            sugars.append(s)

for w in waters:
    for s in sugars:
        if (w+s) <= f:
            s_e = w/100 * e
            if s_e < s or w+s == 0:
                continue
            if (100*s/(w+s)) > ans_d:
                ans_w = w
                ans_s = s
                ans_d = 100*s/(w+s)

if ans_w == ans_s == ans_d == 0:
    print('%d 0' % (a*100))
else:
    print('%d %d' % (ans_w+ans_s,ans_s))


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long x, n;
    cin >> x >> n;
    if (n == 0) {
        cout << x << '\n';
        return 0;
    }
    vector<long long> p(n);
    map<long long, int> score;
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    for (int i = 0; i < n; ++i) {
        score[p[i]] = 1;
    }
    if (score[x] == 0) {
        cout << x << '\n';
        return 0;
    }
    long long num = 1;
    while (1) {
        if (score[x - num] == 0) {
            long long ans = x - num;
            cout << ans << '\n';
            return 0;
        }
        if (score[x + num] == 0) {
            long long ans = x + num;
            cout << ans << '\n';
            return 0;
        }
        ++num;
    }
    return 0;
}

Measured memory_bytes: 3652
n = int(input())
data = [tuple(map(int, input().split())) for _ in range(n)] #(t,x,y)
flag = True
for i in range(n):
    dt,dx,dy = [data[i][k]-(0 if i==0 else data[i-1][k]) for k in range(3)]
    if not(dx+dy<=dt and (dt-dx-dy)%2==0):
        flag = False
        break
print('Yes' if flag else 'No')

Measured memory_bytes: 17324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PI acos(-1.0)
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

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

  return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int ans = 0;
		for(int i = 0; i < 3; i++) {
			int local = 0;
			if(s.charAt(i) == 'R') {
				int j = i;
				local = 0;
				while(j < 3 && s.charAt(j) == 'R') {
					j++;
					local++;
				}
				i = j;
			}
			ans = Math.max(ans, local);
		}
		System.out.println(ans);
	}
}


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

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	if (abs(a - c) <= d)cout << "Yes" << endl;
	else if (abs(a - b) <= d && abs(b - c) <= d) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

ll dp[MAX_N][2];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,z,w;
    cin >> n >> z >> w;
    vl a(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n+1){
        rep(j,2){
            dp[i][j] = (1LL << 60);
        }
    }
    dp[n][0] = dp[n][1] = abs(a[n-1]-a[n-2]);
    for(int i=n;i>=1;i--){
        if(i == 1){
            dp[i][0] = abs(w-a[n-1]);
        }else{
            dp[i][0] = dp[i][1] = abs(a[i-2]-a[n-1]);
        }
        srep(j,i+1,n+1){
            cmx(dp[i][0],dp[j][1]);
            cmn(dp[i][1],dp[j][0]);
        }
    }
    cout << dp[1][0] << "\n";
    return 0;
}


Measured memory_bytes: 256
// aribon2-3-3_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int dp[394];

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    vector<P> sl(N);
    vector<int> p(N);
    REP(i, N) cin >> sl[i].first >> sl[i].second >> p[i];

    int M;
    cin >> M;
    vector<int> Ws(M);
    REP(i, M) cin >> Ws[i];

    REP(j, 394) dp[j] = -1;
    dp[0] = 0;
    REP(i, N){
        int s = sl[i].first;
        int l = sl[i].second;
        REP(j, 394){
            if (dp[j] == -1) continue;
            REPN(k, s, l+1){
                if (j + k > 393) continue;
                dp[j+k] = max(dp[j+k], dp[j] + p[i]);
            }
        }
    }

    REP(i, M){
        if (dp[Ws[i]] == -1) {
            print(-1);
            return 0;
        }
    }

    REP(i, M) {
        print(dp[Ws[i]]);
    }

    return 0;
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
#include <vector>
#include <set>
#include <queue>
using namespace std;
int main()
{
	string a,b,c;
	cin>>a>>b>>c;
	queue<int> a2,b2,c2;
	for (int i=0;i<a.size();i++){
		a2.push(a[i]);
	}
	for (int i=0;i<b.size();i++){
		b2.push(b[i]);
	}
	for (int i=0;i<c.size();i++){
		c2.push(c[i]);
	}
	char card=a2.front();
	a2.pop();
	while (true){
		if (card=='a' && a2.size()==0){
			cout<<"A";
			return 0;
		}
		else if (card=='b' && b2.size()==0){
			cout<<"B";
			return 0;
		}
		else if (card=='c' && c2.size()==0){
			cout<<"C";
			return 0;
		}
		if (card=='a'){
			card=a2.front();
			a2.pop();
		}
		else if (card=='b'){
			card=b2.front();
			b2.pop();
		}
		else {
			card=c2.front();
			c2.pop();
		}
		}}

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

int main(void){
    int N;
    cin>>N;
    vector<int> T(N);
    int sum=0;
    for (int i=0;i<N;i++){
        cin>>T[i];
        sum+=T[i];
    }

    int M;
    cin>>M;
    vector<int> P(M),X(M);
    for (int i=0;i<M;i++){
        cin>>P[i]>>X[i];
    }
    for (int i=0;i<M;i++){
        int ans=sum;
        ans+=X[i]-T[P[i]-1];
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    INT(m);
    OUT(48-m);
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define max(a,b) (a)>(b) ? (a):(b);
int n;
int a[100][100];
int psum[100][100][100];
int getpsum(int uly,int ulx,int lry,int lrx){
	psum[ulx][lry][lrx]=0;
	int i,j;

	for(i=uly;i<=lry;i++)
		for(j=ulx;j<=lrx;j++)
			psum[ulx][lry][lrx]+=a[i][j];
	return psum[ulx][lry][lrx];
}
int getpsumu(int uly,int ulx,int lry,int lrx){
	int i;

	for(i=ulx;i<=lrx;i++)
		psum[ulx][lry][lrx]-=a[uly-1][i];

	return psum[ulx][lry][lrx];
}
int getpsuml(int uly,int ulx,int lry,int lrx){
	int i;
	psum[ulx][lry][lrx]=psum[ulx-1][lry][lrx];

	for(i=uly;i<=lry;i++)
		psum[ulx][lry][lrx]-=a[i][ulx-1];

	return psum[ulx][lry][lrx];
}
main(){
	int i,j,k,l;
	int  maxsum=-100000000LL;
	int tmp;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			scanf("%d",&a[i][j]);
	/*
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			for(k=i;k<n;k++)
				for(l=j;l<n;l++)
					maxsum=max(maxsum,getpsum(i,j,k,l));
	*/
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			for(k=i;k<n;k++)
				for(l=j;l<n;l++){
					if(i==0){
						if(j==0){
							tmp=getpsum(i,j,k,l);
							maxsum=max(maxsum,tmp);
						}else{
							tmp=getpsuml(i,j,k,l);
							maxsum=max(maxsum,tmp);
						}
					}else{
						tmp=getpsumu(i,j,k,l);
						maxsum=max(maxsum,tmp);
					}
				}

	printf("%d\n",maxsum);
	return 0;
}

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

using Vi = vector<int>;
using Vs = vector<string>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef pair<int, int> P;
typedef long long ll;

const int INF = 10000000, MAX_N = 100, MAX_M = 1000, MAX_W = 10000;

int compare_char(const void* left, const void* right) {

    const char* left_char = *(const char**)left;
    const char* right_char = *(const char**)right;

    return strcmp(left_char, right_char);
}


int main() {
    int H,A;
    cin >> H >> A;
    if (H % A == 0)
        cout << H / A << endl;
    else
        cout << H / A + 1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int p,q,i,j,k,count;
    char ar[100000],br[100000];
    scanf("%s\n%s",ar,br);
    p=strlen(ar);
    q=strlen(br);
    if(p==q)
    {
        for(i=0;i<q;i++)
        {
            count=0;
            for(j=i,k=0;j<p;j++,k++)
            {
                if(ar[j]==br[k]) count++;
            }
            if(count==q)
            {
                printf("Yes\n");
                return 0;
            }
            else
            {
                p++;
                ar[j]=ar[i];
            }
        }
    }
    printf("No\n");
    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  cout << N*(N-1)/2 + M*(M-1)/2 << endl;
}


Measured memory_bytes: 256
import sys
import random
import time
import numpy as np
import bisect

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def prob(e1,e2,T):
    if e2 < e1:
        return 1
    else:
        return np.exp((e1-e2)/T)

def solve():
    m = 26
    start = time.time()
    dT = 0.995
    T = 200
    D = ni()
    c = nl()
    s = [nl() for _ in range(D)]
    H = [None]*D
    for i in range(D):
        g = [s[i][j] - 20 * c[j] for j in range(m)]
        y = min(g)
        h = sum(g) - m * y
        g = [(x-y)/h for x in g]
        for j in range(1, m):
            g[j] += g[j-1]
        H[i] = g

    def calc(sche, m=26):
        last = [-1] * m
        ans = 0
        for i in range(D):
            t = sche[i]
            ans += s[i][t]
            last[t] = i
            for j in range(m):
                ans -= c[j] * (i - last[j])
        return ans

    def change(d, q, sc):
        b = sche[d]
        fq, bq = -1, D
        fb, bb = -1, D
        for i in range(d):
            if sche[i] == q:
                fq = i
            if sche[i] == b:
                fb = i
        for i in range(D-1, d, -1):
            if sche[i] == q:
                bq = i
            if sche[i] == b:
                bb = i
        sc += ((bb - d) * (bb - d - 1) // 2 + (d - fb) * (d - fb - 1) // 2) * c[b]
        sc += ((bq - fq) * (bq - fq - 1) // 2) * c[q]
        sc -= s[d][b]
        sc -= ((bq - d) * (bq - d - 1) // 2 + (d - fq) * (d - fq - 1) // 2) * c[q]
        sc -= ((bb - fb) * (bb - fb - 1) // 2) * c[b]
        sc += s[d][q]
        return sc

    sche = [0] * D
    for i in range(D):
        sche[i] = s[i].index(max(s[i]))
    sc = calc(sche)
    bestst = sche[:]
    best = sc

    while time.time() - start < 1.75:
        for _ in range(200):
            d = random.randint(0, D-1)
            q = bisect.bisect(H[d], random.random())
            nsc = change(d, q, sc)
            if best < nsc:
                bestst = sche[:]
                best = nsc
            if random.random() < prob(-sc, -nsc, T):
                sche[d] = q
                sc = nsc
        T *= dT
    prn([1 + x for x in bestst])

    return

solve()


Measured memory_bytes: 27904
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        n: usize,
        a: u32,
        b: u32,
    }

    let mut ret = 0;
    for i in 1..=n {
        let v: u32 = i.to_string().chars().map(|e| e.to_digit(10).unwrap()).sum();
        if v >= a && v <= b {
            ret += i;
        }
    }

    println!("{}", ret);
}


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

int main(){
  int N,D,X;
  cin >> N >> D >> X;
  int ans=X;
  int A;
  for (int i=0;i<N;i++){
    cin >> A;
    ans+=(D-1)/A+1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int del[100050];
char in[100050];
int main() {
	scanf("%s", in + 1);

	int L = strlen(in + 1), i;
	in[0] = in[L + 1] = '0';
	for (i = 1; i <= L + 1; i++) {
		int t1 = in[i] - '0';
		int t2 = in[i - 1] - '0';
		del[i] = t1^t2;
	}

	int st = 1, en = L, mi, rv = 0;
	while (st <= en) {
		mi = (st + en) / 2;
		for (i = L - mi + 2; i <= mi; i++) if (del[i]) break;
		if (i > mi) {
			rv = mi;
			st = mi + 1;
		}
		else en = mi - 1;
	}
	return !printf("%d\n", rv);
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int n;
    cin >> n;
    Int l[n];
    rep(i,n) {
        cin >> l[i]; 
    }
    sort(l, l+n);
    int ans = 0;
    rep(i,n) {
        for (int j = i+1; j < n; j++) {
            for (int k = j+1; k < n; k++) {
                if (l[i] == l[j] || l[j] == l[k]) continue;
                if (l[i] + l[j] > l[k]) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
typedef pair<int,int> P;
const int INF = 1<<29;


int main(){
    while(1){
        int L;
        scanf("%d",&L);
        if(L==0)break;

        int chokin = 0, ans = 0;
        for(int i=0;i<12;i++){
            int M,N;
            scanf("%d %d",&M,&N);
            if(ans)continue;
            chokin += M-N;
            if(L <= chokin) ans = i+1;
        }
        if(ans)cout << ans << endl;
        else cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <algorithm>

#define LIM_N 100002

char str[LIM_N];

int N;
char S[LIM_N];

const long long DIV = 1000000007;
long long count[26];
long long ans;

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d", &N);

	fgets(str, sizeof(str), stdin);
	sscanf(str, "%s", S);
}

void initialize() {
	// nop
}

void swap(long long &a, long long &b) {
	long long temp = a;
	a = b;
	b = temp;
}

long long mod_inv(long long a) {
	long long b = DIV, u = 1, v = 0;
	while (b) {
		long long t = a / b;

		a -= t * b;
		swap(a, b);

		u -= t * v;
		swap(u, v);
	}
	u %= DIV;
	if (u < 0) u += DIV;
	return u;
}

long long mod_div(long long a, long long b) {
	long long result = a * mod_inv(b);
	result %= DIV;
	return result;
}

void solve() {

	for (size_t i = 0; S[i]; i++) {
		int c = S[i] - 'a';
		ans += 1;

		ans = mod_div(ans, count[c]+1);
		count[c] += 1;
		ans *= count[c]+1;

		ans -= 1;
		ans %= DIV;
	}
}

int main(void) {
	receive_input();
	initialize();

	solve();

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

	return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a, b, t;
	cin >> a >> b >> t;
	cout << b * (int)((t + 0.5) / a) << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

const ll maxn=3e3+5; 
ll n;
double a[maxn], dp[maxn][maxn];

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cout<<fixed<<setprecision(9);
    
    cin>>n;
    rep(i,1,n+1)cin>>a[i];
    dp[0][0]=1;
    rep(i,1,n+1) {
        dp[i][0]=(1-a[i])*dp[i-1][0];
        rep(j,1,n+1) {
            dp[i][j]=a[i]*dp[i-1][j-1] + (1-a[i])*dp[i-1][j];
        }
    }
    double ans=accumulate(dp[n]+n/2+1, dp[n]+n+1,0.0);
    cout<<ans<<"\n";
}


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

int main() {
    string s;
    cin>>s;
    int ans=0;
    int temp=0;
    for(long int i=0;i<3;i++)
    {
        if(s[i]=='R')
        temp++;
        else
        {
         ans=max(ans,temp);
            temp=0;
        }
    }
    ans=max(ans,temp);
    cout<<ans<<endl;
	// your code goes here
	return 0;
}


Measured memory_bytes: 3624
//invincible M15
//IIT-(ISM)Dhanbad
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define pi  3.141592653589793238462643383279
#define ff first
#define ss second
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=(int)x; i<y; i++)
#define high_functioning_sociopath  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const unsigned int M = 998244353;
/*------------------------------------- THE GAME IS ON ---------------------------------------------*/
void solve()
{
     string s,t;
     cin>>s>>t;
     int minn=INT_MAX;
     int p=s.size()-t.size();
     int z=t.size();
     for(int i=0;i<=p;i++)
     {
            int ct=0;
            int k=i;
            for(int j=0;j<z;j++)
            {
                   if(s[k]!=t[j])ct++;
                   k++;
            }
            minn=min(ct,minn);
     }
     cout<<minn<<endl;
}
int32_t main()
{
   high_functioning_sociopath
   ll t=1;
   //cin>>t;
   while(t--)
   {
      solve();
   }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int root(int x) {
      if (d[x] < 0) return x;
      return d[x] = root(d[x]);
    }
    bool unite(int x, int y) {
      x = root(x); y = root(y);
      if (x == y) return false;
      if (d[x] > d[y]) swap(x,y);
      d[x] += d[y];
      d[y] = x;
      return true;
    }
    bool same(int x, int y) { return root(x) == root(y);}
    int size(int x) { return -d[root(x)];}
  };
signed main(){
    int n,m;cin >> n >> m;
    UnionFind uf(n);
    rep(i,m){
        int a,b,c;cin >> a >> b >> c;
        a--;b--;
        uf.unite(a,b);
    }
    int ret = 0;
    vector<int> vis(n);
    rep(i,n){
        int x = uf.root(i);
        if(vis[x])continue;
        vis[x] = 1;
        ret++;

    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 4824
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main {

	/* --------------------------------------------------------------------
	   main
	 * -------------------------------------------------------------------- */
	public static void main(String args[]) throws Exception {

		// ----- input -----
		Input input = new Input();
		final Data l = input.readLine();
		Queue<Integer> q = input.getColQueue();
		input.close();

		// ----- main -----
		int ans = 0;
		while(!q.isEmpty()) {
			int d = q.poll();
			while(d%2==0) {
				ans++;
				d /= 2;
			}
		}

		System.out.println(ans);
	}

	/* --------------------------------------------------------------------
	 * inupt class
	 * -------------------------------------------------------------------- */
	static class Input {

		public BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		public void close() throws Exception {
			input.close();
		}

		public Data readLine() throws Exception {
			return new Data(input.readLine().split(" "));
		}

		public Queue<Data> getDataQueue(int num) throws Exception {

			Queue<Data> q;
			q = new ArrayDeque<>();
//			data = new PriorityQueue<>( (a,b) -> a.col[0] - b.col[0]);	// 降順


			for(int i=0; i < num; i++) {
				q.offer(readLine());
			}
			return q;
		}

		public Queue<Integer> getColQueue() throws Exception {

			Data d = readLine();
			Queue<Integer> q;
			q = new ArrayDeque<>();
//			queue = new PriorityQueue<>( (a,b) -> a.col[0] - b.col[0]);	// 降順
			for(int i=0; i < d.col.length; i++) {
				q.offer(d.col[i]);
			}
			return q;
		}
	}
	/* --------------------------------------------------------------------
	 * data class
	 * -------------------------------------------------------------------- */
	static class Data{
		public int[] col;
		public Data(String[] values) {
			col = new int[values.length];
			for(int i=0; i < values.length; i++) {
				col[i] = Integer.parseInt(values[i]);
			}
		}
	}
}

Measured memory_bytes: 25684
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

bool DEBUG=0;
const int MAXN = 100005;
const int LG = 21;

int prt[MAXN][LG];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	string s; cin>>s;
	int n=s.length();
	
	forn(i,0,n){
		if(s[i]=='L') prt[i][0]=i-1;
		else prt[i][0]=i+1;
	}
	
	forn(j,1,LG){
		forn(i,0,n){
			prt[i][j]=prt[prt[i][j-1]][j-1];
		}
	}
	
	int ans[n]{};
	forn(i,0,n){
		ans[prt[i][20]]++;
	}
	forn(i,0,n) cout<<ans[i]<<" ";
	
	return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, K, S; cin >> N >> K >> S;
	for (int i = 0; i < N; ++i) {
		if (S != 1e9)
			cout << S + (i >= K) << " ";
		else cout << S - (i >= K) << " ";
	}
	cout << endl;
}

Measured memory_bytes: 3640
H,W = map(int,input().split())
S = []
for h in range(H):
    S.append(input())
from collections import deque
ans = 0
for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            Q = deque([])
        else:
            Q = deque([[h,w]])
        count_map = [[-1 for _ in range(W)] for __ in range(H)]
        count_map[h][w] = 0
        while Q:
            q = Q.popleft()
            cnt = count_map[q[0]][q[1]] + 1
            if q[0]-1 >= 0:#上
                if S[q[0]-1][q[1]] == "." and count_map[q[0]-1][q[1]] == -1:
                    count_map[q[0]-1][q[1]] = cnt
                    Q.append([q[0]-1,q[1]])
            if q[1]-1 >= 0:#左
                if S[q[0]][q[1]-1] == "." and count_map[q[0]][q[1]-1] == -1:
                    count_map[q[0]][q[1]-1] = cnt
                    Q.append([q[0],q[1]-1])
            if q[0]+1 <= H-1:#下
                if S[q[0]+1][q[1]] == "." and count_map[q[0]+1][q[1]] == -1:
                    count_map[q[0]+1][q[1]] = cnt
                    Q.append([q[0]+1,q[1]])
            if q[1]+1 <= W-1:#右
                if S[q[0]][q[1]+1] == "." and count_map[q[0]][q[1]+1] == -1:
                    count_map[q[0]][q[1]+1] = cnt
                    Q.append([q[0],q[1]+1])
        temp_max = 0
        for cm in count_map:
            temp_max = max(temp_max,max(cm))
        ans = max(ans,temp_max)
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)

typedef pair<int, int> Pi;
#define fi first
#define se second

#define pb push_back
const int LLINF = 1LL << 60;

signed main()
{
  int N, L, T;
  int A, B;

  vector < Pi > ant[2];
  int ans[100005];
  
  cin >> N >> L >> T; T *= 2;
  Rep(i, N) {
    cin >> A >> B;
    ant[--B].pb(Pi(A, i)); ant[B].pb(Pi(A - L, i)); ant[B].pb(Pi(A + L, i));
  }

  
  Rep(p, 2) {
    sort(ant[p].begin(), ant[p].end());
  }

  Rep(p, 2) {
    for(int i = ant[p].size() / 3; i < ant[p].size() / 3 * 2; i++) {
      
      int rule = T / L, dis = T % L;
      int val;
      int point = ant[p][i].fi; //仮の座標
      int g = 1;
      if(p) g = -1;
    
      point += (dis * g);
      
      int a = ant[p][i].fi, b = point;
      if(p) swap(a, b);
      
      int l = lower_bound(ant[1 - p].begin(), ant[1 - p].end(), Pi(a, -LLINF)) - ant[1 - p].begin();
      int r = upper_bound(ant[1 - p].begin(), ant[1 - p].end(), Pi(b, LLINF)) - ant[1 - p].begin() - 1;
      // cout << " " << l << " " << r << endl;
      
      
      val = (r - l + 1 + rule * (ant[1 - p].size() / 3)) % N;

      //cout << p << " " << (ant[p][i].se + val * g) % N << endl;
      ans[(ant[p][i].se + val * g + N) % N] = (ant[p][i].fi + L + ((T / 2) % L) * g) % L;
      
    }
  }

  Rep(i, N) cout << ans[i] << endl;

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    ll X;
    cin >> X;
    ll tmp = X / 11;
    if(X - 11 * tmp == 0) cout << 2 * tmp << endl;
    else if (X - 11 * tmp <= 6) cout << 2 * tmp + 1 << endl;
    else cout << 2 * tmp + 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>a;
    	ld ans = 2 * PI * a ;
    	printf("%6Lf \n",ans);
    }
    return 0;
}

Measured memory_bytes: 3808
#include<stdio.h>
#define M 100
#define W 0
#define G 1
#define B 2
#define I 2097152


int main(){
	int d[M],p[M],color[M],MIMI[M][M];
	int n,i,j,e;
	int min,u,v,sum;

	//nyu
	scanf("%d",&n);

	//nyu
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			scanf("%d",&e);
			MIMI[i][j]=(e==-1)?I:e;
		}
	}


		//kansu
	for(i=0;i<n;i++){
		color[i]=W;
		d[i]=I;
		p[i]=-1;
	}
	d[0]=0;

	while(1){
		min=I;
		u=-1;

		for(i=0;i<n;i++){
			if(min>d[i]&&color[i]!=B){
				u=i;
				min=d[i];
			}
		}

		if(u==-1)
			break;

		color[u]=B;

		for(v=0;v<n;v++){
			if(color[v]!=B&&MIMI[u][v]!=I){
				if(d[v]>MIMI[u][v]){
					d[v]=MIMI[u][v];
					p[v]=u;
					color[v]=G;
				}
			}
		}
	}

	sum=0;
	for(i=0;i<n;i++){
		if(p[i]!=-1)
			sum+=MIMI[i][p[i]];
	}


	//syutu
	printf("%d\n",sum);

	return 0;
}




Measured memory_bytes: 2044
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int a = scan.nextInt();
        String s = scan.next();
        if(a >= 3200)
            os.println(s);
        else
            os.println("red");
    }
}

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Yes or No
void yesno(bool ok, string yes = "Yes", string no = "No") {
  cout << (ok ? yes : no) << endl;
}

// Paste snippets here!!
template <class INT_T>
INT_T gcd(INT_T a, INT_T b) {
  if(a < b) return gcd(b, a);
  INT_T r;
  while ((r=a%b)) { a = b; b = r; }
  return b;
}
// template <class INT_T>
// INT_T ___gcd(INT_T a, INT_T b){
//     if(a<b) swap(a,b);
//     if(a%b==0) return b;
//     return ___gcd(a%b,b);
// }
// template <class INT_T>
// INT_T lcm(INT_T a, INT_T b){
//     return a/___gcd(a,b)*b;
// }
//

void solve(long long N, long long X, std::vector<long long> x) {
  rep(i,N) { x[i] -= X; x[i] = abs(x[i]); }
  //dump(x);
  // xの最大公約数を求めればOK
  ll D = x[0];
  rep(i,1,N){
    D = gcd(D,x[i]);
  }
  cout << D << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long N;
  std::cin >> N;
  long long X;
  std::cin >> X;
  std::vector<long long> x(N);
  for (int i = 0; i < N; i++) {
    std::cin >> x[i];
  }
  solve(N, X, std::move(x));
  return 0;
}


Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
#define    sz    100110
#define    ll    long long int
ll n,c=0,p,q,k;
ll num[sz];
ll vis[sz];
ll dp[sz];


ll tani(ll pos)
{
    ll mn=100000000000;

    if(pos>=n )
        return 0;
    if(vis[pos]==1)
        return dp[pos];

    vis[pos]=1;

    for(ll i=1; i<=k ; i++)
    {
        mn=min(mn,abs(num[pos]-num[pos+i])+tani(pos+i));
    }
    // cout<<mn<<endl;
    return dp[pos]=mn;
}

int main()
{
    ll t,i;

    for(i=1; i<sz; i++)
        num[i]=10000000000;

    //cin>>n>>k;
    scanf("%lld %lld",&n,&k);

    for(i=1; i<=n; i++)
    {
        // cin>>num[i];
        scanf("%lld",&num[i]);
    }
    t=tani(1);
    // cout<<t<<endl;
    printf("%lld\n",t);
    return 0;
}



Measured memory_bytes: 7296