akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>

using namespace std;

#define ll long long
#define ull unsigned long long
const ll MOD = 1000000007;
#define rep(i,n) for (int i = 0; i < (n); ++i)

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
	int A, B, K;
	cin >> A >> B >> K;

	vector <int> div;
	for (int ii = max(A, B); ii > 0; --ii){
		if ( (A%ii==0) && (B%ii==0) ){
			div.push_back(ii);
		}
	}

	int cnt = 1;
	for (int ii = 0; ii < div.size(); ++ii){
		if (cnt==K){
			cout << div[ii] << "\n";
			break;
		}
		cnt++;
	}

	return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define debug(x) cout << "> x:" << x << endl;
#define len(x) int(x.size())
#define all(x) x.begin(), x.end()
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(){
	ios::sync_with_stdio(0);
	int a, b;
	cin >> a >> b;
	if(a>b) swap(a, b);
	int dff = b-a;
	if(dff%2==1) cout << "IMPOSSIBLE\n";
	else cout << a+(dff)/2 << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

class Main {
    public static void main (String[] args) {
        Scanner scan_ = new Scanner(System.in);
        int a_ = scan_.nextInt();
        int b_ = scan_.nextInt();
      
        int d_ = a_/b_;
        int r_ = a_%b_;
        Number f_ = (1.0*a_)/(1.0 * b_);
       
       //BigDecimal d_ =new BigDecimal( (1.0 * a_) /(1.0 *  b_));
       // d_ = d_.setScale(5);
        System.out.println(d_ + " " + r_ + " " + String.format("%.8f", f_));
    }
}


Measured memory_bytes: 26612
n,m = map(int,input().split())
mod = 10**9+7
d = m-n
#mPn
p = 1
for i in range(n):
  p *= m-i
  p %= mod
dp = [0,1]
for i in range(n):
  tmp = dp[-2]*i + dp[-1]*(i+d)
  tmp %= mod
  dp.append(tmp)
#print(dp)
p *= dp[-1]
p %= mod
print(p)

Measured memory_bytes: 102508
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

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

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
//ブロック2×4 
int w,h;//ボードの横,縦
int xs,ys;//スタートの座標
int xg,yg;//ゴールの座標
int n;//ブロックの個数
int c,d;//ブロックの色,ブロックの向き,ブロックの位置x,y

int board[102][102];

bool dfs(int x,int y,int color){
  if(color ==0 ||board[x][y] !=color)
    return false;
  if(x ==xg&&y ==yg)
    return true;
  board[x][y] = 0;
  for(int i = 0 ;i < 4;i++){
    if(x +dx[i] <=0 || x+dx[i]>w || y+dy[i] <=0 ||y +dy[i] >h)
      continue;
    if(dfs(x+dx[i],y+dy[i],color))
      return true;
  }
  return false;
}

int main(){
  while(scanf("%d %d",&w,&h)){
    if(w==0&&h==0)
      break;
    cin>>xs>>ys>>xg>>yg>>n;
    for(int i = 0;i < n;i++){
      int x,y;
      cin >>c>>d>>x>>y;
      int W,H;
      if(d ==0){
	W =4;
	H =2;
      }else{
	W = 2;
	H = 4;
      }
      for(int i = 0;i < H;i++){
	for(int j = 0;j < W;j++){
	  board[j+x][i+y] =c;
	}
      }
  }
    cout<<((dfs(xs,ys,board[xs][ys]))?"OK":"NG")<<endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b, x;
  cin >> N;
  x = 0;
  
  for (int i = 0; i < N ; i++) {
    cin >> a >> b;
    x += b - a + 1;
  }
  
  cout << x << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	final static int ICHIMANEN_AMOUNT = 10000;
	final static int GOSENEN_AMOUNT = 5000;
	final static int SENEN_AMOUNT = 1000;
	
    public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int osatsuNum = scan.nextInt();
		int otoshidamaAmount = scan.nextInt();

		int ichimanenNum = osatsuNum;
		int gosenenNum = 0;
		int senenNum = 0;

		while (ichimanenNum >= 0) {
			gosenenNum = osatsuNum - ichimanenNum;
			while (gosenenNum >= 0) {
				senenNum = osatsuNum - ichimanenNum - gosenenNum;
				if (isMatch(ichimanenNum, gosenenNum, senenNum, otoshidamaAmount)) {
					System.out.print(ichimanenNum + " " + gosenenNum + " " + senenNum);
					return;	
				}
				gosenenNum--;
			}
			ichimanenNum--;
		}	
        System.out.print(-1 + " " + -1 + " " + -1);
	} 

	static boolean isMatch(int ichimanenNum,  int gosenenNum, int senenNum,  int otoshidamaAmount) {

		int calcResult = ICHIMANEN_AMOUNT * ichimanenNum + GOSENEN_AMOUNT * gosenenNum + SENEN_AMOUNT * senenNum;
		
		return calcResult == otoshidamaAmount;
	}

}


Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>

using namespace std;

long long INF = 1LL << 60;

long long dp[110][100100];

int main(){
    int N;
    long long W;
    long long weight[110], value[110];
    cin >> N >> W;
    for(int i = 0;i < N;i++){
        cin >> weight[i] >> value[i];
    }
    for(int i = 0; i < 110;i++){
        for(int j = 0;j < 100100;j++){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;

    for(int i= 0; i < N;i++){
        for(int j = 0;j < 100100; j++){
            if(j - value[i] >= 0){
                dp[i + 1][j] = min(dp[i+1][j],dp[i][j - value[i]] + weight[i]);
            }
            dp[i + 1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }
    long long Ans = 0;
    for(int i = 0;i < 100100;i++){
        if(dp[N][i] <= W){
            Ans = i;
        }
    }
    cout << Ans << endl;
}

Measured memory_bytes: 86272
#include <stdio.h>
#include <ctype.h>

void MCXI(char* mcxi,int num){                         //十進数をMCXI文字列に変換
  if(num>=1000){
    if(num>=2000)*(mcxi++)=(num/1000)+'0';             //千の位の値が2以上の場合　*mcxiの値が千の位の値と等しくなるまでインクリメント
    *(mcxi++)='m';                                     //千の位の値を表す数字の後ろにmを書き込み
    num%=1000;                                         //1000で割った余りをnumに更新　次のステップに進む
  }
  if(num>=100) {                                       //百の位の変換　理論は千の位と同じ
    if(num>=200)*(mcxi++)=(num/100)+'0';
    *(mcxi++)='c';
    num%=100;
  }
  if(num>=10) {                                        //十の位の変換　理論は千の位と同じ
    if(num>=20)*(mcxi++)=(num/10)+'0';
    *(mcxi++)='x';
    num%=10;
  }
  if(num>=1) {                                         //一の位の変換　理論は千の位と同じ
    if(num>=2)*(mcxi++)=(num/1)+'0';
    *(mcxi++)='i';
    num%=1;
  }
  *mcxi=0;                                             //*mcxiの値を0に初期化する
}

int decimal(const char* mcxi) {
  const char* nowp=mcxi;
  int num=1;
  int decimal=0;
  for(;*nowp;nowp++) {
    switch(*nowp) {
    case 'm':
      decimal+=1000*num;                               //返り値decimalに千の位の値を1000倍して加算
      num=1;                                           //numを1にリセット
      break;
    case 'c':                                          //百の位の変換　理論は千の位と同じ
      decimal+=100*num;
      num=1;
      break;
    case 'x':                                          //十の位の変換　理論は千の位と同じ
      decimal+=10*num;
      num=1;
      break;
    case 'i':                                          //一の位の変換　理論は千の位と同じ
      decimal+=1*num;
      num=1;
      break;
    default:
      if(isdigit(*nowp))num=*nowp-'0';                 //各位に前置きされた数字をnumに読み込み
    }
  }
  return decimal;                                      //変換された十進数を返り値として返す
}

int main(void) {
  int num,i;
  char MCXI_1[100],MCXI_2[100];

  struct{                                              //出力用の構造体配列
    char sum[100];
  }SUM[9999];

  scanf("%d",&num);                                    //先頭nを読み込み

  for(i=0;i<num;i++){
    scanf("%s%s",MCXI_1,MCXI_2);                       //2つのMCXI文字列を読み込み
    MCXI(SUM[i].sum,decimal(MCXI_1)+decimal(MCXI_2));  //2つのMCXI文字列をdecimal関数を使って十進数に変換
  }                                                    //MCXI関数を使ってMCXI文字列に変換　変換結果をi番目構造体配列に入れる

  for(i=0;i<num;i++){
    printf("%s\n", SUM[i].sum);                        //出力
  }

  return 0;
}

Measured memory_bytes: 780
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 20:56:26 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

S = input()

if S == 'ABC':
    print('ARC')
else:
    print('ABC')




Measured memory_bytes: 9092
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;


int f(int a, int b){
    int tmp = abs(a - b);
    int res = tmp;
    if(a > b) res += 2;
    return res;
}

signed main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    ans = min(f(a, b), min(f(-a, b) + 1, f(a, -b) + 1));
    //  ans = min(f(a, b),f(-a, b) + 1);
    
    o(ans);
}

Measured memory_bytes: 764
s = getter = -> {
   require 'stringio'
  _in = StringIO.new
  while l = gets
    _in << l
  end
  _in.string
}.call.split(/\R/)
n,l = s[0].split(/ /).map(&:to_i)
_p = s[1].split(/ /).map(&:to_i)

puts _p.min(l).sum


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

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

    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(y==i*10000+j*5000+(n-i-j)*1000&&n-i-j>=0){
                cout<<i<<" "<<j<<" "<<n-i-j<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    double pi = 3.1415926535;
    double A,B;double N,M;cin >> A >> B >> N >> M;
    double deg = abs(30.0 * N - (5.5 * M));
    if(deg > 360.0) {
        deg = 180.0 - deg;
    }
    deg = (deg*pi)/180.00;
    double ans = 0.0;
	ans = sqrt(A * A + B * B - (2.0 * A * B * cos(deg)));
    cout << fixed << setprecision(11) << ans << endl;
}

Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  kyun;
  dset(10);
  ind w,h,x,y;
  cin >> w >> h >> x >> y;
  ind S = w*h;
  S /= 2;
  bool ans = 0;
  if(2*x == w && 2*y == h) ans = 1;
  cout << S << " " << ans;
  hinata;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second
#define endl "\n"

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int n,m;
    cin>>n>>m;
    if (n%2==1){//ok
        for (int i=1;i<m+1;i++){
            cout<<i<<" "<<n-i<<endl;
        }
    }
    else{
        if (n%4==0){
            int k=n/4;
            for (int i=1;i<min(m+1,k+1);i++)cout<<i<<" "<<n-i+1<<endl;
            for (int i=k+1;i<m+1;i++)cout<<i<<" "<<n-i<<endl;
        }
        else{
            for (int i=1;i<min(m+1,(n+2)/4);i++){
                cout<<i<<" "<<n-i+1<<endl;
            }
            for (int i=(n+2)/4;i<m+1;i++){
                cout<<i<<" "<<n-i<<endl;
            }
        }
    }


    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

int x,y;
cin>>x>>y;
long long ans=0;
if(x==1 && y==1){
ans+=400000;
}
if(x==1){
ans+=300000;
}
else if(x==2){
ans+=200000;
}
else if(x==3){
ans+=100000;
}
x=y;
if(x==1){
ans+=300000;
}
else if(x==2){
ans+=200000;
}
else if(x==3){
ans+=100000;
}
cout<<ans;
 return 0;
}
/*
1 1

1000000

*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
const double EPS = 1e-9;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, D; cin >> N >> D;
    vector<int> v[N];
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < D; j++)
        {
            int x; cin >> x;
            v[i].push_back(x);
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        for(int j = i + 1; j < N; j++)
        {
            double sum = 0;
            for(int k = 0; k < D; k++)
            {
                sum += pow(v[i][k] - v[j][k], 2);
            }
            double p = sqrt(sum);
            int q = sqrt(sum);
            if(abs(p - q) < EPS) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import math

n=int(input())
D={}
for _ in range(n):
    a,b=map(int, input().split())
    if a==0 and b==0:
        key=(0,0)
    elif a==0:
        key=(0,1)
    elif b==0:
        key=(1,0)
    else:
        if a<0:
            a=-a
            b=-b
        g=math.gcd(a, abs(b))
        key=(a//g, b//g)
    if key not in D:
        D[key]=0
    D[key]+=1

mod=10**9+7
ans=1
zz=0

for k1, v1 in D.items():
    if k1==(0,0):
        zz+=v1
        continue
    if v1==0:
        continue

    if k1[1]>0:
        k2=(k1[1], -k1[0])
    else:
        k2=(-k1[1], k1[0])

    if k2 not in D:
        ans=ans*pow(2, v1, mod)%mod
    else:
        v2=D[k2]
        m=(pow(2, v1, mod)+pow(2, v2, mod)-1)%mod
        ans=ans*m%mod
        D[k2]=0

print((ans+zz-1)%mod)


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

int main(){
  int n;
  cin >> n;
  int y, m, d, t;
  for (int i = 0; i < n; ++i){
    t = 196470;
    cin >> y >> m >> d;
    t -= 195*(y-1) + 5*((y-1)/3);
    if (y%3) t -= 20*(m-1) - (m-1)/2;
    else t -= 20*(m-1);
    t -= d-1;
    cout << t << endl;
  }
}

Measured memory_bytes: 3056
A = [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]
k = int(input())
print(A[k - 1])

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


def z_algorithm(s):
    n = len(s)
    lcpls = [0] * n  # Longest common prefix length
    lcpls[0] = n

    l = r = 1
    while l < n:
        while (r < n) and (s[r - l] == s[r]):
            r += 1

        if l == r:
            l += 1
            r += 1
            continue

        lcpls[l] = r - l

        k = 1
        while (l + k < r) and (lcpls[k] < r - l - k):
            lcpls[l + k] = lcpls[k]
            k += 1
        l += k

    return lcpls


ans = 0
for i in range(N):
    X = S[i:]
    Z = z_algorithm(X)

    for j, z in enumerate(Z):
        if j >= z:
            ans = max(ans, z)

print(ans)


Measured memory_bytes: 52828
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
template<int VW, int VH> struct Ruisekiwa2D {
    int v[VH][VW];
    void set(int x, int y, int c) { v[y][x] = c; }
    void build() {
        rep(y, 0, VH) rep(x, 0, VW) {
            if (0 < y) v[y][x] += v[y - 1][x];
            if (0 < x) v[y][x] += v[y][x - 1];
            if (0 < y && 0 < x) v[y][x] -= v[y - 1][x - 1];
        }
    }
    int get(int sx, int sy, int tx, int ty) {
        assert(sx <= tx && sy <= ty);
        int rs = v[ty][tx];
        if (0 < sx) rs -= v[ty][sx - 1];
        if (0 < sy) rs -= v[sy - 1][tx];
        if (0 < sx && 0 < sy) rs += v[sy - 1][sx - 1];
        return rs;
    }
};
/*---------------------------------------------------------------------------------------------------
????????????????????????????????? ??§?????§  
??????????????? ??§?????§ ???????´<_??? ?????? Welcome to My Coding Space!
???????????? ??? ?´_???`??????/??? ???i     
?????????????????????????????? ???  |???|     
????????? /?????? /??£??£??£??£/??????|  
??? ???_(__??????/???    ???/ .| .|????????????  
??? ????????????/????????????/??????u??????  
---------------------------------------------------------------------------------------------------*/




int N;
string A[201];
Ruisekiwa2D<201, 201> rui;
//--------------------------------------------------------------------------------------------------
int f(int sx, int sy, int tx, int ty) {
    if (rui.get(sx, sy, tx, ty) == 0) return 0;

    rep(y, sy, ty + 1) rep(x, sx, tx + 1) if(y % 2 == 1) if(x % 2 == 1) {
        if (rui.get(x, sy, x, ty) == (ty - sy + 1)) if (rui.get(sx, y, tx, y) == (tx - sx + 1)) {
            int A = f(sx, sy, x - 1, y - 1);
            if (A < 0) continue;
            int B = f(x + 1, sy, tx, y - 1);
            if (B < 0) continue;
            int C = f(sx, y + 1, x - 1, ty);
            if (C < 0) continue;
            int D = f(x + 1, y + 1, tx, ty);
            if (D < 0) continue;

            return A + B + C + D + 1;
        }
    }

    return -1;
}
//--------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    rep(y, 0, N) rep(x, 0, N) if(A[y][x] == 'x') rui.set(x, y, 1);
    rui.build();

    cout << f(0, 0, N - 1, N - 1) << endl;
}

Measured memory_bytes: 3368
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

N,M = two_int()

if N==M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
    int n,m;
    scanf("%d %d",&n,&m);
    int a[n][m],b[m],c[n];
    int i;
    for(i=0;i<n;i++){
        int j;
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
    for(i=0;i<n;i++){
        c[i] = 0;
        int j;
        for(j=0;j<m;j++){
            c[i] += a[i][j] * b[j];
        }
    }
    for(i=0;i<n;i++){
        printf("%d\n",c[i]);
    }
    return 0;
}


Measured memory_bytes: 2104
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char s[15];
int main()
{
 int ans=1000;
 scanf("%s",s);
 int len=strlen(s);
 for(int i=0;i<len;i++)
  s[i]-='0';
 for(int i=2;i<len;i++)
 {
  int num=s[i-2]*100+s[i-1]*10+s[i];
  ans=min(ans,abs(num-753));
 }
 printf("%d\n",ans);
 return 0;
}

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

using namespace std;

typedef vector<int> vi;

int median(int a, int b, int c)
{
	return (a+b+c) - max(max(a,b),c) - min(min(a,b),c);
}

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

	int N, n, x;
	while(cin >> N >> x)
	{
		n = 2*N-1;
		if(x == 1 || x == n)
		{
			cout << "No" << endl;
			continue;
		}

		vi track(n,-1);
		vector<bool> use(n+1);
		if(x < N)
		{
			track[N-1] = x;
			track[N-2] = x-1;
			use[x] = use[x-1] = true;
		}
		else if(x > N)
		{
			track[N-1] = x;
			track[N] = x+1;
			use[x] = use[x+1] = true;
		}
		for(int j=0, place = 1; j<n; j++)
		{
			if(track[j] != -1)
				continue;
			while(use[place]) place++;
			track[j] = place++;
		}
		cout << "Yes\n";
		for(auto x: track)
			cout << x << '\n';
	}

	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_cxx;
#define dprint(v) cout << #v"=" << v << endl //;)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define INF (ll)1e16
#define endl '\n'
#define isin(x,y) ((y).find(x)!=(y).end())
#define forr(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

typedef pair<int,int> ii;

ll f(ll n){
switch(n%4){
case 0: return n;
case 1: return 1;
case 2: return n+1;
default: return 0;
}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
        cin>>a>>b;
        cout<<(f(a-1)^f(b))<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys

def main():
    n = sys.stdin.readline().rstrip()

    cnt = 1
    for i in range(3):
        if n[i] == n[i+1]:
            cnt += 1
            if cnt == 3:
                ans = 'Yes'
                break
        else:
            cnt = 1
    else:
        ans = 'No'
    
    print(ans)
    
if __name__ == "__main__":
    main()


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll Cost[int(1e5+5)][3], DP[int(1e5+5)][3];

int main(){
  cin >> N;
  for (int i = 1; i <= N; i++){
    for (int j = 0; j < 3; j++){
      cin >> Cost[i][j];
    }
  }

  for (int i = 1; i <= N; i++){
    for (int j = 0; j < 3; j++){
      for (int k = 0; k < 3; k++){
        if (j == k) continue;
        DP[i][j] = max(DP[i][j], DP[i-1][k] + Cost[i][j]);
      }
    }
  }

  ll ans = 0;
  for (int j = 0; j < 3; j++){
    ans = max(ans, DP[N][j]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8220
X = sorted(list(map(int, input().split())))
d1 = X[2]-X[0]
d2 = X[2]-X[1]

ans = d1//2 + d2//2
k = (d1&1) + (d2&1)
if k==2:
    ans += 1
elif k==1:
    ans += 2
print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main
{
    public static void main(String []args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        int arr[] = new int[n];
        for(int i = 0 ; i< n ; i++)
        {
            arr[i] = sc.nextInt();
        }
        long mod = 1000000007;
        long dp[][] = new long[n+1][k+1];
        for(int i = 0 ; i <= k ; i++)
        {
            dp[0][i] = 1;
        }
        
        for(int i = 1 ; i <= n ; i++)
        {
            for(int kk = 0 ; kk <= k ; kk++)
            {
                if(arr[i-1] >= kk)
                dp[i][kk] += dp[i-1][kk];
                
                else
                dp[i][kk] += dp[i-1][kk] - dp[i-1][kk-arr[i-1]-1];
                
                dp[i][kk] %= mod;
            }
            
            for(int kk = 1 ; kk <= k ; kk++)
            {
                dp[i][kk] += dp[i][kk-1];
                dp[i][kk] %= mod;
            }
        }
        if(k > 0)
        System.out.println((dp[n][k] - dp[n][k-1]+mod)%mod);
        
        else
        System.out.println(dp[n][k]);
    }
}

Measured memory_bytes: 140992
#include<bits/stdc++.h>
#define cases long long t;cin>>t;while(t--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;

int main()
{
    f_io;
    vector<ll> primes(1000001);
    foi(2,1000001)
    {
        if(!primes[i])
        {
            primes[i] = i;
            ll j = i*2;
            while(j<1000001)
            {
                primes[j] = i;
                j+=i;
            }
        }
    }
    ll n;
    cin >> n;
    vector<ll> arr(n);
    foi(0,n)
        cin >> arr[i];
    ll gcd = arr[0];
    foi(1,n)
        gcd = __gcd(gcd,arr[i]);
    if(gcd==1)
    {
        bool ck = true;
        unordered_map<ll,bool> mp;
        foi(0,n)
        {
            while(primes[arr[i]]>1)
            {
                ll x = primes[arr[i]];
                if(mp[x])
                {
                    ck = false;
                    break;
                }
                while(arr[i]%x==0)
                    arr[i]/=x;
                mp[x] = true;
            }
            if(!ck)
                break;
        }
        if(ck)
            cout << "pairwise coprime";
        else
            cout << "setwise coprime";
    }
    else
        cout << "not coprime";
    return 0;
}


Measured memory_bytes: 18768
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_pow(int base, int exp)
{
	_T ans = 1;

	for (int i = 0; i < exp; i++) {
		ans *= (_T)base;
	}
	return ans;
}

static void D();

int main()
{
	D();
	fflush(stdout);
	return 0;
}

static void D()
{
	int H, W;
	get(H, W);

	std::vector<std::string> grid(H);
	for (int i = 0; i < H; i++) {
		get(grid[i]);
	}
	
	int g1 = 0, g2 = 0, g4 = (H / 2) * (W / 2);
	if (H % 2 && W % 2) {
		g1 = 1;
		g2 = H / 2 + W / 2;
	}
	else if (H % 2) {
		g2 = W / 2;
	}
	else if (W % 2) {
		g2 = H / 2;
	}

	std::vector<int> ch(26, 0);
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			ch[grid[h][w] - 'a']++;
		}
	}

	int surp = 0;
	for (int i = 0; i < 26; i++) {
		surp = ch[i] % 4;
		if (surp % 2 && g1) {
			ch[i]--;
			g1--;
		}
	}

	for (int i = 0; i < 26; i++) {
		surp = ch[i] % 4;
		if (surp == 2 && g2) {
			ch[i] -= 2;
			g2--;
		}
	}

	if (g2 / 2) {
		g4 += g2 / 2;
		g2 -= (g2 / 2) * 2;
	}
	for (int i = 0; i < 26; i++) {
		surp = ch[i] % 4;
		if (!surp && ch[i] && g4) {
			g4 -= ch[i] / 4;
			ch[i] = 0;
		}
	}
	if (g1 || g2 || g4) {
		printf("No\n");
		return;
	}
	for (int i = 0; i < 26; i++) {
		if (ch[i]) {
			printf("No\n");
			return;
		}
	}
	printf("Yes\n");
}



Measured memory_bytes: 3656
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	n := readInt()
	for i := n; i <= 999; i++ {

		m := make(map[rune]bool)
		for _, r := range fmt.Sprintf("%d", i) {
			m[r] = true
		}
		if len(m) == 1 {
			println(i)
			return
		}
	}
}

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


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;

#pragma GCC optimize("O3")
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define fr front()
#define ba back()
#define tp top()
#define mem(x,n) memset(x,n,sizeof(x));
#define sz(x) (int)((x).size())
#define all(x) (x).begin(),(x).end()
#define foreach(it,l) for(auto it=l.begin();it!=l.end();it++)
#define pnl printf("\n")
#define len(x) x.length()

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
const int inf=(1<<30);
const LL llinf=(1ll<<60);
const double eps=(1e-10);
//const double pi=2*acos(0.0);
//const double GOLD=((1+sqrt(5))/2);
const int xx[8]={1,0,-1,0,1,-1,1,-1};
const int yy[8]={0,1,0,-1,-1,1,1,-1};

/* \( ·w·)~ Clapie ~(·w· )/ */

int main(){
	int n;
	scanf("%d",&n);
	double tot=0;
	for(int i=0;i<n;i++){
		double x;
		string str;
		cin>>x>>str;

		if(str=="JPY"){
			tot+=x;
		}
		else{
			tot+=(x*380000);
		}
	}
	printf("%lf\n",tot);
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        x: usize,
        m: usize,
    }

    let max_d = 50;
    let mut next = vec![vec![0; m]; max_d + 1];
    let mut sum = vec![vec![0u128; m]; max_d + 1];

    for r in 0..m {
        next[0][r] = r * r % m;
        sum[0][r] = r as u128;
    }

    for p in 0..max_d {
        for r in 0..m {
            //一つ上のマス(2^p先の値)が指してる列のp行目(2^p先の値)
            next[p + 1][r] = next[p][next[p][r]];
            sum[p + 1][r] = sum[p][r] + sum[p][next[p][r]];
        }
    }

    let mut ans = 0;
    let mut cur = x;
    for p in (0..=max_d).rev() {
        if (n & (1usize << p)) != 0 {
            ans += sum[p][cur];
            cur = next[p][cur];
        }
    }
    println!("{}", ans);
}


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

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    int N; cin >> N;
    for( int i = 1; i <= 50000; i++ ){
        if( floor( i * 1.08 ) == N ){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

/*
38

*/

Measured memory_bytes: 256
H, W = map(int, input().split())
#field = [list(input()) for _ in range(H)]
field = []
for _ in range(H):
    tmp = list(input())
    tmp.append("#")
    field.append(tmp)
field.append(["#"] * (W))
dp = [[0] * (W+1) for _ in range(H+1)]
dp[0][0] = 1
mod = 10 ** 9 + 7
for h in range(H):
    for w in range(W):
        if field[h][w] == "#":
            continue
        # 配り先のマスを見て、回数を増やせるか判定
        if field[h+1][w] == ".":
            dp[h+1][w] += dp[h][w]
            dp[h+1][w] %= mod
        if field[h][w+1] == ".":
            dp[h][w+1] += dp[h][w]
            dp[h][w+1] %= mod

print(dp[H-1][W-1])
        


Measured memory_bytes: 89712
import sys
 
 
def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    s = str(input().rstrip('\n'))
    ls = [[0] * 13 for _ in range(len(s))]
    for i in range(len(s)):
        if i == 0:
            if s[-i-1] == "?":
                for j in range(10):
                    ls[i][j] += 1
            else:
                ls[i][int(s[-i-1])] += 1
        else:
            mult = pow(10, i, 13)
            if s[-i-1] == "?":
                for j in range(13):
                    for k in range(10):
                        ls[i][(k * mult + j) % 13] += ls[i-1][j]
            else:
                st = int(s[-i-1])
                for j in range(13):
                    ls[i][(st * mult + j) % 13] += ls[i-1][j]
        for j in range(13):
            ls[i][j] = ls[i][j] % mod
    print(ls[-1][5])
 
 
if __name__ == '__main__':
    solve()

Measured memory_bytes: 61788
h,w=map(int,list(input().split()))
all=[[None] for i in range (h)]
temp=[[0]*w for i in range (h)]


for i in range(h):
    all[i]=list(input())



for i in range(h):
    for j in range(w):
        if(all[i][j]=="#"):
            temp[i][j]="#"
            if(i+1!=h):
                if(temp[i + 1][j]!="#"):
                    temp[i + 1][j] += 1
                if(j-1!=-1):
                    if (temp[i + 1][j-1] != "#"):
                        temp[i + 1][j - 1] += 1
                if(j+1!=w):
                    if (temp[i + 1][j+1] != "#"):
                        temp[i + 1][j + 1] += 1

            if(i-1!=-1):
                if (temp[i - 1][j] != "#"):
                    temp[i - 1][j] += 1
                if(j-1!=-1):
                    if (temp[i -1][j-1] != "#"):
                         temp[i - 1][j - 1] += 1
                if(j+1!=w):
                   if(temp[i - 1][j+1]!="#"):
                       temp[i - 1][j + 1] += 1

            if (j - 1 != -1):
                if (temp[i][j-1] != "#"):
                   temp[i][j - 1] += 1
            if (j + 1 != w):
                if (temp[i][j+1] != "#"):
                    temp[i][j + 1] += 1

for i in range(h):
    temp[i]=map(str,temp[i])
    print("".join(temp[i]))


Measured memory_bytes: 3188
N = int(input())
A = [int(x) for x in input().split()]
B = []
pena = 0
for i in A:
    if i%2 == 0:
        B.append(i)
for i in B:
    if i%3 != 0 and i%5 != 0:
        pena += 1
        break
if pena != 0:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}




template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


int n;
UG es(1100);
int x[1100];
P dp[1100];

bool f(int k){
  int sum=0;
  bitset<5100> b;
  b[0]=1;
  for(int e:es[k]){
    P a=dp[e];
    b= (b<<a.F)|(b<<a.S);
    sum+=(a.F+a.S);
  }
  rrep(i,x[k]){
    if(b[i]){
      dp[k]=P(x[k],sum-i);
      return false;
    }
  }

  cout<<"IMPOSSIBLE"<<endl;

  return true;
}


main(){
  cin>>n;
  
  FOR(i,2,n+1){
    int a;
    cin>>a;
    es[a].PB(i);
  }

  FOR(i,1,n+1){
    cin>>x[i];
  }

  RFOR(i,n,1){
    if(f(i)){
      return 0;
    }
  }

  cout<<"POSSIBLE"<<endl;
}


Measured memory_bytes: 384
n = gets.chomp.to_i
jobs = []
n.times do
  a, b = gets.split.map(&:to_i)
  jobs << [a, b]
end

jobs.sort! { |a, b| a[1] <=> b[1] }

c = 0
jobs.each do |job|
  c += job[0]
  if c > job[1]
    puts 'No'
    exit
  end
end

puts 'Yes'

Measured memory_bytes: 19064
#include <iostream>
#include <string>

using namespace std;
int main() {
	int l, r, d, res = 0;

	cin >> l;
	cin >> r;
	cin >> d;

	for (int i = l; i <= r; i++)
	{
		if (i % d == 0) {
			res++;
		}
	}

	cout << res << endl;
}

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

int main (void) {
  int N;
  cin >> N;
  vector<int> W(N);
  for (int i = 0; i < N; i++)
    cin >> W[i];
  int ans = 1e9;
  for (int i = 1; i < N; i++) {
    int S1 = 0, S2 = 0;
    for (int j = 0; j < i; j++)
      S1 += W[j];
    for (int j = i; j < N; j++)
      S2 += W[j];
    // cerr << S1 << ", " << S2 << endl;
    ans = min(ans, abs(S1 - S2));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

int main(){
    ll N;
    cin >> N;
    pair<ll, ll> X[N];
    ll t1, t2;
    rep(i, N){
        cin >> t1 >> t2;
        X[i] = make_pair(t1+t2, t1-t2);
    }
    sort(X, X+N);
    int t = X[0].first;
    ll ans = 0;
    REP(i, 1, N) {
        if (X[i].second >= t) {
            t = X[i].first;
        } else {
            ans++;
        }
    }

    cout << N - ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
using namespace std;

int main() {
	int k;
	cin >> k;
	string s;
	cin >> s;
	int len = s.size();
	if (len <= k)cout << s;
	else {
		for (int i = 0; i < k; i++) {
			cout << s[i];
		}
		cout << "...";
	}

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int func(){
  int n;
  vector<int> line;
  {
    int last = -1;
    int cnt = 0;
    string str = in<string>();
    n = str.size();
    foreach(i,str){
      int num = i - '0';
      if(num==last){
        ++cnt;
      }else{
        last = num;
        if(cnt)line.emplace_back(cnt);
        cnt = 1;
      }
    }
    line.emplace_back(cnt);
  }
  method(func,int,vector<int> line){
    int sum = 0;
    foreach(i,line){
      sum += i;
      if((n+1)/2<=sum){
        return sum;
      }
    }
    return INF;
  };
  return min(func(line),func(reversed(line)));
}

int main(){
  cout << func() << endl;
  return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int N;
  cin >> N;
  vector< int > P(N);
  cin >> P;
  vector< int > g[100000];
  for(int i = 1; i < N; i++) {
    int s, t;
    cin >> s >> t;
    --s, --t;
    g[s].emplace_back(t);
    g[t].emplace_back(s);
  }
  int64 ret = -infll;
  vector< int > dp1(N), dp2(N), dp3(N);
  function< void(int, int) > dfs = [&](int idx, int par) {
    for(auto &to : g[idx]) {
      if(to == par) continue;
      dfs(to, idx);
    }

    dp1[idx] = P[idx];
    dp2[idx] = P[idx];
    dp3[idx] = P[idx];

    vector< int > best;
    for(auto &to : g[idx]) {
      if(to == par) continue;
      dp2[idx] += max(0, dp2[to] - 2);
      best.emplace_back(max(0, dp1[to] - 1) - max(0, dp2[to] - 2));
    }
    sort(best.rbegin(), best.rend());

    if(best.size() >= 1) chmax(dp1[idx], dp2[idx] + best[0]);
    if(best.size() >= 2) chmax(dp3[idx], dp2[idx] + best[0] + best[1]);

    for(auto &to : g[idx]) {
      if(to == par) continue;
      chmax(dp1[idx], dp2[idx] - max(0, dp2[to] - 2) + (dp1[to] - 1));
      chmax(dp3[idx], dp2[idx] - max(0, dp2[to] - 2) + (dp3[to] - 2));
    }
    chmax(ret, dp1[idx]);
    chmax(ret, dp2[idx]);
    chmax(ret, dp3[idx]);
  };
  dfs(0, -1);

  cout << ret << endl;
}







Measured memory_bytes: 25564
#include <stdio.h>
    int main(){
        int n,a,b,c,i,kotae[100];
        scanf("%d",&n);
        for(i=0;i<n;i++){
            scanf("%d %d %d",&a,&b,&c);
            if((a*a)+(b*b)==(c*c)||(c*c)+(b*b)==(a*a)||(a*a)+(c*c)==(b*b)){
                printf("YES\n");
            }else{
                printf("NO\n");
            }
        }
    return 0;
}

Measured memory_bytes: 580