akhauriyash/Code-Regression huggingface dataset:
import math
input = input().split()
r = int(input[0])
g = int(input[1])
b = int(input[2])
N = int(input[3])

count = 0
# print(N/r)
# print(math.ceil(N/r))
for x in range(math.ceil(N/r+0.0001)):
    for y in range(math.ceil((N-x*r)/g + 0.0001)):
        # print(str(x), str(y))
        if  (N - x*r - y*g) % b == 0:
            count +=1

print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <numeric>
#include <cmath>

#define rep(i, n) for(int i = 0;i < (int)(n); i++)
#define pb push_back
typedef long long ll;

using namespace std;

int main() {
    ll n , k;
    cin >> n >> k;
    vector<pair<ll,ll>> v;
    rep(i, n){
        ll ta, tb;
        cin >> ta >> tb;
        v.pb(make_pair(ta,tb));
    }
    sort(v.begin(),v.end(),[](const std::pair<ll,ll> &left, const std::pair<ll,ll> &right) {
        return left.first < right.first;
    });
    ll sum = 0;
    rep(i, n){
        if(k <= sum + v[i].second){
            cout << v[i].first << endl;
            break;
        }
        sum += v[i].second;
    }
    return 0;
}


Measured memory_bytes: 2420
(let* ((n (read))
    (*hash* (make-hash-table :test 'equal :size n))
    (a 1)
    (ans (make-array 1 :fill-pointer 0 :adjustable t :fill-pointer 0)))
    (loop for i below n do
        (let ((s (read)))
            (if (gethash s *hash*)
                (progn
                (incf (gethash s *hash*))
                    (if (< a (gethash s *hash*))
                        (incf a)
                    )
                )
                (setf (gethash s *hash*) 1)
            )
        )
    )
    (loop for key being each hash-key of *hash*
        using (hash-value value) when (= value a) 
        do
            (vector-push-extend key ans)
    )
    (setf ans (sort ans #'string<))

    (loop for j below (length ans) do
        (format t "~(~A~)~%" (aref ans j))
    )
)

Measured memory_bytes: 108788
str1 = input().split(" ")
h = int(str1[0])
w = int(str1[1])
d = int(str1[2])
res = [0 for i in range(90001)]
px = [0 for i in range(90001)]
py = [0 for j in range(90001)]
for i in range(h):
    str2 = input().split(" ")
    for j in range(w):
        px[int(str2[j])] = i
        py[int(str2[j])] = j

for i in range(d+1, h*w+1):
    res[i] = res[i - d] + abs(px[i] - px[i - d]) + abs(py[i] - py[i - d])
q = int(input())
for i in range(q):
    str3 = input().split(" ")
    print(res[int(str3[1])] - res[int(str3[0])])



Measured memory_bytes: 9432
#include <iostream>

using namespace std;

int main(void){

string S;

    cin >> S;
            if (S == "SUN")
        {
             cout << "7" << endl;
        }
        if (S == "MON")
        {
             cout << "6" << endl;
        }
        if (S == "TUE")
        {
             cout << "5" << endl;
        }
        if (S == "WED")
        {
             cout << "4" << endl;
        }
        if (S == "THU")
        {
             cout << "3" << endl;
        } 
        if (S == "FRI")
        {
             cout << "2" << endl;
        }
        if (S == "SAT")
        {
             cout << "1" << endl;
        } 

    
}

Measured memory_bytes: 256
base1 = 1009
base2 = 1013
mask = (1 << 32) - 1
def calc_hash(f, r, c):
    global ph, pw, h
    tmp = [[0] * c for _ in range(r)]
    dr, dc = r - ph, c - pw
    # t1 = 1
    t1 = (base1 ** pw) & mask
    # for _ in range(pw):
        # t1 = (t1 * base1) & mask
    for i in range(r):
        e = 0
        for j in range(pw):
            e = e * base1 + f[i][j]
        for j in range(dc):
            tmp[i][j] = e
            e = (e * base1 - t1 * f[i][j] + f[i][j + pw]) & mask
        tmp[i][dc] = e
    t2 = 1
    for _ in range(ph):
        t2 = (t2 * base2) & mask
    for j in range(dc + 1):
        e = 0
        for i in range(ph):
            e = e * base2 + tmp[i][j]
        for i in range(dr):
            h[i][j] = e
            e = (e * base2 - t2 * tmp[i][j] + tmp[i + ph][j]) & mask
        h[dr][j] = e
th, tw = map(int, input().split())
t = tuple(tuple(ord(c) for c in input()) for _ in range(th))
ph, pw = map(int, input().split())
p = tuple(tuple(ord(c) for c in input()) for _ in range(ph))
ans = []
if th >= ph and tw >= pw:
    h = [[0] * tw for _ in range(th)]
    calc_hash(p, ph, pw)
    key = h[0][0] & mask
    calc_hash(t, th, tw)
    for i in range(th - ph + 1):
        for j in range(tw - pw + 1):
            if h[i][j] & mask == key:
                ans.append(f"{i} {j}")
if ans:
    print("\n".join(a for a in ans))


Measured memory_bytes: 92008
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]


N, M = lmi()
B = lmi()

limit = sum(B)/4/M
if len(list(filter(lambda v:v>=limit,B))) >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
using namespace std;
static const int MAX = 1e+5 + 1;

int a[MAX];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        scanf("%d", &a[i+1]);
    }

    int cnt = 0;
    for (int i = 1; i <= N; i++) {
        if (i == a[a[i]]){
            cnt++;
            a[i] = -1;
        }
    }


    cout << cnt << '\n';
}


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

int main() {
  int N;
  cin >> N;
  string W;
  set<string> words;
  cin >> W;
  char start{W[W.length() - 1]};
  words.insert(W);
  bool ans{true};
  for (int i{1}; i < N; ++i) {
    cin >> W;
    if (W[0] != start || words.find(W) != words.end()) {
      ans = false;
      break;
    }
    start = W[W.length() - 1];
    words.insert(W);
  }

  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <fstream>
#include <numeric>
#define ll long long 
#define pb push_back
#define INF (ll)1e18
#define IINF (int)1e9 
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);   
#define MOD 1000000000 + 7
#define F first 
#define S second
#define sp << " " << 
/*rrrohan*/ 
using namespace std; 
 
/*less than or equal to -> l + r + 1*/
ll gcd(ll a, ll b) //O(log(a+b))
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}  
/*class dsu{
private: 
	vector <int> r,p; 
public: 
	dsu(int n){
		p.resize(n+1);
		r.resize(n+1);  
		for(int i = 0; i < n+1; i++){
			p[i] = i; 
			r[i] = 0; 
		}
	}
	int findset(int i){
		return (p[i] == i) ? i : (p[i] = findset(p[i])); 
	}
	bool issameset(int a, int b){
		return findset(a) == findset(b); 
	}
	void unionset(int i, int j){
		if(!issameset(i,j)){
			int x = findset(i), y = findset(j); 
			if(r[x] > r[y]){
				p[y]  = x; 
			}else{
				p[x] = y; 
				if(r[x] == r[y]){
					r[y]++; 
				}
			}
		}
	}
};
*/ 


int main(){
	int n; 
	cin >> n; 
	ll arr[n]; 
	for(int i = 0; i < n; i++){
		cin >> arr[i]; 
	}
	ll l[n]; 
	ll r[n];
	l[0] = arr[0], r[n-1] = arr[n-1]; 
	for(int i = 1; i < n; i++){
		l[i] = gcd(l[i-1], arr[i]); 
	}
	for(int i = n-2; i >= 0; i--){
		r[i] = gcd(arr[i], r[i+1]); 
	}
	ll mx = 0; 
	if(n > 2){
		for(int i = 1; i < n-1; i++){
			mx = max(mx,gcd(l[i-1],r[i+1])); 
		}
		mx = max(mx, r[1]); 
		mx = max(mx, l[n-2]); 
		cout << mx; 
	}else if(n==2){
		cout << max(arr[0], arr[1]); 
	}else cout << arr[0]; 
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

set<int> st[26];

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

    REP(i,26) {
      st[i].clear();
      st[i].insert(n);
    }

    REP(i,n) {
      st[s[i]-'a'].insert(i);
    }

    int Q;
    cin>> Q;
    while(Q--) {
      int x;
      input(x);
      if (x == 1) {
        int i;
        char c;
        scanf("%d %c", &i, &c);
        i--;
        st[s[i]-'a'].erase(i);
        st[c-'a'].insert(i);
        s[i] = c;
      } else {
        int l,r;
        input(l,r);
        l--;
        int ans = 0;
        REP(i,26) {
          if (*st[i].lower_bound(l) < r) ans++;
        }
        printf("%d\n", ans);
      }
    }
  }
}


Measured memory_bytes: 24196
// Coded by Yash Pradhan
// bit.ly/yashpradhan

#include<iostream>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
typedef long long ll;

using namespace std;

void solve()
{
    ll n;
    cin>>n;
    ll pro = 1;
    bool stopcomp = false;
    for(int i=0;i<n;++i)
    {
        ll x;
        cin>>x;
        if(x==0)
        {
            cout<<0<<endl;
            return;
        }
        
        if(x > (ll)1e18/pro)
        {
            stopcomp = true;
        }

        if(stopcomp)
        {
            continue;
        }

        pro*=x;

        if(pro>(ll)1e18)
        {
            stopcomp = true;
        }
    }
    if(stopcomp)
    {
        cout<<-1<<endl;
    }
    else
    {
        cout<<pro<<endl;
    }
    
}

int main()
{
    fastio
    solve();
}


Measured memory_bytes: 3652
function main(a){
	a = a.split("\n");
	a=stn(a);
	op(((a[0]+a[1])*a[2])/2);
}
function op(a){
	console.log(a);
}
function stn(a){
		return a.map(function(x){return parseInt(x,10);});
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  ll ret = 0;
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    int cur = i;
    while(cur<=n){
      ret += cur;
      cur += i;
    }
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

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

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

    string u;
    cin>>u;

    if(u==s) n-=1;
    else m-=1;

    cout<<n<<" "<<m<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		int[] NM = readLineInt();
		int N = NM[0];
		
		long ans = 0;
		for(int i=1;i<=N;i++) {
			for(int j=1;j<=N;j++) {
				for(int k=1;k<=N;k++) {
					ans+=gcd(i,gcd(j,k));
				}
			}
		}
		
		print(ans);
	}
	
	//functions here
	//note that all methods should be STATIC
	
	static int[][] GCD = new int[200][200];
	private static int gcd(int x, int y) {
		if(x>y) {
			int z = y;
			y = x;
			x = z;
		}
		if(GCD[x-1][y-1]==0) {
			if(y%x==0) {
				return GCD[x-1][y-1] = x;
			}
			int max = 1;
			for(int i=2;i*2<=x;i++) {
				if(x%i==0&&y%i==0) {
					max = i;
				}
			}
			return GCD[x-1][y-1] = max;
		}else {
			return GCD[x-1][y-1];
		}
	}

	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static int[] sort(int[] base) {
		int[] copy = array_copy(base);
		Arrays.sort(copy);
		return copy;
	}
	private static int[] array_copy(int[] base) {
		int[] copy = new int[base.length];
		for(int i=0;i<base.length;i++) {
			copy[i] = base[i];
		}
		return copy;
	}
	private static int[] asArray(ArrayList<Integer> ints) {
		int[] intlist = new int[ints.size()];
		for(int i=0;i<intlist.length;i++) {
			intlist[i] = ints.get(i);
		}
		return intlist;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


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

int main() {

	int a, b; cin >> a >> b;
	int ans = -1;
	for (int i = 1; i <= 1100; i++) {
		int x = i * 0.08;
		int y = i * 0.1;
		if (x== a && y== b) {
			ans = i;
			break;
		}
	}	
	cout << ans << endl;
    return 0;
}

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

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

    if (a[0] == 'H') {
        cout << b[0] << endl;
    }
    else {
        if (b[0] == 'H') {
            cout << "D" << endl;
        }
        else {
            cout << "H" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
L = []
d = {}
for _ in range(n-1):
    a, b = map(int, input().split())
    L.append((a, b))
    if a not in d:
        d[a] = [b]
    else:
        d[a].append(b)
k = 0
for i in d.keys():
    tmp_k = len(d[i]) if i == 1 else len(d[i]) + 1
    k = max(k, tmp_k)
print(k)
key = sorted(d.keys())
dd = {1: 0}
ans = {}
for i in key:
    v = d[i]
    cnt = 1
    for j in v:
        if cnt != dd[i]:
            c = cnt
            cnt += 1
        else:
            c = cnt + 1
            cnt += 2
        ans[(i, j)] = c
        dd[j] = c
for a, b in L:
    print(ans[(a, b)])


Measured memory_bytes: 49144
using System;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		int a = int.Parse(Console.ReadLine());
		// スペース区切りの整数の入力
		int b = int.Parse(Console.ReadLine());
		int c = 0;
		// 文字列の入力
		//出力
         
  			if(a==1){
              if(b==2) c=3;
              	else c=2;
                    }
			if(a==2){
              if(b==3) c=1;
              	else c=3;
                    }
  			if(a==3){
              if(b==1) c=2;
              	else c=1;
                    }  
		Console.WriteLine(c);
	}
}

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

int main(void){
	double x1,x2,y1,y2;
	cin>>x1>>y1>>x2>>y2;
	cout<<setprecision(10)<<sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))<<endl;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
#define print(x) cout<<'>'<<#x<<':'<<x<<endl;
#define F first
#define S second
const int mod=1000000007;

void solve(){
    int n,m;
    cin>>n>>m;
    int s[m];char c[m];
    string num="";
    for (int i=0;i<n;i++)num+="0";
    for (int i=0;i<m;i++)cin>>s[i]>>c[i];
    for (int i=0;i<m;i++){
        if ((c[i]=='0')&&(s[i]==1)){
            if (n>1){cout<<-1<<endl;return;}
            else {cout<<0<<endl;return;}
        }
        if (num[s[i]-1]!=c[i]){
            if (num[s[i]-1]!='0'){
                cout<<-1<<endl;
                return;
            }else{
                num[s[i]-1]=c[i];
            }
        }
    }if (num[0]=='0'){
        if (n==1){cout<<0<<endl;return;}
        else num[0]='1';
    }cout<<num<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    solve();

    return 0;
}


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

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

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

    int ans = INT_MAX;
    for (int i = 1; i < 101; i++)
    {
        int i_min = 0;
        for (int j = 0; j < n; j++)
        {
            i_min += pow(x[j] - i, 2);
        }
        ans = min(ans, i_min);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
x = gets.to_i
t = x % 100
while t >= 5
    x -= 105
    t -= 5
end
while t >= 4
    x -= 104
    t -= 4
end
while t >= 3
    x -= 103
    t -= 3
end
while t >= 2
    x -= 102
    t -= 2
end
while t >= 1
    x -= 101
    t -= 1
end
if x >= 0 && t == 0
    puts 1
else
    puts 0
end


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    int H[100];
    int a=1;
    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>H[i];
    }
    for(int k=2;k<=N;k++){
    static int Hmax=H[1];
    if(Hmax<=H[k]){
        Hmax=H[k];
        a+=1;
        }
    }
    cout<<a<<endl;
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N;
  cin >> N;
  vec<ll> t(N + 1), x(N + 1), y(N + 1);
  t[0] = x[0] = y[0] = 0;
  REP1(i, N) cin >> t[i] >> x[i] >> y[i];

  FOR(i, 0, N) {
    const ll u = t[i + 1] - t[i];
    const ll d = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (d > u || abs(u - d) & 0x01) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 5472
//IIT Kanpur FacelessMen India
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif
int ct[N];
int main(){
  // freopen("product.in","r",stdin);
  // freopen("product.out","w",stdout);
  int n,m; 
  scanf("%d%d",&n,&m);
  REP(i,m){
    int x,y; scanf("%d%d",&x,&y);x--;y--;
    ct[x]++;ct[y]++;
  }
  int fl=1;
  REP(i,n) if(ct[i]%2) fl=0;
  if(fl) printf("YES\n"); else printf("NO\n");
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int h,w,k;
    cin >> h >> w >> k;
    vector< vector<char> > a(h, vector<char>(w));
    vector< vector<int> > ans(h, vector<int>(w,0));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> a[i][j];
        }
    }
    //hw
    int nowcake=1;
    int pastcount=0;
    for(int i=0; i<h; i++){
        if(i!=0 && pastcount!=0)nowcake++;
        int nextcount=0;
        int nowcount=0;
        for(int j=0; j<w; j++){
            if(a[i][j]=='#')nextcount++;
        }
        pastcount=nextcount;
        if(nextcount==0)continue;
        for(int j=0; j<w; j++){
            if(a[i][j]=='#'&&nowcount==0){
                nowcount++;
            }
            else if(a[i][j]=='#'){
                nowcake++;
                nowcount++;
            }
            ans[i][j]=nowcake;
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int k=0;
            if(i==0 && ans[i][j]==0){
                while(ans[i+k][j]==0)k++;
                ans[i][j]=ans[i+k][j];
            }else if(ans[i][j]==0){
                ans[i][j]=ans[i-1][j];
                while(ans[i-k][j]==0)k--;
                ans[i][j]=ans[i-k][j];
            }
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w-1; j++){
            cout << ans[i][j] << " ";
        }
        cout << ans[i][w-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
import sys

list1=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
for line in sys.stdin:
	print(list1[int(line)-1])

Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
int main() {
	int a[5];
	scanf("%d %d %d", &a[0],&a[1],&a[2]);
	std::sort(a, a + 3);
	printf("%d %d %d\n", a[0], a[1], a[2]);
	return 0;
}

Measured memory_bytes: 2768
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def merge(N, modulo, A, B):
    C = [[0]*N for _ in range(N)]
    for i in range(N):
        for j in range(N):
            for j0 in range(N):
                C[i][j] = (C[i][j]+A[i][j0]*B[j0][j])%modulo
    return C


def solve():
    """
    OPT[k][i][j] - number of ways from i to j in K step
    OPT[1] = A

    OPT[k] = 
    """
    N, K = read_ints()
    A = []
    modulo = 10**9+7
    for _ in range(N):
        A.append(read_ints())
    def opt(k):
        if k == 1:
            return A
        half = opt(k//2)
        answer = merge(N, modulo, half, half)
        if k%2 == 1:
            answer = merge(N, modulo, answer, A)
        return answer
    return sum(c for row in opt(K) for c in row)%modulo


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 42460
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,d,e,f,g,h,p=100,i,n=1;
    cin>>a;
    while(1)
    {
        i=p/100;
        b=p+i;
        p=p+i;
        n++;
        if(b>=a)
        {
            cout<<n-1<<endl;
            break;
        }

    }

}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define ll long long
using namespace std;

int main()
{
	int n, k;
	cin >> n;
	priority_queue<pair<int, int>> que;
	pair<int, int> tmp;

	for (int i = 0; i < n; i++) {
		cin >> tmp.first;
		tmp.first *= -1;
		tmp.second = i + 1;
		que.push(tmp);
	}

	while (!que.empty()) {
		printf("%d ", que.top().second);
		que.pop();
	}



	return 0;
}




Measured memory_bytes: 1780
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
using namespace std;

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end());
#define fill(a,x) memset(a,x,sizeof(a))
#define zero(a) fill(a,0)
#define minus(a) fill(a,-1)
#define dbg(x) cout << #x"=" << x << endl

const int INF=INT_MAX/3;
const int LIMIT=100;

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

ll n;
ll a,b;

int main(){
  cin>>n>>a>>b;
  if(a==b) cout<<1<<endl;
  else if(a>b) cout<<0<<endl;
  else if(n==1) cout<<0<<endl;
  else cout<<(b-a)*(n-2)+1<<endl;
  return 0;
}

Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n;
    cin>>n;

    int cur=100;
    for(int i=1;;++i)
    {
        cur=cur+cur/100;

        if(cur>=n)
        {
            cout<<i;
            return;
        }
    }
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3624
def gcd(x, y):
    x, y = max(x, y), min(x, y)
    if y == 0:
        return x
    return gcd(y, x % y)


if __name__ == "__main__":
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    max_a = max(a)
    while len(a) > 1:
        tmp = gcd(a.pop(), a.pop())
        a.append(tmp)

    if k % a[0] == 0:
        ans = "POSSIBLE"
    else:
        ans = "IMPOSSIBLE"
    if k > max_a:
        ans = "IMPOSSIBLE"
    print(ans)


Measured memory_bytes: 14096
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var t = new long[n];
            var a = new long[n];

            for (var i = 0; i < n; i++)
            {
                var tmp = Console.ReadLine().Split().Select(long.Parse).ToArray();
                t[i] = tmp[0];
                a[i] = tmp[1];
            }

            long curT = 1, curA = 1;
            for (var i = 0; i < n; i++)
            {
                long max = Math.Max(curT / t[i] + (curT % t[i] != 0 ? 1 : 0), curA / a[i] + (curA % a[i] != 0 ? 1 : 0));
                curT = max * t[i];
                curA = max * a[i];
            }

            Console.WriteLine(curT + curA);
        }
    }
}


Measured memory_bytes: 13372
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;

LL a[N];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);

    LL ans1=0,sum1=0;
    LL ans2=0,sum2=0;
    if(a[1]>0){
        sum1=a[1];
        sum2=-1;
        ans2=a[1]+1;
    }
    else if(a[1]==0){
        sum1=1;
        ans1=1;
        sum2=-1;
        ans2=1;
    }
    else{
        sum1=1;
        sum2=a[1];
        ans1=llabs(a[1])+1;
    }

    for(int i=2;i<=n;i++){
		if(sum1>0){
			if(a[i]+sum1>=0){
				ans1+=a[i]+sum1+1;
				sum1=-1;
			}
			else
				sum1+=a[i];
		}
		else{
			if (a[i]+sum1<=0){
				ans1+=llabs(sum1+a[i])+1;
				sum1=1;
			}
			else
				sum1 += a[i];
		}
	}
	if(sum1==0)
		ans1++;

    for(int i=2;i<=n;i++){
        if(sum2>0){
            if(a[i]+sum2<0)
                sum2+=a[i];
			else{
				ans2+=a[i]+sum2+1;
				sum2=-1;
			}
        }
        else {
            if(a[i]+sum2>0)
                sum2+=a[i];
            else{
				ans2+=llabs(sum2+a[i])+1;
				sum2=1;
			}
        }
    }
    if(sum2==0)
        ans2++;



    LL res=min(ans1,ans2);
    printf("%lld\n",res);
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <functional>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
  int X, A;
  cin >> X >> A;
  if(X<A) cout << 0 << endl;
  else cout << 10 << endl;
  return 0;
}


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

int main(){
    int n,m;
    long long ans=0;
    cin >> n >> m;
    vector< pair<long long,long long> > AB(n);
    for(int i=0;i<n;i++){
        int a,b;
        cin >> a >> b;
        AB[i] = make_pair(a,b);
    }
    sort(AB.begin(),AB.end());
    for(int i=0;;i++){
        if(AB[i].second>=m){
            ans += AB[i].first*m;
            cout << ans << endl;
            return 0;
        }
        ans += AB[i].first * AB[i].second;
        m -= AB[i].second;
    }
}

Measured memory_bytes: 1792
s = input()
ans=[]
for i in range(len(s)):
    if s[i]!='A':
        ans+=s[i]

if ''.join(ans)=='KIHBR' and len(s)<=9 and 'AA' not in s and 'AAA' not in s and 'AAAA' not in s and 'KIH' in s:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9016
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
string s;

string rev(string ori){
	string ss=ori;
	int j=ori.length()-1;
	for (int i=0;i<s.length();i++){
		ss[i]=ori[j];j--;
	}
	return ss;
}

int main(){
	cin>>s;
	string s2=s;
	string s3=rev(s);
	for (int i=0;i<s.length();i++){
		if(s2[i]=='b') {s2[i]='d';continue;}
		if(s2[i]=='d') {s2[i]='b';continue;}
		if(s2[i]=='p') {s2[i]='q';continue;}
		if(s2[i]=='q') {s2[i]='p';continue;}
	}
	string s4=rev(s2);
	//cout<<s2<<endl<<s3<<endl<<s4<<endl;
	if(s2==s||s3==s||s4==s) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll a[1000005];
int n, ans;
int main()
{
	cin >> n;
	for(int i = 0; i < n; i ++) 
		cin >> a[i];
	sort(a, a + n);
	for(int i = 0; i < n; i ++) 
	{
		a[i] += a[i - 1];
		ans ++;
		if(a[i] * 2 < a[i+1])
			ans=0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4420
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 4e5 + 5, mod = 1e9 + 7;

ll n, m;
pair<int, int> p[N];
vector<int> group[N];
ll vis[N], ans[N], cnt;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // cout << p[5].second << '\n';
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        cin >> p[i].first >> p[i].second;
    }
    ans[m] = n * (n - 1) / 2;
    set<int> st;
    for(int i = m; i >= 2; i--){
        int u, v;
        u = vis[p[i].first];
        v = vis[p[i].second];
        if(u && v){
            ll sz = group[v].size(), sz2 = group[u].size();
            if(u == v){
                ans[i-1] = ans[i];
                continue;
            }
            if(group[u] < group[v]){
                swap(u, v);
            }
            for(auto j: group[v]){
                group[u].push_back(j);
                vis[j] = u;
            }
            ll sum = sz + sz2;
            ll val1 = sz * (sz - 1) / 2;
            ll val2 = sz2 * (sz2 - 1) / 2;
            ans[i - 1] = ans[i] - ((sum - 1) * sum / 2 - val1 - val2);
        }
        else if(u && !v){
            group[u].push_back(p[i].second);
            vis[p[i].second] = u;
            st.insert(p[i].second);
            ans[i - 1] = ans[i] - (group[u].size() - 1);
        }
        else if(!u && v){
            group[v].push_back(p[i].first);
            vis[p[i].first] = v;
            st.insert(p[i].first);
            ans[i - 1] = ans[i] -(group[v].size() - 1);
        }
        else{
            st.insert(p[i].first);
            st.insert(p[i].second);
            vis[p[i].first] = vis[p[i].second] = ++cnt;
            group[cnt].push_back(p[i].first);
            group[cnt].push_back(p[i].second);
            ans[i - 1] = ans[i] - 1;
        }
    }
    for(int i = 1; i <= m; i++){
        cout << ans[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 26552
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	ll a, b, k;
	cin >> a >> b >> k;


	if (a >= k)cout << a - k << " " << b << endl;
	else {
		ll c = k - a;
		if (c < b) {
			cout << 0 << " " << b - c << endl;
		}
		else {
			cout << 0 << " " << 0 << endl;
		}
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/algorithm/string/join.hpp>
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;
using boost::algorithm::join;

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int N;
  cin >> N;

  int e = N/2;
  int o = (N+1)/2;

  cout << double(o)/double(N) << endl;

  return 0;
}


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

vector<vector<long long>> warshall_floyd(vector<vector<long long>> graph) {
    for (int k = 0; k < graph.size(); k++){
        for (int i = 0; i < graph.size(); i++) {
            for (int j = 0; j < graph.size(); j++) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
    return graph;
}

int main(void){
    ll n, m, l;
    cin >> n >> m >> l;
    vector<vector<ll>> rinsetu(n, vector<ll>(n, INF));
    rep(i, n) rinsetu[i][i] = 0;
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        rinsetu[a-1][b-1] = c;
        rinsetu[b-1][a-1] = c;
    }
    
    vector<vector<ll>> saitan_kero = warshall_floyd(rinsetu);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (saitan_kero[i][j] <= l)
                saitan_kero[i][j] = 1;
            else
                saitan_kero[i][j] = INF;
        }
    }
    vector<vector<ll>> ans = warshall_floyd(saitan_kero);
    
    int q;
    cin >> q;
    for(int i = 0; i < q; i++) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        if (ans[s][t] != INF)
            cout << ans[s][t]-1 << endl;
        else
            cout << -1 << endl;
    }
}


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

int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;

  if (a1 + a2 + a3 >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

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

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

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

template <class T>
struct BIT {
    int n;
    vector<T> bit;

    BIT(int _n = 0) : n(_n), bit(n + 1) {}

    // sum of [0, i), 0 <= i <= n
    T sum(int i) {
        T s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    // 0 <= i < n
    void add(int i, T x) {
        ++i;
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }

    //[l, r) 0 <= l < r < n
    T sum(int l, int r) { return sum(r) - sum(l); }
};

int main() {
    int N, M;
    cin >> N >> M;
    V<pii> vec(N);
    rep(i, N) {
        int l, r;
        cin >> l >> r;
        vec[i] = mp(r - l + 1, l);
    }
    sort(ALL(vec));
    int pt = 0;
    BIT<int> T(M + 10);
    for (int d = 1; d <= M; ++d) {
        while (pt < N && vec[pt].fi <= d) {
            int l = vec[pt].se;
            int r = vec[pt].fi + vec[pt].se;
            T.add(l, 1);
            T.add(r, -1);
            pt++;
        }
        int ans = N - pt;
        for (int k = d; k <= M; k += d) {
            ans += T.sum(k + 1);
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
signed main(signed argc, char* argv[]) {
    int n,m;
    cin>>n>>m;
    vector<int> x(n),y(m);
    rep(i,n)cin>>x[i];
    rep(i,m)cin>>y[i];
    int x_sum=0,y_sum=0;
    rep(i,n-1){
        x_sum=(x_sum+(x[i+1]-x[i])*(n-i-1)%1000000007*(i+1)%1000000007)%1000000007;
    }
    rep(i,m-1){
        y_sum=(y_sum+(y[i+1]-y[i])*(m-i-1)%1000000007*(i+1)%1000000007)%1000000007;
    }
    cout<<y_sum*x_sum%1000000007<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

  if (x == 1 || x == 2 * N - 1) {
    cout << "No" << endl;
    return 0;
  }
  vector<int> a(2 * N - 1, 0);

  int i = N - 1, k = x - 1;
  for (int j = 0; j < (int)(2 * N - 1); ++j) {
    a[i] = k + 1;
    k = (k + 1) % (2 * N - 1);
    i = (i + 1) % (2 * N - 1);
  }

  cout << "Yes" << endl;
  for (int i = 0; i < (int)(2 * N - 1); ++i) cout << a[i] << endl;
  return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

template<typename T1, typename T2>
ostream& operator <<(ostream &out, const pair<T1, T2> &item) {
	out << '(' << item.first << ", " << item.second << ')';
	return out;
}

template <typename T>
ostream& operator <<(ostream &out, const vector<T>& v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	int k;
	vector<int> v = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	cin >> k;
	cout << v[k - 1] << '\n';

	return 0;
}



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

int main(){
	int n,m;
	int t[n],p[n],x[n];
	int sum=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>t[i];
		sum+=t[i];
	}
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>p[i]>>x[i];
	}
	for(int i=0;i<m;i++){
		int ans=sum-t[p[i]-1]+x[i];
		cout<<ans<<endl;
	}
}		

Measured memory_bytes: 4352
import sys
from collections import deque

H, W = map(int, input().split())
S = [input() for a in range(H)]
dy = [1, 0, -1, 0]
dx = [0, 1, 0, -1]

answer = 0

for s_y in range(H):
  for s_x in range(W):
    if S[s_y][s_x] == '.':
      d = [[ 0 for b in range(W)] for a in range(H)]
      e = [[ 0 for b in range(W)] for a in range(H)]
      q = deque([[s_y, s_x]])
      e[s_y][s_x] = 1
      while len(q) > 0:
        y, x = q.popleft()
        for i in range(4):
          ny = y + dy[i]
          nx = x + dx[i]
          if 0 <= nx and nx <= W-1 and 0 <= ny and ny <= H-1 and S[ny][nx] == '.' and e[ny][nx] == 0:
            q.append([ny, nx])
            d[ny][nx] = d[y][x]+1
            e[ny][nx] = 1
      for i in range(H):
        answer = max(answer, max(d[i]))
print(answer)

Measured memory_bytes: 3316
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=S()
  n=len(s)
  ls=list(s)

  f=True
  _s=copy.deepcopy(ls)
  _s.reverse()
  if _s!=ls:
    f=False

  ls2=ls[:(n-1)//2]
  _ls2=copy.deepcopy(ls2)
  _ls2.reverse()

  if ls2!=_ls2:
    f=False

  ls3=ls[(n+3)//2-1:]
  _ls3=copy.deepcopy(ls3)
  _ls3.reverse()

  if ls3!=_ls3:
    f=False

  # print(ls,_s)
  # print(ls2,_ls2)
  # print(ls3,_ls3)

  if f:
    return 'Yes'
  return 'No'

# main()
print(main())


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong a, b;
	char c;

	cin >> a >> c >> b;

	cout << (c == '+' ? a+b : a-b) << endl;

	return 0;
}

Measured memory_bytes: 256