akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
int n,k;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>n>>k;
    int ans = 0;
    while(n){
        ans++;
        n/=k;
    }
    cout<<ans<<newl;
}



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

int H, W;
char field[55][55];
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int main() {
  // 入力
  cin >> H >> W;
  fill(field[0], field[54], '.'); // 番兵
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      cin >> field[i][j];
    }
  }

  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      if (field[i][j] == '#') continue;
      int cnt = 0;
      for (int k = 0; k < 8; k++) {
        int y = i + dy[k];
        int x = j + dx[k];
        if (field[y][x] == '#') cnt++;
      }
      field[i][j] = cnt + '0';
    }
  }

  // 解答
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      cout << field[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
l,r = input().split()
l = int(l)
r = int(r)
N = int(2019)
  
ans = N
count = 0
right = min(l + N, r)
for i in range(l,right):
  for j in range(i+1,right+1):
    ans = min(ans, (i * j) % N)
    
print(ans)


Measured memory_bytes: 3060
def main():
    #A, B, C = [int(f) for f in input().split()]
    N = int(input())

    length = len(str(N))
    counter = 0
    if length < 3:
        for _ in range(1, min(10, N+1)):
            counter += 1
    elif length < 5:
        counter = 9
        for _ in range(100, min(1000, N+1)):
            counter += 1
    else:
        counter = 909
        for _ in range(10000, min(100000, N+1)):
            counter += 1
    
    print(counter)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    char s[100][11];
    for (i = 0; i < n; i++)
        scanf("%s", s[i]);
    int m;
    scanf("%d", &m);
    char t[100][11];
    for (i = 0; i < m; i++)
        scanf("%s", t[i]);
    int ans = 0;
    int y, j;
    for (i = 0; i < n; i++)
    {
        y = 1;
        for (j = i + 1; j < n; j++)
        {
            if (strcmp(s[i], s[j]) == 0)
                y++;
        }
        for (j = 0; j < m; j++)
        {
            if (strcmp(s[i], t[j]) == 0)
                y--;
        }
        if (ans < y)
            ans = y;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int len =Integer.parseInt(sc.nextLine());
		int[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
		int[] ans = new int[len];
		
		for (int i = 0; i < len; i++) {
			ans[line[i] - 1] =i;
		}

		for (int i = 0;i < len;i++) {
			System.out.print(ans[i] + 1);
			if (i != len -1) {
				System.out.print(" ");
			}
		}
	}
}


Measured memory_bytes: 58248
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,k = MI()

if k%2!=0:
    count = 0
    for i in range(1,n+1):
        if (i%k)==0:
            count += 1
    ans = count ** 3
    print(ans)
    exit()
else:
    count_1 = 0
    count_2 = 0
    for i in range(1,n+1):
        if (i%k)==0:
            count_1 += 1
        elif (i%k)==(k//2):
            count_2 += 1
    ans = count_1**3 + count_2**3
    print(ans)
    exit()

Measured memory_bytes: 77136
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int main(){
	boost;
	int a,b;
	cin>>a>>b;
	if((a+b)&1)cout<<"IMPOSSIBLE";
	else cout<<((a+b)>>1);
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int h,m,s,S;
  cin>>S;
  h=S/3600;
  m=(S-h*3600)/60;
  s=S-h*3600-m*60;
  cout<<h<<":"<<m<<":"<<s<<endl;
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  ll h,w;
  cin >> h >> w;
  if(h == 1 || w == 1){
    cout << 1 << endl;
    return 0;
  }
  if(h%2 == 0 || w%2 == 0){
    cout << h*w/2 << endl;
  }else{
    cout << (h+1)/2*(w+1)/2 + (h-1)/2*(w-1)/2 << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
using ll = long long int;

int main() {
	ll N, ans = 0;
	cin >> N;

	for (ll i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
local s = io.read()
local q = io.read("*n", "*l")
local w = true
local left, right = {}, {}
for i = 1, q do
  local sq = io.read()
  if sq == "1" then
    w = not w
  else
    local f, c = sq:sub(3, 3), sq:sub(5, 5)
    if f == "1" then
      if w then
        table.insert(left, c)
      else
        table.insert(right, c)
      end
    else
      if w then
        table.insert(right, c)
      else
        table.insert(left, c)
      end
    end
  end
end
if w then
  for i = #left, 1, -1 do
    io.write(left[i])
  end
  io.write(s)
  for i = 1, #right do
    io.write(right[i])
  end
  io.write("\n")
else
  for i = #right, 1, -1 do
    io.write(right[i])
  end
  io.write(s:reverse())
  for i = 1, #left do
    io.write(left[i])
  end
  io.write("\n")
end


Measured memory_bytes: 5928
import java.util.Scanner;

public class Main{
  static int n;
  static int[] a;

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

    n = sc.nextInt();
    a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }

    int max = a[0], min = a[0];
    for(int i = 1; i < n; i++){
      max = Math.max(max, a[i]);
      min = Math.min(min, a[i]);
    }

    System.out.println(max - min);
  }
}


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

int main(){
  long long int N, D, ans = 0;
  cin >> N >> D;
  
  long long int X, Y;
  for (int i = 0; i < N; i++){
    cin >> X >> Y;
    
    if (X*X + Y*Y <= D*D){
      ans++;
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3632
#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");}

struct SegmentTree{
  vector <ll> Tree[21];
  void Make(){
    for (int i = 0; i < 21; i++) Tree[i].resize(1<<i);
  }
  void Add(int loc, ll val){
    for (int i = 20; i >= 0; i--){
      Tree[i][loc] += val;
      loc /= 2;
    }
  }

  ll Sum(int loc){
    if (loc < 0) return 0;
    ll ans = Tree[20][loc];
    int now = 20;
    while (loc > 0){
      if (loc % 2 == 0){
        loc /= 2; loc--; now--;
      }else{
        loc--;
      }
      ans += Tree[now][loc];
    }
    return ans;
  }
};

int main(){
  SegmentTree T; T.Make();
  int N, Q; cin >> N >> Q;
  for (int i = 0; i < N; i++){
    ll A; cin >> A;
    T.Add(i, A);
  }

  for (int i = 0; i < Q; i++){
    ll A, B, C; cin >> A >> B >> C;
    if (A == 0){
      T.Add(B, C);
    }else{
      cout << T.Sum(C-1) - T.Sum(B-1) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 20768
import sys

input = sys.stdin.readline


def main():
    N = int(input())

    for h in range(1, 3501):
        for n in range(1, 3501):
            a = N * h * n
            b = 4 * h * n - (h + n) * N
            if b > 0 and a % b == 0:
                w = a // b
                print(h, n, w)
                exit()


if __name__ == "__main__":
    main()


Measured memory_bytes: 9184
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    sort(ALL(s));
    sort(ALL(t), greater<char>());
    if(s < t){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

if n % 2 == 0:
    ts = sum(A[:n//2])
    print(ts + ts - A[0])
else:
    ts = sum(A[:n//2])
    print(ts + ts - A[0] + A[n//2])

Measured memory_bytes: 31448
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

int main(){
    ll x=0,y,d=0,n,h,w,k,m,min=1000,ans=0,ptr=0,count=0;
    string s,s1,s2;
    cin >> n;
    for(int i=1;i<n;i++){
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math

n_str,d_str =input().split()
n = int(n_str)
d = int(d_str)

ct = 0
for i in range(n):
    x,y = map(int,input().split())
    dis = math.sqrt(x **2 + y **2)
    if d>=dis:
        ct += 1
print(ct)


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

class UnionFind{
    vector<int>p,sz;
public:
    UnionFind(int n){
        p.resize(n,-1);
        sz.resize(n,1);
    }
    int find(int x){
        if(p[x] == -1)return x;
        else return p[x] = find(p[x]);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y)return;
        if(sz[x] > sz[y])swap(x,y);
        p[x] = y;
        sz[y] += sz[x];
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        int a,b; cin>>a>>b;
        a--; b--;
        uf.unite(a,b);
    }
    int ans=0;
    rep(i,n)ans=max(ans,uf.size(i));
    cout<<ans<<endl;
}

Measured memory_bytes: 4808
#include <iostream>

using namespace std;

int main(){
  int n;

  int omori[10] = {1,2,4,8,16,32,64,128,256,512};

  while( cin >> n){
  int used[10]={0,0,0,0,0,0,0,0,0,0};
    int i = 0;
    int f = 0;
    while(n){
      if(n >= omori[9-i]) {n -= omori[9-i];used[i] = omori[9-i];f++;}
      i++;
    }

    for(int j=9;j >= 0;j--){
      if(used[j] != 0 && f == 1){ cout << used[j] << endl;}
      if(used[j] != 0 && f != 1){ cout << used[j] << ' ' << flush;f--;}
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 202
#define MOD 998244353
#define EPS 0.0000000001
char Graph[MAX][MAX];
int value[MAX];
bool possible(int root,int N)
{
    int i,node;
    for(i=0;i<N;i++)
    {
        value[i]=0;
    }
    value[root]=1;
    queue<int> Nodes;
    Nodes.push(root);
    while(!Nodes.empty())
    {
        node=Nodes.front();
        Nodes.pop();
        for(i=0;i<N;i++)
        {
            if(Graph[node][i]=='0') continue;
            if(value[node]+value[i]==3) continue;
            else if(value[node]==value[i]) return false;
            else
            {
                value[i]=3-value[node];
                Nodes.push(i);
            }
        }
    }
    return true;
}
int height(int root,int N)
{
    int i,node;
    for(i=0;i<N;i++)
    {
        value[i]=0;
    }
    value[root]=1;
    queue<int> Nodes;
    Nodes.push(root);
    int ans=1;
    while(!Nodes.empty())
    {
        node=Nodes.front();
        Nodes.pop();
        for(i=0;i<N;i++)
        {
            if(Graph[node][i]=='1'&&value[i]==0)
            {
                value[i]=value[node]+1;
                ans=max(ans,value[i]);
                Nodes.push(i);
            }
        }
    }
    return ans;
}
int main()
{
    int N,i,j;
    scanf("%d ",&N);
    for(i=0;i<N;i++)
    {
        for(j=0;j<N;j++)
        {
            scanf("%c",&Graph[i][j]);
        }
        scanf("%*c");
    }
    if(!possible(0,N))
    {
        printf("-1");
        return 0;
    }
    int ans=0,temp=0;
    for(i=0;i<N;i++)
    {
        temp=height(i,N);
        ans=max(ans,temp);
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n,m;
	cin>>n>>m;
	vi in(m);
	rep(i,m)cin>>in[i];
	int ma=in[0]-1;
	rep(i,m-1){
		int q=in[i+1]-in[i];
		q/=2;
		ma=max(ma,q);
	}
	ma=max(ma,n-in[m-1]);
	cout<<ma<<endl;
}

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


int main(){
    string S;
    cin >> S;
    int l = 0,r= S.length()-1;
    int res = 0;
    while(l < r){
        if(S[l] == S[r]){
            l++;
            r--;
        }else if(S[l] == 'x'){
            res++;
            l++;
        }else if(S[r] == 'x'){
            res++;
            r--;
        }else{
            res = -1;
            break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
using namespace std;
int main(){
    double r,area,circ,c=3.141592653589;
    scanf("%lf",&r);
    area = r * r * c;
    circ = 2 * r  * c;
    printf("%f %f\n",area,circ);
    return 0;
}


Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define S second
const int INF = 987654321;
const int MOD = (int)1e9+7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
int dy[4] = {-1, 0, 1, 1};
int dx[4] = {0, 1, 0, 1};

ll n,k;
vl A;
vl F;

bool can(ll t) {
	vl B(n);
	rep(i,0,n) {
		B[i] = t/F[n-1-i];
	}
	ll nk = 0;
	rep(i,0,n) {
		nk += max(A[i] - B[i], 0LL);
	}
	return nk <= k;
}

ll solve() {
	ll t = 0;
	rep(i,0,n) {
		t = max(t, A[i]*F[n-1-i]);
	}

	ll left = 0;
	ll right = t;
	ll mid;
	while(left < right) {
		mid = (left+right)/2;
		if(can(mid)) {
			right = mid;
		} else {
			left = mid+1;
		}
	}
	return left;
}

int main(void) {
	//freopen("in.txt", "r", stdin);
	cin >> n >> k;
	A.resize(n);
	F.resize(n);
	rep(i,0,n) {
		cin >> A[i];
	}
	rep(i,0,n) {
		cin >> F[i];
	}

	sort(all(A));
	sort(all(F));
	printf("%lld\n", solve());
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int W[200];
int main(){
    int N;
    cin >> N;
    int wa = 0;
    REP(i,N){
        int w;
        cin >> w;
        W[i] = w;
        wa += w;
    }

    int ans = INT_MAX;
    int sum = 0;
    REP(i,N){
        int w = W[i];
        sum += w;
        wa -= w;
        chmin(ans, abs(wa - sum));
    }


    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

bool flag = true;
vector<int> ans;

void solve(int n,int a,int b){
	if(!n) return;
	a = min(a,n - b + 1);
	if(a * b < n){
		flag = false;
		return;
	}
	for(int i = 1;i <= a;i++) ans.pb(n - a + i);
	solve(n - a,a,b - 1);
}

signed main(){
	int n,a,b;
	cin >> n >> a >> b;
	if(a * b < n || a + b > n + 1){
		cout << -1 << endl;
		return 0;
	}
	solve(n,a,b);
	if(!flag) cout << -1 << endl;
	else{
		for(int i = 0;i < n;i++) cout << (i ? " " : "") << ans[i];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 16496
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string s, t;
int dp[3005][3005], n, m;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> s;
cin >> t;
n = (int)s.size();
m = (int)t.size();
for(int i = 1 ; i <= n ; ++i){
	for(int j = 1 ; j <= m ; ++j){
		dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		if(s[i - 1] == t[j - 1]){
			dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
		}
	}
}
int i = n, j = m;
string sol = "";
while(i > 0 && j > 0){
	if(s[i - 1] == t[j - 1]){
		if(dp[i][j] == dp[i - 1][j - 1] + 1){
			sol.push_back(s[i - 1]);
			i--;
			j--;
			continue;
		}
	}
	if(dp[i - 1][j] > dp[i][j - 1]){
		i--;
	}
	else{
		j--;
	}
}
reverse(sol.begin(), sol.end());
cout << sol << endl;

return 0;
}



Measured memory_bytes: 35456
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b; cin >> a >> b;
	cout << (a+b)%24 << endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {

int h = 0;
int m = 0;
int S = 0;
int sec = 0;

scanf("%d",&S);

h = S / 3600;
m = (S - (h * 3600))/60;
sec = S - (h * 3600) - (m * 60);

printf("%d:%d:%d\n",h,m,sec);

return 0;

}


Measured memory_bytes: 2112
N = int(input())

def solve(x0,y0,x1,y1,t):
    if (t >= (abs(x1-x0) + abs(y0-y1))) and (((t -abs(x1-x0)-abs(y0-y1))%2)==0):
        return True
    else:
        return False
x0=0
y0=0
t0=0
for i in range(N):
    ti,xi,yi = map(int,input().split())
    if solve(x0,y0,xi,yi,ti-t0) == True:
        x0 = xi
        y0 = yi
        t0 = ti
    else:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll  n;
    cin>>n;
    ll arr[n+10];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    ll cnt=0,maxx=0;
    for(ll i=0;i<n-1;i++)
    {
        ll j=i+1;
        cnt=0;
        while(arr[j]<=arr[i])
        {
            j++;
            i++;
            cnt++;
        }
        maxx=max(maxx,cnt);
    }
    cout<<maxx<<'\n';
return 0;
}

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

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean isApproved = true;
        int n = sc.nextInt();
        int[] intArray = new int[n];
        for(int i = 0; i < n; i++) intArray[i] = Integer.parseInt(sc.next());
        for(int num : intArray) {
            if(num % 2 == 0) {
                if(num % 3 != 0 && num % 5 != 0) isApproved = false;
            }
        }

        System.out.println(isApproved ? "APPROVED" : "DENIED");
    }
}


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

const int mod = 998244353, N = 2010;
typedef long long ll;
int n, K;
ll C[N << 1][N << 1], p[N << 1];

void prework() {
    p[0] = 1;
    for (int i = 1; i <= 4000; i++) p[i] = p[i - 1] * 2ll % mod;
    C[0][0] = 1;
    for (int i = 1; i <= 4000; i++) {
        C[i][0] = 1;
        for (int j = 1; j <= i; j++)
            C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
    }
}

ll calc(int s, int tot) { return C[s + tot - 1][s - 1]; }

ll solve(int i, int tot) {
    int k2 = min(K - i / 2, (i - 1) / 2);
    int k1 = K - k2 * 2 - ((i % 2) == 0);
    ll flag = 1, res = 0;
    for (int l = k2; l + k1 > 0 && l >= 0; l--, flag = -flag) {
        res += flag * calc(l + k1, tot) * p[l] % mod * C[k2][l] % mod;
        res %= mod;
    } return (res + mod) % mod;
}

int main() {
    scanf("%d%d", &K, &n);
    prework();
    ll ans = 0;
    for (int i = 2; i <= 2 * K; i++) {
        if (i % 2) ans = solve(i, n);
        else ans = (solve(i, n) + solve(i, n - 1)) % mod;
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 124288
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ctoi(x) x-'0'
#define fr(i,n) for(ll i=0;i<n;i++)
#define srt(a) sort(a.begin(),a.end())
#define WUBBAxxLUBAxxDUBxxDUB int main
#define salamo3lekooooom ios::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
#define pb(a,x) ll x; cin>>x; a.push_back(x);
#define test() ll q; cin>>q; while(q--)
using namespace std;
const string alph="abcdefghijklmnopqrstuvwxyz";
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
   {
       return (a.second < b.second);
   }

                #define LIMIT 1000000
                long long i, j;
                long long prime_flag[LIMIT];
                void calculate_prime_flag()
                {
                    prime_flag[0] = prime_flag[1] = 1;
                    for(i=2; i<LIMIT; i++)
                    {
                        if (prime_flag[i]==0)
                        {
                            for(j=i*i; j<LIMIT; j+=i)
                            {
                                prime_flag[j] = 1;
                            }
                        }
                    }
                }





                int LPS(char *str)
                {
                    int n=strlen(str);
                    int i,j,cl;
                    int l[n][n];
                    for(i=0; i<n; i++)
                        l[i][i]=1;
                    for(cl=2; cl<=n; cl++)
                    {
                        for(i=0; i<n-cl+1; i++)
                        {
                            j=i+cl-1;
                            if(str[i]==str[j]&&cl==2)
                                l[i][j]=2;
                            else if (str[i]==str[j])
                                l[i][j]=l[i+1][j-1]+2;
                            else
                                l[i][j]=max(l[i][j-1],l[i+1][j]);


                        }
                    }
                    return l[0][n-1];


                }


bool prime(ll x)
{
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return false;

    }
    return true;
}

/////3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
// Get SHWIFTY

ll LCM ( ll x,ll y)
{
    return (x*y)/__gcd(x,y);
}

int setBitNumber(int n)
{
    if (n == 0)
        return 0;

    int msb = 0;
    while (n != 0) {
        n = n / 2;
        msb++;
    }

    return msb-1;
}


const ll mod = 1e9+7;
long long fastpower(long long a,long long b)
{
    if(b==0)
        return 1;
    if(b==1)
        return a;
    long long res = fastpower(a,b/2);
    res = (res* res);
    res%= mod;
    if(b%2!=0)
        res*=a;
    return res%mod;
}


WUBBAxxLUBAxxDUBxxDUB(){
salamo3lekooooom;


    string x,y;
    cin>>x>>y;
    bool ok=0;
    for(int i=0;i<y.size()-1;i++)
    {
        if(x[i]!=y[i])
        {
            ok=1;
            break;
        }
    }
    if(ok==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3652
#include<stdio.h>
int main()
{
	int i,j=0,N;
	scanf("%d",&N);
	char a[N];
	scanf("%s",a);
	for(i=0;i<N;i++)
	{
		if(i<N-2)
		{
			if(a[i]=='A'&&a[i+1]=='B'&&a[i+2]=='C')
			{
				j++;
			}
			
		}
	}
	printf("%d",j);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var ai = Console.ReadLine().Trim().Split(' ').Select(decimal.Parse).ToArray();
            if (ai.Contains(0))
            {
                Console.WriteLine(0);
                return;
            }
            var limit = (decimal)1e18;
            decimal answer = 1;
            for (var i = 0; i < ai.Length; i++)
            {
                try
                {
                    answer *= ai[i];
                }
                catch
                {
                    Console.WriteLine(-1);
                    return;
                }
                if (answer > limit)
                {
                    Console.WriteLine(-1);
                    return;
                }
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 43132
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	vector<ll> B(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i)>> B.at(i);
	}
	ll an = 0;
	for (int i = N-1; i >=0; i--) {
		an += (B.at(i) - (A.at(i) + an) % B.at(i)) % B.at(i);
		
	}

	cout << an << endl;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;
constexpr int INF = 1 << 30;

void solve()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	reverse(a.begin(), a.end());

	vector<int> dp(n, INF);
	for(int i = 0; i < n; ++i)
	{
		*upper_bound(dp.begin(), dp.end(), a[i]) = a[i];
	}

	cout << lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3980
import sys
input=sys.stdin.buffer.readline
mod=10**9+7

n,m=map(int,input().split())
*x,=map(int,input().split())
*y,=map(int,input().split())
xd=[i-j for j,i in zip(x,x[1:])]
yd=[i-j for j,i in zip(y,y[1:])]
xs=ys=0
for i,d in enumerate(xd):
	xs+=d*(i+1)*(n-1-i)%mod
	xs%=mod
for i,d in enumerate(yd):
	ys+=d*(i+1)*(m-1-i)%mod
	ys%=mod
print(xs*ys%mod)

Measured memory_bytes: 20892
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

// 分割数は、写像12相のうち以下に相当する
//  ・玉の区別をしない
//  ・箱の区別をしない
//  ・箱に入る玉の数に制限はない
// cf: http://drken1215.hatenablog.com/entry/2018/01/16/222843

// 定義
//  P(n,k): 区別のないn個の玉を、区別のないk個の箱に、中身が0個以上になるように分ける方法
//  Q(n,k): 区別のないn個の玉を、区別のないk個の箱に、中身が1個以上になるように分ける方法

// PとQの関係
//  Q(n,k) = P(n-k,k)

// Pの初期化
//  P(0,?) = P(?,1) = 1

// Pの漸化式
//  P(n,k) = P(n,k-1) + P(n-k,k)  if n >= k > 1
//  P(n,k) = P(n,n)               if n < m

// Qの初期化
//  Q(?,1) = Q(?,?) = 1

// Qの漸化式
//  Q(n,k) = Q(n-1,k-1) + Q(n-k,k)  if n >= k >= 2


class PartitionNumber {
    vector <vector<ll>> P, Q;

    void initP(int N) {
        for (int k = 0; k <= N; k++) P[0][k] = P[k][1] = 1;
        for (int n = 1; n <= N; n++) {
            for (int k = 2; k <= n; k++) P[n][k] = (P[n][k - 1] + P[n - k][k]) % MOD;
            for (int k = n + 1; k <= N; k++) P[n][k] = P[n][n];
        }
    }

    void initQ(int N) {
        for (int n = 0; n <= N; n++) Q[n][1] = Q[n][n] = 1;
        for (int n = 2; n <= N; n++) {
            for (int k = 2; k <= n; k++) Q[n][k] = (Q[n - 1][k - 1] + Q[n - k][k]) % MOD;
        }
    }

public:
    PartitionNumber(int N) {
        P.assign(N+1, vector<ll>(N + 1, 0));
        Q.assign(N+1, vector<ll>(N + 1, 0));
        initP(N);
        initQ(N);
    }

    ll p(int n, int k) { return P[n][k]; }

    ll q(int n, int k) { return Q[n][k]; }
};


// verified
//   https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/5/DPL_5_J
void AOJ_DPL_5_J() {
    int n, k;
    cin >> n >> k;
    PartitionNumber pn(1000);
    cout << pn.p(n, k) << "\n";
}


// verified
//   https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/5/DPL_5_L
void AOJ_DPL_5_L() {
    int n, k;
    cin >> n >> k;
    PartitionNumber pn(1000);
    cout << pn.q(n, k) << "\n";
}


// verified
//   https://yukicoder.me/problems/no/269
void yuki269() {
    int N, S, K;
    cin >> N >> S >> K;
    S -= K * N * (N - 1) / 2;
    if (S < 0) cout << 0 << '\n';
    else {
        PartitionNumber pn(S);
        cout << pn.p(S, N) << "\n";
    }
}

int main() {
    // AOJ_DPL_5_J();
    AOJ_DPL_5_L();
    //yuki269();
    return 0;
}


Measured memory_bytes: 18720
#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <stack>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#define esp 1e-9
#define INF 0x3f3f3f3f
#define Pi acos(-1.0)
const int maxn = 3*1e6;
typedef long long ll;
using namespace std;

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

    if(a<=0 && b>=0)
        printf("Zero\n");
    else if(a>0 && b>0)
        printf("Positive\n");
    else if(a<0 && b<0)
    {
        if((b-a)%2)
            printf("Positive\n");
        else
            printf("Negative\n");
    }
    return 0;
}


Measured memory_bytes: 256
import collections
compare = lambda x, y: collections.Counter(x) == collections.Counter(y)

counter = [0] * 4
for i in range(3):
    a, b = map(int, input().rstrip().split())
    counter[a - 1] += 1
    counter[b - 1] += 1
if compare(counter, [1, 1, 2, 2]):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	double ans;
	double x = round((n + 1) / 2);
	ans = x / n;
	printf("%.6f", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<pair<int,int>>> vec(100010);
	vector<pair<int, int>> pa(100010);
	for (int i = 0; i < m; i++) {
		int p, y;
		cin >> p >> y;
		vec[p].emplace_back(make_pair(y,i));
	}
	for (int j = 1; j <= n; j++) {
		sort(vec[j].begin(), vec[j].end());
	}
	for (int k = 0; k <= n; k++) {
		for (int l = 0; l < vec[k].size(); l++) {
			pa[vec[k][l].second] = make_pair(k, l);
		}
	}
	for (int i = 0; i < m; i++) {
		string s = to_string(pa[i].first);
		string s1 = to_string(pa[i].second + 1);
		for (int j = 0; j < 6 - s.size(); j++) {
			cout << "0";
		}
		cout << s;
		for (int k = 0; k < 6 - s1.size(); k++) {
			cout << "0";
		}
		cout << s1 << endl;
	}
}

Measured memory_bytes: 7808
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;
int gcd(int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int main() {
    // int n;
    // cin >> n;

    // vector<int> value(n);
    // rep(i, 0, n) {
    //     cin >> value[i];
    // }

    // vector<bool> visit(n, false);
    // rep(i, 0, n) {
    //     if (visit[i]) continue;
    //     rep(j, i + 1, n) {
    //         if (visit[j]) continue;
    //         if (value[i] % value[j] == 0) {
    //             visit[j] == true;
    //         }
    //     }
    // }

    int x, n;
    cin >> x >> n;

    vector<int> value(n);
    rep(i, 0, n) {
        cin >> value[i];
    }
    sort(value.begin(), value.end());

    int ans = -1;
    repe(y, 0, 101) {
        bool isExsist = false;
        rep(i, 0, n) {
            if (y == value[i]) {
                isExsist = true;
                break;
            }
        }
        if (!isExsist) {
            if (abs(ans - x) > abs(x - y)) {
                ans = y;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
	int n, m, x;
	cin >> n >> m >> x;
	int a[m], b[n] = {};
	for (int i = 0; i < m; i++) {
		cin >> a[i];
		b[a[i]]++;
	}
	int cnt1 = 0, cnt2 = 0;
	for (int i = 0; i < x; i++) {
		cnt1 += b[i];
	}
	for (int i = x; i < n; i++) {
		cnt2 += b[i];
	}
	cout << min(cnt1, cnt2) << endl;
	return 0;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())

for i in range(K):
    if i % 2 == 0:
        if A % 2 != 0:
            A -= 1
        num = A // 2
        A = num
        B += num
    else:
        if B % 2 != 0:
            B -= 1
        num = B // 2
        B = num
        A += num

print(A, B)

Measured memory_bytes: 3060
nums = list(map(int, list(input())))

flag = 7
while flag >= 0:
    S = []
    total = nums[0]
    bin_str = format(flag, "03b")
    for i, bit in enumerate(bin_str, 1):
        if int(bit):
            total += nums[i]
            S.append("+")
        else:
            total -= nums[i]
            S.append("-")
    if total == 7:
        break
    
    flag -= 1
print(f"{nums[0]}{S[0]}{nums[1]}{S[1]}{nums[2]}{S[2]}{nums[3]}=7")

Measured memory_bytes: 9140
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

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

    int ans = 1;
    char prev = s.front();
    for (int i = 1; i < n; i++)
    {
        if (s[i] != prev)
        {
            ans++;
        }
        prev = s[i];
    }

    cout << ans << endl;

    return 0;
}

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

int N,M;
int T[101],P[101],X[101];
int sum(){
	int ret=0;
	for(int i=1;i<=N;i++){
		ret += T[i];
	}
	return ret;
}

int main(){
	
	
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> T[i];
	}
	cin >> M;
	for(int i=0;i<M;i++){
		cin >> P[i] >> X[i];
	}
	
	for(int i=0;i<M;i++){
		int memo = T[P[i]];
		T[P[i]] = X[i];
		cout << sum() << endl;
		T[P[i]] = memo;
	}
	
	return 0;
}

Measured memory_bytes: 256
S = input()
mod = 2019

t = len(S)
l = [0] * (t + 1)
for i in range(t-1, -1, -1):
    l[i] = (l[i+1] + int(S[i]) * pow(10, t-i-1, mod)) % mod

from collections import Counter

def nC2(n):
    return n * (n - 1) // 2

l = list(Counter(l).values())

ans = 0
for i in l:
    ans += nC2(i)

print(ans)

Measured memory_bytes: 16524
#include <iostream>
#include <string>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  for(int i=0;i< s.size();i++){
    int x=s[i]-'A';
    x=(x+n)%26;
    s[i] = ('A'+x);
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  bool buy = false;
  for(int i = 0; i < (n/7 + 1); i++){
    for(int j = 0; j < (n/4 + 1); j++){
      if((7*i + 4*j) == n){
        buy = true;
        break;
      }
    }
    if(buy) break;
  }
  if(buy) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <random>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int main () {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    unordered_set<string> s;
    string t, p;
    cin >> t;
    p = t;
    s.emplace(t);
    bool b = false;
    for (int i = 0; i < n-1; ++i) {
        cin >> t;
        if (s.find(t) != s.end() || p[p.size()-1] != t[0]) {
            b = true;
        }
        
        s.emplace(t);
        p = t;
    }
    
    
    
    cout << (b?"No":"Yes") << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

def io_generator():
	while True:
		yield raw_input()

#+++++++++++++++++++

def gojo(i,j):
	a=max(i,j)
	b=min(i,j)
	while b > 0:
		t=b
		c=a/b
		b=a%b
		a=t
	return a
		

def main(io):
	a=int(io.next())
	l= list(map(int, io.next().split()))
	
	a=l[0]
	for i in l[1:]:
		a=gojo(a,i)
	return a


#++++++++++++++++++++

if __name__ == "__main__":
	io=io_generator()
	print main(io)


Measured memory_bytes: 11296
#include <stdio.h>

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    
    int answer[] = {a, b, c};
    int i, small, big;
    if (answer[1] > answer[2]) {
        small = answer[2];
        big = answer[1];
        answer[1] = small;
        answer[2] = big;
    }
    
    if (answer[0] > answer[1]) {
        small = answer[1];
        big = answer[0];
        answer[0] = small;
        answer[1] = big;
    }
    
    if (answer[1] > answer[2]) {
        small = answer[2];
        big = answer[1];
        answer[1] = small;
        answer[2] = big;
    }
    
    printf("%d %d %d\n", answer[0], answer[1], answer[2]);
}


Measured memory_bytes: 2708