akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    int a[] = new int[m];
    int sum = 0;
    for(int i = 0; i<m; i++){
      a[i] = scan.nextInt();
    }
    for(int i = 0; i<m; i++){
      sum += a[i];
    }
    if(sum <= n){
      System.out.println(n - sum);
    }else{
      System.out.println(-1);
    }
  }
}


Measured memory_bytes: 46600
import collections

S=input()
T=input()

S_list=[i for i in S]
T_list=[i for i in T]

S_dict=collections.Counter(S_list)
T_dict=collections.Counter(T_list)

S_count=sorted([v for k,v in S_dict.items()])
T_count=sorted([v for k,v in T_dict.items()])

if S_count==T_count:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 7464
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        m: usize,
        abc: [(usize, usize, i64); m],
    }
    let mut map = vec![vec![std::i64::MAX / 2; n + 1]; n + 1];
    for i in 1..n + 1 {
        map[i][i] = 0;
    }

    for i in 0..abc.len() {
        let x = abc[i];
        map[x.0][x.1] = x.2;
        map[x.1][x.0] = x.2;
    }

    for k in 1..n + 1 {
        for i in 1..n + 1 {
            for j in 1..n + 1 {
                map[i][j] = min(map[i][j], map[i][k] + map[k][j]);
            }
        }
    }

    let mut v = vec![false; m];
    for i in 1..n + 1 {
        for j in 1..n + 1 {
            for k in 0..m {
                let mut x = abc[k];
                if map[i][j] == map[i][x.0] + map[x.1][j] + x.2 {
                    v[k] = true;
                }
            }
        }
    }
    println!("{}", v.iter().filter(|&x| *x == false).count());
}


Measured memory_bytes: 2220
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int main(){
    char s[4];
    scanf("%s",s);

    if(s[1]=='R'){
       printf("ABC");
    }
    else{
        printf("ARC");
    }
    return 0;
}



Measured memory_bytes: 1728
#include <cstdio>
#include <string>
#include <map>
#include <queue>

using namespace std;

int main()
{
	char s[11];
	while (~scanf("%s", s), s[0] != '0') {
		map<string, bool> m;

		queue<string> q, r;

		q.push(s);

		int cnt = 0;

		while (q.size()) {
			while (q.size()) {
				string t = q.front(); q.pop();
				if (m[t]) continue;
				m[t] = true;
				bool f = true;
				for (int i = 0; i < t.size() - 1; ++i) {
					if ((t[i] == 'r' && t[i + 1] == 'b') || (t[i] == 'b' && t[i + 1] == 'r')) {
						char c = t[i], d = t[i + 1];
						t[i] = t[i + 1] = 'g';
						r.push(t);
						t[i] = c, t[i + 1] = d;
						f = false;
					} else if ((t[i] == 'b' && t[i + 1] == 'g') || (t[i] == 'g' && t[i + 1] == 'b')) {
						char c = t[i], d = t[i + 1];
						t[i] = t[i + 1] = 'r';
						r.push(t);
						t[i] = c, t[i + 1] = d;
						f = false;
					} else if ((t[i] == 'r' && t[i + 1] == 'g') || (t[i] == 'g' && t[i + 1] == 'r')) {
						char c = t[i], d = t[i + 1];
						t[i] = t[i + 1] = 'b';
						r.push(t);
						t[i] = c, t[i + 1] = d;
						f = false;
					}
				}
				if (f) {
					printf("%d\n", cnt);
					goto nxt;
				}
			}
			while (r.size()) {
				string t = r.front(); r.pop();
				q.push(t);
			}
			cnt++;
		}

		printf("NA\n");
nxt:;
	}
}

Measured memory_bytes: 3184
#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	S = list(input())
	N = len(S)
	D = defaultdict(int)
	D[0] = 1
	var = 0
	for i in range(N):
		var = var + pow(10, i, 2019) * int(S[N - 1 - i])
		var %= 2019
		D[var] += 1

	ans = 0
	for i in D:
		v = D[i]
		ans += int(v * (v - 1) // 2)

	print(ans)
	


if __name__ == '__main__':
	main()

Measured memory_bytes: 83680
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
ll gcd(ll a,ll b){
	return (b==0?a:gcd(b,a%b));
}
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
int main(){
	int q;
	cin>>q;
	while(q--){
		int n;cin>>n;
		vs in(n);
		rep(i,n)cin>>in[i];
		
		rep(i,n){
			int t=in[i].size()/2;
			rep(j,in[i].size())if(in[i][j]!='0')t=gcd(t,j/2);
			if(t==0){
				in[i]="00";
			}else{
				string w="";
				rep(j,in[i].size()/t/2){
					w+=in[i][j*2*t];
					w+=in[i][j*2*t+1];
				}
				in[i]=w;
			}
		}
		ll t=1;
		rep(i,n){
			t=lcm(t,in[i].size());
			if(t>2048)break;
		}
//		rep(i,n)cout<<in[i]<<endl;cout<<endl;
		if(t>2048)cout<<"Too complex."<<endl;
		else{
			rep(i,n){
				int w=t/in[i].size();
				string a="";
				rep(j,in[i].size()/2){
					a+=in[i][2*j];
					a+=in[i][2*j+1];
					a+=string(2*w-2,'0');
				}
				in[i]=a;
			}
			rep(i,t){
				int s=0;
				rep(j,n)s+=in[j][i]-'0';
				printf("%01X",s);
			}
			cout<<endl;
		}
	}
}







Measured memory_bytes: 3348
#!/usr/bin/pypy
from math import factorial as f
from sys import exit

X, Y=map(int, raw_input().split())
j = (X+Y)/3

if (X+Y)%3 != 0 or X-j < 0 or Y-j <0:
    print str(0)
    exit(0)


mod = pow(10,9)+7
#ans = (f(j) / f(X-j) / f(Y-j)) % mod

nu = reduce(lambda x,y: (x*y)%mod, xrange(max(X-j, Y-j)+1, j+1), 1)
denu = reduce(lambda x,y: (x*y)%mod, xrange(1, min(X-j, Y-j)+1), 1)


ans = (nu * pow(denu, mod-2, mod)) % mod

print str(ans)

Measured memory_bytes: 30060
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s, t, u;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> s >> t >> a >> b >> u;
  if (s == u)
    a--;
  else
    b--;
  cout << a << " " << b << "\n";
  return 0;
}

Measured memory_bytes: 256
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
b = sorted(a)
max = b[-1]
max_sec = b[-2]

for A in a:
    if A == max:
        print(max_sec)
    else:
        print(max)


Measured memory_bytes: 70488
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        cs: chars,
    }

    let mut kioku = 0;
    let ans = dfs(&cs, 0, &mut kioku);

    if let Some(ans) = ans {
        for i in 0..3 {
            print!("{}", cs[i]);
            if ans & 2usize.pow(i as u32) != 0  {
                print!("+");
            } else {
                print!("-");
            }
        }
        print!("{}", cs[3]);
        println!("=7");
    }       
}

fn dfs(cs: &Vec<char>, pos: usize, kioku: &mut usize) -> Option<usize>{
    if pos == 3 {
        let mut ans: i32= cs[0].to_digit(10).unwrap() as i32;
        for i in 1..4 {
            if *kioku & 2usize.pow(i-1) != 0 {
                ans = ans + cs[i as usize].to_digit(10).unwrap() as i32;
            } else {
                ans = ans - cs[i as usize].to_digit(10).unwrap() as i32;
            }
        }
        if ans == 7 {
            //println!("kioku: {}", *kioku);
            return Some(*kioku);
        } else {
            return None;
        }

    }

    let ret1 = dfs(cs, pos+1, kioku);
    *kioku = *kioku + 2usize.pow(pos as u32);
    let ret2 = dfs(cs, pos+1, kioku);

    if ret1.is_some() {
        return ret1; 
    } else if ret2.is_some() {
        return ret2;
    } else {
        return None;
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

/*
 * 2 50
 * 6 14
 * ans -> (7 21 35 49) (3 9 15 21 27 33 39 45)
 * 
 */
ll __lcm(ll a, ll b) {
	return (a * b) / __gcd(a, b);
}
int main() {
	ll n, m;
	cin >> n >> m;
	vector <ll> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		A[i] /= 2;
	}
	ll lcm = A[0];
	for (int i = 1; i < n; i++) {
		lcm = __lcm(lcm, A[i]);
		if (lcm > m) {
			cout << 0;
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		if ((lcm / A[i]) % 2 == 0) {
			cout << 0;
			return 0;
		}
	}
	cout << m / lcm - m / (2 * lcm);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
const int mod=998244353;
const int INF=0x3f3f3f3f;
ll quick(ll a,ll b)
{
	ll ret=1;
	while(b)
	{
		if(b&1)
			ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}
ll inv(ll a){return quick(a,mod-2);}
const int maxn=1e5+7;
int x[maxn];
int n;
int l,q;
int r[maxn][20];
int getnxt(int cur)
{
	int L=cur,R=n,ret=-1;
	while(L<=R)
	{
		int mid=L+R>>1;
		if(x[mid]-x[cur]<=l)
			L=mid+1,ret=mid;
		else R=mid-1;
	}
	assert(ret!=-1);
	return ret;
}
void db()
{
	for(int i=1;i<=n;i++)
		r[i][0]=getnxt(i);
	for(int j=1;j<20;j++)
	{
		for(int i=1;i<=n;i++)
			r[i][j]=r[r[i][j-1]][j-1];
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&x[i]);
	scanf("%d%d",&l,&q);
	db();
	while(q--)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		if(a>b) swap(a,b);
		int L=1,R=n,ans=-1;
		while(L<=R)
		{
			int mid=L+R>>1;
			int st=mid;
			int tmp=0;
			int fin=a;
			while(st)
			{
				if(st&1)
					fin=r[fin][tmp];
				tmp++;
				st>>=1;
			}
			if(fin>=b)
				R=mid-1,ans=mid;
			else L=mid+1;
		}
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 9088
// In the name of Allah the Lord of the Worlds.

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

typedef long long ll;

ll MOD = 1e9+7;
ll dp[2005][2005];
vector<int>v1 , v2;
int n , m;

ll f(int n1 , int n2)
{
    for (int i = 0; i <= n1; i++) {
        for (int j = 0; j <= n2; j++) {
            dp[i][j] = 0;
        }
    }
    for (int i = 1; i <= n1; i++) {
        for (int j = 1; j <= n2; j++) {
            if (v1[i - 1] == v2[j - 1])
                dp[i][j] = 1 + dp[i][j - 1] + dp[i - 1][j];
            else
                dp[i][j] = dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1];
            dp[i][j]+=MOD;
            dp[i][j]%=MOD;
        }
    }
    return dp[n1][n2]+1;
}

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

    cin >> n >> m;
    for(int i=0;i<n;i++){
        int in;
        cin >> in;
        v1.push_back(in);
    }
    for(int i=0;i<m;i++){
        int in;
        cin >> in;
        v2.push_back(in);
    }
    cout << (f(n , m)+MOD)%MOD << endl;

    return 0;
}


Measured memory_bytes: 31616
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int uint;

int popcount(uint x) {
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

int tzcnt(uint x) {
    return popcount(~x & x - 1);
}

struct Point {
    int x, y;

    Point(int p, int q) : x(p), y(q) {}
};

ll ans[100];

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

    int N; 
    cin >> N;

    bool four = false;

    for (int i = 0; i < N; ++i) {
        char c;
        cin >> c;

        if (c == 'Y') {
            four = true;
        }
    }

    out(four ? "Four" : "Three");

    int aaa;
    cin >> aaa;
}

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

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}


int main(){

  int a,b,c,d,e;
  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);

  int ans = 0;
  if(a == 0) ans = 1;
  if(b == 0) ans = 2;
    if(c == 0) ans =3;
      if(d == 0) ans =4;
        if(e == 0) ans =5;
  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define all(a) (a).begin(),(a).end()
#define X first
#define Y second
#define inf 2e9+5
using namespace std;
const int mod=1e9+7;
void solve()
{
  int n,k; cin>>n>>k; int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  int dp[k+1]={0}; dp[0]=1;
  for(int i=0;i<n;i++)
  {
      int cnt=0;
      for(int j=k;j>=k-a[i];j--){cnt+=dp[j]; cnt%=mod;}
      for(int j=k;j>=0;j--)
      {
          int t=dp[j];
          dp[j]=cnt;
          cnt-=t;
          if(j-a[i]-1>=0)cnt+=dp[j-a[i]-1];
          cnt=(cnt+mod)%mod;
      }
  }
  cout<<dp[k];
  return;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t; t=1;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 4404
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=b-1;i>=a;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A[200007],C[200007];
vector<ll> V;

int main(){
  ll N,K;
  cin >> N >> K;
  rep(i,N){
    cin >> A[i+1];
  }
  ll key=1,Z=1;
  while(1){
    C[key]=Z;
    V.pb(key);
    key=A[key];
    if(C[key]>0){
      break;
    }
    Z++;
  }
  if(K<V.size()){
    cout << V[K] << endl;
    return 0;
  }
  K-=C[key]-1;
  //cout << V[C[key]] 
  cout  << V[C[key]-1+K%(Z+1-C[key])] << endl;
}

Measured memory_bytes: 8420
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


ll c[15];
vector<ll> a[15];

int main(){
    ll n, m, x;
    cin >> n >> m >> x;
    rep(i, n){
        cin >> c[i];
        rep(j, m) {
            ll tmp;
            cin >> tmp;
            a[i].push_back(tmp);
        }
    }


    ll ans = LINF;



    for(int bits = 0; bits < (1<<n); bits++){
        ll score[m] = {};
        ll tcost = 0;
        rep(i, n){
            if (!(bits&(1<<i))) continue;
            rep(j, m) score[j] += a[i][j];
            tcost += c[i];
        }
        bool flag = true;
        // rep(j, m) cout << score[j] << " ";
        // cout << endl;
        rep(i, m) flag &= (score[i] >= x);
        if (flag) ans = min(ans, tcost);
    }
    if (ans == LINF) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a % (2 * b + 1) == 0) {
    cout << a / (2 * b + 1) << endl;
  }
  else {
    cout << a / (2 * b + 1) + 1 << endl;
  }
}

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

int main(){
    string str;
    cin >> str;
    int a,b;
    a = (str[0]-'0')*10+(str[1]-'0');
    b = (str[2]-'0')*10+(str[3]-'0');
    string ans = "";
    if(a>0 && a<=12 && b>0 && b<=12){
        ans = "AMBIGUOUS";
    }
    else if(a>0 && a<=12 && b>=0 && b<100){
        ans = "MMYY";
    }
    else if(b>0 && b<=12 && a>=0 && a<100){
        ans = "YYMM";
    }
    else{
        ans = "NA";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll N, M;
vector<ll>A;
vector<ll>sum;
int check(ll mid) {
	ll cnt = 0;
	for (int i = 0; i < N; i++) {
		if (A[N - 1] < mid - A[i])continue;
		int idx = lower_bound(all(A),mid-A[i]) - A.begin();
		cnt += N-idx;
	}
	return cnt >= M;
}


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

	cin >> N >> M;
	A.resize(N);
	sum.resize(N + 1);
	for (int i = 0; i < N; i++)cin >> A[i];
	sort(all(A));
	for (int i = 0; i < N; i++)sum[i + 1] = sum[i] + A[i];

	ll ok = 0, ng = inf;
	while (ng - ok > 1) {
		ll mid = (ng + ok) / 2LL;
		if (check(mid))ok = mid;
		else ng = mid;
	}

	ll cntover = 0;
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		if (A[N - 1] <= ok - A[i])continue;
		int idx = upper_bound(all(A), ok - A[i]) - A.begin();
		ll tempcnt = N-idx;
		cntover += tempcnt;
		ans += tempcnt * A[i] + (sum[N]-sum[idx]);
	}
	ans += (M-cntover)*ok;
	puts(ans);

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int dp[2][101][10001];
int a[101],b[101],c[101];
int main(){
    int n,C,ai,bi;
    cin>>n>>C;
    rep(i,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    memset(dp,-1,sizeof(dp));
    dp[0][0][0]=0;
    rep(i,n){
        rep(j,C+1)rep(k,i*100+1){
            if(dp[0][j][k]==-1) continue;
            if(j+c[i]<=C){
                int u=max(k+a[i],dp[0][j][k]+b[i]);
                int l=min(k+a[i],dp[0][j][k]+b[i]);
                dp[1][j+c[i]][l]=max(dp[1][j+c[i]][l],u);
                u=max(k+b[i],dp[0][j][k]+a[i]);
                l=min(k+b[i],dp[0][j][k]+a[i]);
                dp[1][j+c[i]][l]=max(dp[1][j+c[i]][l],u);            
            }
            dp[1][j][k]=max(dp[1][j][k],dp[0][j][k]);
        }
        swap(dp[0],dp[1]);
        memset(dp[1],-1,sizeof(dp[1]));
    }
    int mx=0;
    rep(i,C+1)rep(j,10001)if(dp[0][i][j]!=-1) mx=max(mx,j);
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 11012
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            int D = in.Int();
            int ans = 0;
            long d = (long) D * D;
            for (int i = 0; i < N; i++) {
                long X = in.Int();
                long Y = in.Int();
                if (X * X + Y * Y <= d) ans++;
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

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

    }
}



Measured memory_bytes: 54192
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define LINE_BUF_SIZE 101

int main(){

    int N,v;
    int i,j,k;

    int a[LINE_BUF_SIZE];
    int a_hold[LINE_BUF_SIZE];
    int sor_a[LINE_BUF_SIZE];
    int max_value;
    int sum;
    int judge;

    scanf("%d", &N);

    judge = 0;

    if(N % 2 != 0){
        N = N + 1;
        a[N-1] = 0;
        a_hold[N-1] = 0;
        judge = 1;
    }

    max_value = 0;
    sum = 0;

    //printf("ok1");

    if(judge == 1){
        for(i=0;i<N-1;i++){
            scanf("%d", &v);
            a[i] = v;
            a_hold[i] = v;
        }
    }

    if(judge == 0){
        for(i=0;i<N;i++){
            scanf("%d", &v);
            a[i] = v;
            a_hold[i] = v;
        }
    }
    //printf("ok2");

    for(j=0;j<N;j++){
        for(i=0;i<N;i++){
            if(a[i] >= max_value){
                max_value = a[i];
                sor_a[j] = i;
        //printf("%d\n", sor_a[j]); 
            }
        }
        a[sor_a[j]] = -1;
        //printf("%d\n", max_value);
        //printf("sor[%d] is %d\n", j,sor_a[j]);
        max_value = 0;
    }

    for(k=0;k<N;k++){
        sum += a_hold[ sor_a[k] ] - a_hold[ sor_a[k+1] ];
        k += 1;
    }

    printf("%d", sum);

    return 0;

}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int a, b; cin >> a >> b;
  cout << (a + b - 1) / 2 + 1 << endl;
}


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

using namespace std;

using ll = long long;
#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 FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#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 repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;



int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,m;
	cin>>n>>m;
	
	int left=0, right=n;
	
	rep(i,m){
		int l,r;
		cin>>l>>r;
		
		left = max(left, l);
		right = min(right, r);
	}
	
	if(right - left < 0) cout<<0<<endl;
	else cout<<right-left + 1<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, n;
  int f[45];
  scanf("%d", &n);
  f[0] = f[1] = 1;
  for(i = 2; i <= 44; ++i) {
    f[i] = f[i-1] + f[i-2];
  }

  printf("%d\n", f[n]);
  
return (0);
}



Measured memory_bytes: 2104
# N 個の宝石があり、i 番目の宝石の価値は Viです
# あなたはこれらの宝石の中からいくつかを選んで手に入れます
# このとき、1つも選ばなくとも、全て選んでも構いません
# ただし、i番目の宝石を手に入れる場合コスト Ciを支払わなければいけません
# 手に入れた宝石の価値の合計を X、支払ったコストの合計を Yとします
# X−Yの最大値を求めてください

N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))

# print(N)
# print(V)
# print(C)

sum=0
for i in range(N):
  max=V[i]-C[i]
#  print(V[i],C[i],max)
  if max > 0:
    sum=sum+max

print(sum)

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

int N;
long long ans;

int calc(int n,vector<vector<int>> &num){
  if(n==N-1){
    return ans;
  }
  if(ans<num[n][1]){
    ans=num[n][1];
  }if(ans%num[n][2]!=0){
    ans+=num[n][2]-ans%num[n][2];
  }ans+=num[n][0];
  return calc(n+1,num);
}

int main(){
  cin>>N;
  vector<vector<int>> num(N-1,vector<int>(3));
  for(int i=0;i<N-1;i++){
    cin>>num[i][0]>>num[i][1]>>num[i][2];
  }
  for(int i=0;i<N;i++){
    ans=0;
    cout<<calc(i,num)<<endl;
  }
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut ans: u64 = 0;
    let mut rest = 0;
    for _ in 0..n {
        let mut a: u64 = sc.cin();
        if rest > 0 && a >= rest {
            ans += rest;
            a -= rest;
        }
        ans += a / 2;
        rest = a % 2;
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<random>
#include<map>
#include<queue>
using namespace std;

int main(){

  int n, p;
  while(cin >> n >> p){
    if( n == 0 && p == 0 ) break;

    long long int step = 0;
    vector<int> a(n, 0);
    int tmp = p;
    while(true){
      step %= n;
      if( p != 0 ){
        p--;
        a[step]++;
      }else{
        if( a[step] != 0 && a[step] != tmp ){
          p += a[step];
          a[step] = 0;
        }else if(a[step] == tmp){
          cout << step << endl;
          break;
        }
      }
      step++;
    }
  }

  return 0;
}

Measured memory_bytes: 3004
#include<stdio.h>
int main()
{
    int i,msg=0;
    char a[1000];

    scanf("%s",a);

    i=0;
    while(a[i]!='\0'){
        if (a[i]=='7'){
            msg=1;
            break;
        }
        i++;
    }
    if(msg==1) {
            printf("Yes");
    }
    else printf("No");



}


Measured memory_bytes: 1732
module Vector =
  struct
    type t = { x: float; y: float }
    let eps = 1e-10
    let set x y = {x = x; y = y}
    let add v1 v2 = {x = v1.x +. v2.x; y = v1.y +. v2.y}
    let sub v1 v2 = {x = v1.x -. v2.x; y = v1.y -. v2.y}
    let mul v a = {x = v.x *. a; y = v.y *. a}
    let div v a = {x = v.x /. a; y = v.y /. a}
    let norm v = v.x *. v.x +. v.y *. v.y
    let abs v = sqrt (norm v)
    let dot v1 v2 = v1.x *. v2.x +. v1.y *. v2.y
    let cross v1 v2 = v1.x *. v2.y -. v1.y *. v2.x
  end

let is_convex va vb vc vd =
  let vba = Vector.sub vb va
  and vda = Vector.sub vd va
  and vcb = Vector.sub vc vb
  and vab = Vector.sub va vb
  and vdc = Vector.sub vd vc
  and vbc = Vector.sub vb vc
  and vad = Vector.sub va vd
  and vcd = Vector.sub vc vd
  in
  (Vector.cross vba vda > 0.0) && (Vector.cross vcb vab > 0.0) && (Vector.cross vdc vbc > 0.0) && (Vector.cross vad vcd > 0.0) || (Vector.cross vba vda < 0.0) && (Vector.cross vcb vab < 0.0) && (Vector.cross vdc vbc < 0.0) && (Vector.cross vad vcd < 0.0)

let _ = 
  try
    while true do
      let va, vb, vc, vd = Scanf.scanf "%f,%f,%f,%f,%f,%f,%f,%f\n" (fun xa ya xb yb xc yc xd yd -> (Vector.set xa ya, Vector.set xb yb, Vector.set xc yc, Vector.set xd yd)) in
      print_endline (if (is_convex va vb vc vd) then "YES" else "NO")
    done
  with
    End_of_file -> ()
        

Measured memory_bytes: 2368
tbl = [0] * 51
for i in range(10):
    for j in range(10):
        tbl[i + j] += 1
try:
    while 1:
        n = int(input())
        res = 0
        for i in range(n + 1):
            res += tbl[i] * tbl[n - i]

        print(res)

except Exception:
    pass

Measured memory_bytes: 7584
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int to, cost; };

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

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}


signed main()
{
   int H, W, K;
   cin >> H >> W >> K;

   vec<int> fibo(W,0);
   fibo[0] = 1; fibo[1] = 1;
   rep(i, 2, W) {
      fibo[i] = fibo[i-1] + fibo[i-2];
   }

   vec<vec<int>> dp(H+1, vec<int>(W,0));
   dp[0][0] = 1;
   rep(h, 0, H) {
      rep(w, 0, W) {
         if (w == 0) {
            dp[h+1][w  ] += mod( dp[h+1][w  ] + fibo[w  ] * fibo[W-w-1] * dp[h][w] );
            dp[h+1][w+1] = mod( dp[h+1][w+1] + fibo[w  ] * fibo[W-w-2] * dp[h][w] );
         } else if (w == W-1) {
            dp[h+1][w-1] = mod( dp[h+1][w-1] + fibo[w-1] * fibo[W-w-1] * dp[h][w] );
            dp[h+1][w  ] = mod( dp[h+1][w  ] + fibo[w  ] * fibo[W-w-1] * dp[h][w] );
         } else {
            dp[h+1][w-1] = mod( dp[h+1][w-1] + fibo[w-1] * fibo[W-w-1] * dp[h][w] );
            dp[h+1][w  ] = mod( dp[h+1][w  ] + fibo[w  ] * fibo[W-w-1] * dp[h][w] );
            dp[h+1][w+1] = mod( dp[h+1][w+1] + fibo[w  ] * fibo[W-w-2] * dp[h][w] );
         }
      }
   }

   dump(dp)
   cout << dp[H][K-1] << endl;

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  double n;
  R n;
  n/=3;
  pd(n*n*n);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main(){
	int a,b,c,x[5000],i,j,count;
	j=0;
	cin >>a>>b>>c;
	for(i=1;i<=c;i++){
		if(c%i){
		}else{
		x[j]=i;
		j++;
		}
	}
	c=j;
	for(j=0;j<=c;j++){
		if(x[j]>=a && x[j]<=b){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3116
using System;
using System.Linq;

class D
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(long.Parse).ToArray();
		long a = h[0], b = h[1];
		Console.WriteLine(new[] { 0, a - 1, 1, a }[a % 4] ^ new[] { b, 1, b + 1, 0 }[b % 4]);
	}
}


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

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a;
  ll tmp;
  for(int i=0; i<n; i++){
    cin >> tmp;
    a.push_back(tmp);
  }
  ll tentou=0;
  ll ans=0;
  bool first = false;
  ll sumtentou=0;
  for(int i=0; i<n; i++){
    first = false;
    ll tentou=0;
    for(int j=0; j<n; j++){
      if(i==j){first=true;}
      
      if(first){
        if(a.at(i)>a.at(j)){
          tentou++;
          ans++;
        }
      }else{
        if(a.at(i)>a.at(j)){
          tentou++;
        }
      }
    }
    sumtentou += tentou;
  }
  //cout << ans << endl;
  //cout << sumtentou << endl;
  ll out=0;
  ans = (ans*k)%1000000007;
  //cout << k*(k-1) << endl;
  out = (sumtentou%1000000007)*((k*(k-1)/2)%1000000007);
  cout << (out%1000000007 + ans%1000000007)%1000000007 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n, r, i;

  scanf("%d%d", &n, &r);

  if (n >= 10)
  {
    i = r;

    printf("%d\n", i);
  }
  else
  {
    i = r + (100 * (10 - n));

    printf("%d\n", i);
  }

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,k;
int arr[105];
int dp[100005][2];
int f(int left,int turn){
	//cout<<left<<" "<<turn<<'\n';
	int&ret = dp[left][turn];
	if(~ret) return ret;
	ret = 0;
	if(left==0) return ret = 0;
	for(int i=0; i<n; i++){
		if(left>=arr[i]){
			//내가 이기는 경우가 있다면 
			if(f(left-arr[i],!turn)==0) return ret = true;
		}
	}
	return ret;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	for(int i=0; i<n; i++) cin>>arr[i];
	if(f(k,0)) cout<<"First";
	else cout<<"Second";
}

Measured memory_bytes: 9036
readlines.each do |l|
  a = l.chomp.scan(/.{3}/).map(&:chars)
  puts(%w(o x).find do |c|
    a.any?{|i| i.all?{|j| j==c}} ||
    a.transpose.any?{|i| i.all?{|j| j==c}} ||
    [a[0][0], a[1][1], a[2][2]].all?{|i| i==c} ||
    [a[2][0], a[1][1], a[0][2]].all?{|i| i==c}
  end || "d")
end

Measured memory_bytes: 6096
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        int dig = scanner.nextInt();
        int dis = scanner.nextInt();

        if((dig<=8)&&(dis<=8)){
            System.out.println("Yay!\n");
        }else{
            System.out.println(":(\n");
        }






    }

}


Measured memory_bytes: 23636
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcount((unsigned int)x);};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    vl D(N); rep(i, N) cin >> D[i];
    sort(D.begin(), D.end());
    ll mid = N/2;
    ll ans = D[mid]-D[mid-1];
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int a, b, c, d, e, f;
	int z[3];
	
	scanf("%d", &a);
	
	for (b = 0; b < a; b++) {
		scanf("%d %d %d", &z[0], &z[1], &z[2]);
		for (e = 0; e < 3; e++) {
			for (f = 0; f < 3; f++) {
				if (z[e] < z[f]) {
					c = z[f];
					z[f] = z[e];
					z[e] = c;
				}
			}
		}
		z[0] = z[0] * z[0];
		z[1] = z[1] * z[1];
		z[2] = z[2] * z[2];
		
		if ((z[0] + z[1]) == z[2]) {
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	return (0);
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
#define ll long long int

int main() {
	string s,t;
	cin >> s >> t;
	ll count,ans = 1000;
	
	ll len_s = (ll)(s.length());
	ll len_t = (ll)(t.length());
	rep(i,len_s-len_t+1){
		count = 0;
		rep(j,len_t){
			if(s[i+j] != t[j]){
				count++;
			}
		}

		if (ans > count){
			ans = count;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define NMAX 100000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int A[NMAX]={},N,ans = 0;
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	int gap = 0;
	for (int i = 1; i < N; ++i)
	{
		 if(gap == 1){
		 	if(A[i] < A[i-1]){
		 		ans++;
		 		gap = 0;
		 	}
		 }else if(gap == -1){
		 	if(A[i] > A[i-1]){
		 		ans++;
		 		gap = 0;
		 	}
		 }else{
		 	if(A[i] > A[i-1]){
		 		gap = 1;
		 	}else if(A[i] < A[i-1]){
		 		gap = -1;
		 	}
		 }
	}
	ans++;
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 640