akhauriyash/Code-Regression huggingface dataset:
#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;

// definition of turning
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

class Point
{
public:
  double x, y;
  Point (double x = 0, double y = 0) : x(x), y(y) {}
  Point operator + (Point p) {return Point(x + p.x, y + p.y); }
  Point operator - (Point p) {return Point(x - p.x, y - p.y); }
  Point operator * (double a) {return Point(a * x, a * y); }
  Point operator / (double a) {return Point(x / a, y / a); }

  double norm() { return x * x + y * y; }
  double abs() { return sqrt(norm()); }

  bool operator < (const Point &p) const
  {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const
  {
    return equals(x, p.x) && equals(y, p.y);
  }
};

typedef Point Vector;
typedef vector<Point> Polygon;

struct Segment
{
  Point p1, p2;
  Segment(Point p1, Point p2) : p1(p1), p2(p2) {}
  Segment(double x1, double y1, double x2, double y2)
  {
    p1 = Point(x1, y1);
    p2 = Point(x2, y2);
  }
};

typedef Segment Line;

// dot and cross product
double dot(Vector a, Vector b)
{
  return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b)
{
  return a.x * b.y - a.y * b.x;
}

int ccw(Point p0, Point p1, Point p2)
{
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if (cross(a, b) > EPS) return COUNTER_CLOCKWISE;
  if (cross(a, b) < -EPS) return CLOCKWISE;
  if (dot(a, b) < -EPS) return ONLINE_BACK;
  if (a.norm() < b.norm()) return ONLINE_FRONT;
  return ON_SEGMENT;
}

int main()
{
  Point p0, p1;
  scanf("%lf%lf%lf%lf", &p0.x, &p0.y, &p1.x, &p1.y);
  int q;
  scanf("%d", &q);
  while (q--)
  {
    Point p2;
    scanf("%lf%lf", &p2.x, &p2.y);
    int retval = ccw(p0, p1, p2);
    if (retval == COUNTER_CLOCKWISE) printf("COUNTER_CLOCKWISE\n");
    else if (retval == CLOCKWISE) printf("CLOCKWISE\n");
    else if (retval == ONLINE_BACK) printf("ONLINE_BACK\n");
    else if (retval == ONLINE_FRONT) printf("ONLINE_FRONT\n");
    else printf("ON_SEGMENT\n");
  }
  return 0;
}



Measured memory_bytes: 2756
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	string str;

	cin >> str;

	str[3] = '8';

	cout << str << endl;










	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long asum=0;
    int amin=1000010,amax=-1000010;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        asum += a;
        amin = min(amin,a);
        amax = max(amax,a);
    }
    cout << amin << ' ' << amax << ' ' << asum << endl;
}


Measured memory_bytes: 3092
def insertion_sort(A, n, g, cnt):
  for i in range(g, n):
    v = A[i]
    j = i - g
    while j >= 0 and A[j] > v:
      A[j + g] = A[j]
      j = j - g
      cnt += 1
    A[j + g] = v
  return cnt

def shell_sort(A, n):
  cnt = 0
  G = []
  h = 1
  while h <= n:
    G.append(h)
    h = h * 3 + 1
  m = len(G)
  G = G[::-1]

  for i in range(m):
    cnt = insertion_sort(A, n, G[i], cnt)

  return m, G, cnt

data = []
for i in range(int(input())):
  data.append(int(input()))

m, G, cnt = shell_sort(data, len(data))
print(m)
print(" ".join(map(str, G)))
print(cnt)
for i in data: print(i)

Measured memory_bytes: 47552
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  string S;
  cin >> S;
  i64 size = S.size();
  for (i64 i = 0; i < size / 2; i++)
    if (S[i] != S[size - i - 1])
    {
      cout << "No" << endl;
      return 0;
    }
  for (i64 i = 0; i < size / 4; i++)
    if (S[i] != S[size / 2 - i - 1])
    {
      cout << "No" << endl;
      return 0;
    }
  for (i64 i = 0; i < size / 4; i++)
    if (S[i + size / 2 + 1] != S[size - i - 1])
    {
      cout << "No" << endl;
      return 0;
    }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    vector<int> p(3);
    rep(i,3) cin>>p[i];
    sort(etob(p));
    int dif=p[0]*2-p[1]-p[2];
    if(dif%2==0){
        cout<<dif/2<<endl;
    }else{
        cout<<dif/2+2<<endl;
    }

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k[ohara],p[ohara];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
bool fl;
struct edge{int to,cost;};
vector<ll> s[12];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>m;
    rep(i,m){
        cin>>k[i];
        rep(j,k[i]){
            cin>>a;
            s[i].push_back(a);
        }
    }
    rep(i,m)cin>>p[i];
    for(int bit=0;bit<(1<<(n));bit++){
        ll on[12]={};
       rep(i,n){
           if(bit & (1<<i)){
               on[i]=1;
           }
       }
       int ok=1;
       rep(i,m){
           cnt=0;
           rep(j,Size(s[i])){
               if(on[s[i][j]-1]==1)cnt++;
           }
           if(cnt%2!=p[i]){
               ok=0;
               break;
           }
       }
       if(ok)ans++;
   }
   Cout(ans);
    return 0;
}


Measured memory_bytes: 2304
n = int(input())
m = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049]
dp = [10**6 for i in range(100001)]
for mi in m:
    dp[mi] = 1
for i in range(1,100001):
    for mi in m:
        if i+mi <= 100000:
            dp[i+mi] = min(dp[i+mi],dp[i]+1)
        else:
            break
print(dp[n])


Measured memory_bytes: 45040
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    S = input()
    n = S.count('N')
    w = S.count('W')
    s = S.count('S')
    e = S.count('E')
    if n == 0 and s == 0:
        pass
    else:
        if n!=0 and s!= 0:
            pass
        else:
            print('No')
            exit()
    if w == 0 and e == 0:
        pass
    else:
        if w!=0 and e!= 0:
            pass
        else:
            print('No')
            exit()
    print('Yes')
if __name__ == '__main__':
  main()


Measured memory_bytes: 5276
<?php
$n=trim(fgets(STDIN));
$i=1;
$ans=0;
while($i<=$n){
  $j=1;
  while($j<=$n){
    $k=1;
    while($k<=$n){
      $gcd=gcd($i,$j);
      ($gcd==1)?++$ans:$ans+=gcd($k,$gcd);
      ++$k;
    }
    ++$j;
  }
  ++$i;
}
echo $ans;
function gcd($x,$y){
  return($x%$y)?gcd($y,$x%$y):$y;
}

Measured memory_bytes: 16008
import sys
sys.setrecursionlimit(200000)
def dfs(u, fa = -1):
	res = 0
	for v in adj[u]:
		if v != fa:
			res ^= dfs(v, u) + 1
	return res
n = int(raw_input())
adj = [[] for i in xrange(n)]
for i in xrange(n - 1):
	x, y = [int(t) - 1 for t in raw_input().split()]
	adj[x].append(y)
	adj[y].append(x)
print 'Alice' if dfs(0) else 'Bob'

Measured memory_bytes: 124676
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		sc.close();

		if( Character.isUpperCase( n.charAt( 0 ) ) ) {
		    System.out.println( "A" );
		}
		else {
		    System.out.println( "a" );
		}

	}
}


Measured memory_bytes: 35764
program main
  implicit none
  integer :: n, m, c, i, res
  integer, allocatable :: b(:), ai(:)
  read (*, *) n, m, c
  allocate (b(m), ai(m))
  read (*, *) b(:)
  res = 0
  do i = 1, n
    read (*, *) ai(:)
    if (dot_product(ai, b) > -c) res = res + 1
  end do

  write (*, "(i0)") res
end program main


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int b[101];
int a[105];
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
	  cin>>b[i];
	  
	a[1]=b[1];
	a[n]=b[n-1];
	
	for(int i=2;i<n;i++)
	   a[i]=min(b[i-1],b[i]);
	   
	int sum=0;
	for(int i=1;i<=n;i++)
	   sum=sum+a[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
# 小さい距離から見ていく
# 既に作った道の範囲で、任意の2点の最短距離を持っておく
# 既存の最短距離より大きい：矛盾
# 既存の最短距離と等しい：増やしても何も変わらず
# 既存の最短距離より小さい：追加する必要あり

import numpy as np
N = int(input())
A = [[int(x) for x in input().split()] for _ in range(N)]

edge = []

for i in range(N):
  for j in range(i):
    edge.append((A[i][j],j,i))
edge.sort()

INF = 10**18
dist = np.full((N,N),INF,dtype=np.int64) - np.eye(N,dtype=np.int64)*INF

answer = 0
for d,x,y in edge:
  if d > dist[x,y]:
    answer = -1
    break
  if d == dist[x,y]:
    continue
  # 追加
  answer += d
  dist[x,y] = d
  dist[y,x] = d
  # 距離行列の更新
  # (i,j) -> (i,x),(x,y),(y,j)
  dist_use_xy = np.add.outer(dist[:,x], dist[:,y]) + d
  dist = np.minimum(dist,np.minimum(dist_use_xy,dist_use_xy.T))
  
print(answer)
      

Measured memory_bytes: 22060
# 1以上a以下の整数のうち、CでもDでも割り切れないものの数を求める
def solve(a, c, d)
  a - a / c - a / d + a / c.lcm(d)
end

A, B, C, D = gets.chomp.split.map(&:to_i)

puts solve(B, C, D) - solve(A - 1, C, D)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<queue<int>> a(n + 1);
    queue<pair<int, int>> matches;
    map<pair<int, int>, int> active;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j < n; j++) {
            int aij;
            cin >> aij;
            a[i].push(aij);
            if(j == 1) {
                if(++active[{min(i, aij), max(i, aij)}] == 2) {
                    matches.push({min(i, aij), max(i, aij)});
                }
            }
        }
    }
    queue<pair<int, int>> matches_waiting;
    auto update = [&](int i) {
        a[i].pop();
        if(not a[i].empty()) {
            if(++active[{min(i, a[i].front()), max(i, a[i].front())}] == 2) {
                matches_waiting.push({min(i, a[i].front()), max(i, a[i].front())});
            }
        }
    };
    bool can = true;
    int days = 0;
    for(int mcount = 0; mcount < n * (n - 1) / 2 and can; ) {
        if(can &= not matches.empty()) {
            while(not matches.empty()) {
                update(matches.front().first);
                update(matches.front().second);
                matches.pop();
                mcount++;
            }
            while(not matches_waiting.empty()) {
                matches.push(matches_waiting.front());
                matches_waiting.pop();
            }
            days++;
        }
    }
    cout << (can ? days : -1) << endl;
    return 0;
}


Measured memory_bytes: 32640
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod =1'000'000'007;

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
    }
    int ans = mp.size();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19152
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<cstring>
using namespace std;
const int inf=1e9+5;
const int maxn=100000;
typedef vector<int> vi;
typedef long long ll;
#define fi first
#define se second
typedef pair<int,int> P;
int d[maxn+5];
bool visited[maxn+5];
int v,e,r;

struct Edge
{
  int cost,to;
  Edge(int _cost,int _to):cost(_cost),to(_to){}
};

vector<Edge> adj[maxn];
bool nega=false;
void bellman_ford(int n,int s)
{
  for(int i=0;i<n;i++)
  {
    d[i]=inf;
  }
  d[s]=0;
  for(int i=0;i<n;i++)
  {
    for(int v=0;v<n;v++)
    {
      for(int k=0;k<adj[v].size();k++)
      {
        Edge e=adj[v][k];
        if(d[v]!= inf && d[e.to]>d[v]+e.cost)
        {
          d[e.to]=d[v]+e.cost;
          if(i==n-1) 
          {
            nega=true;
            return;
          }
        }
      }
    }
  }
  return;
}


int main(void)
{
  cin >> v >> e>> r;
  for(int i=0;i<e;i++)
  {
    int s,t,d;
    cin >> s >> t >> d;
    adj[s].push_back(Edge(d,t));
    //Edge[t].push_back(P(d,s));
  }
  bellman_ford(v,r);
  if(nega)
  {
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }
  else
  {
    for(int i=0;i<v;i++)
    {
      if(d[i]==inf)
      {
        cout << "INF" << endl;
      }
      else cout << d[i] << endl;
    }
  }
  return 0;
}



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

bool check(int n){
    return (n/10000 == n%10) && ((n/1000)%10 == (n/10)%10);    
}

int main()
{
    int a,b;
    cin >> a >> b;
    int count = 0;
    for(int i = a; i<=b; i++){
        if(check(i)) count++;
    }
    cout << count << endl;
    return 0;
}


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

int main() {
  
  string S;
  cin >> S;
  int N = S.size();
  
  // 極小のセッティング
  
  vector<int> a(N + 1, -1);
  if (S[0] == '<') a[0] = 0;
  if (S[N - 1] == '>') a[N] = 0;
  
  for (int i = 0; i < N - 1; i++) {
    if (S[i] == '>' && S[i + 1] == '<') a[i + 1] = 0;
  }
  
  // ほかを作る
  
  for (int i = 0; i <= N; i++) {
    
    if (a[i] == 0) {
      
      if (i != 0) {
        for (int j = i - 1; j >= 0; j--) {
          if (S[j] == '>' && a[j] < a[j + 1] + 1) a[j] = a[j + 1] + 1;
          else break;
        }
      }
      
      if (i != N) {
        for (int j = i + 1; j <= N; j++) {
          if (S[j - 1] == '<' && a[j] < a[j - 1] + 1) a[j] = a[j - 1] + 1;
          else break;
        }
      }
      
    }
    
  }
  
  // 和の計算
  
  long long sum = 0;
  
  for (int i = 0; i <= N; i++) {
    sum += a[i];
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 2820
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n, r;
	cin >> n >> r;
	cout << (n >= 10 ? r : r + (100 * (10 - n))) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mp make_pair
#define mt make_tuple


signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	int a;
	int b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<int,int> P;

int main(){
    int  n;
    cin >> n;
    vector<ll> a(n),aa(n),cnt(n);
    rep(i,n)cin >> a[i];
    rep(i,n)--a[i];
    rep(i,n)++cnt[a[i]];
    ll tot = 0;
    rep(i,n){
        if(cnt[i]<2)continue;
        tot += cnt[i]* (cnt[i]-1) /2;
    }
    rep(i,n){
        if(cnt[a[i]] == 1)cout << tot << endl;
        else{
            cout << tot - (cnt[a[i]]-1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 7296
import sys
input = sys.stdin.readline
from bisect import bisect_left
from itertools import accumulate

def func(A, N, M, x):
    count = 0
    for Ai in A:
        idx = bisect_left(A, x - Ai)
        count += N - idx
    if count >= M:
        return True
    else:
        return False

def main():
    N, M = map(int, input().split())
    A = sorted(list(map(int, input().split())))
    A_rev = list(reversed(A))
    B = [0] + list(accumulate(A_rev))
 
    min_ = 0
    max_ = 2 * 10 ** 5 + 1
    while max_ - min_ > 1:
        mid = (min_ + max_) // 2
        if func(A, N, M, mid):
            min_ = mid
        else:
            max_ = mid
    
    ans = 0
    count = 0
    for Ai in A_rev:
        idx = bisect_left(A, min_-Ai)
        ans += Ai * (N - idx) + B[N-idx]
        count += N - idx
    print(ans-(count-M)*min_)

if __name__ == '__main__':
    main()

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

const int N = 1e5 + 20;

int s[3][N];
int dp[3][N];

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

Measured memory_bytes: 2560
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int a,b,c,d,e,f,answater=0,anssugar=0;
	double midu=-1;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	a*=100;b*=100;
	for(int i=0;i*a<=f;++i)
		for(int j=0;i*a+j*b<=f;++j)
			for(int m=0;i*a+j*b+m*c<=f;++m)
				for(int n=0;i*a+j*b+m*c+n*d<=f;++n)
				{
					double water=i*a+j*b+m*c+n*d,sugar=m*c+n*d;
					if((i*a+j*b)*e/100<sugar) break; 
					double k=sugar/water;
					if(k>midu) {answater=water;anssugar=sugar;midu=k;}
				}
	printf("%d %d",answater,anssugar);
	return 0;
}

Measured memory_bytes: 256
R, G, B, N = map( int, input().split())
ans = 0
for i in range(N//R+1):
    for j in range(N//G+1):
        if i*R + j*G <= N:
            if (N-R*i-j*G)%B == 0:
                ans += 1
        else:
            break
print(ans)

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

int main(){
	string s;
	cin >> s;
	vector<char> ans(12, 3);
	rep(i,s.size()){
		if(s[i] == '1' || s[i] == '0') ans.push_back(s[i]);
		if(s[i] == 'B') ans.pop_back();
	}
	for(auto x : ans){
		if(x != 3){
			cout << x;
		}
	}
	cout << endl;
}

Measured memory_bytes: 3600
#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 <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

int main(void) {
    int64_t k, a, b;
    cin >> k >> a >> b;
    int64_t rem = k - a + 1;
    int64_t ans = k + 1;
    if(a <= b) {
        debug("%d\n", rem);
        ans = max(ans, a + (rem/2)*(b-a) + (rem%2));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
module DoublyChainedTree = struct
  let nil = -1

  type t = {
    mutable parent : int;
    mutable child : int;
    mutable bro : int;
    mutable depth : int;
  }

  let make () = { parent = nil; child = nil; bro = nil; depth = nil }
end

module T = DoublyChainedTree

let () =
  let n = Scanf.scanf "%d " (fun i -> i) in
  let t = Array.init n (fun _ -> T.make ()) in
  let rec read_tree i =
    if i < n then begin
      let id, k = Scanf.scanf "%d %d " (fun id k -> id, k) in
      let rec read_node j left_child =
        if j < k then begin
          let c = Scanf.scanf "%d " (fun c -> c) in
          t.(c).T.parent <- id;
          if j = 0 then t.(id).T.child <- c else t.(left_child).T.bro <- c;
          read_node (j + 1) c
        end
      in
      read_node 0 0;
      read_tree (i + 1)
    end
  in
  read_tree 0;
  let rec search_root i =
    if i = n then T.nil
    else if t.(i).T.parent = T.nil then i
    else search_root (i + 1)
  in
  let root = search_root 0 in
  let rec set_depth i p =
    t.(i).T.depth <- p;
    if t.(i).T.bro <> T.nil then set_depth t.(i).T.bro p;
    if t.(i).T.child <> T.nil then set_depth t.(i).T.child (p + 1);
  in
  set_depth root 0;
  let print_node i =
    Printf.printf "node %d: parent = %d, depth = %d, " i t.(i).T.parent t.(i).T.depth;
    print_string (if t.(i).T.parent = T.nil then "root, " else if t.(i).T.child = T.nil then "leaf, " else "internal node, ");
    print_string "[";
    let rec print_children c =
      if c <> T.nil then begin
        if c <> t.(i).T.child then print_string ", ";
        print_int c;
        print_children t.(c).T.bro
      end
    in
    print_children t.(i).T.child;
    print_endline "]"
  in
  let rec print i =
    if i < n then (print_node i; print (i + 1))
  in
  print 0

Measured memory_bytes: 13164
f = lambda :[int(i) for i in input().split()]
from sys import stderr
debug = lambda x:stderr.write(repr(x)+'\n')

a,b,k = f()
if a + k * 2 > b:
    for i in range(a,b+1):
        print(i)
else:    
    for i in range(a,a+k):
        print(i)
    for j in range(b-k+1,b+1):
        print(j)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<bitset>
#include<random>
#include<time.h>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

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



// Main Code

int main()
{
  string s;
  cin>>s;
  s[3] = '8';
  cout<<s<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int selectionSort(int n, int a[]);

int main(void){
	
	
	int n;
	
	scanf("%d", &n);
	
	int a[n], i;
	
	for(i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	
	selectionSort(n, a);
	
	return 0;
	
}

int selectionSort(int n, int a[]){
	
	int i, j, min, count=0, ii, check;
	
	for(j=0; j<n-1; j++){
		min=a[j];
		check=0;
		for(i=j+1; i<n; i++){
			if(a[i]<min){
				ii=i;
				min=a[i];
				check=1;
			}
		}
		if(check==1){
			a[ii]=a[j];
			a[j]=min;
			count++;
		}
		
	}
	
	for(i=0; i<n-1; i++){
		printf("%d ", a[i]);
	}
	
	printf("%d\n", a[i]);
	printf("%d\n", count);
	
}


Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for(int i = 0; i < n; ++i)  cin >> h[i];
    if(k >= n){
        cout << 0 << endl;
        return 0;
    }

    sort(h.begin(), h.end(), greater<ll>());
    ll sum = accumulate(h.begin() + k, h.end(), 0ll);
    cout << sum << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

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

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int n, r ; cin >> n >> r, n || r; ) {
		vector<int> v(n);
		rep(i,n) v[i] = n - i;
		rep(i,r) {
			int p, c;
			vector<int> tmp;
			cin >> p >> c;
			rep(j,c) {
				tmp.pb(v[p+j - 1]);
			}
			rep(j,p - 1) {
				tmp.pb(v[j]);
			}
			for(int j = p + c - 1; j < n; j++) {
				tmp.pb(v[j]);
			}
#if 0
			preview(tmp.begin(), tmp.end());
#endif
			v = tmp;
		}
		cout << *v.begin() << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int x;
int a;
int b;

int main()
{
    cin >> x >> a >> b;

    int da = abs(x - a);
    int db = abs(x - b);

    if(da < db)
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "B" << endl;
    }
    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(c>a-b) printf("%d\n",c-a+b);
    else
      printf("0\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
ll N;
ll X;//def(a,b)でレベルaバーガーの下からb層に含まれるパティの枚数
ll a[55];//レベルiバーガーの厚さをai
ll p[55];//レベルiバーガーに含まれるパティの総数
ll def(ll x, ll y) {
	if (x == 0)return 1;
	if (y == 1)return 0;
	else if (y <= a[x - 1]+1) { 
		return def(x - 1, y - 1);
	}
	else if (y == a[x - 1] + 2) {
		return p[x - 1] + 1;
	}
	else if (y <= 2 * a[x - 1] + 2) {
		return p[x - 1] + 1 + def(x - 1, y - a[x - 1] - 2);
	}
	else {
		return 2 * p[x - 1] + 1;
	}
}
int main() {
	cin >> N >> X;
	a[0] = 1;
	p[0] = 1;
	for (int i = 0; i < N; ++i) {
		a[i + 1] = 2 * a[i] + 3;
		p[i + 1] = 2*p[i] + 1;
	}
	cout << def(N, X) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

bool is_leap (int y )
{
	return (y % 4 == 0 && ((y % 100 != 0 ) || (y % 400 == 0 ) ) );
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.leap_year", "r", stdin );

	int a, b;
	int cnt = 0;
	while (scanf ("%d %d", &a, &b ), a, b  ){
		vector<int> res; res.clear();
		for (int i = a; i <= b; i++ ){
			if (is_leap (i ) ){
				res.push_back (i );
			} // end if
		} // end for
		if (cnt != 0 ) cout << endl;
		cnt++;
		if (res.empty() ){
			cout << "NA" << endl;
		}else{
			rep (i, res.size() ){
				printf ("%d\n", res[i] );
			} // end rep
		} // end if
	} // end while

	return 0;
}

Measured memory_bytes: 1260
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		if(a<1200) {
		System.out.println("ABC");
	}else {
		System.out.println("ARC");
	}
		}
	}

Measured memory_bytes: 21460
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr int MOD = 1000000007;
using namespace std;

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

VL prime_decomposition(ll n) {
	ll i = 2;
	VL table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace_back(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace_back(n);
		return table;
	}
	return table;
}

int main() {
	ll n, k;
	cin >> n >> k;
	VL v(n);
	REP(i, n) { cin >> v[i]; }

	ll sum = 0;
	REPC(x, v) {
		sum += 2 * std::min(x, abs(x - k));
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N = z()
C_ = S()
C = [1 if c == 'R' else 0 for c in C_]
# print(C)
ans = sum(C)
ans = min(ans, N-ans)


ans_ = 0
i = N - 2
_C = copy.copy(C)
for _ in range(N-1):
    # print(i, 'C[i + 1]', C[i + 1])
    if (_C[i] == 0 and _C[i + 1] == 1):
        _C[i] = 1
        # print(C)
        ans_ += 1
    i -= 1
ans = min(ans, ans_)


# 入れ替えで達成を目指す
# 右にW=0をかためる
_C = copy.copy(C)

l = 0
r = N-1
ans_ = 0
while (l < r):
    while (_C[l] != 0):
        l += 1
        if (l >= r):
            break
    while (_C[r] != 1):
        r -= 1
        if (l >= r):
            break
    if (l >= r):
        break
    _C[l], _C[r] = _C[r], _C[l]
    # print(_C)
    ans_ += 1
ans = min(ans, ans_)


print(ans)


Measured memory_bytes: 47336
import math
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n = int(input())
yaku = make_divisors(n)

Min = float('inf')
for i in range(math.ceil(len(yaku)/2)):
    Min = min(Min, yaku[i]+yaku[-(i+1)])

print(Min-2)

Measured memory_bytes: 9216
N = int(input())
b = list(map(int, input().split()))

ans = []
while len(b) != 0:
    tmp = 0
    for i in range(1, len(b)+1):
        if b[i-1] == i:
            tmp = b[i-1]
    if tmp == 0:
        print(-1)
        exit()
    else:
        ans.append(tmp)
        del b[tmp-1]
        
for i in range(N-1, -1, -1):
    print(ans[i])

Measured memory_bytes: 3064
using System;
    class test
    {
        static void Main()
        {
            while (true)
            {
                string n = Console.ReadLine().Trim();
                if (n == "-") break;
                int h = int.Parse(Console.ReadLine());
                for (var i = 0; i < h; i++)
                {
                    int s = int.Parse(Console.ReadLine());
                    n = n.Substring(s) + n.Substring(0, s);
                }
                Console.WriteLine(n);
            }
        }
    }

Measured memory_bytes: 8944
//059
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int a[102]={}; //全ての要素を0で初期化
    int b[102]={};
    string sa, sb;
    cin >> sa >> sb;
    for(int i=0; i<sa.size(); i++){
        //cout << (int)(sa[i] -'0') << endl;
        a[101-sa.size()+i+1] = (int)(sa[i] -'0');
    }
    for(int i=0; i<sb.size(); i++){
        b[101-sb.size()+i+1] = (int)(sb[i] -'0');
    }
    rep(i,102){
        if(a[i]>b[i]){
            cout << "GREATER" << endl;
            return 0;
        }else if(a[i]<b[i]){
            cout << "LESS" << endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

map<char, char> computeMap(int a, int b) {
	map<char, char> res;
	for (int x = 0; x < 26; x++) {
		int y = (a * x + b) % 26;
		res[y + 'a'] = x + 'a';
	}

	return res;
}

string decode(string str, map<char, char> m) {
	for (auto &c : str) {
		c = isalpha(c) ? m[c] : c;
	}
	return str;
}

string solve(string str) {
	for (int a = 0; a < 26; a++) {
		for (int b = 0; b < 26; b++) {
			if (__gcd(a, 26) != 1) continue;
			map<char, char> m = computeMap(a, b);
			string decoded = decode(str, m);
			if (decoded.find("that") != string::npos || 
				decoded.find("this") != string::npos) {
				return decoded;
			}
		}
	}
	return "hoge";
}

int main(void) {
	int N;
	cin >> N;
	cin.get();

	for (int i = 0; i < N; i++) {
		string str;
		getline(cin, str);
		cout << solve(str) << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include<tuple>

using namespace std;

int main() {
	int N, K;

	cin >> N >> K;

	if (N % K == 0)cout << 0 << endl;
	else cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bitset>
#include <utility>
#define Max 20
using namespace std;

int main(){
    int n;
    vector<pair<int,int> > adj[Max];
    cin >> n;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        for(int j=0;j<a;j++){
            int x,y;
            cin >> x >> y;
            x--;
            adj[i].push_back(make_pair(x,y));
        }
    }

    int ans =0;
    bitset<15> b;
    for(int bit=0;bit<(1<<n);bit++){
        bool flag = 1;
        bitset<15> B(bit);
        for(int i=0;i<n;i++){
            //i人目が不親切なら飛ばす
            if(!(B[i])){
                continue;
            }
            for(int j=0;j<adj[i].size();j++){
              if(adj[i][j].second != B[adj[i][j].first]){
                  flag = 0;
                  break;
                  }
            }
        }
        if(flag){
            if(ans<B.count()){
                ans = B.count();
                b = B;
            }
        }
    }
    cout << ans << endl;
    //cout << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int maxn=1e5+100;
ll n,t;
ll a[maxn];
int main()
{
    scanf("%lld%lld",&n,&t);
    for(ll i=1;i<=n;i++)
        scanf("%lld",&a[i]);
//    int zz=t/a[1];
//    printf("%d\n",zz+1);
    ll tt=0;
    ll maxa=0;
    for(ll i=1;i<=n;i++)
    {
        if(maxa<a[i]) maxa=a[i];
        tt+=a[i];
        if(tt>t)
        {
            printf("1\n");
        }
        else
        {
            ll ff=(t-tt)/maxa+1;
            printf("%lld\n",ff+1);
        }
    }
    return 0;
}



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

int main() { 
  string s, t;
  int ans = 0;
  cin >> s >> t;
  rep(i, s.size()){
    if (s[i] != t[i]){
        ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3852
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;
        Solver s = new Solver();
        for (int i = 1; i <= t; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }

}

class Solver {

    void solve(int test, InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int x = 0, y = 0, t = 0;
        for (int i = 0; i < n; i++) {
            int t1 = in.nextInt();
            int x1 = in.nextInt();
            int y1 = in.nextInt();
            int diff = t1 - t;
            int dist = Math.abs(x1 - x) + Math.abs(y1 - y);
//            System.out.println(diff + " " + dist);
            if (diff >= dist) {
                if (dist % 2 == 0 && diff % 2 == 1) {
                    out.println("No");
                    return;
                }
                x = x1;
                y = y1;
                t = t1;
                continue;
            }
            out.println("No");
            return;
        }
        out.println("Yes");
    }

}

class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
        st = null;
    }

    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public String nextLine() throws IOException {
        return br.readLine();
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 39684
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int s, w;
    cin >> s >> w;
    cout << (s <= w ? "unsafe" : "safe") << endl;
}

Measured memory_bytes: 3648
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // int n = Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        int x = Integer.parseInt(st.nextToken());
        StringBuilder sb = new StringBuilder();
        for(int i=x-k+1; i<=x+k-1; i++) sb.append(i+" ");
        out.println(sb.toString());
        out.close(); System.exit(0);
    }
}


Measured memory_bytes: 20692
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

int main(){
  char in;
  int count=0,all=0;
  while(cin >> in){
    if(in=='p') count++;
    all++;
  }
  cout << (all/2)-count << endl;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
d = [int(i) for i in input().split()]
d_dic = Counter(d)
count = 0
dp = 0
for i in range(1,max(d)+1):
    dp += d_dic[i]
    if dp == N / 2:
        count += 1
    elif dp > N / 2:
        break
print(count)


Measured memory_bytes: 14908
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
const int N = 1e5 + 10;
const int S = 18;
vector<int>g[N], edge[N];
int v[N];
int dfn[N];
int n, m;
int fa[N];
int l[N], r[N];
bool ans = 1;
void dfs(int x) {
    if (v[x] == -1)
        l[x] = r[x] = -1e9;
    else
        l[x] = r[x] = v[x];
    for (auto u:g[x])
        if (u != fa[x]) {
            fa[u] = x;
            dfs(u);
            if (l[u] == -1e9) continue;
            int L = l[u] - 1, R  = r[u] + 1;
            if (l[x] == -1e9)
                l[x] = L, r[x]  = R;
            else{
                ans &= ((l[x] & 1) == (L & 1));
                l[x] = max(l[x], L);
                r[x] = min(r[x], R);
                ans &= (l[x] <= r[x]);
            }
        }
}
void dfs1(int x) {
    for (auto u:g[x])
        if (u != fa[x]) {
            if (l[u] == -1e9)
                v[u] = v[x]  +1, dfs1(u);
            else
            {
                if (v[x] + 1<= r[u])
                    v[u] = v[x] + 1, dfs1(u);
                else
                    v[u] = v[x] - 1, dfs1(u);
            }
        }
}
int main() {
    scanf("%d", &n);
    for (int i = 1; i < n ; i ++) {
        int x, y;
        scanf("%d %d", &x, &y);
        g[x].push_back(y);
        g[y].push_back(x);
        v[i] = -1;
    }
    v[n] = -1;
    scanf("%d", &m);
    for (int i = 1; i <= m; i ++) {
        int x,y;
        scanf("%d %d", &x, &y);
        v[x] = y;
    }
    dfs(1);
    v[1] = l[1];
  //  for (int i = 1; i <= n; i ++)
   //     printf("%d %d %d\n",i, l[i], r[i]);
    dfs1(1);
    if (ans) {
        puts("Yes");
        for (int i= 1; i <= n; i ++)
            printf("%d\n", v[i]);
    } else {
        puts("No");
    }
    return 0;
}

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

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

    if(S == "abc" || S == "acb" || S == "bac" || S == "bca" || S == "cab" || S == "cba")
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main() {
  string S;
  cin>>S;
char a,b,c;
a=S[0];
b=S[1];
c=S[2];
if(S.size()==2){
cout<<S<<endl;
}else{
cout<<c<<b<<a<<endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<pair<int,int> > v;
    int m=(n%2)?n:n+1;
    for(int i=1;i<=n;i++){
    	for(int j=i+1;j<=n;j++){
    		if(i+j!=m){
    			v.pb(make_pair(i,j));
    		}
    	}
    }
    cout << (v.size()) <<endl;
    for(auto i:v){
    	cout <<i.first<<" "<<i.second<<endl;
    }
    return 0;
}


Measured memory_bytes: 384