akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[]) {
    int N, M;
    cin >> N >> M;
    
    multimap<int, int> m;
    using iterator = decltype(m)::iterator;
    
    vector<int> destarr;
    int from, to;
    for (int i = 0; i < M; i++) {
        cin >> from >> to;
        m.emplace(from ,to);
        if (from == 1) {
            destarr.push_back(to);
        }
    }

    bool ok(false);
    for (auto& var: destarr) {
        pair<iterator, iterator> ret = m.equal_range(var);
        for (iterator it = ret.first; it != ret.second; ++it) {
            if (it->second == N) {
                ok = true;
                break;
            }    
        }
        if (ok) break;
    }

    cout << ((ok) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}


Measured memory_bytes: 9976
#include <cstdio>
#include <cmath>

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

typedef long long   signed int LL;
typedef long long unsigned int LU;

template<typename T> void swap(T &x, T &y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

template<typename T> LL m_sort_(T a[], T b[], int l, int r, bool as) {
	if(r - l < 2) { return 0; }
	
	int s = 0;
	int m = (l + r) / 2;
	s += m_sort_(a, b, l, m, as);
	s += m_sort_(a, b, m, r, as);
	
	int ll = l, rr = m, bb = 0;
	while(bb < r - l) {
		bool l_flag;
		if(rr == r || ll == m) { l_flag = (rr == r); }
		else { l_flag = ( as ? (a[ll] <= a[rr]) : (a[rr] <= a[ll]) ); }
		
		if(l_flag) { s += rr - m; }
		b[bb++] = (l_flag ? a[ll++] : a[rr++]);
	}
	
	for(int i = l; i < r; i++) { a[i] = b[i - l]; }
	return s;
}
template<typename T> LL m_sort(T a[], int l, int r, bool as = true) {
	T *b = new T[r - l];
	LL temp = m_sort_(a, b, l, r, as);
	delete[] b;
	return temp;
}


int n, a[3][100000];

int main() {
	scanf("%d", &n);
	inc(i, 3) {
	inc(j, n) {
		scanf("%d", &a[i][j]); a[i][j]--;
	}
	}
	
	bool ans = true;
	inc(i, n) {
		int x = a[0][i];
		int y = a[1][i];
		int z = a[2][i];
		
		if(y % 3 == 1 && (y / 3) % 2 == i % 2 && x / 3 == y / 3 && y / 3 == z / 3) { } else { ans = false; break; }
	}
	
	if(ans) {
		int me = 0, mo = 0;
		inc(i, n) {
			if(i % 2 == 0) { if(a[0][i] > a[2][i]) { me++; } }
			if(i % 2 == 1) { if(a[0][i] > a[2][i]) { mo++; } }
		}
		
		int b[100000];
		int c[100000];
		inc(i, n) {
			if(i % 2 == 0) { b[i / 2] = a[1][i]; }
			if(i % 2 == 1) { c[i / 2] = a[1][i]; }
		}
		
		int ie = m_sort(b, 0, (n + 1) / 2);
		int io = m_sort(c, 0, (n + 0) / 2);
		
		me %= 2;
		mo %= 2;
		ie %= 2;
		io %= 2;
		ans = (me == io && mo == ie);
	}
		
	printf("%s\n", ans ? "Yes" : "No");
	
	return 0;
}


Measured memory_bytes: 2112
//Compiler optimization
#pragma GCC optimize("Ofast")

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

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define each(x, v) for (auto &x : v)

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl

//const
const  ll INF = 1e18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n;cin >> n;
    vl a(n);
    fr(i,n)cin>> a[i];
    sort(a);
    reverse(a);
    ll res = 0;
    fr(i,n-1){
        res += a[(i+1)/2];
    }
    cout << res << endl;
}

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

Measured memory_bytes: 580
fun main(args: Array<String>) {

    val pairList = arrayListOf<Pair<Int, Int>>()

    while (true) {

        val input = readLine()?.split(" ") ?: return
        val list = arrayListOf<Int>()
        input.forEach { list.add(it.toInt()) }

        if (list[0] == 0 && list[1] == 0) break
        pairList.add(Pair(list[0], list[1]))
    }

    for (pair in pairList) {
        for (h in 0 until pair.first) {
            for (w in 0 until pair.second) {
                if (h % 2 == 0 && w % 2 != 0) print(".")
                else if (h % 2 != 0 && w % 2 == 0) print(".")
                else print("#")
            }
            println()
        }
        println()
    }
}



Measured memory_bytes: 41496
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	private static final long MOD = (long)Math.pow(10, 9) + 7l;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		
		int[] primes = new int[1001];
		primes[1] = 1;
		int pos = 1;
		
		for (int i = 2; i <= n; i++) {
			int num = i;
			int k = 2;
			while (num >= k) {
				if (num == k) {
					primes[k]++;
					break;
				}
				if (num % k == 0) {
					primes[k]++;
					num /= k;
				} else {
					k++;
				}
			}
		}
		long res = 1L;
		
		for (int i = 1; i <= 1000; i++) {
			if (primes[i] >= 1) {
				res = (res % MOD) * ((primes[i]+1) % MOD);
			}
		}
		// System.out.println(Arrays.toString(primes));
		System.out.println(res/2);
	}
  
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  int n;
  cin >> n;
  cout << n / 3;
    return 0;
}

Measured memory_bytes: 256
import time
import numpy as np
import copy

tflag = False
if tflag:
  N = 2000
  m = 1000000000
  x = np.random.randint(m)
  A = list(np.random.randint(m,size=(N)))
  st = time.time()
else:
  N, x = map(int,raw_input().split())
  A = map(int,raw_input().split())

#B = copy.deepcopy(A)
B = A
A = A + A
m = sum(B)
for idx in xrange(1,N):
  for jdx in xrange(N):
    if B[jdx] > A[jdx+N-idx]:
      B[jdx] = A[jdx+N-idx]
#  A = np.append(A, A[0])
#  A = np.delete(A, 0)
#  B = np.fmin(B,A)
  m = min(sum(B)+idx*x, m)

print int(m)

Measured memory_bytes: 20460
"use strict"

function main(input) {

    input = input.split(' ').map(v => ~~v)

    let s = Math.max(input[0], input[2])
    let g = Math.min(input[1], input[3])

    const ans = g - s > 0 ? g - s : 0


    console.log(ans)

}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
using namespace std;
const int mod=1000000007;
typedef long long ll;
typedef pair<int,int> P;

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

    cout << t << s << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#문제를 풀때 너무 조급하기도 해서 행간을 읽지 못했다.
#TIME : 
import sys
from math import sqrt
input = sys.stdin.readline

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

n = inp()

def factoriation(n):
    arr = []
    temp = n
    for i in range(2,int(sqrt(n))+1):
        if temp%i == 0:
            cnt = 0
            while temp%i == 0:
                cnt+=1
                temp //= i
            arr.append([i,cnt])

    if temp != 1:
        arr.append([temp,1])
    if arr==[]:
        arr.append([n,1])
    return arr

fact = factoriation(n)
res = 0
if n==1:
    print(0)
    exit()
for i in range(len(fact)):
    for j in range(1,fact[i][1]+1):
        if n%(fact[i][0]**j) == 0:
            res+=1
            n = n/(fact[i][0]**j)
print(res)

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

int main() {
  int N;
  cin >> N;
  if(N % 1110 <= 9 || (N % 1000) % 111 == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter
import kotlin.math.min
import kotlin.math.pow

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun Int.pow(n: Int) = pow(n.toLong())
fun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()
fun Long.pow(n: Int) = pow(n.toLong())
fun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    var S = next().groupBy { it }
    if (S.containsKey('N') && !S.containsKey('S')) {
        println("No")
        return
    }
    if (!S.containsKey('N') && S.containsKey('S')) {
        println("No")
        return
    }
    if (S.containsKey('E') && !S.containsKey('W')) {
        println("No")
        return
    }
    if (!S.containsKey('E') && S.containsKey('W')) {
        println("No")
        return
    }
    println("Yes")
}


Measured memory_bytes: 36184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define N 1000000007

int n;
char s1[53], s2[53];

ull sum(int ind, int prev, ull ans){
  for(int i=ind;i<n;i++){
    if (s1[i] == s1[i+1]){
      if (prev == 0){
        ans = ans * 3 % N;
      }else{
        ans = ans * 2 % N;
      }
      prev = 0;
      i++;
    }else if (s1[i] == s2[i]){
      if (prev == 1){
        ans = ans * 2 % N;
      }
      prev = 1;
    }
  }
  return ans;
}

int main(){
  ull ans;
  int prev, ind;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s1[i];
  }
  for(int i=0;i<n;i++){
    cin >> s2[i];
  }
  if (s1[0] == s1[1]){
    ans = 3 * 2;
    prev = 0;
    ind = 2;
  }else{
    ans = 3;
    prev = 1;
    ind = 1;
  }
  cout << sum(ind, prev, ans) << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    N, K, C = map(int, input().split())
    S = input()

    # greedy
    head, tail = [-C - 1] * (K + 1), [N + C + 1] * (K + 1)
    idx = 0
    for i in range(N):
        if S[i] == 'o' and i - head[idx] > C:
            idx += 1
            head[idx] = i
            if idx == K:
                break
    idx = K
    for i in range(N - 1, -1, -1):
        if S[i] == 'o' and tail[idx] - i > C:
            idx -= 1
            tail[idx] = i
            if idx == 0:
                break
    # ans
    for i in range(K):
        if head[i + 1] == tail[i]:
            print(tail[i] + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 50764
// #include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
const int MOD = 1e9 + 7; // 10^9 + 7
const ll inf = 1e10;
using namespace std;

// ------------------ コンビネーション関数 ------------------ //
// ---------------- 使用前「COMinit();」必須 ---------------- //
const int MAX = 510000;
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 GCD(int x, int y) {
	if (x == 0) return y;
	else GCD(y % x, x);
}

// ------------------ ベクター表示 ------------------ //
void printVec(vector<ll>& vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<ll> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}


// ------------------------------------------------ //
// ------------------ ここから下 ------------------ //
// ------------------------------------------------ //

int main(void) {

	int K,A,B;

	cin >> K >> A >> B;
	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	if (A == B && A % K == 0) {
		cout << "OK" << endl;
		return 0;
	}
	cout << "NG" << endl;
	return 0;
}

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

int main(){
    int N; cin>>N;
    map<char,long> name;
    for(int i=0;i<N;i++){
        string S;cin>>S;
        if(S.at(0)=='M'||S.at(0)=='A'||S.at(0)=='R'||S.at(0)=='C'||S.at(0)=='H'){
            name[S.at(0)]++;
        }
    }
    long sum=name['M']*name['A']*name['R']+name['M']*name['A']*name['C']+name['M']*name['A']*name['H']+name['M']*name['R']*name['C']+name['M']*name['R']*name['H']+name['M']*name['C']*name['H']+name['C']*name['A']*name['R']+name['H']*name['A']*name['R']+name['C']*name['A']*name['H']+name['R']*name['C']*name['H'];
    cout<<sum<<endl;
}

Measured memory_bytes: 256
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


def array(size, init=0):
    return [[init for j in range(size[1])] for i in range(size[0])]


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


def II():
    return int(input())


x = II()

print((x+1) % 2)


Measured memory_bytes: 27096
#include <stdio.h>

int gcd(int a, int b)
{
  if (b == 0){
    return (a);
  }
  return (gcd(b, a % b));
}

int main(void)
{
  int a, b;
  
  while (~scanf("%d%d", &a, &b)){
    printf("%d %d\n", gcd(a, b), a / gcd(a, b) * b);
  }

  return (0);
}

Measured memory_bytes: 592
(defun convert (h w num)
  (let* ((r1 0))
    (loop for i from 0 below h
          do (setf r1 (+ (ash r1 w)
                         (if (zerop (logand (ash 1 (+ i w)) num))
                             0
                             (1- (expt 2 w))))))

    (loop with pat = (logand num (1- (expt 2 w)))
          for i from 0 below h
          do (setf r1 (logior r1 (ash pat (* i w)))))
    (logxor r1 (1- (expt 2 (* h w))))))
;;(convert 2 3 #b01000)

(defun cnt (bits)
  (loop with num = 0
        until (zerop bits)
        do (unless (zerop (logand bits 1))
             (incf num))
           (setf bits(ash bits -1))
        finally (return num)))

(let* ((h (read))
       (w (read))
       (k (read))
       (bits (loop with result = 0
                   repeat h
                   do (loop
                        repeat w
                        do (setf result (+ (* 2 result) (if (eql (read-char) #\#) 1 0))))
                   do (read-char)
                   finally (return result))))
  (format t "~A~%" (loop for i from 0 below (expt 2 (+ h w))
                         count (eql (cnt (logand bits (convert h w i)))
                                    k))))

Measured memory_bytes: 24632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
        int num = Integer.parseInt(sc.next());
        List<Integer> list = new ArrayList<>();
        int res = 0;
        for(int x=1; x<=num;x++) {
            list.add(Integer.parseInt(sc.next()));
        }
        res = list.get(0);
        for(int x=2; x<=num; x++) {
            res -= list.get(x-1);
        }
        if(res<0){
            res = res*-1;
        }
        for(int x=2; x<=num;x++) {
            int temp = 0;
            for(int y=1; y<=x; y++) {
                temp += list.get(y-1);
            }
            for(int z=1+x; z<=num; z++){
                temp -= list.get(z-1);
            }
            if(temp<0){
                temp = temp*-1;
            }
            res = res<temp?res:temp;
        }
        System.out.println(res);
    }
}


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


int main(){
    string s;
    cin >> s;
    string s_rev = s;
    reverse(s_rev.begin(),s_rev.end());
    if(s==s_rev){
        string l,r;
        l = s.substr(0,(int(s.size())-1)/2);
        r = s.substr(int(s.size())/2+1,s.size()/2);
        string l_rev = l, r_rev = r;
        reverse(l_rev.begin(),l_rev.end());        
        reverse(r_rev.begin(),r_rev.end());        
        if(l==l_rev && r==r_rev){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
using namespace std;

int linearSearch(int A[],int n,int key);

int main(){
  int n,S[10000+1],q,key,C=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++) scanf("%d",&S[i]);
  scanf("%d",&q);
  int T[q];
  for(int i=0;i<q;i++){
    scanf("%d",&key);
    C += linearSearch(S,n,key);
  }
  printf("%d\n",C);
  return 0;
}

int linearSearch(int A[],int n,int key){
  int i=0;
  A[n] = key;
  while(A[i]!=key) i++;
  return i != n;
}

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



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

int co=0;
  while(x>=0){
    x-= 100;
    co++;
  }
  x+=100;
  co--;


int t=0;
  for(int i=0;i<co;i++){
    if(x>=5){
      x-=5;
    }else if(x==4){
      x -= 4;
    }else if(x==3){
      x -= 3;
    }else if(x==2){
      x -= 2;
    }else if(x==1){
      x -= 1;
    }else if(x==0){
      t = 1;
      cout<<1<<endl;
      break;
    }
    if(x==0&&i==(co-1)){
      t = 1;
      cout<<1<<endl;
      break;
    }
  }

  if(t==0){
    cout<<0<<endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n,m;
    char temp;
    string a,b;
    cin>>a>>b;
    n=a.length();
    m=b.length();
    int k=0;
    if(n!=3&&m!=3)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }


    }
    return 0;
}

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

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

	if (s.size() > k) {
		rep(i,k) {
			cout << s.at(i);
		}
		cout << "..." << endl;
	}
	else {
		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 3636
import java.awt.Point;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
  
public class Main {
     
    static int N, M;
    static int[] A, B, COST, TIME;
    static int K;
    static int[] P, Q, R;
    
    static void start()
    {
    	int[][] cost = new int[M][M];
    	int[][] time = new int[M][M];
    	
    	for (int i = 0; i < M; i++) {
			for (int j = 0; j < M; j++) {
				cost[i][j] = Integer.MAX_VALUE/2;
				time[i][j] = Integer.MAX_VALUE/2;
			}
		}
    	
    	for (int i = 0; i < N; i++) {
			cost[A[i]-1][B[i]-1] = COST[i];
			cost[B[i]-1][A[i]-1] = COST[i];
			
			time[A[i]-1][B[i]-1] = TIME[i];
			time[B[i]-1][A[i]-1] = TIME[i];
		}
    	
    	for (int k = 0; k < M; k++) {
			for (int i = 0; i < M; i++) {
				for (int j = 0; j < M; j++) {
					cost[i][j] = Math.min(cost[i][j], cost[i][k] + cost[k][j]);
					time[i][j] = Math.min(time[i][j], time[i][k] + time[k][j]);
				}
			}
		}
    	
    	for (int i = 0; i < K; i++) {
			if(R[i] == 0)
				System.out.println(cost[P[i]-1][Q[i]-1]);
			else {
				System.out.println(time[P[i]-1][Q[i]-1]);
			}
		}
    }
      
    public static void main(String[] args)
    {
        Scanner sca = new Scanner(System.in);
        
        while(true)
        {
            N = sca.nextInt();
            M = sca.nextInt();
            if(N == 0) break;
            
            A = new int[N];
            B = new int[N];
            COST = new int[N];
            TIME = new int[N];
            for (int i = 0; i < N; i++) {
				A[i] = sca.nextInt();
				B[i] = sca.nextInt();
				COST[i] = sca.nextInt();
				TIME[i] = sca.nextInt();
			}
            
            K = sca.nextInt();
            P = new int[K];
            Q = new int[K];
            R = new int[K];
            for (int i = 0; i < K; i++) {
				P[i] = sca.nextInt();
				Q[i] = sca.nextInt();
				R[i] = sca.nextInt();
			}
            
            start();
        }
         
    }
}

Measured memory_bytes: 66636
// Problem : E - Logs
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
	“Whether you think you can, or you think you can’t – you’re right” - Henry Ford 
*/

#pragma GCC optimize("Ofast")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define pb push_back
#define pl pair<ll, ll>
#define vl vector<ll>
#define vi vector<int>
#define endl '\n'

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
    for (auto &i : t) os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t : v) is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
    for (pair<T1, T2> &t : v) is >> t.first >> t.second;
    return is;
}

const ll mod = 1e9 + 7;

ll check(vl &v, ll mid) {
	ll c = 0;
	for(int i = 0; i < v.size(); i++) {
		c += (v[i] + mid - 1) / mid - 1;
	}
	return c;
}

void solve() {
	ll n, k; cin >> n >> k;
	vl v(n); cin >> v;
	ll lo = 1, hi = mod, ans = hi, mid;
	while(lo <= hi) {
		mid = lo + (hi - lo) / 2;
		if(check(v, mid) <= k) ans = mid, hi = mid - 1;
		else lo = mid + 1;
	}
	cout << ans << endl;
}

int main()
{
	fast;
   ll t = 1;
   // cin >> t;
   while(t--) {
   	solve();
   }
	return 0;
}


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


int main() {

    int a, b, k;
    cin >> a >> b >> k;
    vector<int> A;
    for (int i = min(a,b); i >= 1; --i) {
        if (a%i==0 && b%i==0) {
            A.push_back(i);
        }
    }
    cout << A[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = Array{Int}(3,n)
	for i in 1:n
		a[:,i] = readline() |> split |> parseMap
	end
	dp = Array{Int}(3,n)
	dp[:,1] = [a[1,1],a[2,1],a[3,1]]
	for i in 2:n
		dp[1,i] = max(dp[2,i-1],dp[3,i-1])+a[1,i]
		dp[2,i] = max(dp[1,i-1],dp[3,i-1])+a[2,i]
		dp[3,i] = max(dp[1,i-1],dp[2,i-1])+a[3,i]
	end
	println(max(dp[1,n],dp[2,n],dp[3,n]))
end

main()


Measured memory_bytes: 156284
from math import gcd 

n = int(input())
maxA = 10**6+5
A = list(map(int, input().split()))
c = [0]*maxA
for a in A:
    c[a] += 1

for i in range(2, maxA):
    cnt = 0
    for j in range(i, maxA, i):
        cnt += c[j]
    if cnt >= 2:
        break
else:
    print('pairwise coprime')
    exit()

g = 0
for a in A:
    g = gcd(g, a)
if g == 1:
    print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 195028
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
if x in a:
    if y in a:
        print("Yes")
    else:
        print("No")
elif x in b:
    if y in b:
        print("Yes")
    else:
        print("No")
else:
    if y in c:
        print("yes")
    else:
        print("No")
    

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000
#define SZ 20

int mat[SZ+1][2*SZ+1];  //no-shade:0, shade:plus, mat[height][width+20]

int main(){
  int r,n;
  while(scanf("%d %d",&r,&n), r|n){
    // initialize
    rep(i,SZ+1){
      rep(j,2*SZ+1){
	mat[i][j]=0;
      }
    }

    // input provess for imosu
    rep(i,n){
      int xl, xr, h;
      scanf("%d %d %d", &xl, &xr, &h);
      mat[0][xl+20]++;
      mat[0][xr+20]--;
      mat[h][xl+20]--;
      mat[h][xr+20]++;
    }
    
    // imosu
    rep(i,SZ){
      repl(j,1,2*SZ){
	mat[i][j] += mat[i][j-1];
      }
    }
    rep(i,2*SZ){
      repl(j,1,SZ){
	mat[j][i] += mat[j-1][i];
      }
    }

    // debug
    /*
    rep(i,SZ){
      rep(j,2*SZ){
	printf("%d", mat[SZ-i-1][j]);
      }printf("\n");
    }
    */

    // move sun from bottom
    int t=0;
    int w;
    double res=INF;
    while(t<20){
      w=0; //width
      while(w<r){
	if(mat[t][20+w]>0 && mat[t][19-w]>0){
	  w++;
	}else{
	  break;
	}
      }
      if(w==0){
	res=min(res, (double)t);
	break;
      } else if(w==r){
	t++;
	continue;
      } else {
	res = min(res, (double)(r+t) - sqrt(r*r-w*w));
	t++;
      }
    }

    if(t==20 && (res==INF|| res>=20)){
      printf("20.0000\n");
      continue;
    }

    printf("%.4f\n", res);
  }
  return 0;
}

Measured memory_bytes: 1236
#include<stdio.h>
#include<math.h>
int main(void){
    int x[100001];
    int y[100001];
    int t[100001];

    int N;
    
    scanf("%d",&N);
    int i;
    for(i=1;i<N+1;i++){
        scanf("%d %d %d",&t[i],&x[i],&y[i]);
    }
    x[0]=0;
    y[0]=0;
    t[0]=0;
    
    for(i=0;i<N;i++){
        if(abs(x[i+1]-x[i])+abs(y[i+1]-y[i]) > t[i+1]-t[i]){
            printf("No");
            return 0;
        }
        if(abs((abs(x[i+1]-x[i])+abs(y[i+1]-y[i]) - (t[i+1]-t[i])))%2==1){
            printf("No");
            return 0;
        }
    }
    printf("Yes");

    return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>

int main(){
  int n,r=0,R=0;
  scanf("%d",&n);
  char c[n+1];
  scanf("%s",c);
  
  for(int i=0;i<n;i++){
    if(c[i]=='R')r+=1;
  }
  for(int i=0;i<r;i++){
    if(c[i]=='R')R+=1;
  }
  
  printf("%d",r-R);
  return 0;
}


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

/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

using namespace std;

typedef long long ll;

int n;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    cout << ((n + 999) / 1000) * 1000 - n << "\n";
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define m_p make_pair

int gg(int n, vector<pair<int, int> > v)
{
    int maxu = 0;
    if (v.size() == 0)
        maxu = n;
    else if (v.size() == 1)
    {
        int nn = 0;
        int b = (n - nn) / v[0].first;
        nn = n - b * v[0].first;
        nn = nn + b * v[0].second;
        maxu = max(maxu, nn);
    }
    else if (v.size() == 2)
    {
        for (int s = 0; s <= n; ++s)
        {
            int nn = s * v[0].first;
            if (nn > n)
                break;
            int b = (n - nn) / v[1].first;
            nn = n - s * v[0].first - b * v[1].first;
            nn = nn + s * v[0].second + b * v[1].second;
            maxu = max(maxu, nn);
        }
    }
    else
    {
        for (int g = 0; g <= n; ++g)
        {
            if (g * v[0].first > n)
                break;
            for (int s = 0; s <= n; ++s)
            {
                int nn = g * v[0].first + s * v[1].first;
                if (nn > n)
                    break;
                int b = (n - nn) / v[2].first;
                nn = n - g * v[0].first - s * v[1].first - b * v[2].first;
                nn = nn + g * v[0].second + s * v[1].second + b * v[2].second;
                maxu = max(maxu, nn);
            }
        }
    }
    return maxu;
}

int n;
int ga, sa, ba;
int gb, sb, bb;

int32_t main()
{
    cin >> n;
    cin >> ga >> sa >> ba;
    cin >> gb >> sb >> bb;
    vector<pair<int, int> > va, vb;
    if (ga < gb)
        va.push_back(m_p(ga, gb));
    if (sa < sb)
        va.push_back(m_p(sa, sb));
    if (ba < bb)
        va.push_back(m_p(ba, bb));
    if (ga > gb)
        vb.push_back(m_p(gb, ga));
    if (sa > sb)
        vb.push_back(m_p(sb, sa));
    if (ba > bb)
        vb.push_back(m_p(bb, ba));
    n = gg(n, va);
    n = gg(n, vb);
    cout << n << endl;
    return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S;
  cin >> S;
  VI cnt(3);
  for(auto c: S)
	cnt[c-'a']++;
  SORT(cnt);
  
  cout << (cnt[1] - cnt[0] <= 1 && cnt[2]-cnt[0] <= 1? "YES": "NO") << endl;

  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
main(void){
   int m,f,r;
   int sum;
   int score;
   scanf("%d%d%d",&m,&f,&r);
   while(m!=-1||f!=-1||r!=-1){
      if(m==-1||f==-1)printf("%s\n","F");
      else{
         sum = m + f;
         if(sum>=80)printf("%s\n","A");
         else if(sum>=65)printf("%s\n","B");
         else if(sum>=50)printf("%s\n","C");
         else if(sum>=30){
            if(r>=50)printf("%s\n","C");
            else printf("%s\n","D");
         }
         else printf("%s\n","F");
      }
      scanf("%d%d%d",&m,&f,&r);
   }
   return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if ( s < t )  cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
using namespace std;
int N;
bool ans = true;
int maxN;

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

	if (N >= 2) {
		maxN = H[0];
		for (int i = 0;i < N - 1;i++) {
			maxN = max(maxN, H[i]);
			if (H[i] - H[i + 1] >= 2) {
				ans = false;
				break;
			}
			if (maxN - H[i + 1] >= 2) {
				ans = false;
				break;
			}
		}
	}
	if (ans) {
		cout << "Yes";
	}	else {
		cout << "No";
	}
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
//#define int long long

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int ans = 0;
    REP(i, 4) if(s[i] == '+') ans++; else ans--;
    cout << ans << endl;
}


Measured memory_bytes: 256
"""
参考：https://www.hamayanhamayan.com/entry/2018/03/18/085108
　　　http://vartkw.hatenablog.com/entry/2016/12/02/002703
　　　https://ikatakos.com/pot/programming_algorithm/graph_theory/maximum_flow
・二部最大マッチング
・最大流アルゴリズム(Dinic法)
"""
 
from collections import deque
 
class BipartiteMatching:
 
	def __init__(self, n, m):
		self.n = n
		self.m = m
		# ペアとして有りうる相手を格納する
		self.E = [[] * (n+m+2) for i in range(n+m+2)]
		# 決まったペアを格納する
		self.match = [0] * (n+m+2)
		# 距離(付け替え候補を決める時の深さみたいなものが入ってる)
		self.dist = [0] * (n+m+2)
	
	def bfs(self):
		que = deque()
		for i in range(1, self.n+1):
			# マッチングの決まっていないノードをキューに詰める
			if not self.match[i]:
				self.dist[i] = 0
				que.append(i)
			else:
				self.dist[i] = float('inf')
		self.dist[0] = float('inf')
		while len(que) != 0:
			u = que.popleft()
			if u != 0:
				for v in self.E[u]:
					if self.dist[self.match[v]] == float('inf'):
						self.dist[self.match[v]] = self.dist[u] + 1
						# 付け替えの候補になりうるノードがここで追加されていく
						que.append(self.match[v])
		# フローを流せるエッジが存在しなければ、dist[0]がINFのまま(Falseを返して終了)
		return self.dist[0] != float('inf')
 
	def dfs(self, u):
		if u != 0:
			for v in self.E[u]:
				if self.dist[self.match[v]] == self.dist[u] + 1:
					if self.dfs(self.match[v]):
						# ペア確定(あとで変わることもある)
						self.match[v] = u
						self.match[u] = v
						return True
			# 今回決められなかったノード
			self.dist[u] = float('inf')
			return False
		return True
	
	def add(self, a, b):
		b += self.n
		self.E[a+1].append(b+1)
		self.E[b+1].append(a+1)
 
	def whois(self, x):
		return self.match[x+1]-1
 
	def solve(self):
		for i in range(self.n+self.m+1):
			self.match[i] = 0
		res = 0
		while self.bfs():
			for i in range(1, self.n+1):
				# 前から順に繋げる所は繋いでいって、
				# もっといいのがあれば後から付け替える
				if not self.match[i] and self.dfs(i):
					res += 1
		return res
      
N = int(input())
aN, bN, cN, dN = [0] * N, [0] * N, [0] * N, [0] * N
# 赤い点
for i in range(N):
	aN[i], bN[i] = map(int, input().split())
# 青い点
for i in range(N):
	cN[i], dN[i] = map(int, input().split())

# (赤い点の数, 青い点の数)
bm = BipartiteMatching(N, N)
for i in range(N):
	for j in range(N):
		if aN[i] < cN[j] and bN[i] < dN[j]:
			# ペア候補として適切な組を追加していく(0-indexed)
			bm.add(i, j)
print(bm.solve())
      
      

Measured memory_bytes: 3444
import java.util.*;

public class Main{
    public static void main(String[] args){
        try{
            Scanner sc = new Scanner(System.in);
   
            int H = sc.nextInt();
            int W = sc.nextInt();

            int N = sc.nextInt();

            int m = Math.max(H,W);
            
            int total = 0;
            int count = 0;
          
            for(int i = 1; i < H*W; i++){
                total = m * i;
                count++;
                if(total >= N){
                    break;
                }  
            }

        System.out.println(count);
            
    
        sc.close();

        }catch(NoSuchElementException e){
			System.out.println("無効な値です");
		}
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int x;
  cin >> x;
  int ans = 0;
  int s = 0;
  for (int i = 1; x > s; i++) {
    s += i;
    ans = i;
  }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[int(x) for x in input().split()]
m=1000
k=0

for i in range(n-1):
    m=m+k*a[i]
    k=0
    if a[i]<a[i+1]:
        k=m//a[i]
        m=m%a[i]
print(m+k*a[n-1])


Measured memory_bytes: 8852
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------


int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	int N;
	int ans = 0;
	cin >> N;

	FOR(i, 1, N + 1) {
		ans += i;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 26

typedef struct cell{
 int id;
 struct cell *right;
 struct cell *left;
 struct cell *parent;
}cell;


void preorder(cell *root,cell N[]){
cell *p=root;
printf(" %d",p->id);

if(p->left!=NULL){preorder(p->left,N);}
if(p->right!=NULL){preorder(p->right,N);}

return;
}

void inorder(cell *root,cell N[]){
cell *p=root;
if(p->left!=NULL){inorder(p->left,N);}
printf(" %d",p->id);
if(p->right!=NULL){inorder(p->right,N);}

return;
}

void postorder(cell *root,cell N[]){
cell *p=root;
if(p->left!=NULL){postorder(p->left,N);}
if(p->right!=NULL){postorder(p->right,N);}
printf(" %d",p->id);

return;
}










int main(){
int i,n;
int x,y,z;
cell *root;
cell N[MAX];


scanf("%d",&n);

for(i=0;i<n;i++){N[i].parent=NULL;}



for(i=0;i<n;i++){
 scanf("%d %d %d",&x,&y,&z);
 N[x].id=x;
 if(y==-1){N[x].left=NULL;}
 else{N[x].left=&N[y];N[y].parent=&N[x];}
 if(z==-1){N[x].right=NULL;}
 else{N[x].right=&N[z];N[z].parent=&N[x];}
}

for(i=0;i<n;i++){if(N[i].parent==NULL){root=&N[i];break;}}


printf("Preorder\n");
preorder(root,N);
printf("\n");

printf("Inorder\n");
inorder(root,N);
printf("\n");

printf("Postorder\n");
postorder(root,N);
printf("\n");





return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	ll n; cin >> n;
	map<ll, ll> cnt;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	ll sum = 0;
	for (auto p : cnt) {
		sum += p.second*(p.second - 1) / 2;
	}
	for (int i = 0; i < n; i++) {
		ll t = cnt[a[i]];
		cout << sum - t*(t - 1) / 2 + (t - 1)*(t - 2) / 2 << endl;
	}
	return 0;
}


Measured memory_bytes: 12672
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <stdio.h>
#include <math.h>
using namespace std;
 
#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
 
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, P> PP;
 
struct edge {
	int to, cost;
	edge(int t, int c) :to(t), cost(c) {}
};
 
int dx[] = { 1,-1,0,0 }, dy[] = { 0,0,1,-1 };
int ddx[] = { 1,1,1,0,-1,-1,-1,0 }, ddy[] = { 1,0,-1,-1,-1,0,1,1 };
 
ll mypow(ll x, ll n, ll m) {	//xのn乗をmで割った余り
	if (n == 0) return 1;
	if (n % 2 == 0) return mypow(x*x%m, n / 2, m);
	else return x*mypow(x, n - 1, m) % m;
}
 
//-----------------------------------------------------------------------------
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int a,b;
	cin>>a>>b;
	cout<<(a+b+1)/2<<endl;
 
	return 0;
}
 

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

struct food {
	int id;
	int p, q, r;
	int k;
};

int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		int Y; cin >> Y;
		ld amax = 0;
		int ans = -1;
		for (int i = 0; i < N; ++i) {
			int b, r, t; cin >> b >> r >> t;
			ld money = 0;
			if (t == 1) {
				money = 1 + Y*r / 100.0;
			}
			else {
				money = powl(1 + r / 100.0, Y);
			}
			if (amax < money) {
				amax = money;
				ans = b;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3252