akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;

int main() {
  string s;
  cin >> s;
  int n;
  n=s.size();
  char c;
  int d=0;
  rep(i,n){
    c = s.at(i);
    if(c=='1') d+=1;
    if(c=='2') d+=2;
    if(c=='3') d+=3;
    if(c=='4') d+=4;
    if(c=='5') d+=5;
    if(c=='6') d+=6;
    if(c=='7') d+=7;
    if(c=='8') d+=8;
    d%=9;
  }
  if(d==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<b){
        cout<<"a < b"<<endl;
    }else if(a>b){
        cout<<"a > b"<<endl;
    }else{
        cout<<"a == b"<<endl;
    }
    return 0;
}


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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i = a; i <= b; i++) {
    string s = to_string(i);
    if (s[0] == s[4] && s[1] == s[3]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int a[3];

int main(){
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[2]-a[0]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

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

  int length = s.length();

  if (s.substr(0, length/2) == s.substr(length / 2 + 1, length)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	N := nextInt()

	c := 0
	for i := 1; i <= N; i++ {
		b := 1
		n := 0

		for i/b != 0 {
			b *= 10
			n++
		}

		if n%2 == 1 {
			c++
		}
	}

	fmt.Println(c)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}


int main() {
	int N; cin >> N;
	vector<int> p(N);
	for (int i = 0; i < N; i++)cin >> p[i];
	sort(ALL(p));
	int ans = 0;
	for (int i = 0; i < N - 1; i++)ans += p[i];
	ans += p[N - 1] / 2;
	cout << ans << endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc130/tasks/abc130_c
import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    W, H, x, y = map(int, input().split())
    area = W * H
    if x == W / 2 and y == H / 2:  # 中点
        print('{} {}'.format(area / 2, 1))
    else:
        print('{} {}'.format(area / 2, 0))
        # center_x = W / 2
        # center_y = H / 2
        # if x == center_x or y == center_y:
        #     print('{} {}'.format(area // 2), 0)
        # else:
        #     a = (center_x - x) / (center_y - y)
        #     b = y - a * x
        #     if 0 <= b <= H:
        #         area1 = (b + )
        #
        #
        #     else:




if __name__ == '__main__':
    main()


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

enum {LUNCH, DINNER, MIDNIGHT};

int main() {
	const string times[] = {"lunch", "dinner", "midnight"};

	for(int n; scanf("%d", &n) == 1 && n;) {
		array<int, 3> num, ok;
		num.fill(0);
		ok.fill(0);

		for(int i = 0; i < n; ++i) {
			int h, m;
			scanf("%d:%d", &h, &m);

			int M;
			scanf("%d", &M);

			int t = -1;
			if(11 <= h && h <= 14) {
				t = LUNCH;
			}
			else if(18 <= h && h <= 20) {
				t = DINNER;
			}
			else if(21 <= h || h <= 1) {
				t = MIDNIGHT;
			}
			else {
				continue;
			}

			++num[t];
			if((M - m + 60) % 60 <= 8) ++ok[t];
		}

		for(int t = 0; t < 3; ++t) {
			cout << times[t] << " ";

			if(num[t]) {
				cout << 100 * ok[t] / num[t] << "\n";
			}
			else {
				cout << "no guest\n";
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if (a <= 9 && b <= 9) printf("%d\n", a*b);
    else printf("-1\n");
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int total = 0;
		int[] l = new int[N];
		for(int i = 0 ; i < N ; i++) {
			l[i] = sc.nextInt();
		}
		Arrays.sort(l);
		for(int i = N - 1 ; i >= N - K ; i--) {
			total += l[i];
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 23636
a, b = map(int, input().split())

if a > 0 and b > 0 or a < 0 and b < 0:
    if a > b:
        print(a-b+2)
    else:
        print(b-a)
elif abs(a) == abs(b):
    print(1)
else:
    if b == 0 and a > b:
        print(abs(abs(a)-abs(b))+1)
    elif b == 0:
        print(abs(abs(a)-abs(b)))
    elif a == 0 and b > 0:
        print(abs(abs(a)-abs(b)))
    else:
        print(abs(abs(a)-abs(b))+1)


Measured memory_bytes: 62008
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

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

#############
# Main Code #
#############

N, M, L = getNM()
edges = [getList() for i in range(M)]
Q = getN()
query = [getList() for i in range(Q)]

dist = [[float('inf')] * N for i in range(N)]
for i in range(N):
    dist[i][i] = 0
for i in range(M):
    a, b, c = edges[i]
    dist[a - 1][b - 1] = c
    dist[b - 1][a - 1] = c

def warshall_floyd(dist):
    for k in range(N):
        # i:start j:goal k:中間地点でループ回す
        for i in range(N):
            for j in range(N):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
    return dist

# まず一回回す
warshall_floyd(dist)

# distの抽象化
# edgesの張り替え
dist_alta = [[float('inf')] * N for i in range(N)]
for i in range(N):
    for j in range(i, N):
        if i == j:
            dist_alta[i][j] = 0
            continue
        if dist[i][j] <= L:
            dist_alta[i][j] = 1
            dist_alta[j][i] = 1

warshall_floyd(dist_alta)

for s, t in query:
    if dist_alta[s - 1][t - 1] == float('inf'):
        print(-1)
        continue
    print(dist_alta[s - 1][t - 1] - 1)

Measured memory_bytes: 102224
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    string s,ss;
    cin >> s;
    rep(i,s.size()) {
        if (i%2==0) {
            ss += s[i];
        }
    }
    cout << ss << "\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
void rotateU(vector<string>& cube){
  string s = cube[2].substr(2) + cube[2].substr(0,2);
  cube[2] = s;
  char c = cube[0][2];
  cube[0][2] = cube[1][2];
  cube[1][2] = cube[1][3];
  cube[1][3] = cube[0][3];
  cube[0][3] = c;
}
void rotateF(vector<string>& cube){
  char c1 = cube[1][3];
  char c2 = cube[1][2];
  cube[1][3] = cube[2][1];
  cube[1][2] = cube[3][1];
  cube[2][1] = cube[4][2];
  cube[3][1] = cube[4][3];
  cube[4][2] = cube[3][4];
  cube[4][3] = cube[2][4];
  cube[3][4] = c1;
  cube[2][4] = c2;
  char c = cube[2][2];
  cube[2][2] = cube[3][2];
  cube[3][2] = cube[3][3];
  cube[3][3] = cube[2][3];
  cube[2][3] = c;
}
void rotateR(vector<string>& cube){
  char c1 = cube[0][3];
  char c2 = cube[1][3];
  cube[0][3] = cube[2][3];
  cube[1][3] = cube[3][3];
  cube[2][3] = cube[4][3];
  cube[3][3] = cube[5][3];
  cube[4][3] = cube[3][6];
  cube[5][3] = cube[2][6];
  cube[3][6] = c1;
  cube[2][6] = c2;
  char c = cube[2][4];
  cube[2][4] = cube[3][4];
  cube[3][4] = cube[3][5];
  cube[3][5] = cube[2][5];
  cube[2][5] = c;
}
void rotateD(vector<string>& cube){
  string s = cube[3].substr(6) + cube[3].substr(0,6);
  cube[3] = s;
  char c = cube[4][2];
  cube[4][2] = cube[5][2];
  cube[5][2] = cube[5][3];
  cube[5][3] = cube[4][3];
  cube[4][3] = c;
}
void rotateB(vector<string>& cube){
  char c1 = cube[0][2];
  char c2 = cube[0][3];
  cube[0][2] = cube[2][5];
  cube[0][3] = cube[3][5];
  cube[2][5] = cube[5][3];
  cube[3][5] = cube[5][2];
  cube[5][3] = cube[3][0];
  cube[5][2] = cube[2][0];
  cube[3][0] = c1;
  cube[2][0] = c2;
  char c = cube[2][6];
  cube[2][6] = cube[3][6];
  cube[3][6] = cube[3][7];
  cube[3][7] = cube[2][7];
  cube[2][7] = c;
}
void rotateL(vector<string>& cube){
  char c1 = cube[1][2];
  char c2 = cube[0][2];
  cube[1][2] = cube[2][7];
  cube[0][2] = cube[3][7];
  cube[2][7] = cube[5][2];
  cube[3][7] = cube[4][2];
  cube[5][2] = cube[3][2];
  cube[4][2] = cube[2][2];
  cube[3][2] = c1;
  cube[2][2] = c2;
  char c = cube[2][0];
  cube[2][0] = cube[3][0];
  cube[3][0] = cube[3][1];
  cube[3][1] = cube[2][1];
  cube[2][1] = c;
}
int main()
{
  vector<string> cube(6);
  cube[0] = "..rr....";
  cube[1] = "..rr....";
  cube[2] = "ggyybbww";
  cube[3] = "ggyybbww";
  cube[4] = "..oo....";
  cube[5] = "..oo....";
  string s;
  cin >> s;
  for(int i=0; i<s.length(); i++){
    switch(s[i]){
    case 'U': rotateU(cube); break;
    case 'F': rotateF(cube); break;
    case 'R': rotateR(cube); break;
    case 'D': rotateD(cube); break;
    case 'B': rotateB(cube); break;
    case 'L': rotateL(cube); break;
    }
  }
  for(int i=0; i<6; i++){
    cout << cube[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
#include <cstdio>
#include <algorithm>
#include <cmath>
#define INF 0x3f3f3f3f

using namespace std;

const int MAXN = (int)1e6;
//int P[MAXN],X[MAXN];

struct item{
	int ord;
	int val;
	inline bool operator < 	(item rhs) const{
		if(ord == rhs.ord){
			return val < rhs.val;
		}
		else{
			return ord < rhs.ord;
		}
	}
}X[MAXN],T[MAXN];
int main(){
	int o,m;
	scanf("%d%d",&o,&m);
	for(int i = 1;i <= m;i++){
		scanf("%d%d",&X[i].ord,&X[i].val);
		T[i] = X[i];
	}
	sort(T + 1,T + m + 1);
	for(int i = 1;i <= m;i++){
		item t;
		t.ord = X[i].ord - 1;
		t.val = INF;
		printf("%06d%06d\n",X[i].ord,lower_bound(T,T + m + 1,X[i]) - lower_bound(T,T + m + 1,t) + 1);	
	}
	return 0;
} 

Measured memory_bytes: 6272
#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;

int main(){
    int n,k;
    cin >> n >> k;
    vector<double> p(2*n,0.0);
    rep(i,n)cin>>p[i];
    rep(i,n)p[i] = (float)(p[i]+1)/2;
    vector<double> a(n+1,0);
    double a_0=0;
    rep(i,k)a_0+=p[i];
    a[0] = a_0;
    rrep(i,n){
        a[i] = a[i-1]-p[i-1]+p[i+k-1];
    }
    double ans = 0;
    rep(i,n-k+1){
        ans = max(ans, a[i]);
    }
    printf("%.10f\n",ans);
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n;
    set<char> s;
    cin >> n;
    repeat(i, n) {
        char c;
        cin >> c;
        s.insert(c);
    }
    if (s.size() == 3) {
        cout << "Three" << endl;
    }
    else {
        cout << "Four" << endl;
    }
}
    


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   int a,b,c;
   scanf("%d %d %d", &a, &b, &c);
   if(a <= b && b <= c) {
    printf("%d %d %d\n", a, b, c);
   }
   else if(b <= a && a <= c) {
   printf("%d %d %d\n", b, a, c);
   }
   else if(c <= a && a <= b) {
   printf("%d %d %d\n", c, a, b);
   }
   else if(a <= c && c <= b) {
   printf("%d %d %d\n", a, c, b);
   }
   else if(b <= c && c <= a) {
   printf("%d %d %d\n", b, c, a);
   }
   else if(c <= b && b <= a) {
   printf("%d %d %d\n", c, b, a);
   }
   return 0;
}


Measured memory_bytes: 2044
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication17 {
    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            var result = Method(n);
            Console.WriteLine(result);
        }


        private static int Method(int n) {

            int X = 800; //今までに払った金額
            int y = 200; //もらった金額
            int result = 0; //結果

            result = n * X - y * (n / 15);

            return result;
        } 

    }
}


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

int main() {
    int N, A, B;
    cin >> N;
    if (N == 1){
        cout << "Hello World" << endl;;
    }else if (N == 2){
        cin >> A >> B;
        cout << A + B << endl;
    }
    
}

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

int H, N;
int A[100000];

int main(){

	cin >> H >> N;

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

	int sum = 0;
	for (int i=0; i<N; i++) {
		sum += A[i];
	}

	string ans;
	if (sum >= H) {
		ans = "Yes";
	} else {
		ans = "No";
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int w = sc.nextInt();
            int n = sc.nextInt();
            int val[] = new int[w];
            for (int i = 0; i < w; i++){
                val[i] = i;
            }
            for (int i = 0; i < n; i++) {
                String str = sc.next();
                String[] ab = str.split(",");
                int a = Integer.parseInt(ab[0]) - 1;
                int b = Integer.parseInt(ab[1]) - 1;
                int tmp = val[a];
                val[a] = val[b];
                val[b] = tmp;
            }
            for (int i = 0; i < w; i++) {
                System.out.println(val[i]+1);
            }
        }
    }
}


Measured memory_bytes: 26160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repeq(i,a,b) for(int i=a;i<=(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    const int C=2000*1000+1;
    bitset<C> bs;
    bs[0] = true;
    int sum=0;
    rep(i,0,n) {
        int a;
        cin >> a;
        sum+=a;
        bs|=bs<<a;
    }
    int best=0;
    repeq(i,0,sum/2) if(bs[i]) best=i;
    int ans = sum-best;
    cout<<ans<<endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
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;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s;cin>>s;
	int cnt=0,mx=0;
	rep(i,len(s)){
		if(s[i]=='R')cnt++;
		else cnt=0;
		chmax(mx,cnt);
	}
	cout<<mx<<endl;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;
int Solve(int Number)
{
	int a = 0, Temp;
	Temp = Number % 1000;
	if (Temp != 0)
	{
		a = 1000 - Temp;
		return a;
	}
	else
	{
		return 0;
	}
}
int main()
{
	int Num;
	cin >> Num;
	cout << Solve(Num) << endl;
	return 0;
}

Measured memory_bytes: 3168
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
int gcd(int a, int b){return b?gcd(b,a%b):a;}

int N, A, B[] = {[0 ... 1<<20] 0}, t = 0;
bool flg = true;
int main(){
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		scanf("%d", &A);
		t = gcd(A, t);
		if(flg){
			for(int j=2; j*j <= A; j++){
				if(A%j == 0){
					while(A%j==0)A /= j;
					B[j]++;
					if(B[j] > 1){
						flg = false;
						break;
					}
				}
			}
			B[A]++;
			if(A!=1 && B[A] > 1)flg = false;
		}
	}
	if(flg){
		puts("pairwise coprime");
	}else if(t == 1){
		puts("setwise coprime");
	}else {
		puts("not coprime");
	}
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  bool seven = false;
  
  if (N/100 == 7) seven = true;
  N = N % 100;
  if (N/10 == 7) seven = true;
  N = N % 10;
  if (N == 7) seven = true;

  if (seven) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3636
n = int(input())
task = [[0 for i in range(2)] for j in range(n)]
frag = True
total = 0
for i in range(0, n):
    task[i][0], task[i][1] = map(int, input().split())
task = sorted(task, key=lambda x: x[1])

for i in range(n):
    total += task[i][0]
    if total > task[i][1]:
        frag = False

if frag == True:
    print("Yes")
if frag == False:
    print("No")


Measured memory_bytes: 42776
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)

int main(){
  ll i,j,N,M,Q,l,r;
  cin>>N>>M>>Q;
  mat v(N,vec(N,0));
  rep(i,M){
    cin>>l>>r;
    v[l-1][r-1]++;
  }

  rep(i,N){
    rep1(j,N){
      v[i][j]+=v[i][j-1];
    }
  }
  rep(j,N){
    for(i=j-1;i>=0;i--){
      v[i][j]+=v[i+1][j];
    }
  }

  while(Q--){
    cin>>l>>r;
    cout<<v[l-1][r-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 2944
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
    int i,j,len,lenr,lenp;
    string s,m,m2,n,m3,n2;
    cin >> s;
    len=s.size();
    lenr=(len-1)/2;
    m=s;
    m2=s.substr(0,lenr);
    n=m2;
    m3=s.substr((len+3)/2-1,lenr);
    n2=m3;
    
    reverse(m.begin(), m.end());
    reverse(n.begin(), n.end());
    reverse(n2.begin(), n2.end());
        if(s!=m || m2!=n || m3!=n2)
        {
            cout << "No" << endl;
            return 0;
        }
    
    

    cout << "Yes" << endl;
    

    

}


Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
	int n,i,k,flg,sum;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		flg=0;
		sum=0;
		for(i=0;i<n;i++){
			scanf("%d",&k);
			if(k>=2){
				flg=1;
			}
			if(k==0){
				sum=sum-1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
		else{
		sum=sum+n+1;
		printf("%d\n",sum);
		}
	}
	return 0;
}


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

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

int a[101];

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    rep(i,1,n+1) cin >> a[i];
    int ans=0;
    int cnt=1;
    for(int i=1; i<=n; i++){
        if(a[i]==a[i-1]) cnt++;
        if(a[i]!=a[i-1] || i==n){
            ans+=cnt/2;
            cnt=1;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <cassert>
#include <time.h>
#include <numeric>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef vector<int> vi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define ll long long int
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i, a, b) for(int i = a; i < b; i++)


#define trarr(a,n) forn(i,0,n) cerr<<a[i]<<" \n"[i==n-1];
#define trmat(g,n,m) forn(i,0,n)forn(j,0,m) cerr<<g[i][j]<<" \n"[i==m-1];
#define tr(...) cerr<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const ld PI = acos(-1);
const ld EPS = 1e-9;
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int P = 1e9+7;
const int N = 2e5+10;

void solve(int _t){
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, 0, s.length()){
		if(s[i]!=t[i])
			ans++;
	}
	cout<<ans<<endl;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	// cin >> t;
	rep(test, 1, t+1){
		solve(test);
	}
	return 0;
}  

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

int main(){
  int n,j,fa,fb,acount,acount2,i;
  string data;
  
  cin >> n;
  
  getline(cin,data);
  for(j = 0; j < n; j++){
    fa = 0;
    fb = 0;
    acount = acount2 = 0;
    getline(cin,data);
    if(data.length() < 6)
      data = "OOHAZURE";
    if(data[0] == '>' && data[1] == '\''){
      fa = 1;
      i = 2;
      while(data[i] == '='){
	acount++;
	i++;
      }
      if(data[i] != '#')
	fa = 0;
      i++;
      while(data[i] == '='){
	acount2++;
	i++;
      }
      if(i != data.length()-1)
	fa = 0; 
      if(acount != acount2)
	fa = 0;
      if(data[data.length()-1] != '~'){
	fa = 0;
      }
    }
    if(data[0] == '>' && data[1] == '^'){
      fb = 1;
      for(i = 2; i < data.length()-3; i = i+2){
	if(data[i] != 'Q' || data[i+1] != '=')
	  fb = 0;
      }
      if(i != data.length()-2)
	fb = 0;
      if(data[data.length()-1] != '~' || data[data.length()-2] != '~')
	fb = 0;
    }
    if(fa == 1)
      cout << "A" << endl; 
    else if(fb == 1)
      cout << "B" << endl;
    else 
      cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
// 2020-08-07 18:30:38
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

int q;
ll r1, c1, r2, c2, pow3[40];
void solve() {
  REPCM(k, 30, 1) {
    int j = k - 1;
    bool interrupted = true;
    interrupted &= (r1 / pow3[j] + 2 <= r2 / pow3[j]);
    interrupted &= (c1 / pow3[j] == c2 / pow3[j]);
    interrupted &= ((c1 / pow3[j]) % 3 == 1);
    if(interrupted) {
      int j = k - 1;
      ll l = c1 / pow3[j] * pow3[j];
      ll r = l + pow3[j];
      ll cd = min(c1-l+c2-l+2, r-c1+r-c2);
      cout << r2-r1+cd << '\n';
      return;
    }
  }
  cout << abs(r2-r1) + abs(c2-c1) << '\n';
}
void answer() {
  cin >> q;
  pow3[0] = 1;
  rep(i, 35) pow3[i+1] = pow3[i] * 3;
  auto normalize = [&]() {
    r1--; r2--; c1--; c2--;
    if(abs(r1-r2) < abs(c1-c2)) {
      swap(r1, c1);
      swap(r2, c2);
    }
    if(r1 > r2) {
      swap(r1, r2);
      swap(c1, c2);
    }
  };
  rep(qi, q) {
    cin >> r1 >> c1 >> r2 >> c2;
    normalize();
    solve();
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
    #pragma gcc optimize("ofast")
    using namespace std;

    #define ll long long
    #define ull unsigned long long
    #define ui unsigned int
    #define mod 1000000007
    #define us unsigned short
    #define IOS ios_base::sync_with_stdio(0);
    #define INF LONG_MAX
    #define PI 3.1415926535897932384626
    #define mp make_pair
    #define fi first
    #define se second
    #define pb push_back
    #define rep(x,j,n)for(int x=j;x<n;x++)
    typedef vector<pair<ll,ll>> vpi;
    typedef vector<ll> vi;
    typedef vector<vi> vvi;

    ll modexp(ll a,ll b,ll m)
    {
    	ll r=1;
    	a=a%m;
    	while(b>0)
    	{
    	if(b&1)
    		r=(r*a)%m;
    	b=b/2;
    	a=(a*a)%m;
    	}
    	return r%m;
    }


    int main()
    {
        IOS
        ll n;
        cin>>n;
        cout<<n*n*n<<'\n';
        return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
ll n,k;
ll a[200001];
vector<ll> tin(200001,0);
vector<bool> vis(200001,0);
int timer=0;
int kth=0;
int  solve(int idx){
  if(vis[idx]) {kth=idx;return(timer-tin[idx]);}
  tin[idx]=timer++;
  vis[idx]=1;
  return solve(a[idx]);
}
int solve1(int idx,int k){
  if(k==0) return idx;
  vis[idx]=1;
  k--;
  return solve1(a[idx],k);
}
void solve(){
  cin>>n>>k;
  rep(i,0,n) cin>>a[i];
  rep(i,0,n) a[i]-=1;
  int z=solve(0);
  ll ans=0;
  rep(i,0,n) if(vis[i]) ans++;

  rep(i,0,n) vis[i]=0;
  // cout<<k<<ans<<endl;
  if(k<=ans){
    // cout<<kth<<" "<<k<<endl;
    cout<<solve1(0,k)+1<<endl;
  }
  else{
    // cout<<ans<<" "<<z<<" "<<endl;
    k=k-(ans-z);
    // cout<<k<<endl;
    // if(ans>z) k--;
    // if(k<0) k+=z;
    // cout<<k<<endl;
    k=k%z;

    // cout<<k<<endl;
    // k--;
    // cout<<kth<<endl;
    cout<<solve1(kth,k)+1<<endl;
  }
}
int main(){
    optimizeIO();
    // tc
    {
      solve();
    }
}


Measured memory_bytes: 6372
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;
 
int main(){
  int H,W;
  cin >> H >> W;
  vector<string> S(H+2);
  for(int i = 1; i <= H; ++i){
    cin >> S[i];
    S[i] = "." + S[i] + ".";
  }
  S[0] = string(W+2, '.');
  S[H+1] = string(W+2, '.');
  bool flag = true;
  for(int i = 1; i <= H; ++i){
    for(int j = 1; j <= W; ++j){
      if(S[i][j] == '.') continue;
      if(S[i-1][j] == '.' && S[i][j-1] == '.' && S[i][j+1] == '.' && S[i+1][j] == '.' ){
	flag = false;
      }
    }
  }
 
 
  if(flag)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC diagnostic warning "-std=c++11"
using namespace std;
#define ll long long 
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((ll)(1e18+100))
#define MX ((ll)(1e6+90))
#define ARRS ((ll)(3e5+100))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define EPS ((double)(1e-8))
#define pb push_back
#define PI ((double)3.141592653)
#define LG 16

ll n,m;
pair<ll,ll>  a[ARRS];
ll pas[ARRS];

int main(){
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>a[i].fr;
		a[i].sc=i;
	}

	ll m=n/2;
	m--;

	sort(a,a+n);

	for(int i=0; i<n; i++){
		if(i<=m)
			pas[a[i].sc]=a[m+1].fr;
		else pas[a[i].sc]=a[m].fr;
	}

	for(int i=0; i<n; i++)
		cout<<pas[i]<<endl;
}


Measured memory_bytes: 7808
S = input()

flg = True
for i in range(len(S)):
    s = S[i]
    if (i+1) % 2 == 0:
        if s == 'R':
            flg = False
            break
    elif (i+1) % 2 == 1:
        if s == 'L':
            flg = False
            break
if flg:
    print('Yes')
else:
    print('No')

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

typedef long long ll;

ll MINIMUM(ll a, ll b){
  if(a >= b){
    return b;
  }else{
    return a;
  }
}

int main(){
  ll N, K;
  std::cin >> N >> K;
  std::vector<ll> h(N);
  for(int i = 0 ; i < N ; i++){
    std::cin >> h[i];
  }

  std::vector<ll> dp(N, (ll)1e18);
  dp[0] = 0;
  dp[1] = std::fabs(h[1] - h[0]);
  for(int i = 2 ; i < N ; i++){
    for(int j = 1 ; j <= K && i - j >= 0 ; j++){
      dp[i] = MINIMUM(dp[i], dp[i - j] + std::fabs(h[i] - h[i - j]) );
    }
  }
  std::cout << dp[N - 1] << std::endl;
  return 0;
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000007;
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  string S;
  cin >> S;
  for(int i=0;i<S.size();i++){
    if(i % 2 == 0){
      if(S[i] == 'L'){
        cout << "No" << endl;
        return 0;
      }
    }
    else{
      if(S[i] == 'R'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

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

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p,q,x,y,z,max1=0,ans;
    string s,t,u;
    cin>>a>>b>>c;
    ans=min(b/a,c);
    cout<<ans<<endl;
}



Measured memory_bytes: 256
unittest
{
	assert( [ "3 3" ].parse.expand.solve == "Yes" );
	assert( [ "3 2" ].parse.expand.solve == "No" );
	assert( [ "1 1" ].parse.expand.solve == "Yes" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	return tuple( nm[ 0 ], nm[ 1 ] );
}

auto solve( long n, long m )
{
	return ( n == m ) ? "Yes" : "No";
}


Measured memory_bytes: 256
from sys import stdin
from collections import defaultdict
def main():
    n = int(stdin.readline())
    a = map(int, stdin.readline().split())
    d = defaultdict(int)
    for x in a:
        d[x] += 1
    s = d.keys()
    if len(s) == 1:
        print 'Yes' if s[0] == 0 else 'No'
    elif len(s) == 2:
        print 'Yes' if (0 in s and n % 3 == 0 and d[0] == n / 3) else 'No'
    elif len(s) == 3:
        print 'Yes' if (s[0] ^ s[1] ^ s[2] == 0 and d[s[0]] == d[s[1]] == d[s[2]]) else 'No'
    else:
        print 'No'
main()


Measured memory_bytes: 11500
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)



main :: IO ()
main = do
    n <- readLn
    (t,a) <- rp
    res <- loop (t,a) (n-1)
    print res


loop :: (Int,Int) -> Int -> IO Int 
loop (t,a) 0 = return $ t+a
loop (t,a) n = do
    (t',a') <- rp
    let fac = untilGreater' (t',a') (t,a)
    loop (fac*t',fac*a') (n-1)


cl x y = ceiling ((fromIntegral x) / (fromIntegral y) :: Rational)


untilGreater' (a,b) (x,y) = max (cl x a) (cl y b)



Measured memory_bytes: 1148
# define _CRT_SECUREj_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }

int main()
{
	int n = 0, s = 0, e = 0, w = 0;
	string str;
	cin >> str;
	for (int i = 0; i < str.size(); i++)
	{
		if (str[i] == 'N')n++;
		if (str[i] == 'S')s++;
		if (str[i] == 'E')e++;
		if (str[i] == 'W')w++;
	}
	if((n&&!s)||(!n&&s)||(e&&!w)||(!e&&w))cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll int n;
    cin>>n;
    long double l=n/3.0;
    long double k=l*l*l;
    cout<<fixed<<setprecision(12)<<k;
    return 0;
}

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

const int Q = 1e9 + 7;
	
ll exp(ll n, ll m) {
    if (m == 0) return 1;
    if (m % 2 == 0) return (exp(n, m / 2) * exp(n, m / 2)) % Q;
    else return (n * exp (n, m - 1)) % Q;
}
 
signed main() {
	int N;
	cin >> N;
	
    ll w_all = exp(10, N); // 0...9
    ll w_wo_0 = exp(9, N); // 1..9 ( = 0..8)
    ll w_wo_09 = exp(8, N); // 1...8
    
    cout << ((w_wo_09 - (2 * w_wo_0) % Q + 
				w_all) % Q + Q) % Q << "\n";
    
    return 0;
}

Measured memory_bytes: 3576
# -*- coding: utf-8 -*-

def solve():
    N, K = map(int,input().split())
    if K > (N+1)/2:
        return '-1'

    L = [[K,K+N,K+2*N] for i in range(N)]
    for i in range(N):
        if N%2:
            j = (N-1-2*i)%N
            k = (2*i)%N
        else:
            j = (N-1-2*i)%N-i//(N//2)
            k = (1+2*i)%N-i//(N//2)
        L[i][0] += i
        L[j][1] += i
        L[k][2] += i
    res = '\n'.join(' '.join(map(str, l)) for l in L)
    return res

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


Measured memory_bytes: 32744
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 998244353;
ll dp[302][302][302];

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

	string s;
	cin >> s;
	int k;
	cin >> k;
	int n = s.size();
	chmin(k, n);
	dp[0][0][k] = 1;
	vector<int> v;
	v.pb(0);
	int num = 0;
	for (char c : s) {
		if (c == '0') v.pb(num);
		else num++;
	}
	v.pb(num);
	rep(i, v.size() - 1) {
		rep(j, num + 1) {
			rep(rem, k + 1) {
				for (int nj = max((ll)v[i + 1], j); nj <= num; nj++) {
					ll use = max(0ll, j + v[i + 1] - v[i] - nj);
					if (rem >= use) {
						dp[i + 1][nj][rem - use] += dp[i][j][rem];
						dp[i + 1][nj][rem - use] %= mod;
					}
				}
			}
		}
	}
	ll ans = 0;
	rep(rem, k + 1) ans += dp[v.size() - 1][num][rem];
	cout << ans % mod << '\n';
}

Measured memory_bytes: 56132
#include <iostream>
using namespace std;
 
int main(){
	int h,w;
	while(cin >> h >> w,h*w){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if((i + j)%2==0) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
n, c, k = map(int, input().split())

t = [0] * n
for i in range(n):
    t[i] = int(input())
t = sorted(t)
ans = 0
i = 0
while i < n:
    j = 1
    while i + j < n and t[i + j] <= t[i] + k and j < c:
        j += 1
    i += j
    ans += 1 
print(ans)


Measured memory_bytes: 8240
/*
 * C.c
 *
 *  Created on: 2019/02/17
 *      Author: X250
 */


#include <stdio.h>

int gcd(int,int);

int main(void) {
	int N,A[100000],i;
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%d",&A[i]);
	for(i=0;i<N-1;i++) {
		A[i+1]=gcd(A[i],A[i+1]);
	}
	printf("%d",A[N-1]);
}
int gcd(int a,int b) {
	if(a%b==0)return b;
	else if(b%a==0)return a;
	else if(a>b)return gcd(a%b,b);
	else return gcd(b%a,a);
}

Measured memory_bytes: 512
#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
//using ll = long long;
using P = pair<int,int>;

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};

int n,a[5010],dp[5010][5010][2],newdp[5010][2];

vector<int> G[5010];

int dfs(int v,int par){
	dp[v][0][a[v] < 0] = a[v];
	int macut = 0;
	for(int to : G[v]){
		if(to == par) continue;
		int cut = dfs(to,v);
		for(int j = 0;j <= macut + cut + 1;j++) newdp[j][0] = newdp[j][1] = INF;
		for(int j = 0;j <= macut;j++){
			for(int k = 0;k <= cut;k++){
				for(int l = 0;l < 2;l++){
					for(int m = 0;m < 2;m++){
						chmin(newdp[j + k][l | m],dp[v][j][l] + dp[to][k][m]);
						if((!m && dp[to][k][m] != INF) || dp[to][k][m] < 0) chmin(newdp[j + k + 1][l],dp[v][j][l]);
					}
				}
			}
		}
		for(int j = 0;j <= macut + cut + 1;j++){
			dp[v][j][0] = newdp[j][0];
			dp[v][j][1] = newdp[j][1];
		}
		macut += cut + 1;
	}
	return macut;
}

signed main(){
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i < n - 1;i++){
		int u,v;
		cin >> u >> v; u--;v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++) dp[i][j][0] = dp[i][j][1] = INF;
	}
	dfs(0,-1);
	for(int i = 0;i < n;i++){
		if(dp[0][i][0] != INF || dp[0][i][1] < 0){
			cout << i << endl;
			return 0;
		}
	}
}


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

int main(int argc, char const *argv[]) {
  string s, t;
  cin >> s >> t;

  int s_cnt[26], t_cnt[26];
  for (int i = 0; i < 26; i++) {
    s_cnt[i] = 0;
    t_cnt[i] = 0;
  }

  for (int i = 0; i < s.length(); i++) {
    s_cnt[s[i] - 'a']++;
  }
  for (int i = 0; i < t.length(); i++) {
    t_cnt[t[i] - 'a']++;
  }

  string s_new;
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < s_cnt[i]; j++) {
      char ch = 'a' + i;
      string str;
      str = ch;
      s_new = s_new + str;
    }
  }
  string t_new;
  for (int i = 25; i >= 0; i--) {
    for (int j = 0; j < t_cnt[i]; j++) {
      char ch = 'a' + i;
      string str;
      str = ch;
      t_new = t_new + str;
    }
  }

  if (s_new == t_new) {
    cout << "No" << endl;
    return 0;
  }
  if (s_new < t_new) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  // cout << s_new << " " << t_new << endl;
  // for (int i = 0; i < s_new.length(); i++) {
  // cout << i << endl;
  // cout << i << endl;
  // if (s_new[i - 1] < t_new[i - 1]) {
  //   cout << "Yes" << endl;
  //   break;
  // } else if (s_new[i - 1] - 'a' > t_new[i - 1] - 'a') {
  //   cout << "No" << endl;
  //   break;
  // }
  // if (i == s_new.length() - 1) {
  //   cout << "Yes" << endl;
  //   break;
  // }
  // }
  return 0;
}

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

int main(){
	
	int a[6]={1,5,10,50,100,500};
	int b,c=0;
	for(int i=0;i<6;i++){
		cin>>b;
		c+=(b*a[i]);
	}
	cout<<(c>=1000)<<endl;
	return 0;
}


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

vector< int64_t > divisor(int64_t n) {
    vector< int64_t > ret;
    for(int64_t i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int main(void){
    int64_t N;
    cin >> N;
    
    vector<int64_t> s = divisor(N);
    long long int m = N-1;
    for (int64_t i = 1; i < s.size(); i++)
        if ((s[i] + N/s[i])-2 < m)
            m = (s[i] + N/s[i])-2;
    cout << m << endl;
}

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


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

     vector<int> MAX(n);

     int ans = 0;

     rep(i,n){
         if(s[i]=='I') {ans++;
          MAX[i]= ans;}
         if(s[i]=='D') {ans--;
         MAX[i]=ans;}
     }
     int x = 0;
     rep(i,n){
         x = max(x,MAX[i]);
     }
     cout << x << endl;
  }

Measured memory_bytes: 256