akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(), v.end()
using namespace std;

ll n,k,a[200010],pos;
bool use[200010];
stack< ll > p;
vector< ll > c;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;
    for(ll i=1; i<=n; i++) cin >> a[i];

    pos = 1;
    for(ll i=1; ; i++){
        k--;
        if( k==-1 ){
            cout << pos;
            return 0;
        }

        if( use[pos] ){
            while( p.top()!=pos ) c.pb( p.top() ) , p.pop();
            c.pb( pos );
            reverse( all( c ) );
            break;
        }

        use[ pos ] = true;
        p.push( pos );

        pos = a[ pos ];
    }

    cout << c[ (k+1)%(c.size()) ];

    return 0;
}


Measured memory_bytes: 7032
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

struct Query {
    time: i32,
    initial: i32
}

fn main() {
    let x: i32 = read();
    let k: usize = read();
    let mut reverse_at: Vec<i32> = readnc();
    reverse_at.insert(0, 0);
    reverse_at.push(1000000010);

    let q: usize = read();
    let queries: Vec<(i32, i32)> = readn(q);
    let queries: Vec<Query> = queries.into_iter().map(|(a, b)| {
        Query { time: a, initial: b }
    }).collect();

    let mut min_sand = 0;
    let mut max_sand = x;
    let mut argmin = 0;
    let mut argmax = x;

    let mut answers: Vec<i32> = vec![0; q];

    let mut head: usize = 0;
    let mut incr = -1;
    for ti in 1..k+2 {
        let next_reverse = reverse_at[ti];
        let prev_reverse = reverse_at[ti-1];
        while head < q && queries[head].time < next_reverse {
            let q = &queries[head];
            let diff = q.time - prev_reverse;
            let at0= if q.initial < argmin {
                min_sand
            } else if argmax < q.initial {
                max_sand
            } else {
                min_sand + q.initial - argmin
            };

            let to = min(x, max(0, at0 + diff * incr));
            answers[head] = to;
            head += 1;
        }

        let diff = next_reverse - prev_reverse;
        let to_min_sand = min_sand + diff * incr;
        let to_max_sand = max_sand + diff * incr;

        if to_min_sand < 0 {
            argmin -= to_min_sand;
        }
        if to_max_sand > x {
            argmax -= to_max_sand - x;
        }
        min_sand = min(x, max(0, to_min_sand));
        max_sand = min(x, max(0, to_max_sand));
        if min_sand == max_sand {
            argmin = x;
            argmax = x;
        }
        incr *= -1;
    }

    for a in answers {
        println!("{}", a);
    }
}


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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

const int dxs[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dys[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

int prime[1001001];
bool is_prime[1001001];

int sieve(int n) {
  int p = 0;
  for (int i = 0; i < n; i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i < n; i++){
    if (is_prime[i]){
      prime[p++] = i;
      for (int j = 2*i; j < n; j+=i) is_prime[j] = false;
    }
  }
  return p;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

  int N,M;
  cin >> N >> M;
  int A[M],B[M];
  REP(i,M) {
    int a,b;
    cin >> a >> b;
    A[i] = --a;
    B[i] = --b;
  }

  UnionFind tree(N);

  REP(i,M) {
    tree.unite(A[i],B[i]);
  }

  int ans = 0;
  vector<int> group_size(N,0);
  REP(i,N) {
    ans = max(ans, ++group_size[tree.root(i)]);
  }

  cout << ans << endl;
}



Measured memory_bytes: 12700
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#include <stack>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N) cin>>A[i];

  vector<int> B;
  for(int i=0;i<N;i++){
    if(B.size()==0) B.push_back(A[i]);
    else if(B.back()!=A[i]) B.push_back(A[i]);
  }

  int M=B.size();
  vector<int> pos;
  for(int i=0;i<M;i++){
    if(i==0||i==M-1) pos.push_back(i);
    else if(B[i-1]<B[i]&&B[i]>B[i+1]) pos.push_back(i);
    else if(B[i-1]>B[i]&&B[i]<B[i+1]) pos.push_back(i);
  }

  ll kab=0;
  ll money=1000;
  for(int i=0;i+1<pos.size();i++){
    if(B[pos[i]]<B[pos[i+1]]){
      ll plus=money/B[pos[i]];
      kab+=plus;
      money-=plus*B[pos[i]];

      money+=kab*B[pos[i+1]];
      kab=0;
    }
  }

  cout<<money<<endl;

  return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
#define int long long
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
	int N; cin>>N;
	vector<int>A(N);
	REP(i,101){
		REP(j,101){
			REP(k,101){
				if(i*i+j*j+k*k+i*j+i*k+j*k<=N)A[i*i+j*j+k*k+i*j+i*k+j*k-1]++;
			}
		}
	}
	rep(i,N){
		cout<<A[i]<<endl;
	}
}

Measured memory_bytes: 3672
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

class Main {
  public static void main(String[] args) throws IOException {
    ArrayList<Integer> array = new ArrayList<Integer>();
    BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
    for(int i = 0; i < 10; i++) {
      int x = Integer.valueOf(buf.readLine());
      array.add(x);
    }
    Collections.sort(array);
    Collections.reverse(array);
    for(int i = 0; i < 3; i++) {
      System.out.println(array.get(i));
    }
  }
}

Measured memory_bytes: 24168
H,W=map(int,input().split(' '))
N=int(input())
a=list(map(int,input().split(' ')))
l = []
ans = []
for n,i in enumerate(a):
    for j in range(i):
        l.append(n+1)
for i in range(H):
    tmp = []
    if i%2==0:
        for j in range(W):
           tmp.append(l[i*W+j])
    else:
        for j in range(W-1,-1,-1):
            tmp.append(l[i*W+j])
    ans.append(tmp)
for i in ans:
    for j in i[:-1]:
        print(j,"",end="")
    print(i[-1])

Measured memory_bytes: 4600
#include <iostream>
#include <vector>
#include <math.h>
//v.erase(unique(v.begin(),v.end()),v.end());

using namespace std;
 
typedef long double ld;
typedef long long ll;
typedef  pair <ll, ll> pii;
 
const ll N = 200500;
const ll mod = 1e9 + 7;
const ld PI = 3.141592654;

vector <int> xd[200500];

int main() {


	int n;
	cin >> n;

	for(int i = 2; i <= n; i++){
		int a;
		cin >> a;

		xd[a].push_back(i);
	}

	for(int i = 1; i <= n; i++){
		cout << xd[i].size() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 14112
A,B,K = map (int, input().split())
l = []
if A+K > B+1:
    for i in range(A,B+1):
        if i < A+K or B - K < i:
            l.append(i)
else :
    for i in range(A,A+K):
        if i < A+K or B - K < i:
            l.append(i)
if A+K-1 >= B - K+1:
    for i in range(A+K,B+1):
        l.append(i)
else :
    for i in range(B-K+1,B+1):
        l.append(i)


for i in l:
    print(i)

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

int main() {
  int K,S,z,count=0;
  cin >> K >> S;
  for(int x=0;x<=K;x++){
  	for(int y=0;y<=K;y++){
      z=S-x-y;
      if(z>=0 && z<=K) count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
K=input()
D=int(input())
#余り0,余り1,余り2,…,余り(D-1)
dp=[0]*D
mod=10**9+7
s=0
for i in range(len(K)):
  ndp=[0]*D
  #余りがjだったものは(j+d)%Dの余りに変わるので
  for j in range(D):
    for d in range(10):
      ndp[(j+d)%D]=(ndp[(j+d)%D]+dp[j])%mod
  #直前までKと数字が同じだったものをカウント
  for d in range(int(K[i])):
    ndp[(s+d)%D]+=1 
  dp=ndp
  s=(s+int(K[i]))%D
#0000…の場合を引き、もしもKが該当するなら1を加える
ans=dp[0]-1
if s%D==0:
  ans+=1
print(ans%mod)

Measured memory_bytes: 43740
#include <iostream>
#include <set>
#include <string>

int main() {
  const uint32_t p10k = 10000, p5k = 5000, p1k = 1000;
  uint32_t N = 0, Y = 0;
  std::cin >> N >> Y;

  if (Y > N * p10k || Y < N * p1k) {
    std::cout << "-1 -1 -1" << std::endl;
    return 0;
  }

  uint32_t d_1kto10k = p10k / p1k - 1;
  uint32_t d_1kto5k = p5k / p1k - 1;
  uint32_t d = Y / p1k - N;

  // d_1kto10k*i + d_1kto5k*j = d (m +n <= N)

  for (size_t i = 0; i < d / d_1kto10k + 1; i++) {
    if ((d - d_1kto10k * i) % d_1kto5k != 0) continue;
    uint32_t j = (d - d_1kto10k * i) / d_1kto5k;
    if (i + j > N) continue;
    std::cout << i << " " << j << " " << N - i - j << std::endl;
    return 0;
  }
  std::cout << "-1 -1 -1" << std::endl;
  return 0;
}

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

int pcnt(int x) {
  return __builtin_popcount(x);
}
int f(int x) {
  if (x == 0) return 0;
  return f(x%pcnt(x))+1;
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> x(n);
  rep(i,n) x[i] = s[i]-'0';
  int pc = 0;
  rep(i,n) pc += x[i];
  vector<int> ans(n);
  rep(b,2) {
    int npc = pc;
    if (b == 0) npc++; else npc--;
    if (npc <= 0) continue;
    int r0 = 0;
    rep(i,n) {
      r0 = (r0*2)%npc;
      r0 += x[i];
    }
    int k = 1;
    for (int i = n-1; i >= 0; --i) {
      if (x[i] == b) {
        int r = r0;
        if (b == 0) r = (r+k)%npc;
        else r = (r-k+npc)%npc;
        ans[i] = f(r)+1;
      }
      k = (k*2)%npc;
    }
  }

  rep(i,n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 5148
#include<stdio.h>
int selectionSort(int *,int);
int main(){
  int a[100];
  int i,j,tmp,minj,n,c=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%d",&a[i]);
  }
  for(i = 0;i < n;i++) {
    minj = i;
    for(j = i;j < n;j++) {
      if(a[j] < a[minj]) {
	minj = j;
      }
    }
    if(i != minj){
      tmp = a[i];
      a[i] = a[minj];
      a[minj] = tmp;
      c++;
    }
  }
  for(i=0;i<n;i++) {
    if(i > 0) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
  printf("%d\n",c);
 
  return 0;
}
 

Measured memory_bytes: 604
package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)
	H := make([][]int, N+1)
	for i := 0; i <= N; i++ {
		H[i] = make([]int, 3)
		if i == 0 {
			continue
		}
		var a, b, c int
		fmt.Scanf("%d %d %d", &a, &b, &c)
		H[i][0] = max(H[i-1][1], H[i-1][2]) + a
		H[i][1] = max(H[i-1][0], H[i-1][2]) + b
		H[i][2] = max(H[i-1][0], H[i-1][1]) + c
	}
	max := 0
	for i := 0; i < 3; i++ {
		if max < H[N][i] {
			max = H[N][i]
		}
	}
	fmt.Println(max)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.exceptions(cin.failbit)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define endl '\n'  
#define show(a) for(auto i:a) cout<<i<<" ";cout<<endl
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< int , int > mypair;
typedef priority_queue <int> max_heap;
typedef priority_queue <mypair, vector<mypair>, greater<mypair> > min_heap;
const int mod=1000000007;
const int inf=1e9+100;
const int N=2e6+10;

int main()
{
	boost;
	int m=1e5;
	int a[10];
	a[1]=3*m;
	a[2]=2*m;
	a[3]=m;
	int x,y;
	cin>>x>>y;
	if(x==1 and y==1) cout<<10*m;
	else 
	{
		int ans=0;
		if(x<=3) ans+=a[x];
		if(y<=3) ans+=a[y];
		cout<<ans;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,x,y;
    double z;
    scanf("%d %d",&a,&b);
    x=a/b;
    y=a%b;
    z=1.0*a/b;
    printf("%d %d %f\n",x,y,z);
    return 0;
}



Measured memory_bytes: 2048
import std.stdio;

int[][int] graph;
bool[int] used;

void dependent(int n) {
  if (!used[n]) {
    foreach(i; graph[n]) {
      dependent(i);
    }
    writeln(n);
    used[n] = true;
  }
}

void main() {
  int m, n;
  scanf("%d\n%d\n", &m, &n);
  foreach(i; 1..(m + 1)) {graph[i] = []; used[i] = false;}
  foreach(i; 0..n) {
    int to, from;
    scanf("%d %d", &from, &to);
    graph[to] ~= from;
  }
  foreach(i; 1..m) dependent(i);
}

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

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

	int count = 0;
	int max = 0;
	for (int i = 0; i < n; i++)
	{
		if (s.at(i) == 'I')
		{
			count++;
		}
		else if (s.at(i) == 'D')
		{
			count--;
		}
		if (max < count)
		{
			max = count;
		}
	}
	cout << max << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

#define PI 3.14159265358979323846264338327950L

// 絶対値を求める
double Abs(const double a) {
    return a > 0 ? a : -a;
}
// 二つの値の最小値を求める関数
double Min(const double a, const double b) {
    if (a <= b) {
        return a;
    } else {
        return b;
    }
}

int main(void) {
    Int a, b, h, m;
    cin >> a >> b >> h >> m;
    Int minutes = 60 * h + m;
    double a_angle = 0.5 * (double)minutes;
    double b_angle = (double)((6 * minutes) % 360);
    double angle = Abs(a_angle - b_angle);
    angle = (double)Min(angle, 360.0f - angle) * PI / 180.0f;
    double c = sqrt((double)(a * a + b * b)  - (double)(2 * a * b) * cosl(angle));
    cout << fixed << setprecision(20) << c << endl;
    return 0;
}



Measured memory_bytes: 4100
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    x, a, b = map(int, input().split())
    if abs(x - a) < abs(x - b):
        print("A")
    else:
        print("B")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>

int main() {
  size_t n;
  scanf("%zu ", &n);

  int const inf = 1e9;
  std::vector<std::vector<int>> d(n+1, std::vector<int>(n+1, inf));

  d[n][n] = 0;
  for (size_t i = 0; i < n; ++i)
    d[i][i] = d[i][i+1] = 0;

  std::map<std::string, size_t> to;
  std::map<std::string, std::vector<size_t>> from;
  for (size_t i = 0; i < n; ++i) {
    char buf[20];
    fgets(buf, sizeof buf, stdin);
    std::string s = buf;
    s.pop_back();
    if (s.back() == ':') {
      s.pop_back();
      to[s] = i;
    } else if (s.back() == ';') {
      s.pop_back();
      s = s.substr(5);
      from[s].push_back(i);
      d[i][i+1] = 1;
    }
  }

  for (auto const& p: from) {
    size_t s1 = to.at(p.first);
    for (auto s0: p.second) {
      d[s0][s1] = 0;
    }
  }

  for (size_t k = 0; k <= n; ++k)
    for (size_t i = 0; i <= n; ++i)
      for (size_t j = 0; j <= n; ++j)
        d[i][j] = std::min(d[i][j], d[i][k]+d[k][j]);

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



Measured memory_bytes: 3008
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<set>
#include<queue>
#define pi pair<int,int>
#define mk make_pair
using namespace std;
int num,n,sum,d[101001];
char ch,S[3][101]={"NO","YES"};
multiset<int> s[100010];
multiset<int>::iterator it,it2;
queue<pi> q;
int read()
{
	while(!isdigit(ch=getchar()));
	for(num=ch-'0';isdigit(ch=getchar());num=(num<<1)+(num<<3)+ch-'0');
	return num;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n*2-1;i++)
	{
		int x=read(),y=read();
		it=s[x].lower_bound(y);
		if(it!=s[x].end()&&*it==y)
			q.push(mk(x,y));
		s[x].insert(y);s[y].insert(x);
	}
	while(!q.empty())
	{
		int x=q.front().first,y=q.front().second;q.pop();
		if(d[x]||d[y])  continue;
		sum++;
		if(s[x].size()>s[y].size()) swap(x,y);
		s[x].erase(y);
		for(it=s[x].begin();it!=s[x].end();it++)
		{
			int k=*it;
			it2=s[y].lower_bound(k);
			if(it2!=s[y].end()&&*it2==k)
				q.push(mk(k,y));
			s[k].insert(y);s[y].insert(k);
		}
		d[x]=1;s[x].clear();
	}
	printf("%s\n",S[(sum==n-1)]);	
	return 0;
}

Measured memory_bytes: 67072
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll w=0,r=0;
    ll a=0,b=0;
    rep(i,n){
        if(s[i]=='W') a++;
        else if(s[i]=='R') b++;
    }
    if(a==n||b==n){
        cout << 0;
        return 0;
    }

    rep(i,n){
        if((i<b) && s[i]=='W') w++;
        else if((i>=b) && s[i]=='R') r++;
    }
    cout << max(r,w) ;



    return 0;
}

Measured memory_bytes: 3760
#include <stdio.h>

int main(void) {
    double w, h, x, y;
    scanf("%lf %lf %lf %lf", &w, &h, &x, &y);

    printf("%f ", w * h / 2);
    printf("%d\n", (x == w / 2 && y == h / 2) ? 1 : 0);
}


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

int main()
{
  int N,M,C;
  int B[20];
  int A[20][20];

  cin >> N >> M >> C;
  for (int i = 0; i < M; i++)
  {
    cin >> B[i];
  }
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < M; j++)
    {
      cin >> A[i][j];
    }
  }
  
  int res=0;
  for (int i = 0; i < N; i++)
  {
    int ApB=0;
    for (int j = 0; j < M; j++)
    {
      ApB+=A[i][j]*B[j];
    }
    if(ApB+C>0){
      res++;
    }
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
N=int(input())
restranlist=[]
for i in range(N):
    l=input().split()
    restranlist.append([str(l[0]),-int(l[1]),i])
    #print(restranlist)
    restranlist_s=sorted(restranlist)
    #print(restranlist_s)
for i in range(N):
    print(restranlist_s[i][2]+1)

Measured memory_bytes: 3060
def main():
    n = int(input())
    a = list(map(int, input().split()))

    target = [0]
    prev = a[0]
    for i in range(1, n):
        if a[i] > prev:
            target.append(i)
            prev = a[i]

    ax = [None] * n
    for i in range(n):
        ax[i] = [a[i], i]
    ax.sort(reverse=True)

    ans = [0] * n
    mult = 1
    for i in range(n-1):
        ans[target[-1]] += (ax[i][0] - ax[i+1][0]) * mult
        if (ax[i+1][0] < a[target[-1]] and ax[i+1][1] < target[-1]):
            target.pop()
        mult += 1
    ans[target[-1]] += ax[n-1][0] * mult

    for x in ans:
        print(x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 25984
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;

bool ok(int n){
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(n%i==0)cnt++;
	}
	if(cnt==8)return 1;
	return 0;
}


void solve(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(ok(i) && i%2==1){
			ans++;
		}
	}
	cout<<ans;

}


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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int a;
  cin >> a;
  int kekka = 0;
  for(int i = 11; a + 1 > i; i += 2){
    
    int yakusuu = 0;
    for(int j = 1; i > j; j++){
      if(i % j == 0){
        yakusuu++;
      } 
    }
    if(yakusuu == 7){
      kekka++;
    }
  }
  cout << kekka << endl;
  return 0;
}

Measured memory_bytes: 256
a = [int(i) for i in input().split()] 
if a[0] == 1:
  a[0] = a[0] + 13

if a[1] == 1:
  a[1] = a[1] + 13

  
if a[0] > a[1]:
  print("Alice")
elif a[0] < a[1]:
  print("Bob")
else:
  print("Draw")

Measured memory_bytes: 3060
N=int(input())
A=list(map(int,input().split()))
pair=0
As={}

for i in range(N):
    a=A[i]
    x1=i+1-a
    x2=i+1+a
    if x1 in As:
        pair+=As[x1]
    if x2 in As:
        As[x2]+=1
    else:
      As[x2]=1
print(pair)

Measured memory_bytes: 40440
sub f{my$r=$u["@_"]=1;$u[$_]||($r+=f($_))for@{$G["@_"]};$r}
<>=~$";($n,$m)=($`,$');
/ /,push@{$G[$`]},$'+!push@{$G[$']},$`for<>;
$a=f 1;$b=f 2;$a>$b&&($a=$b);print$n*($n-1)/2-$a*($n-$a)-$m

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

int main() {
    int n;
    cin >> n;
    int x = 0, y = 0, z = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        int cnt = 0;
        while(a % 2 == 0) {
            a /= 2;
            cnt++;
        }
        
        if (cnt >= 2) x++;
        else if (cnt == 1) y++;
        else z++;
    }
    
    if (x >= z || (x + 1 == z && y == 0)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;
using LL = long long;

constexpr int N = 15;

vector< int> x[N], y[N];
int A[N];

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

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> A[i];
        for (int j = 0; j < A[i]; j++) {
            int a, b;
            cin >> a >> b;
            a--;
            x[i].push_back(a);
            y[i].push_back(b);
        }
    }

    int result = 0;
    for (int mask = 1; mask < (1 << n); mask++) {
        int task = (1 << n) - 1;
        bool ok = true;

        for (int i = 0; i < n; i++) {
            if (mask >> i & 1) {
                for (int j = 0; j < A[i]; j++) {
                    if (y[i][j] == 0) {
                        if (task >> x[i][j] & 1) {
                            task ^= 1 << x[i][j];
                        }
                    }
                    else {
                        if (!(mask >> x[i][j] & 1)) {
                            ok = false;
                        }
                    }
                }
            }
        }
        if (ok && (mask & task) == mask) result = max(result, __builtin_popcount(mask));
    }

    cout << result << endl;
}

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

int main(){
	long long unsigned int a, b, gcd, lcm;

	while(scanf("%llu %llu", &a, &b)+1){
		long long unsigned int m, n, o;
		m = a;
		n = b;
		while(1){
			if(!(o = m % n)){
				gcd = n;
				break;
			}
			m = n;
			n = o;
		}
		lcm = a * b / gcd;
		printf("%llu %llu\n", gcd, lcm);
	}
	return 0;
} 

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char[] s = S.toCharArray();
    int len = S.length();
    int[] ans = new int[len];
    for(int i = 0;i < len - 1;i++){
      if(s[i] == 'R' && s[i+1] =='L'){
        int rp = 0;
        int lp = 0;
        if(i >= 1){
          for(int x = i - 1;x >= 0;x--){
            if(s[x] == 'R'){
              rp++;
            }else{
              break;
            }
          }
        }
        ans[i] += rp / 2;
        ans[i+1] += rp - (rp / 2);
        if(i + 2 < len){
          for(int y = i + 2;y < len;y++){
            if(s[y] == 'L'){
              lp++;
            }else{
              break;
            }
          } 
        }
        ans[i] += lp - (lp / 2);
        ans[i+1] += lp / 2;
        ans[i]++;
        ans[i+1]++;
      }
    }
    for(int z = 0;z < len;z++){
      System.out.print(ans[z] + " " );
    }
  }
}

Measured memory_bytes: 44292
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  std::cout << "ABC"+to_string(n) << '\n';
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayDeque<Integer> ans = new ArrayDeque<Integer>();

		while(sc.hasNext()){
			int n = sc.nextInt();
			int count=0;
			for(int i=0;i<(600/n);i++){
				count+=i*i*n*n*n;
			}
			ans.push(count);
		}
		int num = ans.size();
		for(int i=0;i<num;i++){
			System.out.println(ans.pollLast());
		}
	}
}

Measured memory_bytes: 17332
#include<stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1
#define tr 1
#define fa 0

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

int X[N][N];

void initialize();
void printBoard();
void recursive(int);

int main() {

  int i,j,k,r,c;

  initialize();

  for(i=0;i<N;i++) {
    for(j=0;j<N;j++) X[i][j] = fa;
  }

  scanf("%d",&k);

  for(i=0;i<k;i++) {
    scanf("%d %d",&r,&c);
    X[r][c] = tr;
  }

  recursive(0);

  return 0;

}

void initialize() {

  int i;

  for(i=0;i<N;i++) {
    row[i] = FREE;
    col[i] = FREE;
  }

  for(i=0;i<2*N-1;i++) {
    dpos[i] = FREE;
    dneg[i] = FREE;
  }

}

void printBoard() {

  int i,j;

  for(i=0;i<N;i++) {
    for(j=0;j<N;j++) {
      if(X[i][j] == tr) {
	if(row[i] != j) return;
      }
    }
  }

  for(i=0;i<N;i++) {
    for(j=0;j<N;j++) {
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }

}

void recursive(int i) {

  int j;

  if(i == N) {
    printBoard();
    return;
  }

  for(j=0;j<N;j++) {
    
    if( col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE) continue;

    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;

    recursive(i+1);

    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;

  }
}



Measured memory_bytes: 2036
#include<stdio.h>
int main()
{
int n,m,i;
  scanf("%d %d",&n,&m);
  int a[m],b[m],sw1[n+1],sw2[n+1],cc;
  
  for(i=0;i<n+1;++i)
  {
  sw1[i]=0;
  sw2[i]=0;
  }
  
  cc=0;
  
  for(i=0;i<m;++i)
  {
  scanf("%d %d",&a[i],&b[i]);
  if(a[i]==1) sw1[b[i]]++;
  if(b[i]==n) sw2[a[i]]++;
  }

  for(i=1;i<n+1;++i)
  {
  if(sw1[i]>0 && sw2[i]>0) cc++;
  }
  if(cc >0) printf("POSSIBLE");
  else printf("IMPOSSIBLE");

return 0;}

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

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

  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());

  long long ans = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      int k = lower_bound(A.begin(), A.end(), A.at(i) + A.at(j)) - A.begin();
      ans += max(k - (j + 1), 0);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
 
#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());
 
using namespace::std;
 
int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}
 
 
int main(){
  int N;
  cin>>N;
  vector<string> a(N);
  rep(i,0,N) cin>>a[i];
  int check=0;
  
  rep(i,0,N){
    if(i==0){
      if(a[0][a[0].length()-1]!=a[1][0]){
        check++;
      }
    }else if(i==N-1){
      if(a[i][0]!=a[i-1][a[i-1].length()-1]){
        check++;
      }
    }else{
      if(a[i][0]!=a[i-1][a[i-1].length()-1]){
        check++;
      }
      if(a[i][a[i].length()-1]!=a[i+1][0]){
        check++;
      }
    }
    if(check) break;
    rep(j,0,N){
      if(i!=j){
        if(a[i]==a[j]){
          check++;
        }
      }
    }
    if(check) break;
  }
 
  cout<<(!check?"Yes":"No");
    
    
}

Measured memory_bytes: 256
N,M=map(int,input().split())
H = list(map(int,input().split()))
A,B=[],[]
good = N
for m in range(M):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
roots = [[] for i in range(N)]
for m in range(M):
    roots[A[m]-1].append(B[m]-1)
    roots[B[m]-1].append(A[m]-1)

for n in range(N):
    L = len(roots[n])
    for l in range(L):
        if H[n] <= H[roots[n][l]]:
            good -=1
            break
    else:
        continue
print(good)

Measured memory_bytes: 37780
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int c =0 , N,a;

    vector <int> A;

    cin>> N;

    while (N){
        cin >> a;
        A.push_back(a);
        N--;
    } for(int i = 0; i< A.size(); i +=2)
        if (A[i] % 2 !=0)
            c++;
        cout<<c ;


    return 0;

}


Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split("");
		int result = 0;

		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (str[i] == str[j])
					continue;
				if (str[i].equals(str[j])) {
					result++;
				}
			}
		}
		if (result == 4) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23380
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

val=get_i
k=gets.to_i
max=val.max
i=val.index(max)
val[i]*=2**k
puts val.inject(:+)

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

int main()
{
    vector<int> numbers;
    int n;
    while(cin >> n)
    {
        numbers.push_back(n);
    }
    sort(numbers.rbegin(), numbers.rend());
    cout << numbers[0];
    for(int i=1; i<numbers.size(); i++)
    {        
        cout << " " << numbers[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3084
using System;

namespace _1_5_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] str = Console.ReadLine().Split(' ');
                int a = int.Parse(str[0]);
                int b = int.Parse(str[1]);
                if (a == 0 || b == 0) break;
                for(int i0 = 0; i0 < b; i0 += 1)
                {
                    Console.Write("#");
                }
                Console.Write("\n");
                if (a == 1) break;
                int count = 0;
                for(int i1 = 0; i1 < a - 2; i1 += 1)
                {
                    if (count == 0) Console.Write("#");
                    for (int i2 = 0; i2 < b - 2; i2 += 1)
                    {
                        Console.Write(".");
                    }
                    Console.WriteLine("#");
                }
                for (int i3 = 0; i3 < b; i3 += 1)
                {
                    Console.Write("#");
                }
                Console.WriteLine("\n");
            }
        }
    }
}

Measured memory_bytes: 8968
#!/usr/bin/env python3

"""Computes all pairs shortest paths in a graph using the Warshall-Floyd algorithm.

Verification: [GRL_1_C]()
"""


import itertools


# the value which represents "infinity."
INF = 10 ** 10


def in_place_warshall_floyd(adj_matrix):
    """Solves the all-pairs shortest path problem using the Warshall-Floyd algorithm.

    The adjacency matrix A of the graph. This object must be
    able to be treated as a $n \times n$ matrix. $A_{i, j}$ represents the
    cost of the edge $i \rightarrow j$. If $A_{i, j}$ is `INF`` or more,
    there is no edge between the two vertices. For all $x$, $A_{x, x} = 0$.
    Note that this matrix will be modified in place during calculation.
    
    Returns: whether the graph has a negative cycle.
    """

    n = len(adj_matrix)
    for k, i, j in itertools.product(range(n), repeat=3):
        if adj_matrix[i][k] == INF or adj_matrix[k][j] == INF:
            continue
        adj_matrix[i][j] = min(adj_matrix[i][j],
                               adj_matrix[i][k] + adj_matrix[k][j])
    return any(adj_matrix[i][i] < 0 for i in range(n))


def dist_to_str(d):
    if d < INF:
        return str(d)
    else:
        return "INF"


def main():
    v, e = (int(z) for z in input().split())
    adj_matrix = [[INF for _ in range(v)] for _ in range(v)]
    for i in range(v):
        adj_matrix[i][i] = 0
    for _ in range(e):
        s, t, d = (int(z) for z in input().split())
        adj_matrix[s][t] = d
    has_nc = in_place_warshall_floyd(adj_matrix)
    if has_nc:
        print("NEGATIVE CYCLE")
    else:
        for line in adj_matrix:
            print(*(dist_to_str(d) for d in line))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6468
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
using namespace std;

#define rep(i,n) for(int i = 0;i < n; i++)

typedef long long ll;

int main(){
    int N,Q;
    ll K;
    int A[100010];
    cin >> N >> K >> Q;
    rep(i,Q) cin >> A[i];
    int pt[100010];
    rep(i,100010) pt[i] = 0;
    rep(i,Q){
        pt[A[i]-1]++;
    }
    rep(i,N){
        if(K-Q+pt[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

int inf = std::numeric_limits<int>().max();

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define ll long long
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

int main() {
	int x, y, k;
	cin >> x >> y;
	if (x > y) swap(x,y);
	if ((x+y) % 2 == 0) k = (x+y) / 2;
	else k = -1;
	if (k == -1) cout << "IMPOSSIBLE" << endl;
	else cout << k << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;


int main() {
    int A, B;
    cin >> A >> B;

    if (A > 8 || B>8) {
        cout << ":(" << endl;
    }
    else {
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    int dis = B - A + 1;
    if (dis % 2)
        cout << "Alice" << endl;
    else
        cout << "Borys" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define tc(t)  int t; cin>>t; while(t--)
#define f(n)    for(int i=0;i<n;i++)
#define endl   "\n"







int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int  a,b;
    cin>>a>>b;
    vector<int>dp(3,0);
    dp[a-1]=1;
    dp[b-1]=1;
    for(int i=0;i<3;i++)
    {
        if(dp[i]==0)
        {
            cout<<i+1<<endl;
            break;
        }
    }







}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    ll k,n,ans=0,osum=0, tmp=0;
    cin>>n>>k;
    vector<pll> v(n);   //oishisa, neta
    priority_queue<pll> pqall;
    priority_queue<pll, vector<pll>, greater<pll>> pqkaburi;
    unordered_set<ll> us;
    for(int i = 0; i < n; i++)
    {
        ll t,d;
        cin>>t>>d;
        v[i]=make_pair(d,t);
        pqall.push(v[i]);
    }
    for(int i = 0; i < k; i++)
    {
        pll top = pqall.top();
        pqall.pop();
        if(us.find(top.second)==us.end())
        {
            us.insert(top.second);
            osum+=top.first;
        }
        else
        {
            pqkaburi.push(top);
            osum+=top.first;
        }
    }
    tmp=osum+us.size()*us.size();
    ans=max(ans,tmp);
    while(us.size()<k && pqall.size()>0){
        pll top = pqall.top();
        pqall.pop();
        if(us.find(top.second)==us.end())
        {
            us.insert(top.second);
            osum+=top.first;
            pll del = pqkaburi.top();
            pqkaburi.pop();
            osum-=del.first;
            tmp=osum+us.size()*us.size();
            ans=max(ans,tmp);
        }
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7792
/**
 *   author: sahushivam
 *   created: 12 April 2020 (Sunday)  17:28:40
**/
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int long long

void solve(){
    string s;
    cin>>s;
    for(int i:s)
    {
        if(i=='7')
        {
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int t=1; while(t--) solve();
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int N;
	char S[110];
	scanf("%d%s", &N, &S);
	int i = 0, count = 0, max = 0;
	while (S[i] != '\0') {
		if (S[i] == 'I') count++;
		else if (S[i] == 'D') count--;
		if (count > max) {
			max = count;
		}
		i++;
	}
	printf("%d", max);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int[] t = new int[N+1];
		int[] x = new int[N+1];
		int[] y = new int[N+1];

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

		int p = 0;
		int pt = 0;
		for(int i = 1;i < N+1;i++){
			t[i] = scanner.nextInt();
			x[i] = scanner.nextInt();
			y[i] = scanner.nextInt();

		}

		for(int i = 1;i < N+1;i++){
			int distance = 0;
			int nextp = x[i]+y[i];				
			distance =  t[i] - pt -Math.abs(nextp - p)  ;			////次の地点までの距離
			if(distance < 0){
				System.out.println("No");
				return;
			}
			if(distance != 0){
				int judge = distance%2;
				if(judge == 1){
					System.out.println("No");
					return;
				}
			}
			p = nextp;
			pt = t[i];
		}

		System.out.println("Yes");





	}
}




class Graph{
	int from;
	int to;
	int cost;

	public Graph() {
	}

	public Graph(int f,int t,int c) {
		from = f;
		to= t;
		cost = c;
	}
}


Measured memory_bytes: 93868
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

int main() {
    ll H, W;
    cin >> H >> W;
    ll sh, sw, gh, gw;
    cin >> sh >> sw;
    cin >> gh >> gw;
    sh--;
    sw--;
    gh--;
    gw--;

    // 道の一覧
    vector<vector<bool>> roads(H, vector<bool>(W, false));
    for (ll h = 0; h < H; h++) {
        for (ll w = 0; w < W; w++) {
            char c;
            cin >> c;
            while (c != '.' && c != '#') {
                cin >> c;
            }
            if (c == '.') {
                roads[h][w] = true;
            }
        }
    }

    vector<vector<bool>> done(H, vector<bool>(W, false));
    vector<stack<pair<ll, ll>>> diststack(3);
    ll d = 0;
    diststack[0].push(make_pair(sh, sw));
    while (true) {
        if (diststack[d].empty()) {
            if (diststack[d + 1].empty()) {
                break;
            }
            if (diststack.size() < (d + 1) * 2) {
                diststack.resize((d + 1) * 2);
            }
            d++;
            continue;
        }
        auto src = diststack[d].top();
        diststack[d].pop();
        ll h = src.first;
        ll w = src.second;
        if (h == gh && w == gw) {
            cout << d << endl;
            return 0;
        }
        if (done[h][w]) {
            continue;
        }
        done[h][w] = true;
        for (ll y = h - 2; y <= h + 2; y++) {
            for (ll x = w - 2; x <= w + 2; x++) {
                if (y >= 0 && y < H && x >= 0 && x < W && roads[y][x] && !done[y][x]) {
                    if (abs(x - w) + abs(y - h) == 1) {
                        diststack[d].push(make_pair(y, x));
                    } else {
                        diststack[d + 1].push(make_pair(y, x));
                    }
                }
            }
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 267660