akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define DEFAULT LL ans=solve();\
 	if(ans==NONE){\
 	}else{\
 		cout << ans << endl;\
 	}
#define YESNO three(solve(),(OUT(YES),1),(OUT(NO),0))
#define YesNo three(solve(),OUT(Yes),OUT(No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p998 = 998244353;
const LL p107 = 1000000007;
const LL p = p107;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const LL NONE=-2;
#define endl "\n"
ut N, M,K,  Q, D, H, W;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
//LL A[SIZE],B[SIZE],C[SIZE];
LL solve(){
	LL A,V,B,W,T;
	cin >>A >>V >> B >> W >> T;
	V-=W;
	A=abs(A-B);
	if(V<=0) return 0;
	return V*T>=A;
	return NONE;
}
 signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	LL T=1;

	REP(i,T){
		YESNO;
	}
	
//	YesNo;
//	YESNO;
//	three(solve(),OUT("First"),OUT("Second"));
	//cin >> N;
	return 0;
 
}


Measured memory_bytes: 15400
class Solver
  def initialize(n, cards)
    @n = n-1
    @cards = cards
  end

  def exec
    quicksort(0, @n)
    puts_stable
    puts_result
  end

  def quicksort(left, right)
    if left < right
      q = partition(left, right)
      quicksort(left, q-1)
      quicksort(q+1, right)
    end
  end

  def partition(left, right)
    pivot = @cards[right]
    @cards[right] = nil
    i = left-1

    (left..right-1).each do |j|
      if @cards[j].num <= pivot.num
        i += 1
        @cards[i], @cards[j] = @cards[j], @cards[i]
      end
    end

    @cards[i+1], @cards[right] = @cards[right], @cards[i+1]
    @cards[i+1] = pivot

    return i+1
  end

  def puts_result
    @cards.each { |card| puts "#{card.mark} #{card.num}" }
  end

  def puts_stable
    @cards.each_with_index do |card, i|
      next_card = @cards[i+1]
      next unless card.num == next_card&.num

      return puts 'Not stable' if next_card&.id < card.id
    end

    puts 'Stable'
  end
end

class Card
  attr_reader :id, :mark, :num

  def initialize(id, mark, num)
    @id = id
    @mark = mark
    @num = num
  end
end

n = gets.to_i
cards = []
n.times do |i|
  card = gets.split(' ')
  cards << Card.new(i, card[0], card[1].to_i)
end

Solver.new(n, cards).exec


Measured memory_bytes: 19084
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
# mod = 10 ** 9 + 7
mod = 998244353 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def functional(N):
    F = [1] * (N + 1)
    for i in range(N):
        F[i + 1] = (i + 1) * F[i] % mod
    return F

D = {}
def inv(a):
    if a in D:
        return D[a]
    
    d = pow(a, mod - 2, mod)
    D[a] = d
    return d


def C(F, a, b):
    return F[a] * inv(F[a - b]) * inv(F[b]) % mod 


def main():
    N, M, K = read_values()
    F = functional(N)
 
    res = 0
    for k in range(K + 1):
        res += M * pow(M - 1, N - 1 - k, mod) * C(F, N - 1, k) % mod
        res %= mod
 
    print(res % mod)


if __name__ == "__main__":
    main()



Measured memory_bytes: 95140
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(long long i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(long long i=int(n);i>0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=1000005;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


int main(){
    int n,x;
    cin>>n>>x;
    vi a(n);
    rep(i,n)cin>>a[i];
    int now=0;
    int ans=1;
    rep(i,n){
        if(now+a[i]>x)break;
        ans++;
        now+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if(S.at(0) == S.at(1) && S.at(1) == S.at(2)){
    cout << "No" << endl;
  }
  else{
    cout <<"Yes" << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n  = Integer.parseInt(input.readLine());
        int [] positions = new int[n + 1];
        int currentIndex = 1;
        for (int i = 1; i <= n; i++) {
            positions[i] = Integer.parseInt(input.readLine());
        }
        int count = 0;
        while (currentIndex != 2 && positions[currentIndex] > 0){
            int copyCurrentIndex = currentIndex;
            currentIndex = positions[currentIndex];
            positions[copyCurrentIndex] = -1;
            count++;
        }
        System.out.println(currentIndex == 2 ? count: -1);
    }

}


Measured memory_bytes: 31060
//g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
//g++ -std=c++14 -Wall -O2 -o main.exe main.cpp

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
#include <queue>
#include <stack>
#include <tuple>

using namespace std;

#define spc " "
#define com ", "

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p_ii;

//------------------------------------------------------------------------------

int main(){
    int a, b, c, n = 1;
    cin >> a >> b >> c;

    if(a != b) n++;
    if(a != c && b != c) n++;

    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集 

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int a, b, c; cin >> a >> b >> c;

    int k; cin >> k;

    while(a >= b){
        b *= 2;
        k--;
    }
    while(b >= c){
        c *= 2;
        k--;
    }

    if(k >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3636
def cond(arr,m):
  tmp=0
  for i in range(n):
    if m*b>=arr[i]:
      continue
    else:
      tmp+=(arr[i]-m*b+(a-b-1))//(a-b)
  if tmp<=m:
    return True
  else:
    return False

def bisect(l,r):
    while r-l!=1:
        m=(r+l)//2
        if cond(arr,m)==True:
            r=m
        else:
            l=m
    return r

n,a,b=map(int,input().split())
arr=[int(input()) for _ in range(n)]
print(bisect(-1,10**9+1))

Measured memory_bytes: 7196
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define pii pair <int, int>
#define pb push_back
#define ll long long
#define ss second
#define ff first
#define N 500010

using namespace std;

int n, m, ans;
pii P[100], P2[100];

int main()
{
	cin >> n >> m;
	
	for(int i=1; i <= n; i++)
		cin >> P[i].ff >> P[i].ss;
	
	for(int i=1; i <= m; i++)
		cin >> P2[i].ff >> P2[i].ss;
	
	for(int i=1; i <= n; i++) {
		int mn = 1e9;
		int x = P[i].ff;
		int y = P[i].ss;
		
		for(int h=m; h >= 1; h--) {
			int x2 = P2[h].ff;
			int y2 = P2[h].ss;
			
			if(mn >= abs(x-x2)+abs(y-y2))
				mn = abs(x-x2)+abs(y-y2), ans = h;
		}
			
		cout << ans << "\n";
	}
}


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

const int NMAX = 1e5+1;

int parent[NMAX], n;
int subnodes[NMAX];
bool visited[NMAX];
vector<int> adj[NMAX];

void dfs(int node){
	visited[node] = true;
	for(int v : adj[node]){
		if(!visited[v]){
			dfs(v);
			parent[v] = node;
			subnodes[node] += subnodes[v];
		}
	}
	subnodes[node]++;
}

bool ans(){
	vector<int> q;
	int node = n - 1;
	parent[0] = -1;
	while(node != -1){
		q.push_back(node);
		node = parent[node];
	}
	int len = q.size(), fennec = len>>1, i = 0;
	ll a = 0, b = 0;
	for(int i = 0; i < len; i++){
		node = q[i];
		for(int v : adj[node]){
			if((i == 0 ||(i > 0 && q[i-1] != v)) && (i + 1 == len||(i + 1 < len && q[i+1] != v))){
				if(i >= fennec){
					a += subnodes[v];
				}else{
					b += subnodes[v];
				}
			}
		}
	}
	if(len%2 == 0){
		return a > b;
	}else{
		return a >= b;
	}
}

int main()
{
	ios::sync_with_stdio(false);cin.tie(NULL);
	cin >> n;
	int a, b;
	for(int i = 0; i < n - 1; i++){
		cin >> a >> b;
		a--;
		b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(0);
	if(ans()){
		cout << "Fennec";
	}else{
		cout << "Snuke";
	}
	return 0;
}



Measured memory_bytes: 11900
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long n = long.Parse(input[0]);
		long a = long.Parse(input[1]);
    long b = long.Parse(input[2]);

    long max = Math.Min(a,b);
    long min = Math.Max(0,a+b-n);

		Console.WriteLine(max + " " + min);
	}
}

Measured memory_bytes: 11092
#include <cstdio>

int dp[8][1001],a[8],b[8],m,g,n;

int main(){
	while(scanf("%d",&m),m != 0){
		for(int i = 1; i <= m; i++){
			scanf("%d%d",&a[i],&b[i]);
		}
		for(int i = 0; i < 8; i++){
			for(int j = 0; j < 1001; j++){
				dp[i][j] = 0;
			}
		}
		dp[0][0] = 1;
		for(int i = 1; i <= m; i++){
			for(int j = 0; j < 1001; j++){
				if(dp[i-1][j] > 0){
					for(int k = 0; k <= b[i]; k++){
						if(j + k*a[i] <= 1000){
							dp[i][j+k*a[i]] += dp[i-1][j];
						}
					}
				}
			}
		}
				

		scanf("%d",&g);
		for(int i = 0; i < g; i++){
			scanf("%d",&n);
			printf("%d\n",dp[m][n]);
		}
	}
	return 0;
}

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

#define SZ(c) int(c.size())
#define all(c) c.begin(), c.end()
#define pb  push_back
#define clr(a, n) memset(a, n, sizeof a)

const int mod = 1e9+7;

typedef vector<int> vi;
typedef long long ll;


int main() {

	ll n, x;
	cin >> n;
	set<int> st;
	for (int i = 0; i < n; ++i) {
		cin >> x;
		st.insert(x); 
	}
	if (st.size() != n) {
		cout << "NO\n";
 	} else {
 		cout << "YES\n";
 	}
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;

typedef long long ll;

const int SZ = 222;
struct Dinic{
    using FlowType = ll;
    const FlowType flow_max = 1e9;
    int s, t; // source, sink;
    struct Edge{ int v, dual; FlowType c; };
    vector<Edge> g[SZ];
    void addEdge(int s, int e, FlowType x){
        g[s].push_back({e, (int)g[e].size(), x});
        g[e].push_back({s, (int)g[s].size()-1, x});
    }
    int lv[SZ], work[SZ];
    bool bfs(){
        memset(lv, -1, sizeof lv);
        queue<int> q; q.push(s); lv[s] = 0;
        while(!q.empty()){
            int v = q.front(); q.pop();
            for(auto i : g[v]){
                if(lv[i.v] == -1 && i.c > 0){
                    q.push(i.v); lv[i.v] = lv[v] + 1;
                }
            }
        }
        return lv[t] != -1;
    }
    FlowType dfs(int v, FlowType tot){
        if(v == t) return tot;
        for(int &_i=work[v]; _i<g[v].size(); _i++){
            Edge &i = g[v][_i];
            if(lv[i.v] == lv[v] + 1 && i.c > 0){
                int fl = dfs(i.v, min(tot, i.c));
                if(fl > 0){
                    i.c -= fl;
                    g[i.v][i.dual].c += fl;
                    return fl;
                }
            }
        }
        return 0;
    }
    FlowType run(int _s, int _t){
        s = _s; t = _t; FlowType ret = 0;
        while(bfs()){
            memset(work, 0, sizeof work);
            FlowType tmp;
            while((tmp = dfs(s, flow_max))) ret += tmp;
        }
        return ret;
    }
} flow;

int n, m;
char a[111][111];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cin >> n >> m;
    const int S = 219, T = 220;
    for(int i=1; i<=n; i++) for(int j=1; j<=m; j++){
        cin >> a[i][j];
        if(a[i][j] == '.') continue;
        flow.addEdge(i, 100+j, 1);
        if(a[i][j] == 'S') flow.addEdge(S, i, 1e9), flow.addEdge(S, 100+j, 1e9);
        if(a[i][j] == 'T') flow.addEdge(i, T, 1e9), flow.addEdge(100+j, T, 1e9);
    }
    auto res = flow.run(S, T);
    if(res > 50505) cout << -1;
    else cout << res;
}

Measured memory_bytes: 3916
#!python3

def iim():
    return map(int, input().rstrip().split())

def resolve():
    N = int(input())
    S = input()

    i = -1
    n = 0
    while True:
        i = S.find("ABC", i+1)
        if i == -1:
            break
        n += 1

    print(n)




if __name__ == "__main__":
    resolve()


Measured memory_bytes: 2940
s = input()
ans = 'WA'
if s[0] == 'A':
  s = s[1:]
  a = s[1:-1]
  if a.count('C') == 1:
    s = s.replace('C' , '' , 1)
    if s.islower():
      ans = 'AC'
print(ans)

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

int main() {
    string s, t; cin >> s >> t;
    map<char, vector<int>> pos;
    for(int i=0; i<s.size(); ++i) {
        pos[s[i]].push_back(i);
    }
    
    int res = 0;
    int cur = 0;
    for(char c : t) {
        if(pos[c].size() == 0) {
            cout << -1 << '\n';
            return 0;
        }
        auto it = lower_bound(begin(pos[c]), end(pos[c]), cur);
        if(it == end(pos[c])) {
            res += 1;
            cur = 0;
            it = lower_bound(begin(pos[c]), end(pos[c]), cur);
        }
        cur = *it + 1;
    }
    long long r = 1LL * s.size() * res + cur;
    cout << r << '\n';
}

Measured memory_bytes: 1216
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
using namespace std;
int main(){
  //int n,k=0;
  //cin>>n;
  //vector<int> d(n);
  //rep(i,n){cin>>d[i];}
  //sort(all(d));
  string s;
  cin>>s;
  bool ans=true;
  rep(i,3){
    if(s[i]==s[i+1]){ans=false;}}
  if(ans){cout<<"Good"<<endl;}
  else cout<<"Bad"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>

#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

using namespace std;

int main(){

  string W,T;
  int i=0,count=0;

  cin >>W;
  while(cin >>T){
    if(T=="END_OF_TEXT") break;
    for(i=0;i<T.size();i++){
      T[i]=tolower(T[i]);
    }
    if(T==W) count++;
  }
  cout <<count <<endl;

  return 0;
}

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


int main() {
    int n; cin>>n;
    vector<vector<int>> v(n, vector<int>(3));
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++) cin>>v[i][j];
    }
    vector<int> dp(3);
    dp[0]=v[0][0];
    dp[1]=v[0][1];
    dp[2]=v[0][2];
    
    for(int i=1;i<n;i++){
        vector<int> m(3);
        m[0]=max(dp[1],dp[2]) + v[i][0];
        m[1]=max(dp[0],dp[2]) + v[i][1];
        m[2]=max(dp[0],dp[1]) + v[i][2];
        dp[0]=m[0];
        dp[1]=m[1];
        dp[2]=m[2];
    }
    int max=-1;
    for(int i=0;i<3;i++) if(dp[i]>max) max=dp[i];
    cout<<max;
    return 0;
}

Measured memory_bytes: 8740
class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]

r1, c1, r2, c2 = map(int, input().split())
MOD = 10**9 + 7
comb = Combination(r2 + c2 + 10)

ans = 0

for c in range(c1, c2 + 1):
    ans = (ans + comb.ncr(r2 + c + 1, c + 1) - comb.ncr(r1 + c, c + 1)) % MOD

print(ans)

Measured memory_bytes: 104688
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;
const int MOD=1000000007;



signed main(){
	int A,B,C;
	cin>>A>>B>>C;
	if(A==B&&B==C){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end(),greater<int>());
  
  int amax = 0;
  int bmax = 0;
 
  
  bool even = (N % 2 == 0);
  bool odd = ! even;
  
  if (even){
  	for(int i =0; i<N/2; i++){
  	  amax += a.at(2*i);
  	  bmax += a.at(2*i+1);
 	 }
  }
  if (odd){
    for(int i =0; i<N/2; i++){
      amax += a.at(2*i);
      bmax += a.at(2*i+1);
    }
    amax += a.at(N-1);
  }
  cout << amax - bmax << endl;
}


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;
  if(tail + 1 == LEN+1)tail = 0;
  else tail++;
}
 
P dequeue(){
  P a;
  a = Q[head];
  if(head + 1 == LEN + 1) head = 0;
  else head++;
  return a;
}
 
int isEmpty(){
  if(head == tail) return 1;
  else return 0;
}
 
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;
   
  for(;;){
    u = dequeue();
    c = u.t - q;
     
    if(c > 0){
      elaps += q;
      u.t = c;
      enqueue(u);
    }
     
    else if(c <= 0){
      elaps += u.t;
      printf("%s %d\n", u.name, elaps);
    }
 
    if(isEmpty() == 1)break;
    else continue;
  }
  return 0;
}

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

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

    int n, wmax;
    cin >> n >> wmax;
    vector<int> v(n), w(n);
    rep(i, n) cin >> v[i] >> w[i];

    vector<vector<int>> dp(n, vector<int>(wmax+1, 0));
    rep(i, wmax+1) dp[0][i] = v[0] * (i / w[0]);

    rep1(i, n) rep(j, wmax+1){
        if(j < w[i]) dp[i][j] = dp[i-1][j];
        else dp[i][j] = max(dp[i-1][j], dp[i][j-w[i]] + v[i]);
    }

    cout << dp[n-1][wmax] << endl;

    return 0;
}


Measured memory_bytes: 6840
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				int s = sc.nextInt();
				if(x+y+s == 0) break;
				
				int max = 0;
				for(int i=1; i<1000; i++) {
					for(int j=1; j<1000; j++) {
						if(Math.floor((i*(100+x)/100+j*(100+x)/100)) == s) {
							max = Math.max((int)Math.floor((i*(100+y)/100+j*(100+y)/100)), max);
						}
					}
				}
				System.out.println(max);
			}
		}
	}
}



Measured memory_bytes: 29012
// AOJ 1281 The Morning after Halloween
// 2018.3.3 bal4u
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int  w, h;
char map[18][18];
int  n;
char sr[3], sc[3], gr[3], gc[3];
char r[3], c[3], nr[3], nc[3];
int  mv[5][2] = {{-1,0},{0,1},{1,0},{0,-1},{0,0}};
short mk[16][16][16][16][16][16];

#define QMAX 300000
typedef struct { char r[3], c[3]; short t; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(short t)
{
	int i, j, min;
	QUE qt;

	i = qsize++;
	for (j = 0; j < n; j++) que[i].r[j] = nr[j], que[i].c[j] = nc[j]; 
	que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

int check(int i, int j)
{
	if (nr[i] == nr[j] && nc[i] == nc[j]) return 1;
	if (r[i] == nr[j] && c[i] == nc[j] && r[j] == nr[i] && c[j] == nc[i]) return 1;
	return 0;
}

void _enq(int t)
{
	if (t < mk[nr[0]][nc[0]][nr[1]][nc[1]][nr[2]][nc[2]]) {
		mk[nr[0]][nc[0]][nr[1]][nc[1]][nr[2]][nc[2]] = t;
		enq(t);
	}
}

int dijkstra()
{
	int i, j, k, t;

	memset(mk, 0x55, sizeof(mk));
	for (i = n; i < 3; i++) r[i] = c[i] = nr[i] = nc[i] = 0;
	for (i = 0; i < n; i++) nr[i] = sr[i], nc[i] = sc[i];
	qsize = 0;
	mk[nr[0]][nc[0]][nr[1]][nc[1]][nr[2]][nc[2]] = 0;
	enq(0);

	while (qsize) {
		for (i = 0; i < n; i++) r[i] = que[0].r[i], c[i] = que[0].c[i];
		t = que[0].t, deq();

		for (i = 0; ; i++) {
			if (i == n) return t;
			if (gr[i] != r[i] || gc[i] != c[i]) break;
		}

		if (mk[r[0]][c[0]][r[1]][c[1]][r[2]][c[2]] < t) continue;
		for (i = 0; i < 5; i++) {
			nr[0] = r[0] + mv[i][0], nc[0] = c[0] + mv[i][1];
			if (map[nr[0]][nc[0]] == '#') continue;

		if (n >= 2) for (j = 0; j < 5; j++) {
			nr[1] = r[1] + mv[j][0], nc[1] = c[1] + mv[j][1];
			if (map[nr[1]][nc[1]] == '#' || check(0, 1)) continue;

		if (n == 3) for (k = 0; k < 5; k++) {
			nr[2] = r[2] + mv[k][0], nc[2] = c[2] + mv[k][1];
			if (map[nr[2]][nc[2]] == '#' || check(0, 2) || check(1,2)) continue;
			_enq(t+1);
		} else _enq(t+1);
		} else _enq(t+1);
		}
	}
	return -1;
}

int main()
{
	int i, r, c;
	char buf[20], *p;

	while (fgets(buf, 20, stdin) && *buf != '0') {
		sscanf(buf, "%d%d%d", &w, &h, &n);
		for (i = n; i < 3; i++) sr[i] = sc[i] = gr[i] = gc[i] = 0;
		for (r = 0; r < h; r++) {
			fgets(p=map[r], 18, stdin);
			for (c = 0; c < w; c++) {
				if (isalpha(*p)) {
					if (islower(*p)) sr[*p-'a'] = r, sc[*p-'a'] = c;
					else             gr[*p-'A'] = r, gc[*p-'A'] = c;
					*p = ' ';
				}
				p++;
			}
		}
		printf("%d\n", dijkstra());
	}
	return 0;
}


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



int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n, m; cin >> n >> m;
    int x[101], c[101];
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> c[i];
    }

    int l, r;
    if (n == 1) {
        l = 0; r = 9;
    } else if (n == 2) {
        l = 10; r = 99;
    } else {
        l = 100; r = 999;
    }

    for (int i = l; i <= r; i++) {
        string s = to_string(i);
        bool failed = false;
        for (int j = 0; j < m; j++) {
            if (s[x[j] - 1] != c[j] + 48) {
                failed = true;
                break;
            }
        }
        if (!failed) {
            cout << s << '\n';
            return 0;
        }
    }

    cout << "-1\n";


    return 0;
}


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

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

    int x[n];
    for(int i=0; i<n; i++){
        cin >> x[i];
    }

    int min = 100*100*100;
    for(int p=0; p<100; p++){
        int sum = 0;
        for(int j=0; j<n; j++){
            sum += (x[j] - p)*(x[j] - p);
        }
        if(sum < min){
            min = sum;
        }
    }

    cout << min << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>

using namespace std;

struct Info {
	int arrive;
	int index;
};

bool xxx(Info& a, Info& b)
{
	if (a.arrive < b.arrive)
	{
		return true;
	}
	return false;
}

int main() {

	int N;
	cin >> N;

	Info tmp;
	vector<Info> vVec(N, tmp);
	for (int i = 0; i < N; i++)
	{
		vVec[i].index = i + 1;
		cin >> vVec[i].arrive;
	}

	sort(vVec.begin(), vVec.end(), xxx);

	for (int i = 0; i < vVec.size(); i++)
	{
		cout << vVec[i].index << " ";
	}

	return 0;
}

Measured memory_bytes: 1536
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	k <- readLn
	s <- getLine
	putStrLn $ if length s <= k
		then s
		else take k s ++ "..."


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

int main(){
  long long int x;
  scanf("%lld",&x);
  
  int cnt=0;
  
  //yen+=yen*0.01;
  
  for(long long int yen=100;yen<x;yen+=yen*0.01) cnt++;
  
  printf("%lld",cnt);
  return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define inf std::numeric_limits<double>::infinity()
#define DECI(n) fixed<<showpoint<<setprecision(n)
#define MOD 1000000007LL
#define FOR(i,start,end) for (int i=start;i<end;i++)
#define FORR(i,end,start) for(int i=end-1;i>start;i--)
#define INPUT(arr,n) FOR(i,0,n) cin>>arr[i];
#define INPUT2d(arr,n,k) FOR(i,0,n) FOR(j,0,k) cin>>arr[i][j];
#define SIZE 100005
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define TC(t) while (t--)
int subCount(ll arr[], ll n, ll k) 
{ 
    // create auxiliary hash array to count frequency 
    // of remainders 
    ll mod[k]; 
    memset(mod, 0, sizeof(mod)); 
  
    // Traverse original array and compute cumulative 
    // sum take remainder of this current cumulative 
    // sum and increase count by 1 for this remainder 
    // in mod[] array 
   ll cumSum = 0; 
    for (ll i = 0; i < n; i++) { 
        cumSum += arr[i]; 
  
        // as the sum can be negative, taking modulo twice 
        mod[((cumSum % k) + k) % k]++; 
    } 
  
  ll result = 0; // Initialize result 
  
    // Traverse mod[] 
    for (ll i = 0; i < k; i++) 
  
        // If there are more than one prefix subarrays 
        // with a particular mod value. 
        if (mod[i] > 1) 
            result += (mod[i] * (mod[i] - 1)) / 2; 
  
    // add the elements which are divisible by k itself 
    // i.e., the elements whose sum = 0 
    result += mod[0]; 
  
    return result; 
} 

  
int main()
{
 

 int n,k,sum=0;
 cin>>n>>k;
 int a[n];
 INPUT(a,n);
 sort(a,a+n);
 for(int i=0;i<k;i++){
 	sum+=a[i];
 }
 cout<<sum<<endl;
 

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1LL << 61);
const int inf = 1001001001;
const int mod = 1000000007;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) {return os << a.x;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int zero = 0;
	map<pair<ll, ll>, P> mp;
	rep(i, n) {
		ll x, y;
		cin >> x >> y;
		if (x == 0 && y == 0) {
			zero++;
			continue;
		}
		ll g = gcd(x, y);
		x /= g;
		y /= g;
		if (y < 0) x = -x, y = -y;
		if (y == 0 && x < 0) x = -x, y = -y;
		bool elf = (x <= 0);
		if (elf) {
			ll tmp = x;
			x = y; y = -tmp;
		}
		if (elf) mp[{x, y}].first++;
		else mp[{x, y}].second++;
	}
	mint ans = 1;
	for (auto p : mp) {
		int s = p.second.first;
		int t = p.second.second;
		mint now = 1;
		now += mint(2).pow(s) - 1;
		now += mint(2).pow(t) - 1;
		ans *= now;
	}
	ans -= 1;
	ans += zero;
	cout << ans << endl;
	return 0;
}

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

vector<vector<char> >vec;
int n,m;
vector<vector<int> >vis;
long long nh=0,nd=0;

bool check(int i ,int j)
{
    if(i<1 || i>n || j<1 || j>m)
        return false;
    if(vis[i][j]==1)
        return false;
    return true;
}

int dfs(int i,int j)
{
    vis[i][j]=1;
    if(vec[i][j]=='#')
    {
        nh++;
        if(check(i+1,j))
        {
            if(vec[i+1][j]=='.')
                dfs(i+1,j);
        }
        if(check(i-1,j))
        {
            if(vec[i-1][j]=='.')
                dfs(i-1,j);
        }
        if(check(i,j+1))
        {
            if(vec[i][j+1]=='.')
                dfs(i,j+1);
        }
        if(check(i,j-1))
        {
            if(vec[i][j-1]=='.')
                dfs(i,j-1);
        }
    }
    else
    {
        nd++;
        if(check(i+1,j))
        {
            if(vec[i+1][j]=='#')
                dfs(i+1,j);
        }
        if(check(i-1,j))
        {
            if(vec[i-1][j]=='#')
                dfs(i-1,j);
        }
        if(check(i,j+1))
        {
            if(vec[i][j+1]=='#')
                dfs(i,j+1);
        }
        if(check(i,j-1))
        {
            if(vec[i][j-1]=='#')
                dfs(i,j-1);
        }
    }
}

int main()
{

    cin>>n>>m;
    vec.resize(n+5,vector<char>(m+5));
    vis.resize(n+5,vector<int>(m+5,0));
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        cin>>vec[i][j];
    long long ans=0;
   // cout<<"ss";
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(vec[i][j]=='#')
            {
                if(vis[i][j]==0)
                {
                dfs(i,j);
                ans+=nd*nh;
                nd=0;
                nh=0;
                }
            }
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 16128
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <stack> 
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
 
#define pb 					push_back
 
template<typename T,typename S>
ostream& operator <<(ostream& os, pair<T, S> input) {
	os<<"("<<input.first<<", "<<input.second<<")";
	return os;
}
 
template<typename T>
ostream& operator <<(ostream& os, vector<T> input) {
	for(auto t: input)
		os << t <<"\n";
 
	return os;
}
 
 
template<typename T>
ostream& operator <<(ostream& os, set<T> input) {
	for(auto t: input)
		os << t <<"\n";
 
	return os;
}

int main() {
	string left, right;
	cin >> right;
	int q;
	cin >> q;
	int isrev =0;
	while(q--) {
		int type;
		cin >> type;
		if(type ==1 ){
			isrev^=1;
		} else {
			int x;
			cin >>x ;
			char c;
			cin >> c;
			if((x==1 && !isrev) ||(x==2 && isrev)){
				left.push_back(c);
			} else {
				right.push_back(c);
			}
		}
	}
	reverse(left.begin(), left.end());
	string ans =left + right;
	if(isrev)
		reverse(ans.begin(), ans.end());
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

class UnionFind {
  vector<int> par, sz;
public:
  UnionFind(int n) {
    par.resize(n);
    for (int i = 0; i < n; i++)
      par[i] = i;
    sz.resize(n, 1);
  }
  int root(int x) {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sz[root(x)];
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (sz[x] >= sz[y]) {
      sz[x] += sz[y];
      par[y] = x;
    } else {
      sz[y] += sz[x];
      par[x] = y;
    }
    return true;
  }
};

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  vector<int> num(n, -1);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    uf.unite(a, b);
    --num[a], --num[b];
  }
  rep(i, n)
    num[i] += uf.size(i);
  rep(i, k) {
    int c, d;
    cin >> c >> d;
    --c, --d;
    if (uf.root(c) == uf.root(d))
      --num[c], --num[d];
  }
  rep(i, n) {
    if (i) cout << ' ';
    cout << num[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};


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

Measured memory_bytes: 3676
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

#define ll long long

using namespace std;

int main() {
  int x; cin >> x;
  int pt = 0;
  while (x >= 500) {
    x -= 500;
    pt += 1000;
  }
  while (x >= 5) {
    x -= 5;
    pt += 5;
  }
  cout << pt << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

ans = 1

a.sort(reverse=True)

if 0 not in a:
    for x in range(n):
        ans *= a[x]

        if ans > 10**18:
            ans = -1
            break
else:
    ans = 0

print(ans)


Measured memory_bytes: 21648
#include<bits/stdc++.h>
using namespace std;
//typedef
typedef long long ll;
typedef pair<ll,ll> PLL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<string> VS;
//template
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;}
//repetition
#define FOR(i,a,b) for(int i=int(a); i<int(b); ++i)
#define FORD(i,a,b) for(int i=int(a); i<int(b); --i)
#define REP(i,N) for(int i=0; i<int(N); ++i)
#define REPD(i,N) for(int i=0; i<int(N); --i)
//container util
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//constant
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //配列の最大のrenge
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
    int N; cin >> N;
    VL a(N); REP(i,N) cin >> a[i];
    VL dp(N); REP(i,N) dp[i] = INF;

    dp[0] = 0;

    FOR(i,1,N) {
        chmin(dp[i], dp[i-1] + abs(a[i] - a[i-1]));
        if (i != 1) chmin(dp[i], dp[i-2] + abs(a[i] - a[i-2]));
    }

    cout << dp[N-1] << endl;
}

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

	public static void main(String[] args) {
		Scanner n=new Scanner(System.in);
		int a=n.nextInt();int b=n.nextInt();
		StringBuilder sb=new StringBuilder("");
		while (a!=0 || b!=0){
			sb=new StringBuilder("");
				for (int c=0;c<a;c++){
					if ((c%2)==0){
						for (int d=0;d<b;d++){
							sb.append("#");
						}
						for (int e=1;e<b;e+=2){
							sb.replace(e,e+1,".");
						}
					}else{
						for (int f=0;f<b;f++){
							sb.append(".");
						}
						for (int g=1;g<b;g+=2){
							sb.replace(g,g+1,"#");
						}
					}
					System.out.println(sb);
					sb=new StringBuilder("");
				}
			a=n.nextInt();b=n.nextInt();
			System.out.println(sb);
		}
	}
}

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

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

    int count = 0,t=0;

    if(s.size() % 2 == 0){
        while(count < s.size()){
            if(s[count] == 'h' && s[count+1] == 'i') count = count +2;
            else {
                t=1;break;
            }
        }

        if(t==0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else{
        cout << "No" <<endl;
    }

}


Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a==c)
	{
		cout<<"No";
		return 0;
	}
	if(a==b||a==c||b==c)
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3072
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
L=[]
for i in range(m):
    bc=list(map(int,input().split()))
    L.append(bc)
L=sorted(L,key=lambda x:x[1],reverse=True)

import bisect
star=0
ans=0
for l in L:
    ind=bisect.bisect_left(a,l[1],star,n)
    if ind>star+l[0]:
        star += l[0]
        ans += l[0]*l[1]
    else:
        ans += (ind-star)*l[1]
        star=ind
        break
ans += sum(a[star:n])
    
print(ans)

Measured memory_bytes: 33740
import math
N = int(input())
A = [list(map(int,input().split())) for _ in range(N-1)]
A.insert(0,0)
for i in range(1,N):
    C,S,F = A[i]
    T = S+C
    j = i+1
    while j<N:
        C,S,F = A[j]
        T = max(S,math.ceil(T/F)*F)
        T += C
        j += 1
    print(T)
print(0)

Measured memory_bytes: 74252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    ll x;
    cin>>x;
    
    ll sum=0,ans=1;
    while(1){
        sum+=ans;
        if(x<=sum){
            cout<<ans<<endl;
            return 0;
        }
        ans++;
    }

}



Measured memory_bytes: 3532