akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
ll inf=1e17;
//LLONG_MIN

//WA

int main(void){
	ll ans=inf;
	int N,C,d[100][100],s[3][100],cost[3][100],t;
	cin>>N>>C;
	reg(i,1,C)reg(j,1,C)cin>>d[i][j];
	rep(i,3)rep(j,100){
		s[i][j]=0;
		cost[i][j]=0;
	}
	rep(i,N){
		rep(j,N){
			cin>>t;
			s[(i+j)%3][t]++;
		}
	}
	rep(i,3){
		reg(k,1,C){//kに変える
			reg(j,1,C)cost[i][k]+=s[i][j]*d[j][k];
		}
	}
	reg(i,1,C){
		reg(j,1,C){
			reg(k,1,C){
				if(i==j || j==k || i==k)continue;
				ll sum=cost[0][i]+cost[1][j]+cost[2][k];
				ans=min(ans,sum);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.annotation.tailrec
import scala.math._

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  case class Light(num: Int, switches: Seq[Int], condition: Int)

  def solve(sc: Scanner): String = {
    val (n, m) = (sc.nextInt(), sc.nextInt())
    val bulbs = (0 until m).map { i =>
      val k = sc.nextInt()
      val switches = IndexedSeq.fill(k)(sc.nextInt() - 1)
      (k, switches)
    }
    val conditions = IndexedSeq.fill(m)(sc.nextInt())
    val lights = (0 until m).foldLeft(ArrayBuffer.empty[Light]) { (acc, i) =>
      val (_, switches) = bulbs(i)
      val condition = conditions(i)
      acc += Light(i + 1, switches, condition)
      acc
    }.toIndexedSeq
    debug(n, m, lights)

    var count = 0
    patterns(n).foreach { p =>
      val lightOnCounts = lights.foldLeft(0) { (acc, light) =>
        if (p.zipWithIndex.filter { case (_, i) => light.switches.contains(i) }.map(_._1).sum % 2 == light.condition) {
          acc + 1
        } else {
          acc
        }
      }
      if (lightOnCounts == lights.size) count += 1
    }
    count.toString
  }

  def patterns(n: Int): IndexedSeq[ArrayBuffer[Int]] = {
    val patternBufList = IndexedSeq.fill(pow(2, n).toInt)(ArrayBuffer.empty[Int])

    @tailrec
    def dfs(patternBufList: IndexedSeq[ArrayBuffer[Int]], n: Int): IndexedSeq[ArrayBuffer[Int]] = {
      if (n > 0) {
        patternBufList.zipWithIndex.foreach { case (a, i) =>
          a += floor(i / (pow(2, n) / 2) % 2).toInt
        }
        dfs(patternBufList, n - 1)
      } else patternBufList
    }

    dfs(patternBufList, n)
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}


Measured memory_bytes: 37576
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x_max = max(x)
y_min = min(y)
if y_min - x_max > 0 and Y - x_max > 0 and y_min - X > 0:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
int n,m,cnt,ans,inf=1e9,l,r,mi;
char ss[100010];
bool jd(int mi)
{
	int i,s,a,b,j,k,mx1,mx2;
	mx1=mx2=inf;
	for(i=1;i<=n;i++)
	{
		if(i-1>=mi || n-i>=mi)continue;
		if(ss[i-1]=='0')mx2=min(mx2,max(i-1,n-i));
		else mx1=min(mx1,max(i-1,n-i));
	}
	return (mx1>=mi || mx2>=mi);
}
int main()
{
	int i,s,a,b,j,k;
	ans=1e9;scanf(" %s",ss);n=strlen(ss);
	l=n/2;r=n;
	while(l<r)
	{
		mi=(l+r)/2+1;
		if(jd(mi))l=mi;
		else r=mi-1;
	}
	printf("%d",l);
	return 0;
}

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

using namespace std;

int main(){
  int i, j;
  string c[3];
  char win;

  while(1){
    for(i=0; i<3; ++i){
      cin >> c[i];
      if(c[0] == "0") break;
    }
    if(c[0] == "0") break;

    win = '0';

    for(i=0; i<3; i++){
      if(c[i][0] == c[i][1] && c[i][0] == c[i][2] && c[i][0] != '+')
	win = c[i][0];
      if(c[0][i] == c[1][i] && c[0][i] == c[2][i] && c[0][i] != '+')
	win = c[0][i];
    }

    if(c[0][0] == c[1][1] && c[0][0] == c[2][2] && c[0][0] != '+')
      win = c[0][0];
    if(c[0][2] == c[1][1] && c[0][2] == c[2][0] && c[0][2] != '+')
      win = c[0][2];


    if(win == '0')
      cout << "NA" << endl;
    else
      cout << win << endl;
  }

  return 0;
}

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

using namespace std;

int main() {
    long a, b, c, k;
    cin >> a >> b >> c >> k;

    // a +1
    // b 0
    // c -1
    // total k

    if(a >= k) {
        // cout << "here1" << endl;
        cout << 1 * k  << endl;
        return 0;
    } else if(a + b >= k) {
        // cout << "here2" << endl;
        cout << 1 * a + 0 * b << endl;
        return 0;
    } else {
        // a + b < k, k - (a + b) > 0
        long max = 1 * a + 0 * b + (-1 * (k - (a + b)));
        cout << max << endl;
        return 0;
    }
}

Measured memory_bytes: 3620
MOD = (10**9) + 7


class modint():
    def __init__(self, value):
        self.value = value % MOD

    def __int__(self):
        return int(self.value)

    def __float__(self):
        return float(self.value)

    def __str__(self):
        return str(self.value)

    def __repr__(self):
        return str(self.value)

    def __add__(self, other):
        return (modint(self.value + other.value) if isinstance(other, modint)
                else modint(self.value + other))

    def __sub__(self, other):
        return (modint(self.value - other.value) if isinstance(other, modint)
                else modint(self.value - other))

    def __mul__(self, other):
        return (modint(self.value * other.value) if isinstance(other, modint)
                else modint(self.value * other))

    def __truediv__(self, other):
        return (modint(self.value * pow(other.value, MOD - 2, MOD))
                if isinstance(other, modint)
                else modint(self.value * pow(other, MOD - 2, MOD)))

    def __pow__(self, other):
        return (modint(pow(self.value, other.value, MOD))
                if isinstance(other, modint)
                else modint(pow(self.value, other, MOD)))

    def __eq__(self, other):
        return (self.value == other.value if isinstance(other, modint)
                else self.value == (other % MOD))

    def __ne__(self, other):
        return (self.value == other.value if isinstance(other, modint)
                else self.value == (other % MOD))

    def __radd__(self, other):
        return (modint(other.value + self.value) if isinstance(other, modint)
                else modint(other + self.value))

    def __rsub__(self, other):
        return (modint(other.value - self.value) if isinstance(other, modint)
                else modint(other - self.value))

    def __rmul__(self, other):
        return (modint(other.value * self.value) if isinstance(other, modint)
                else modint(other * self.value))

    def __rtruediv__(self, other):
        return (modint(other.value * pow(self.value, MOD - 2, MOD))
                if isinstance(other, modint)
                else modint(other * pow(self.value, MOD - 2, MOD)))

    def __rpow__(self, other):
        return (modint(pow(other.value, self.value, MOD))
                if isinstance(other, modint)
                else modint(pow(other, self.value, MOD)))

    def modinv(self):
        return modint(pow(self.value, MOD - 2, MOD))


def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x


def lcm(x, y):
    return x*y//gcd(x, y)


def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    k = A[0]
    for a in A[1:]:
        k *= a//gcd(k, a)
    k = modint(k)
    ans = modint(0)
    for a in A:
        ans += k/a
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43164
(let ((a (read))
      (b (read))
      (c (read))
      (x (read)))

  (format t "~A~%"
          (loop for i from 0 to a
                sum (loop for j from 0 to b
                          sum (loop for k from 0 to c
                                    count (= (+ (* 500 i) (* 100 j) (* 50 k)) x))))))


Measured memory_bytes: 24432
#include <iostream>
#include <cstdio>
int main(){
	int n,i;
	std::cin>>n;
	int a[n];
	for(i=0;i<n;i++){
		std::cin>>a[i];
	}
	for(i=n-1;0<=i;i--){
		std::cout<<a[i];
		if(i!=0)
			std::cout<< " ";
	}
	std::cout<<std::endl;
	return 0;
}

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

int main(void) {
	char s[200000];
	int a, b;

	scanf("%s", s);

	int l = strlen(s);

	for (int i = l - 1; i >= 0; i--) {
		if (s[i] == 'A') {
			a = i;
		}
	}
	for (int i = 0; i < l; i++) {
		if (s[i] == 'Z') {
			b = i;
		}
	}
	
	int ans = b - a + 1;

	printf("%d", ans);
}

Measured memory_bytes: 1928
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main(int argc, char const *argv[]) {
  int n, k;
  cin >> n >> k;
  int count = 0;
  rep(i, n) {
    int h;
    cin >> h;
    if (h >= k)
      count++;
  }
  cout << count << endl;
  return 0;
}


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

int main() {
    ll n,m;
    cin >> n >> m;
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        ans *= (m - i);
        ans %= 1000000007;
    }
    ll p = 1;
    ll q = 0;
    for (int i = 0; i < n; i++) {
        ll pp = p;
        ll qq = q;
        p *= (m - n);
        p += qq * (m - n + 1);
        q = (qq+pp) * (n - i - 1);
        p %= 1000000007;
        q %= 1000000007;
    }
    cout << ans*p%1000000007 << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int N;

vector<vector<pair<int,int>>> G;
vector<int> colors;

bool dfs(int v, int cur = 0){
    colors[v] = cur;
    // cout << v+1 << ' ' << cur << endl;
    for(auto next_v : G[v]){
        
        if(colors[next_v.first] != -1){
            if( (colors[next_v.first] == cur) && (next_v.second % 2 != 0) ) return false;
            continue;
        }
        
        if(next_v.second % 2 == 0){
            if(!dfs(next_v.first, cur)) return false;
        }
        if(next_v.second % 2 != 0){
            if(!dfs(next_v.first, 1 - cur)) return false;
        }
    }
    return true;
}

int main(void){
    cin >> N;
    G.resize(N);
    
    for(int i = 1; i < N; i++){
        int u,v,w; cin >> u >> v >> w;
        u--;
        v--;
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
    }
    
    for(int v = 0; v < N; v++){
        colors.assign(N, -1);
        if(dfs(v)) break;
    }
    
    for(int i = 0; i < N; i++){
        cout << colors[i] << "\n";
    }
}


Measured memory_bytes: 8192
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

macro_rules ! max { ( $ x : expr ) => ( $ x ) ; ( $ x : expr , $ ( $ z : expr ) ,+ ) => { { std :: cmp :: max ( $ x , max ! ( $ ( $ z ) ,* ) ) } } }
macro_rules ! min { ( $ x : expr ) => ( $ x ) ; ( $ x : expr , $ ( $ z : expr ) ,+ ) => { { std :: cmp :: min ( $ x , min ! ( $ ( $ z ) ,* ) ) } } }

const HALF: usize = 1024;
const MAX: usize = 100_001;

fn dfs(n: usize, i: usize, dp: &mut Vec<Vec<usize>>, vw: &Vec<(usize, usize)>) {
    let (v, w) = vw[i];
    if i == 0 {
        for j in 0..MAX {
            dp[i][j] = if j < w { 0 } else { v };
        }
    } else {
        let p = (i - 1) / 2;
        for j in 0..MAX {
            dp[i][j] = if j < w {
                dp[p][j]
            } else {
                max!(dp[p][j], dp[p][j - w] + v)
            };
        }
    }

    for j in 0..2 {
        let next = 2 * i + j + 1;
        if next >= n {
            continue;
        }
        dfs(n, next, dp, vw);
    }
}

fn main() {
    input! {
        n: usize,
        vw: [(usize, usize);n],
        q: usize,
        vl: [(Usize1, usize);q],
    }

    let half = min!(n, HALF);

    let mut dp = vec![vec![0; MAX]; half];
    dfs(half, 0, &mut dp, &vw);

    for (v, l) in vl {
        if v < half {
            println!("{}", dp[v][l]);
            continue;
        }

        let mut vec = Vec::new();
        let mut pos = v;
        while pos >= half {
            vec.push(pos);
            pos = (pos - 1) / 2;
        }

        let size = vec.len();
        let mut mx = 0;
        for i in 0..1 << size {
            let mut val = 0;
            let mut wei = 0;
            for j in 0..size {
                if (i >> j) & 1 == 0 {
                    continue;
                }
                let (v, w) = vw[vec[j]];
                val += v;
                wei += w;
            }
            if wei > l {
                continue;
            }
            mx = max!(mx, val + dp[pos][l - wei]);
        }
        println!("{}", mx);
    }
}


Measured memory_bytes: 815608
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[310][310];
int d[310][310];
int B[310][310];

signed main(){
	cin>>N;
	REP(i,N){
		REP(j,N){
			cin>>A[i][j];
			d[i][j]=A[i][j];
		}
	}
	int ans=0;
	REP(k,N){
		REP(i,N){
			REP(j,N){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	REP(i,N){
		REP(j,N){
			if(d[i][j]!=A[i][j]){
				cout<<-1<<endl;
				return 0;
			}
			B[i][j]=d[i][j];
		}
	}
	REP(k,N){
		REP(i,N){
			REP(j,N){
				if(d[i][j]==d[i][k]+d[k][j]&&B[i][k]!=0&&B[k][j]!=0){
					B[i][j]=0;
					DEB(i)DEB(j)END
				}
			}
		}
	}
	REP(i,N){
		REP(j,N){
			ans+=B[i][j];
		}
	}
	cout<<ans/2<<endl;
	return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n), f(n);
	for(auto &x:a)
		cin >> x;
	for(auto &x:f)
		cin >> x;

	ll l = -1, r = 1e18+100;
	sort(all(a));
	sort(all(f), greater<ll>());
	while(r-l>1){
		ll res = l + (r-l)/2LL;
		ll cost = 0;
		for(ll i=0; i<n; ++i){ 
			ll x = res/f[i];
			if(a[i]<x) continue;
			cost += a[i]-x;
		}
		if(cost<=k) r = res;
		else l = res;
	}
	cout << r << endl;
}


Measured memory_bytes: 3456
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
Main();
function Main(){
  var one = nextIntArray();
  var A = one[0];
  var B = one[1];
  var C = one[2];
  myout(Math.min(C,Math.floor(B / A)));
}

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

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);
	int k;
	int a, b;
	cin >> k >> a >> b;
	int ans;
	if (a %k!=0)
	ans = k*((a / k) + 1);
	else
		ans = k*((a / k));
	if (ans<=b){
		cout << "OK" << "\n";
	}
	else{
		cout << "NG" << "\n";
	}
	return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

bool check(char c) { return c == 'A' || c == 'T' || c == 'G' || c == 'C'; }

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

    string s;
    cin >> s;

    int ans = 0, cnt = 0;

    rep(i, 0, s.size()) {
        if (check(s[i])) {
            ++cnt;
            ans = max(ans, cnt);
        } else {
            cnt = 0;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
// const int mod=1e9+7;
 const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


void solve()
{
    int n;
    cin>>n;
    readv(a,n);
    int q;
    cin>>q;

    map<int, int> cnt;
    for(int i=0;i<n;i++)
        cnt[a[i]]++;


    int sum = accumulate(all(a), (int)0);


    for(int i=0;i<q;i++)
    {
        int b, c;
        cin>>b>>c;

        sum += (c-b) *cnt[b];

        cnt[c] +=cnt[b];
        cnt[b] =0;
        cout<<sum<<endl;
    }




}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t = 1;
    // cin>>t;

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    cin >> N;
    ll cnt = 0;
    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        if(a % 2 == 1){
            cnt++;
        }
    }
    YES(cnt % 2 == 0);
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string a;
    cin >> a;
    
    
    while(a != ""){
        if("hi" == a.substr(0,2)){
            a = a.erase(0,2);
        }else{
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int N;
  string s;

  cin >> N >> s;

  if (N%2 == 0 && s.substr(0, N/2) == s.substr(N/2, N/2)) {
    puts("Yes");
  } else {
    puts("No");
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const int MAXI = 110;

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int h, w; cin >> h >> w;
	vector<vector<char> > s(h + 1, vector<char>(w + 1));
	REP(i, h) REP(j, w)
		cin >> s[i+1][j+1];

	vector<vector<int> > dp(MAXI, vector<int>(MAXI, INT_MAX));
	dp[1][1] = (s[1][1] == '#');

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (i * j != 1) {
				dp[i][j] = min(dp[i-1][j]+(s[i][j]=='#'&&s[i-1][j]=='.'), dp[i][j-1]+(s[i][j]=='#'&&s[i][j-1]=='.'));
			}
		}
	}
	cout << dp[h][w] << '\n';
    return 0;
}


Measured memory_bytes: 3588
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Tree {
	int key;
	struct Tree *parent, *left, *right;
};

struct Tree *root, *nill;
struct Tree *del;

void insert(int key) {
	struct Tree *x, *y, *z;
	y = nill;
	x = root;

	z = (struct Tree*)malloc(sizeof(struct Tree));
	z->key = key;
	z->left = nill;
	z->right = nill;

	while (x != nill) {
		y = x;
		if (key < x->key)
			x = x->left;
		else
			x = x->right;
	}
	z->parent = y;

	if (y == nill) {
		root = z;
	}
	else if (z->key < y->key)
		y->left = z;
	else
		y->right = z;
}

int find(int key) {
	struct Tree *x;
	x = root;

	while (x != nill) {
		if (x->key == key) {
			del = x;
			return 1;
		}
		else if (x->key > key) 
			x = x->left;
		else
			x = x->right;
	}
	return 0;
}

struct Tree *getMinimum(struct Tree *x) {
	while (x->left != nill)
		x = x->left;
	return x;
}

struct Tree *getSuccessor(struct Tree *x) {
	struct Tree *y;
	if (x->right != nill)
		return getMinimum(x->right);

	y = x->parent;
	while (y != nill && x == y->right) {
		x = y;
		y = y->parent;
	}
	return y;
}

void dele(int key) {
	struct Tree *x, *y;
	
	if (del->left == nill || del->right == nill)
		y = del;
	else
		y = getSuccessor(del);

	if (y->left != nill)
		x = y->left;
	else
		x = y->right;

	if (x != nill)
		x->parent = y->parent;

	if (y->parent == nill)
		root = x;
	else if (y == y->parent->left)
		y->parent->left = x;
	else
		y->parent->right = x;

	if (y != del)
		del->key = y->key;
}

void inorder(struct Tree *t) {
	if (t->left != nill)
		inorder(t->left);
	printf(" %d", t->key);
	if (t->right != nill)
		inorder(t->right);
}

void preorder(struct Tree *t) {
	printf(" %d", t->key);
	if (t->left != nill)
		preorder(t->left);
	if (t->right != nill)
		preorder(t->right);
}

int main(void) {
	int n, key;
	char s[10];

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", s);
		if (strcmp(s, "insert") == 0) {
			scanf("%d", &key);
			insert(key);
		}
		else if (strcmp(s, "print") == 0) {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (strcmp(s, "find") == 0) {
			scanf("%d", &key);
			if (find(key) == 1)
				printf("yes\n");
			else
				printf("no\n");
		}
		else {
			scanf("%d", &key);
			if (find(key) == 1)
				dele(key);
		}
	}


	return 0;
}


Measured memory_bytes: 20608
#include <cstdio>
#include <utility>

constexpr int MAX_N = 100000;

struct card{
  char suit;
  int num;
  int index;
};

int partition(card* A, int p, int r){
  card x = A[r];
  int i = p - 1;
  for(int j = p; j < r; j++){
    if(A[j].num <= x.num){
      i++;
      std::swap(A[i], A[j]);
    }
  }
  std::swap(A[i+1], A[r]);
  return i+1;
}

int quicksort(card* A, int p, int r){
  if(p < r){
    int q = partition(A, p, r);
    quicksort(A, p, q - 1);
    quicksort(A, q + 1, r);
  }
  return 0;
}

int main(){
  int n;
  card A[MAX_N];
  scanf("%d", &n);

  for(int i = 0; i < n; i++) {
    A[i] = {' ', 0, i};
    scanf("%s", &A[i].suit);
    scanf("%d", &A[i].num);
  }
  quicksort(A, 0, n-1);

  bool stable = true;
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      if(A[i].num != A[j].num){
	i = j - 1;
	break;
      }
      if(A[i].index > A[j].index){
	stable = false;
	break;
      }
    }
  }
  if(stable){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }
  for(int i = 0; i < n; i++){
    printf("%s %d\n", &A[i].suit, A[i].num);
  }
}

Measured memory_bytes: 2192
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX

using namespace std;
using LL=long long;

int R[1010];

int main(){
    int n,a,b,x=0,r=0;
    cin>>a>>b;
    R[a]++;
    R[b]--;
    cin>>n;
    LP(i,n){
        cin>>a>>b;
        R[a]++;
        R[b]--;
    }
    LP(i,1010){
        x+=R[i];
        if(x>=2) r=1;
    }
    cout<<r<<endl;
    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch GoldenCoins | diff GoldenCoins.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address GoldenCoins.cpp && ./a.out

/*
 
 3/28/2020
 
 5:02-
 
 */

LL X;

void solve() {
  LL res=1000LL*(X/500);
  LL x=X%500;
  res+=5LL*(x/5);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>X;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
P = [0] + list(map(int, input().split()))
C = [0] + list(map(int, input().split()))

# Pが1,2,...Nの順列なので、1,2,3,4,5,3,4,5,...のような途中からのループは起こり得ない
# スタートの点数が入らないのは面倒なので、スタートの次のマスから考える

ans = -(10**9)
# どのマスから始めるか
for i in range(1, N + 1):
    # ループに入るまでの経路(iの次から)
    route = []
    visit = [False] * (N + 1)
    visit[i] = True
    now = i
    while True:
        next = P[now]
        # まだ訪れていないマスの場合
        if visit[next] == False:
            visit[next] = True
            route.append(next)
            now = next
        # 既に訪れたマスの場合
        else:
            break
    # iに戻ってくる
    route.append(i)

    cumsum = [0]
    for x in route:
        cumsum.append(cumsum[-1] + C[x])
    # print(cumsum)

    # ループするほど損する場合
    if cumsum[-1] <= 0:
        if K >= len(route):
            tmp = max(cumsum[1:])
        else:
            tmp = max(cumsum[1:K + 1])
        ans = max(ans, tmp)
    # ループするほど得する場合
    else:
        loop_size = len(route)
        loop_cnt = K // loop_size
        spare_cnt = K % loop_size
        # (loop_cnt -1)回ループしたところから
        cumsum2 = [cumsum[-1] * (loop_cnt - 1)]
        for x in route:
            cumsum2.append(cumsum2[-1] + C[x])
        for x in route[:spare_cnt]:
            cumsum2.append(cumsum2[-1] + C[x])
        tmp = max(cumsum2[1:])
        ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 190496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int N; cin >> N;
    ll K; cin >> K;
    vel A(N); rep(i,N) cin >> A[i];

    if(maxel(A) < K) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    else if(maxel(A) == K) {
        cout << "POSSIBLE" << endl;
        return 0;
    }
    else {
        ll gcd;
        rep(i,N-1) {
            gcd = __gcd(A[i], A[i+1]);
            if(gcd == 1LL) break;
        }

        if(gcd == 1LL) {cout << "POSSIBLE" << endl; return 0;}
        else {
            if(K % gcd == 0) {cout << "POSSIBLE" << endl; return 0;}
            else {cout << "IMPOSSIBLE" << endl; return 0;}
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k;
  string s;
  in3(n, k, s);
  char d = 'A' - 'a';
  s[k - 1] = s[k - 1] - d;
  out(s);
  memi;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N - 1), ans(N);
    for(int i = 0; i < N - 1; ++i)
    {
        cin >> A.at(i);
        ans.at(A.at(i) - 1)++;
    }
    for(int i = 0; i < N; ++i) cout << ans.at(i) << endl;
    return 0;
}


Measured memory_bytes: 4844
import java.util.Scanner;

public class Main {
		public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		char[] a = scan.next().toCharArray();
		char[] b = scan.next().toCharArray();
		char[] c = scan.next().toCharArray();
		int A = 0;
		int B = 0;
		int C = 0;
		char x = a[0];
		String ans = "";
		while (true) {
			if (x == 'a') {
				A++;
				if (A==a.length) {
					ans = "A";
					break;
				} else
				x = a[A];
			}
			if (x == 'b') {
				if (B==b.length) {
					ans = "B";
					break;
				}
				x = b[B];
				B++;
			}
			if (x == 'c') {
				if (C==c.length) {
					ans = "C";
					break;
				}
				x = c[C];
				C++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B, C, D;
  cin >> N ;
  
 //A B C D定義
  A = N/1000 ;
  B = (N - A*1000)/100 ;
  C = (N - A*1000 - B*100)/10 ;
  D = N - A*1000 - B*100 - C*10 ;
     
  if( A == B ){
    if( B == C ){
      cout <<  "Yes" << endl;
    }
    	else{
          cout << "No" << endl;
        }
  }
  	else{
     if( C == D ){
       if( B == C ){
         cout << "Yes" << endl;
       }
       	else{
          cout << "No" << endl;
        }
     }
     else{
       cout << "No" << endl;
      
    }
    }
 
}

Measured memory_bytes: 256
import math

N, M = map(int, input().split(" "))
div1 = []
div2 = []

for i in range(1, int(math.sqrt(M))+1):
    if M % i == 0:
        div1 += (i,)
        div2 += (M//i,)
for d in div2:
    if d * N <= M:
        print(d)
        break
else:
    div1 = div1[::-1]
    for d in div1:
        if d * N <= M:
            print(d)
            break

Measured memory_bytes: 3064
n,k=map(int, input().split())
S = []
for i in range(k):
    d1 = int(input())
    
    S.append(list(map(int, input().split())))

ans = [0]*n

for i,s in enumerate(S):
    for d in s:
        ans[int(d)-1]+=1


cnt = 0
for i in ans:
    if i == 0:
        cnt+=1
print(cnt)

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

    //long long
    using ll = long long;

    // pair<int, int>
    using PII = pair<int, int>;

    //最大値、mod
    const int MOD = 1000000007;
    const int INF = 1000000000;
    const long long LINF = 1e18;

    //出力系
    #define print(x) cout << x << endl
    #define prints(x) cout << fixed << setprecision(10) << x << endl
    #define printc(x) cout << setw(2) << setfill('0') << x << endl;
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

    //for
    #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

    //最大公約数 
    unsigned gcd(unsigned a, unsigned b) {
      if(a < b) return gcd(b, a);
      unsigned r;
      while ((r=a%b)) {
        a = b;
        b = r;
      }
      return b;
    }

    // 最小公倍数
    unsigned lcm(unsigned a, unsigned b){
        return a / gcd(a, b) * b; 
    }

    // a = max(a, b), a = min(a, b)
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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









int main(){
 int N;
 cin >> N;
 bool flag = false;
 REP(i, N){
   int x;
   cin >> x;
   if(x & 1) {
     flag = true; 
     break;
   }
 }
 flag ? print("first") : print("second");
}

  




Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}

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

fn divisors(N: i64) -> HashSet<i64> {
    let mut ds = vec![];
    let mut d = 1;
    while d * d <= N {
        if N % d == 0 {
            ds.push(d);
            ds.push(N / d);
        }
        d += 1;
    }
    let uniq: HashSet<i64> = ds.into_iter().collect();
    uniq
}

fn main() {
    let x: i64 = read();
    let mut ans = x - 1;

    for i in divisors(x) {
        ans = min(ans, (i - 1) + (x / i) - 1);
    }

    println!("{}", ans)
}


Measured memory_bytes: 4352
#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 n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  vector<int> a = p;
  sort(a.begin(), a.end());
  int cnt = 0;
  rep(i, n) {
    if (a[i] != p[i]) cnt++;
  }
  if (cnt <= 2) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
  return 0;
}

Measured memory_bytes: 3564
N, Y = map(int, input().split())
flag = 0
for i in range(N+1):
    for j in range(N+1):
        if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y and i >= 0 and j >= 0 and (N-i-j) >= 0:
            flag += 1
            x = i
            y = j
            z = N - i - j
            break
        else:
            pass

if flag > 0:
    print(x, y, z)
else:
    print(-1, -1, -1)


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

using namespace std;
#define Debug(x) cout << #x << "=" << (x) << endl;
typedef long long LL;
const int maxn = 60;


LL a[maxn];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
    }
    LL minv = a[1], maxv = a[1];
    int minid = 1, maxid = 1;
    for(int i = 2; i <= n; i++)
    {
        if(minv>a[i])
        {
            minv = a[i];
            minid = i;
        }
        if(maxv<a[i])
        {
            maxv = a[i];
            maxid = i;
        }
    }
    //cout << maxv << " " << minv << endl;
    //vector<int>
    if(minv >= 0)
    {
        printf("%d\n", n-1);
        for(int i = 2; i <= n; i++)
        {
            printf("%d %d\n", i-1, i);
        }
        return 0;
    }
    if(maxv <= 0)
    {
        printf("%d\n", n-1);
        for(int i = n; i >= 2; i--)
        {
            printf("%d %d\n", i, i-1);
        }
        return 0;
    }
    printf("%d\n",n-1+n-1);
    if(abs(maxv)>abs(minv))
    {
        for(int i = 1; i <= n; i++)
        {
            if(i==maxid)continue;
            printf("%d %d\n", maxid, i);
        }
        for(int i = 2; i <= n; i++)
        {
            printf("%d %d\n", i-1, i);
        }

    }
    else
    {
        for(int i = 1; i <= n; i++)
        {
            if(i==minid)continue;
            printf("%d %d\n", minid, i);
        }
        for(int i = n; i >= 2; i--)
        {
            printf("%d %d\n", i, i-1);
        }
    }



    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define REP(i, n) for(i = 0; i < n; ++i)
#define FOR(i, a, b) for(i = a; i < b; ++i)

void yes_or_no(char boolean){
    if(boolean){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

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

int main(){
    int N, i;
    scanf("%d", &N);
    long list[N];

    REP(i, N){
        scanf("%ld", &list[i]);
    }
    qsort(list, N, sizeof(long), comp);

    int num = 1;
    int ans = 0;

    if(N == 1){
        ans = 1;
    }

    FOR(i, 1, N){
        if(list[i - 1] == list[i]){
            num++;
        }else{
            ans += (num % 2);
            num = 1;
        }
    }
    
    ans += (num % 2);

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1788
# import numpy as np
# import scipy as sp
# print(ans,sep="")
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

a = list(map(int, input().split()))
print(max(a)-min(a))


Measured memory_bytes: 2940
n,m=map(int,input().split())
p=list(map(int,input().split()))
par=[i for i in range(n)]

def find(x):
  if par[x]==x:
    return par[x]
  else:
    par[x]=find(par[x])
    return par[x]

def union(x,y):
  fx=find(x)
  fy=find(y)
  if fx!=fy:
    par[fx]=fy
    
for i in range(m):
  a,b=map(int,input().split())
  union(a-1,b-1)
  
ans=0
  
for i in range(n):
  if find(p[i]-1)==find(i):
    ans+=1
    

print(ans)

Measured memory_bytes: 20320
#include <bits/stdc++.h>
using namespace std;
struct data_t {
    int num;
	int point;
    string str;
	 bool operator<( const data_t& right ) const {
        return str == right.str ? point > right.point : str < right.str;
    }
} ;
int main(void){
	int N;
	cin >> N;
	vector<data_t> d(N);
	for(int i=0;i<N;i++){
		cin >> d[i].str;
		cin >> d[i].point;
		d[i].num = i+1;
	}
	sort(d.begin(), d.end());
	for(int i=0;i<N;i++){
		cout << d[i].num << endl;
	}
}

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

namespace ABC061A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B, C;

            var word = Console.ReadLine().Split(' ');
            A = int.Parse(word[0]);
            B = int.Parse(word[1]);
            C = int.Parse(word[2]);

            if (A <= C && C <= B)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

                Console.ReadKey();

        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


ll dp[21111];
int main(){   
    int h,n;
    cin>>h>>n;
    vector<int>a(n),b(n);
    rep(i,n)cin>>a[i]>>b[i];
    rep(j,21111){
        dp[j] = INF ;
    }

    dp[0] = 0;//代入されるのはコスト

    rep(i,n){
        rep(j,20010){
            if(j - a[i] >= 0){
                //dpテーブル更新
                dp[j] = min(dp[j] , dp[j - a[i]] + b[i]);
                               
            }
        }
    }

    ll ans = INF;

    for(int i = 20001;i >=h;i--){
        ans = min(ans,dp[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <iomanip>
using namespace std;
int main(void){
    
    double r;
    
    
    cin >> r;
    
   
    std::cout << std::fixed;
    cout<<    std::setprecision(10)<< r*r*3.141592653589 << " " << r*2*3.141592653589 << endl;
    
    
    
    
}



Measured memory_bytes: 3272
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func main() {
    a, b, c := nextLine(), nextLine(), nextLine()
    fmt.Print(a[:1])
    fmt.Print(b[1:2])
    fmt.Print(c[2:])
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fo(i,s,e) for(register int i=s;i<=e;i++)
#define ll long long
int n,m;
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	cout<<max(0,n-m*2);
	return 0;
}

Measured memory_bytes: 256