akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    if s.len() == 2 {
        println!("{}{}", s[0], s[1]);
    } else {
        println!("{}{}{}", s[2], s[1], s[0]);
    }
}


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

int main()
{   
    int n;
    string s;

    while( cin >> n )
    {
        if( n == -1 )
            break;
        else if( n == 0 )
            cout << 0 << endl;
        else
        {
            s = "";
            while( n != 0 )
            {
                s += n % 4 + '0';
                n /= 4;
            }
            for( int i = s.size() - 1; i >= 0; i-- )
                cout << s[i];
            
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    int e=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==0) e++;
    }
    cout<<pow(3,n)-pow(2,e)<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[12123];
int main()
{
    ll i,ans=0,ans2,b,v,w,t,flag=0,n,k;
    scanf("%lld %lld",&n,&k);
    for(i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(i=1;i<=k;i++)
    {
        ans+=a[i];
    }

        printf("%lld\n",ans);


}


Measured memory_bytes: 3828
#include <vector>
#include <functional>
using namespace std;

typedef long long ll;
ll const inf = (1LL<<31) - 1;

/*
  Segment Tree
  区間に対する処理を O(log(n)) で行う
  下の例は RMQ

  コンストラクタ : binary_heap( 要素数 )
*/

#define L_CHILD(n)  (((n)<<1)+1)
#define R_CHILD(n)  (((n)<<1)+2)
#define PARERNT(n)  (((n)-1)>>1)
template<typename T>
struct segment_tree {
    vector<T> dat;
    int n;
    segment_tree(int size) {
        n = 1;
        while (n < size) n <<= 1;
        dat.assign(n << 1, inf);
    }

    const T& operator[](int i) const { return dat[i + n - 1]; }
    T& operator[](int i) { return dat[i + n - 1]; }

    void update(int k, const T& a){
        k += n - 1;
        dat[k] = a;
        while (k) {
            k = PARERNT(k);
            dat[k] = min(dat[L_CHILD(k)], dat[R_CHILD(k)]);
        }
    }

    const T query(int a, int b, int k = 0, int l = 0, int r = -1) const {
        if (r == -1) r = n;
        if (a <= l && r <= b){
            // [l, r) ⊂ [a, b)
            return dat[k];
        } else if (r <= a || b <= l){
            // [l, r) ∩ [a, b) = ?
            return inf;
        } else {
            // [l, r) ∩ [a, b) ≠ ?
            int center = (l + r) / 2;
            int vl = query(a, b, L_CHILD(k), l, center);
            int vr = query(a, b, R_CHILD(k), center, r);
            return min(vl, vr);
        }
    }
};

#include <cstdio>
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
int main(){
    int n,q;
    scanf("%d%d",&n,&q);
    segment_tree<ll> t(n);
    rep(i,q){
        int c,x,y;
        scanf("%d%d%d",&c,&x,&y);
        if(c==0){
            t.update(x,y);
        }else{
            printf("%lld\n",t.query(x,y+1));
        }
    }
}

Measured memory_bytes: 2844
n, k = list(map(int, input().split()))
min_list = []
max_list = []
for i in range(k):
    j, l = list(map(int, input().split()))
    min_list.append(j)
    max_list.append(l)


print(max(0, min(max_list) - max(min_list) + 1))

Measured memory_bytes: 11076
#define TEST_MODE true
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;		\
                               c > 0 ? i < b : i > b;	\
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long
 
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << " "
#define dumpl(x) cerr << #x << " = " << (x) << " " << endl;
#else
const bool test = false;
#define dump(x) 
#define dumpl(x) 
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep))
    {
      v.push_back(buffer);
    }
  return v;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
  return accumulate(begin, end, 0ll);
}
 
template<typename T>
T gcd(T a, T b)
{
  T c;
  while (a != 0) {
    c = a; a = b%a;  b = c;
  }
  return b;
}
 
class Solver {
public:
  int N, A;

  void solve() {
    cin >> N >> A;
    cout <<  ((N % 500 <= A) ? "Yes" : "No") << endl;
  }
};
 
signed main()
{
  srand(time(NULL));
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  // while (true) {    
  //     auto ptr = new Solver();
  //     ptr->solve();
  //     delete ptr;
  // }
  return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
l.append(0)
ans = 0
for i in range(max(l)):
    for j in range(n):
        if l[j] != 0:
            l[j] -= 1
            if l[j + 1] == 0:
                ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
	int N; cin >> N;
	for (int i = 1; i <= 9; i++) {
		if (N % i == 0 && N / i >= 1 && N / i <= 9) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
}

//auto it2 = upper_bound(ALL(L), A);

Measured memory_bytes: 256
S = input()

if S == 'SUN':
  print(7)
elif S == 'MON':
  print(6)
elif S == 'TUE':
  print(5)
elif S == 'WED':
  print(4)
elif S == 'THU':
  print(3)
elif S == 'FRI':
  print(2)
elif S == 'SAT':
  print(1)


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

using namespace std;

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

    vector<int> relPos(str.size());
    vector<int> result(str.size());

    int rightPos = 0;
    int leftPos = 0;

    for (int i = 0; i < str.size(); i++)
    {
        if (str[i] == 'R')
        {
            rightPos = i;
        }
        if (str[i] == 'L')
        {
            relPos[i] = rightPos - i;
        }
    }

    for (int i = str.size() - 1; i >= 0; i--)
    {
        if (str[i] == 'L')
        {
            leftPos = i;
        }
        if (str[i] == 'R')
        {
            relPos[i] = leftPos - i;
        }
    }

    for (int i = 0; i < str.size(); i++)
    {
        int temp;
        if (relPos[i] % 2 == 0)
        {
            temp = i + relPos[i];
        }
        else if (str[i] == 'R')
        {
            temp = i + relPos[i] - 1;
        }
        else
        {
            temp = i + relPos[i] + 1;
        }
        result[temp]++;
    }

    for (int i = 0; i < result.size(); i++)
    {
        cout << result[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1408
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
x = int(input())
if x == 1:
    print(0)
else:
    print(1)
            








Measured memory_bytes: 10568
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let q: usize = iterator.next().unwrap().parse().unwrap();

    let mut ds = DisjointSet::new(n);

    let mut result = String::new();
    for _ in 0..q {
        let command: usize = iterator.next().unwrap().parse().unwrap();
        let x: usize = iterator.next().unwrap().parse().unwrap();
        let y: usize = iterator.next().unwrap().parse().unwrap();
        if command == 0 {
            ds.unite(x, y);
        } else {
            if ds.same(x, y) {
                result.push_str(&format!("{}\n", 1));
            } else {
                result.push_str(&format!("{}\n", 0));
            }
        }
    }
    return result.trim().to_string();
}

struct DisjointSet {
    rank: Vec<usize>,
    p: Vec<usize>,
}

impl DisjointSet {
    fn new(size: usize) -> DisjointSet {
        let mut ds = DisjointSet {
            rank: vec![0; size],
            p: vec![0; size],
        };
        for i in 0..size {
            ds.make_set(i);
        }
        return ds;
    }

    fn make_set(&mut self, x: usize) {
        self.p[x] = x;
        self.rank[x] = 0;
    }

    fn same(&mut self, x: usize, y: usize) -> bool {
        return self.find_set(x) == self.find_set(y)
    }

    fn unite(&mut self, x: usize, y: usize) {
        let a = self.find_set(x);
        let b = self.find_set(y);
        self.link(a, b);
    }

    fn link(&mut self, x: usize, y: usize) {
        if self.rank[x] > self.rank[y] {
            self.p[y] = x;
        } else {
            self.p[x] = y;
            if self.rank[x] == self.rank[y] {
                self.rank[y] += 1;
            }
        }
    }

    fn find_set(&mut self, x: usize) -> usize {
        let parent = self.p[x];
        if x != parent {
            let root = self.find_set(parent);
            self.p[x] = root;
        }
        return self.p[x];
    }
}



Measured memory_bytes: 7076
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <string>
#include <functional>
#include <math.h>
#include <utility>
using namespace std;
typedef pair<int,int> P;
int n,rnk[101];
P p[100];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		p[i].first=0;
		p[i].second=i+1;
	}
	for(int i=0;i<n*(n-1)/2;i++){
		int a,b,c,d;cin>>a>>b>>c>>d;a--;b--;
		if(c!=d){
			p[c>d?a:b].first+=3;
		}else{
			p[a].first+=1;
			p[b].first+=1;
		}
	}
	sort(p,p+n,greater<P>());
	for(int i=1;i<=n;i++){
		int r=i;
		if(i!=1&&p[i-1].first==p[i-2].first)r=rnk[p[i-2].second];
		rnk[p[i-1].second]=r;
	}
	for(int i=1;i<=n;i++){
		cout<<rnk[i]<<endl;
	}
}

Measured memory_bytes: 1164
#include<stdio.h>
#define SIZE 100
int main()
{
  int n,m;
  int i,j;
  int s[2][SIZE];
  int ans[2];
  int sum[3];
  while(1)
    {
      scanf("%d %d",&n,&m);
      if((n==0)&&(m==0)) break;
      sum[0]=0;
      for(i=0;i<n;i++)
	{
	  scanf("%d",&s[0][i]);
	  sum[0]+=s[0][i];
	}
      sum[1]=0;
      for(i=0;i<m;i++)
	{
	  scanf("%d",&s[1][i]);
	  sum[1]+=s[1][i];
	}
      ans[0]=ans[1]=-1;
      sum[2]=201;
      for(i=0;i<n;i++)
	{
	  for(j=0;j<m;j++)
	    {
	      if((sum[0]-s[0][i]+s[1][j]==sum[1]-s[1][j]+s[0][i])&&(s[0][i]+s[1][j]<sum[2]))
		{
		  ans[0]=i;
		  ans[1]=j;
		  sum[2]=s[0][i]+s[1][j];
		}
	    }
	}
      if(ans[0]!=-1) printf("%d %d\n",s[0][ans[0]],s[1][ans[1]]);
      else printf("-1\n");
    }
  return 0;
}

Measured memory_bytes: 612
#include <iostream>

using namespace std;

struct Point {
    double x, y;
};

int main() {
    while (1) {
        Point src[4];
        for (int i = 0; i < 4; i++) {
            if (!(cin >> src[i].x >> src[i].y)) {
                return 0;
            }
        }
        if (src[1].x < src[2].x || src[3].x < src[0].x || src[1].y < src[2].y || src[3].y < src[0].y) {
            cout << "NO" << endl;
        }
        else {
            cout << "YES" << endl;
        }
    }

    return 0;
}

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

string Transition(string Word){
	for(int i = 0; i < Word.size(); i++){
		if('a' <= Word[i] && Word[i] <= 'z') Word[i] += 'A' - 'a';
	}
	return Word;
}

vector<string> ReadWords(){
//	?????????????????????????????????END_OF_TEXT??§???????????°??§???????????´?????????????????????????????????
	vector<string> Sentence;
	while(1){
		string Go;
		cin >> Go;
		if(Go == "END_OF_TEXT") break;
		for(int i = 0; i < Go.size(); i++){
			if('a' <= Go[i] && Go[i] <= 'z') Go[i] += 'A' - 'a';
		}
		Sentence.push_back(Go);
	}
	return Sentence;
}

int Count(string Word, vector<string> Sentence){
//	?????????????????????????????????????????????????????°?????????
	int C = 0;
	for(int i = 0; i < Sentence.size(); i++){
		if(Sentence[i] == Word) C++;
	}
	return C;
}

int main(){
//	??????????????????????????§???????????´??????
	string Word;
	cin >> Word;
	Word = Transition(Word);
//	????????????????????????	
	vector<string> Sentence = ReadWords();
//	?????????????????????????????????????????°??????????????????
	int X = Count(Word, Sentence);
	cout << X << endl;
	
//	system("pause");
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  1000000007;

     signed main(){
         int n;
         cin>>n;
         int x[n];
         for(int i=0;i<n;i++)cin>>x[i];
         int r[20][n];
         int l;cin>>l;
         int m=0;
         for(int i=0;i<n;i++){
              while(m<n&&x[m]-x[i]<=l)m++;
              r[0][i]=m-1;
         }
         for(int i=1;i<20;i++)for(int j=0;j<n;j++)r[i][j]=r[i-1][r[i-1][j]];
         int q,a,b,ans;cin>>q;
          for(int i=0;i<q;i++){
               cin>>a>>b;a--;b--;
               if(a>b)swap(a,b);
               ans=0;
               while(true){
                    int j=0;
                    while(b>r[j][a])j++;
                    if(j==0){
                         ans+=(1<<j);
                         break;
                    }
                    ans+=(1<<(j-1));
                    a=r[j-1][a];
               }
               cout<<ans<<endl;
          }

      }

        


Measured memory_bytes: 17280
x1, y1, x2, y2 = [int(i) for i in input().split()]

dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy

print(x3,y3,x4,y4)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n;
    scanf("%d", &n);
    tuple<string, int, int> t[n];
    rep(i, n){
        string s;
        int p;
        cin >> s >> p;
        t[i] = make_tuple(s, -p, i+1);
    }
    sort(t, t+n);
    for(auto i: t) printf("%d\n", get<2>(i));
}

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

fn main() {
    input! {
        n: u64
    }

    let mut sn = 0;
    let mut nm = n;
    while nm > 0 {
        sn += nm % 10;
        nm /= 10;
    }
    println!("{}", if n % sn == 0 {"Yes"} else {"No"});
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <stack>
using namespace std;


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

    bool flag = true;

    for (int i = 0; i < S.length(); ++i) {
        if (i % 2 == 0 && S[i] == 'L') flag = false;
        else if (i % 2 != 0 && S[i] == 'R') flag = false;
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
s = input()

a1 = [0] * (len(s) + 1)
for i in range(len(s)):
    if s[i] == '<':
        a1[i + 1] = a1[i] + 1
a2 = [0] * (len(s) + 1)
for i in reversed(range(len(s))):
    if s[i] == '>':
        a2[i] = a2[i + 1] + 1

ans = 0
for i in range(len(a1)):
    ans += max(a1[i], a2[i])
print(ans)


Measured memory_bytes: 27300
#include <queue>
#include <string>
#include <iostream>
using namespace std;
int main () {
  priority_queue<int> Q;
  string a; //??????
  while (cin >> a && a != "end") {
    int b; //?????\????????°
    if (a == "insert") {
      cin >> b;
      Q.push(b);
    }
    else {
      cout << Q.top() << endl;
      Q.pop();
    }
  }
}
      

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, M; cin >> N >> M;
  vector<ll> num(N, 1LL), poss(N, 0LL);
  poss[0] = 1;
  for (ll i = 0; i < M; i++) {
    ll x, y; cin >> x >> y; x--; y--;
    if (poss[x]) poss[y] = 1;
    num[x]--;
    if (num[x] == 0) poss[x] = 0;
    num[y]++;
  }
  ll sum = 0;
  for (ll i = 0; i < N; i++) if (poss[i]) sum++;
  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 4740
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre1(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
double pre[200005];
signed main()
{   


      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         
         ll n,k;
         cin>>n>>k;
        //  double ans =0;
         ll a[n];
         for(int i=0;i<n;i++)
         {
             cin>>a[i];
         }
         ll sum = (a[0]*(a[0]+1))/2;
         double p1 = (double)(sum*1.0)/(a[0]*1.0);
         pre[0]=p1;
         for(int i=1;i<n;i++)
         {
          sum = (a[i]*(a[i]+1))/2;
          p1 = (double)(sum*1.0)/(a[i]*1.0);
         pre[i]=pre[i-1]+p1;
         }
         double mx = 0.0;
         double ans = pre[k-1];
         mx = ans;
         for(int i=k;i<n;i++)
         {
               ans = 0.0;
               ans = pre[i]-pre[i-k];
              mx = max(mx,ans);
         }
         cout<<setprecision(10)<<fixed<<mx<<endl;

      }
      






}



























Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
 
int main() {
    int N,M;
    cin >> N >> M;
    vector<int> p(M);
    vector<string> S(M);
    for(int i = 0; i < M; i++){
        cin >> p[i] >> S[i];
    }
    vector<int> WA(N),AC(N);
    /*for(int i = 0; i < N; i++){
        WA[i] = 0;
        AC[i] = 0;
    }*/
    for(int i = 0; i < M; i++){
        if(S[i] == "WA" && AC[p[i] - 1] == 0){
            WA[p[i] - 1] += 1;
        }
        if(S[i] == "AC"){
            AC[p[i] - 1] = 1;
        }
    }
    for(int i = 0; i < N; i++){
        if(AC[i] == 0){
            WA[i] = 0;
        }
    }
    /*for(int i = 0; i < N; i++){
        cout << AC[i] << " " << WA[i] << endl;
    }*/
    int countWA = 0;
    int countAC = 0;
    for(int i = 0; i < N; i++){
        countWA += WA[i];
        countAC += AC[i];
    }
    cout << countAC << " " << countWA << endl;
    /*vector<pair<int,string>> A(M);
    for(int i = 0; i < M; i++){
        A[i] = make_pair(p[i],S[i]);
    }
    sort(A.begin(),A.end());
    for(int i = 0; i < M; i++){
        cout << A[i].first << A[i].second << endl;
    }*/
}

Measured memory_bytes: 6912
n,k=map(int,input().split())
if k==0:
    print(n**2)
    exit(0)
ans=0
for i in range(k+1,n+1):
    q,r=divmod(n,i)
    ans+=q*(i-k)
    if r>=k:
        ans+=max(r-k+1,0)
print(ans)



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

using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

class mint{
    ll n;
public:
    mint(ll m = 0){
        n = ((m % MOD) + MOD) % MOD;
    }
    mint operator-() const {
        return mint(-n);
    }
    mint& operator+=(const mint& m){
        n += m.n;
        if(n >= MOD) n -= MOD;
        return *this;
    }
    mint& operator-=(const mint& m){
        n += MOD - m.n;
        if(n >= MOD) n -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& m){
        n *= m.n;
        n %= MOD;
        return *this;
    }
    mint operator+(const mint& m) const{
        mint res(*this);
        res += m;
        return res;
    }
    mint operator-(const mint& m) const{
        mint res(*this);
        res -= m;
        return res;
    }
    mint operator*(const mint& m) const{
        mint res(*this);
        res *= m;
        return res;
    }
    mint pow(ll t) const{
        if(t == 0) return mint(1);
        mint m = pow(t>>1);
        m *= m;
        if(t & 1 == 1) m *= *this;
        return m;
    }
    // for prime modulo
    mint inv() const{
        return pow(MOD-2);
    }
    mint& operator/=(const mint& m){
        (*this) *= m.inv();
        n %= MOD;
        return *this;
    }
    mint operator/(const mint& m) const{
        mint res(*this);
        res /= m;
        return res;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.n;
        return os;
    }
};

ll N;
ll c[3];
ll A[100000];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<3;i++) c[i] = 0;
    mint ans(1);
    for(int i=0;i<N;i++){
        int count = 0;
        int index = 0;
        for(int j=0;j<3;j++){
            if(c[j] == A[i]){
                count++;
                index = j;
            }
        }
        ans *= mint(count);
        c[index]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int min(int x, int y)
{
  return (x < y ? x : y);
}

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

  int potential_sum = b[0] + b[n-2];

  for(int i = 1; i < n - 1; i++) {
    potential_sum += min(b[i-1], b[i]);
  }

  printf("%d\n", potential_sum);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
    long long int k, a, b;
    
    cin >> k >> a >> b;
    
    if(a >= b){
        cout << 1 + k << endl;
        return 0;
    }else{
        if(b-a > 2){
            if(k-(a-1) >= 1){
                cout << a + (k-(a-1))/2*(b-a) + (k-(a-1))%2 << endl;
                return 0;
            }else{
                cout << 1 + k << endl;
                return 0;
            }
        }else{
            cout << 1 + k << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))

for i in range(1, n+1): a[i] += a[i-1]
for i in range(1, m+1): b[i] += b[i - 1]

ans, b_cnt = 0, m
for a_cnt in range(n+1):
    if a[a_cnt] > k: break
    while a[a_cnt] + b[b_cnt] > k: b_cnt -= 1
    ans = max(ans, a_cnt + b_cnt)

print(ans)


Measured memory_bytes: 119384
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

vector<pair<int,int>> diff{{-1,0},{1,0},{0,-1},{0,1}};
bool is_valid(int x,int y, int n,int m){
    return x>=0 && y>=0 && x<n && y<m;
}

struct node{
    int x,y,sc_first,sc_second;
};

node get_node(int xx,int yy, int ff, int ss){
    node ans;
    ans.x=xx;
    ans.y=yy;
    ans.sc_first=ff;
    ans.sc_second=ss;
    return ans;
}

struct cmp{
    bool operator() (const node& a, const node& b){
        return (a.sc_first>b.sc_first) || (a.sc_first==b.sc_first && a.sc_second>b.sc_second);
    }
};

void bfs(int x,int y,int f,int s, int n, int m,vector<vector<bool>>& v, vector<vector<int>>& sc, vector<string>& grid, priority_queue<node,vector<node>,cmp>& pq){
    if(v[x][y]){
        // cout<<x+1<<" "<<y+1<<" "<<f<<" "<<s<<"\n";
        v[x][y]=false;
        sc[x][y]=f;
        for(int i=0;i<4;i++){
            int xx=x+diff[i].first,yy=y+diff[i].second;
            if(is_valid(xx,yy,n,m) && v[xx][yy]) 
                if(grid[xx][yy]=='.')
                    pq.push(get_node(xx,yy,f,s+1));
        }
        for(int i=-2;i<3;i++) for(int j=-2;j<3;j++){
            int xx=x+i,yy=y+j;
            if(is_valid(xx,yy,n,m) && v[xx][yy] && grid[xx][yy]=='.')
                pq.push(get_node(xx,yy,f+1,s+abs(i)+abs(j)));
        }
    }
}

void solve(){
    int h,w;
    pair<int,int> st,en;
    cin>>h>>w;
    cin>>st.first>>st.second;
    cin>>en.first>>en.second;
    st.first--;
    st.second--;
    en.first--;
    en.second--;
    vector<string> grid(h);
    for(int i=0;i<h;i++) cin>>grid[i];
    vector<vector<int>> score(h,vector<int>(w,-1));
    vector<vector<bool>> vis(h,vector<bool>(w,true));
    priority_queue<node, vector<node>, cmp> pq;
    score[st.first][st.second]=0;
    pq.push(get_node(st.first,st.second,0,0));
    while(!pq.empty()){
        auto x=pq.top();
        bfs(x.x,x.y,x.sc_first,x.sc_second,h,w,vis,score,grid,pq);
        pq.pop();
    }
    cout<<score[en.first][en.second]<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 9476
def era(n)
    $primes = Array.new(n, true)
    $primes[0], $primes[1] = false, false
    (2..Math.sqrt(n)).each do |i|
        if $primes[i]
            (i * i).step(n, i).each do |j|
                $primes[j] = false
            end
        end
    end
end

era(1000000)

while n = gets
    n = n.to_i
    puts $primes.slice(0..n).count(true)
end

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

const int N = 10000;

int n, c[N], m, d[N];
vector<int> G[N];

void dfs(int x, int *ci) {
  d[x] = c[(*ci)++];
  rep(i, G[x].size()) {
    int to = G[x][i];
    if (d[to]) continue;
    dfs(to, ci);
  }
}

int main() {
  cin >> n;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b; a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  rep(i, n) cin >> c[i];
  sort(c, c + n, greater<int>());
  for (int i = 1; i < n; i++) m += c[i];
  int ci = 0;
  dfs(0, &ci);
  printf("%d\n", m);
  rep(i, n - 1) printf("%d ", d[i]);
  printf("%d\n", d[n - 1]);
  return 0;
}

Measured memory_bytes: 4780
import java.util.*;
//import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int ans = 0;
        int num;
        int length;
        String strNum;
        
        while(sc.hasNextLine()){
            strNum = sc.next();            
            if("0".equals(strNum)){
              break;
            }
          
            length = strNum.length();
            String[] strArray = strNum.split("");
    
            for(int i = 0;i<length; i++){
                num = Integer.parseInt(strArray[i]);
                ans += num;
                
            }System.out.println(ans);
             ans = 0;
        }
    }
}



Measured memory_bytes: 27792
/*1803115*/
#include <stdio.h>
int main()
{
    char ch;
    int x,c[26]= {0};
 
    while(scanf("%c",&ch)!=EOF)
    {
        if(ch>='A' && ch<='Z')
        {
            x=ch-'A';
            c[x]+=1;
        }
        else if(ch>='a' && ch<='z')
        {
            x=ch-'a';
            c[x]+=1;
        }
    }
 
    for(x=0,ch='a'; x<26; x++,ch++)
    {
        printf("%c : %d\n",ch,c[x]);
    }
    return 0;
}


Measured memory_bytes: 2056
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

class Hp_neg
  def initialize(len = 200000)
    @main = na(len,[99999999,nil])
    @ind = 1
  end

  def push(n)
    @main[@ind] = n
    sind = @ind
    while(sind >= 2)
      nind = sind/2
      if(@main[sind][0] < @main[nind][0])
        @main[sind], @main[nind] = @main[nind], @main[sind]
      else
        break
      end
      sind /= 2
    end
    @ind += 1
  end

  def put()
    return @main
  end

  def pop()
    ans = @main[1]
    @ind -= 1
    @main[1] = @main[@ind]
    @main[@ind] = [99999999,nil]
    sind = 1
    while(true)
      nind = sind*2
      break if(nind > @ind)
      l = @main[nind]
      nind += 1
      if(nind > @ind)
        ind = nind-1
        if(@main[ind][0] < @main[sind][0])
          @main[sind], @main[ind] = @main[ind], @main[sind]
        end
        break
      end
      r = @main[nind]
      ind = (l[0] > r[0])? nind : nind-1
      if(@main[ind][0] < @main[sind][0])
        @main[sind], @main[ind] = @main[ind], @main[sind]
      end
      sind = ind
    end

    return ans
  end

  def res()
    @ind = 1
    push([99999999,nil])
  end
end

hp = Hp_neg.new()
n,m = inp
a = inp
a.each do |d|
  hp.push([d*-1,0])
end
m.times do
  u = hp.pop
  hp.push([((u[0]*-1)/2)*-1,0])
end
ans = 0
while true
  u = hp.pop

  break if(u[1] == nil)
  ans += u[0]
end
p ans * -1


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

ll dp[1005][1 << 12];

int main(int argc, char* argv[]) {
  ll n, m;
  cin >> n >> m;

  vector<int> price(m), box_bits(m);
  rep(i, 0, m) {
    int c;
    cin >> price[i] >> c;
    rep(j, 0, c) {
      int b;
      cin >> b;
      box_bits[i] |= (1 << (b - 1));
    }
  }

  Fill(dp, LL_INF);
  dp[0][0] = 0;
  rep(i, 0, m) rep(j, 0, (1 << n)) {
    if (dp[i][j] == LL_INF) continue;
    chmin(dp[i + 1][j], dp[i][j]);
    chmin(dp[i + 1][j | box_bits[i]], dp[i][j] + price[i]);
  }

  put(dp[m][(1 << n) - 1] == LL_INF ? -1 : dp[m][(1 << n) - 1]);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

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


Measured memory_bytes: 32384
#include <iostream>
#include <cstdio>                              //scanf,printf
#include <algorithm>                           //max,min
#include <string>                              //string
#include <cstring>                             //strlen,strcat
#include <cctype>                              //isalpha,tolower
using namespace std;

int main(){
    char s[205],q[105],t[101];
    cin>>s>>q;
    strcpy(t,s);
    strcat(s,t);
    if(strstr(s, q)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}




Measured memory_bytes: 3112
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
for i in reversed(range(N)):
  k= N // (i+1)
  tmp=0
  for j in range(1,k):
    tmp+=b[(i+1)*(j+1)-1]
  b[i]=abs((tmp%2)-a[i])
M=sum(b)
ans=[]
for i in range(N):
  if b[i]==1:
    ans.append(i+1)
print(M)
print(" ".join(map(str,ans)))
    

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

int main() {
  int a, b;
  cin >> a >> b;
  int sum = 0;
  if (b >= 100) {
    sum += (a * 1000);
  } else if (b >= 10) {
    sum += (a * 100);
  } else {
    sum += (a * 10);
  }
  sum += b;

  for (int i = 1; i < 1000; i++) {
    if (i * i == sum) {
      cout << "Yes" << endl;
      return 0;

    } else if (i * i > sum) {
      break;
    }
  }

  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;
bool d[33554432];
char k[128];

int c(char str[12]){
	int ans = str[0];
	for(int i = 1;i < strlen(str);i++){
		ans <<= 2;
		ans += k[str[i]];
	}
	return ans;
}

int main(){
	k['A'] = 0;k['C'] = 1;k['G'] = 2;k['T'] = 3;
	int n;scanf("%d", &n);
	char s[7], str[12];
	while(n--){
		scanf("%s %s", s, str);
		if(s[0] == 'i')d[c(str)] = true;
		else puts(d[c(str)] ? "yes" : "no");
	}
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    set<int32> ans;
    int32 x = 0;
    int32 y;
    FOR(i,1,n+1){
        if(x >= n)break;
        x += i;
        ans.insert(i);
        y = i;
    }
    x -= n;
    while(x > 0){
        if(y <= x){
            ans.erase(y);
            x -= y;
        }
        y--;
    }
    for(auto i : ans)cout << i << endl;
    return 0;
}

Measured memory_bytes: 512
program main
    implicit none
    integer:: N,i, no, day
    logical:: battle, flag
    integer, allocatable:: A(:,:), noind(:)
    logical, allocatable:: isbattled(:)
    no = 0
    read*, N
    allocate(A(N,N-1), noind(N), isbattled(N))

    do i=1,N
        read*, A(i,1:N-1)
    enddo
    noind(1:N) = 1 
    day = 1
    battle = .true.
    do while(.true.)
        ! print*, '--- ---day', day, battle
        battle = .false.
        isbattled(1:N) = .false.
        do i = 1, N
            if((noind(i)) == N) cycle
            if(isbattled(i) .eqv. .true.) cycle
            no = A(i, noind(i))
            if(isbattled(no) .eqv. .true.) cycle

            if(A(no, noind(no)) == i)then
                ! print*, i , 'vs' ,no
                noind(i) = noind(i) + 1
                noind(no) = noind(no) + 1
                isbattled(i) = .true.
                isbattled(no) = .true.
                battle = .true.
            endif
        enddo

        if (.not. battle) then
            day = day - 1
            exit
        end if

        day = day + 1
    enddo

    ! print*, noind
    flag = .true.
    do i = 1, N
        if(noind(i) /= N)then
            flag = .false.
        endif
    enddo

    if(flag) then
        print'(i0)',day
    else
        print*, '-1'
    endif


end program

Measured memory_bytes: 4096
s = input()
n = len(s)
def solve():
    for i in range(n - 1):
        if s[i] == s[i + 1]:
            return (i + 1, i + 2)
    for i in range(n - 2):
        if s[i] == s[i + 2]:
            return (i + 1, i + 3)
    return (-1, -1)
a, b = solve()
print(a, b)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;

int main(){
  vector<int> vec={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  k--;
  cout<<vec[k]<<endl;

}


Measured memory_bytes: 256
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int w, h;
	LinkedList<P>[] ps;
	P s, g;
	
	@SuppressWarnings("unchecked")
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			w = sc.nextInt();
			h = sc.nextInt();
			if((w|h) == 0) break;
			
			ps = new LinkedList[5];
			for(int i=0;i<5;i++) ps[i] = new LinkedList<P>();
			for(int i=0;i<h;i++) {
				String line = sc.next();
				for(int j=0;j<w;j++) {
					switch (line.charAt(j)){
					case 'S': s = new P(j, i, 0); break;
					case 'G': g = new P(j, i, 5); break;
					case '.': break;
					default : ps[line.charAt(j)-'1'].add(new P(j, i, line.charAt(j)-'1')); break;
					}
				}
			}
			int ans = INF;
			int id = -1;
			for(int i=0;i<5;i++) {
				int d = dijkstra(i);
				if( ans > d ) {
					ans = d;
					id = i;
				}
			}
			System.out.println((id==-1? "NA": ((id+1) + " " + ans))); 
		}
	}
	
	int dijkstra(int sn) {
		PriorityQueue<P> que = new PriorityQueue<P>();
		int[][] visited = new int[h][w];
		for(int[] a: visited) fill(a, INF);
		visited[s.y][s.x] = 0;
		s.id = sn;
		s.d = 0;
		que.add(s);
		
		while(!que.isEmpty()) {
			P now = que.remove();
			if(visited[now.y][now.x] < now.d) continue;
		//	debug(now.x, now.y, now.id+1, now.d);
			if( now.id == 5 ) return now.d;
			if(now.id == (sn+4)%5 ) {
				que.add(new P(g.x, g.y, g.id, now.d + dist(g, now)));
				continue;
			}
			for(P next: ps[(now.id+1)%5]) if( visited[next.y][next.x] > now.d + dist(next, now) ){
				que.add(new P(next.x, next.y, next.id, now.d + dist(next, now)));
				visited[next.y][next.x] = now.d + dist(next, now);
			}
		}
		
		return INF;
	}
	
	int dist(P p, P q) {
		return abs(p.x-q.x) + abs(p.y-q.y);
	}
	
	class P implements Comparable<P>{
		int x, y, id, d;
		P(int x, int y, int id) {
			this.x = x;
			this.y = y;
			this.id = id;
		}
		
		P(int x, int y, int id, int d) {
			this.x = x;
			this.y = y;
			this.id = id;
			this.d = d;
		}

		@Override
		public int compareTo(P o) {
			// TODO 自動生成されたメソッド・スタブ
			return d - o.d;
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin>>N;
    ll ans = INF;
    REP(i,N) {
        ll t;
        cin>>t;
        ll num = 0;
        while(t%2==0) {
            num++;
            t /= 2;
        }
        ans = min(ans,num);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
  int n, l;
  cin >> n >> l;

  vector<string> word_vec;

  for (int i = 0; i < n; i++){
    string word;
    cin >> word;
    word_vec.push_back(word);
  }

  sort(word_vec.begin(), word_vec.end());
  string out;
  for(int i = 0; i < word_vec.size(); i++){
    out += word_vec[i];
  }
  cout << out << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] V = new int[N];
		long[] Vl = new long[N+1];
		long[] Vr = new long[N+1];
		long ans = 0;
		for(int i = 0; i < N; i++)
			V[i] = sc.nextInt();
		for(int i = 1; i <= N; i++) {
			Vl[i] = Vl[i-1];
			Vl[i] += V[i-1];
		}
		for(int i = 1; i <= N; i++) {
			Vr[i] = Vr[i-1];
			Vr[i] += V[N-i];
		}
		for(int i = 0; i <= K && i <= N; i++) {
			for(int j = 0; j <= K-i && j <= N-i; j++){
				long value = Vl[i] + Vr[j];
				List<Integer> Vsorted = new ArrayList<>();
				for(int k = 0; k < i; k++)
					Vsorted.add(V[k]);
				for(int k = N-1; k >= N-j; k--)
					Vsorted.add(V[k]);
				Collections.sort(Vsorted);
				for(int k = 0; k < K-i-j; k++) {
					if(k >= Vsorted.size())
						break;
					if(Vsorted.get(k) < 0)
						value -= Vsorted.get(k);
					else
						break;
				}
				ans = Math.max(ans, value);
			}
		}
		System.out.println(ans);
	}

}


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

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

            //キーボードから数値を読み込む
            X = int.Parse(Console.ReadLine());
            A = int.Parse(Console.ReadLine());
            B = int.Parse(Console.ReadLine());

            //出力値を計算
            C = (X - A) % B;

            //結果を表示
            Console.WriteLine(C);

            //キー入力待ち
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092