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

using namespace std;

int main ()
{
	int n, sum = 0;
	cin >> n;
	int b[n-1];
	for (int i=0; i<n-1; i++){
		cin >> b[i];
	}
	sum += b[0];
	for (int i=0; i<n-2; i++){
		sum += min(b[i], b[i+1]);
	}
	sum += b[n-2];
	cout << sum << endl;
}

Measured memory_bytes: 256
// <------------- Template -----------------------> //


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(0);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAX5];

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, q, m, k;
string s, t, d;
ll sum = 0;
ll cou = 0;


// <------------- Implement Functions Here ----------> //

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> x >> y;
	vll a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	if (n == 1) {
		cout << abs(y - a[0]);
	}
	else {
		cout << max(abs(y - a[n - 1]), abs(a[n - 1] - a[n - 2]));
	}
}

int main() {
	fastio; randomINT;
	//cin>>T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 5964
#include <iostream>
using namespace std;
int main(void){
    int A,B,C;
    cin >> A >> B >> C;
    if (A==5 && B==5 && C==7){
        cout << "YES" << endl;
        }else if (A==7 && B==5 && C== 5){
            cout << "YES" << endl;
        }else if (A==5 && B==7 && C==5){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }


Measured memory_bytes: 256
N=int(input())

b=list(map(int,input().split()))

b.sort(reverse=True)

alice=[]
bob=[]

for i in range(N):
    if i==0:
        alice.append(b[i])
    elif i%2==0:
        alice.append(b[i])
    else :
        bob.append(b[i])

print(sum(alice)-sum(bob))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define M_PI  3.1415926535
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e9 + 7;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }
// -----------------------------------------------CKMKB-----------------------------------------------------------
// -----------------------------------------------PKMKB-----------------------------------------------------------
 int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin ) ;
  ll t = 1;
  //cin>>t;
  while(t--)
  {
      ll n;
      cin>>n;
      string a = "WA",b = "AC" , c = "TLE", d = "RE" ;
      ll q = 0 ,r = 0 ,s = 0 ,u = 0 ;
      for( ll i = 0 ; i<n ; i++ ){
        string inp ;
        cin>>inp ;
        if( inp == b ) q++;
        if( inp == a ) r++;
        if( inp == c ) s++;
        if( inp == d ) u++;
      }
      cout<<b<<" x "<<q<<endl;
      cout<<a<<" x "<<r<<endl;
      cout<<c<<" x "<<s<<endl;
      cout<<d<<" x "<<u<<endl;
  }
  return 0;

}


Measured memory_bytes: 3680
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')

# input macro
def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())
#

def join(s):
    return ''.join(s)

#iterate macro
def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)

#modulo macro
def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m

#bisect macro
def index(a, x):
    #Locate the leftmost value exactly equal to x
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1

#memoize macro
def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[(args)] = f(*args)
        return cache[args]
    return helper

@memoize
def nck(a,b,m):
    b = min([a-b,b])
    if (b>a or b<0 or a<0):
        return 0
    elif a == 0:
        return 1
    return (nck(a-1,b-1,m)+nck(a-1,b,m)) % m

nh=zip([1,0,-1,0],[0,1,0,-1])

###########

s=slist()
a=list("CODEFESTIVAL2016")
cnt=0
for j in range(16):
    if s[j]!=a[j]:
        cnt+=1

print cnt


Measured memory_bytes: 2816
S = input()
T = input()

ans = 1001

if T in S:
    print(0)
    exit()
else:
    for i in range(len(S) - len(T) + 1):
        count = 0
        s = S[i:i + len(T)]
        for j in range(len(T)):
            if s[j] != T[j]:
                count += 1
        if ans > count:
            ans = count
    print(ans)


Measured memory_bytes: 9116
#include<iostream>
using namespace std;
int main(void){
    int N;
    cin >> N;
    for(int n = 0; n < N; n++){
        int a[3];
        cin >> a[0] >> a[1] >> a[2];
        for(int i = 0; i < 3; i++){
            for(int j = i + 1; j < 3; j++){
                if(a[j] < a[i]){
                    int t = a[j];
                    a[j] = a[i];
                    a[i] = t;
                }
            }
        }
        if(((a[0]*a[0]) + (a[1]*a[1])) == (a[2]*a[2])){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3032
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;
typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef map<int, int> M;
typedef pair<int, int> P;

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

    double r, g;
    cin >> r >> g;
    cout << r + 2 * (g -r) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define Max 100000
using namespace std;
int n,k;
long long a[Max];
int check(long long p)
{
    int i=0;
    for(int j=0;j<k;j++)
    {
        long long s = 0;
        while(s+a[i] <= p)
        {
            s = s+a[i++];
            if(i == n)
                return n;
        }
    }
    return i;
}
int solve()
{
    long long left = 0;
    long long right = 100000*10000;
    long long mid;
    while(left+1 < right)
    {
        mid = (left + right)/2;
        int v = check(mid);
        if(v>=n)
            right = mid;
        else
            left = mid;
    }
    return right;
}
int main()
{
    int i;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    int res = solve();
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 4000
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
        q: usize,
        queries: [(i64, i64); q],
    }

    let mut s: i64 = a.iter().sum();
    let mut counts = vec![0i64; 10usize.pow(5) + 5];
    for ai in a.iter().copied() {
        counts[ai as usize] += 1;
    }

    for (before, after) in queries {
        let c = counts[before as usize];
        let diff = c * (after - before);
        s += diff;
        counts[before as usize] = 0;
        counts[after as usize] += c;

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


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

int main()
{
	int n;
	std::cin >> n;

	std::vector<int> v(n);

	for (int i = 0; i < n; ++i) {
		std::cin >> v[i];
	}

	int result = 0;
	int c;
	for (int i = 0; i < n; ++i) {
		std::cin >> c;
		if (v[i] - c > 0) {
			result += v[i] - c;
		}
	}

	std::cout << result << std::endl;

	return 0;
}

Measured memory_bytes: 256
// D - Widespread
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define rp(i,n) for(int i=0;i<(n);++i)
#define roundup(a,b) (((a)+(b)-1)/(b))

int main(){
	int N,A,B; cin>>N>>A>>B;
	A -= B;//additional damage
	vector<int> H(N); rp(i, N) cin>>H[i];
	int ans = INT_MAX;
	int L = 0, R = 1e9;
	while(L < R){
		int t = (L + R)/2;//mid
		LL tb = (LL)t * B;
		LL at = 0;
		rp(i, N){
			LL h = H[i] - tb;
			if(h > 0) at += roundup(h, A);
		}
		if(t >= at){
			R = t;//mid
		}
		else L = t + 1;//mid+1
	}
	cout<< R <<endl;
}

Measured memory_bytes: 640
mod = 1000000007
eps = 10**-9
inf = 10**15


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    AA = []
    for i, a in enumerate(A):
        AA.append((a, i))
    AA.sort(key=lambda x: x[0], reverse=True)

    dp = [[-inf] * (N+1) for _ in range(N+1)]
    dp[0][0] = 0
    for i in range(N):
        a, x = AA[i]
        for j in range(N):
            if dp[i][j] != -inf:
                # left
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + a * abs(x - j))
                # right
                dp[i+1][j] = max(dp[i+1][j], dp[i][j] + a * abs(x - (N-1 - (i - j))))
    #print(dp)
    print(max(dp[-1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 100676
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		char a = sc.next().charAt(0);
		char b = sc.next().charAt(0);
		sc.close();
		if(a < b) ou.println("<");
		else if(a > b) ou.println(">");
		else ou.println("=");
		ou.flush();
	}
}

Measured memory_bytes: 35712
from itertools import product
 
N, M = map(int, input().split())
switches = [list(map(int, input().split()[1:])) for _ in range(M)]
p = list(map(int, input().split()))
 
num_pattern = 0
for pattern in product(*[range(2) for _ in range(N)]):
    on_switches = [0]*M  # the number of on switches for each bulb
    for i, switch in enumerate(switches):
        for s in switch:
            if pattern[s-1] == 1:
                on_switches[i] += 1
                
    for i, on_num in enumerate(on_switches):
        if on_num % 2 != p[i]:
            break
    else:
        num_pattern += 1
print(num_pattern)

Measured memory_bytes: 41328
#include <iostream>

using namespace std;

int main()
{
  int n;
  cin >> n;
  n %= 10;
  switch(n)
  {
    case 0: cout << "pon" << endl; break;
    case 1: cout << "pon" << endl; break;
    case 2: cout << "hon" << endl; break;
    case 3: cout << "bon" << endl; break;
    case 4: cout << "hon" << endl; break;
    case 5: cout << "hon" << endl; break;
    case 6: cout << "pon" << endl; break;
    case 7: cout << "hon" << endl; break;
    case 8: cout << "pon" << endl; break;
    case 9: cout << "hon" << endl; break;
  }
}

Measured memory_bytes: 3656
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 1000050;
template<typename T>
inline void read(T&x)
{
	T f = 1,c = 0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){c=c*10+ch-'0';ch=getchar();}
	x = f*c;
}
int n;
char s[N],t[N];
bool check()
{
	for(int i=1;i<=n;i++)if(s[i]!=t[i])return 0;
	return 1;
}
int sta[N],hd=1,tl=0,ans;
int main()
{
	read(n);
	scanf("%s%s",s+1,t+1);
	if(check()){puts("0");return 0;}
	for(int i=n,j=n;i>=1;i--)
	{
		if(t[i]==t[i-1])continue;
		if(j>i)j=i;
		while(j&&s[j]!=t[i])j--;
		if(!j){puts("-1");return 0;}
		while(hd<=tl)
		{
			if(sta[hd]-(tl+1-hd)>=i)hd++;
			else break;
		}
		sta[++tl] = j;
		if(i!=j)ans=max(ans,tl-hd+1);
	}
	printf("%d\n",ans+1);
	return 0;
}


Measured memory_bytes: 6016
import Control.Applicative
import Data.Function
import Control.Monad
import Data.List
import Data.Char
import Text.Printf

distance :: [Double] -> Double
distance [x1,y1,x2,y2] = sqrt $ (x2 - x1)^2 + (y1 - y2)^2

main :: IO ()
main = do
    a <- map read . words <$> getLine
    printf "%.10f\n" $ distance a


Measured memory_bytes: 4096
#include <iostream>
#include <string>
using namespace std;
int main(void){

int N = 0;
string S;
int count = 0;
int Max = 0;
int Temp = 0;

cin >> N;
cin >> S;

for(count = 0; count < N; count++){
  if( S[count] == 'I'){
    Temp++;
  }
  else if( S[count] == 'D'){
    Temp--;
  }
  else{
    //do nothing
  }

  if( Max < Temp){
    Max = Temp;
  }
  else{
    //do nothing
  }
}

cout << Max;

return 0;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;

public class Main{

static PrintWriter out;
static InputReader ir;

static void solve(){
 for(;;){
  int e=ir.nextInt();
  if(e==0) return;
  int mi=1000000000;
  for(int i=0;i*i*i<=e;i++){
   int sqrt=(int)(Math.sqrt(e-i*i*i));
   mi=Math.min(mi,i+sqrt+e-i*i*i-sqrt*sqrt);
  }
  out.println(mi);
 }
}

public static void main(String[] args) throws Exception{
 ir=new InputReader(System.in);
 out=new PrintWriter(System.out);
 solve();
 out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;

 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
 
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }

 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
 
 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
 
 public boolean hasNext(){skip(); return hasNextByte();}
 
 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }
 
 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }

 public double nextDouble(){return Double.parseDouble(next());}

 public int[] nextIntArray(int n){
  int[] a=new int[n];
  for(int i=0;i<n;i++) a[i]=nextInt();
  return a;
 }

 public long[] nextLongArray(int n){
  long[] a=new long[n];
  for(int i=0;i<n;i++) a[i]=nextLong();
  return a;
 }

 public char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}

Measured memory_bytes: 26516
# Problem E - This Message Will Self-Destruct

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
num_dic = {}
ans = 0

# count
for i in range(1, N+1):
    a = a_nums[i-1] + i
    if not a in num_dic:
        num_dic[a] = 1
    else:
        num_dic[a] += 1

# count 2
for j in range(1, N+1):
    b = j - a_nums[j-1]
    if b in num_dic:
        ans += num_dic[b]

# output
print(ans)


Measured memory_bytes: 40564
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math,std.random;
const dx = [1,0,-1,0], dy = [0,1,0,-1];
const readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(arg));}};
void read(T...)  (auto ref T args){mixin(readMixin);}
void readArray(T)(auto ref T args){mixin(readMixin);}
int  read(){int n;read(n);return n;}
void times(int n,void delegate() stmt){foreach(i;iota(n))stmt();}
void main(){
	int[] MS;
	for(int i = 6;i < 300000;i +=7)MS ~=[i,i+2];
	int n ;
	while(read(n),n!=1){
		write(n,":");
		int[] res;
		foreach(ms;MS){
			if(ms > n) break;
			if(n % ms == 0) {
				if(!res.any!(a => ms % a == 0)) res ~= ms;
			}
		}
		res.each!(a=> write(" ",a));
		writeln();
	}
}

Measured memory_bytes: 3268
#include <iostream>
using namespace std;
int main(void) {
  int a,b,c;
  cin >> a >> b >> c;
  if (a < b){
    if (b < c){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    cout << "No" << endl;
  }

  return 0;
}



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

using ll = long long;

#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_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int N;
int A[1001];

int main(){
	cin.tie(0);
	
	cin>>N;
	rep(i, N)cin>>A[i];
	
	for_(i, 0, N) {
	    rfor_(j, 0, i) {
	        if(A[j] < A[j+1])break;
	        int v = A[j+1];
	        A[j+1] = A[j];
	        A[j] = v;
	    }
	    rep(j, N) {
	        cout<<A[j];
	        if(j<N-1)cout<<' ';
	    }
	    cout<<endl;
	}

	return 0;
}




Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <stack>
using namespace std;
map<string,long long>m;
typedef long long ll;


string s;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    int n,k,d;
    long long ans=0;
    cin >>n ;
    while(n--){
        cin >> s;
        sort(s.begin(),s.end());
        ans+=m[s];
        m[s]++;
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
int main(){
  ll n;cin>>n;
  ll l[n],r[n];
  vector<pll> v,w;
  for(int i=0;i<n;i++){
    cin>>l[i]>>r[i];
    v.push_back(make_pair(l[i],i));
    w.push_back(make_pair(r[i],i));
  }
  sort(v.begin(),v.end(),greater<pll>());
  sort(w.begin(),w.end());
  ll nl=0,nr=0;
  ll ans=0;
  bool used[n];
  fill(used,used+n,false);
  int c=0;
  ll now=0;
  for(;;){
   if(c==0){
     while(nl<n&&used[v[nl].second])nl++;
     if(nl==n)break;
     c=1;
     ll y=v[nl].second;
     if(l[y]<=now&&r[y]>=now){
       used[y]=true;
       continue;
     }
     else{
       ans+=abs(l[y]-now);
       now=l[y];
       used[y]=true;
       continue;
     }
   }
    else{
      while(nr<n&&used[w[nr].second])nr++;
      if(nr==n)break;
      c=0;
      ll y=w[nr].second;
      if(l[y]<=now&&r[y]>=now){
        used[y]=true;
        continue;
      }
      else{
        ans+=abs(r[y]-now);
        now=r[y];
        used[y]=true;
        continue;
      }
    }
  }
  ans+=abs(now);
  fill(used,used+n,false);
  ll ans2=0;
  nl=0;nr=0;
  c=1;
  now=0;
  for(;;){
   if(c==0){
     while(nl<n&&used[v[nl].second])nl++;
     if(nl==n)break;
     c=1;
     ll y=v[nl].second;
     if(l[y]<=now&&r[y]>=now){
       used[y]=true;
       continue;
     }
     else{
       ans2+=abs(l[y]-now);
       now=l[y];
       used[y]=true;
       continue;
     }
   }
    else{
      while(nr<n&&used[w[nr].second])nr++;
      if(nr==n)break;
      c=0;
      ll y=w[nr].second;
      if(l[y]<=now&&r[y]>=now){
        used[y]=true;
        continue;
      }
      else{
        ans2+=abs(r[y]-now);
        now=r[y];
        used[y]=true;
        continue;
      }
    }
  }
  ans2+=abs(now);
  cout<<max(ans,ans2)<<endl;
}

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

int main(){
    int N;
    int alice = 0;
    int bob = 0;

    cin >> N;

    vector<int> vec(N);
    rep(i, N){
        cin >> vec.at(i);
    }

    int tmp;
    rep(i, N){
        for (int j = i + 1; j < N; j++)
        {
            if (vec.at(i) > vec.at(j)){
                tmp = vec.at(i);
                vec.at(i) = vec.at(j);
                vec.at(j) = tmp;
            }
        }
    }

    rep(i, N){
        if (i % 2 == 0){
            alice += vec.at( N - (i + 1) );
        }
        else
        {
            bob += vec.at( N - (i + 1) );
        }
    }
    cout << alice - bob << endl;
}

Measured memory_bytes: 3580
#include <stdio.h>

int main(){
  int n,p,c=1000000,m=0;
  scanf("%d",&n);
  for(;n>0;n--){
  	scanf("%d",&p);
   	if(p<=c){
      m++;
      if(p<c){
        c=p;
      }
    }
  }
  printf("%d",m);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(){
    while(true){
        int h,w;
        cin >> h >> w;
        if(h==0 && w==0){
            break;
        }
        for(int i=0; i<h; i++){
            if(i%2==0){
                for(int j=0; j<w; j++){
                    if(j%2==0){
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                }
            }else{
                for(int j=0; j<w; j++){
                    if(j%2==0){
                        cout << ".";
                    }else{
                        cout << "#";
                    }
                }
            }

            cout << endl;
        }
        cout << endl;

    }
    return 0;
}



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

using namespace std;


int main(){
	
	
	while(1){
		int n,m,p;
		int sum=0;
		
		cin >> n >> m >> p;
		
		if(n==0) break;
		
		int x[n];
		
		for(int i=0;i<n;i++){
			cin >> x[i];
			sum += x[i];
		}
		int go=sum*100-sum*p;
		
		if(x[m-1]==0) cout << '0' << endl;
		else cout << go/x[m-1] << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n = 3;
  VEC<int> c(4, 0);
  REP(i, 0, n) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    c[a]++;
    c[b]++;
  }
  sort(ALL(c));
  VEC<int> v = {1,1,2,2};
  DUMP(c,v);
  if (c == v)cout<<"YES";
  else cout<<"NO";

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, cc int
	fmt.Scan(&n, &cc)

	tt := make(map[int][]Pair)
	for i := 0; i < cc; i++ {
		tt[i] = make([]Pair, 0)
	}

	tMax := 0
	var s, t, c int
	for i := 0; i < n; i++ {
		fmt.Scan(&s, &t, &c)
		tt[c-1] = append(tt[c-1], Pair{s, t})
		if tMax < t {
			tMax = t
		}
	}

	ts := make([]Pair, 0)
	for i := 0; i < cc; i++ {
		sort.Sort(Pairs(tt[i]))
		us := tt[i]
		if len(us) == 0 {
			continue
		}

		p := us[0]
		for j := 1; j < len(us); j++ {
			u := us[j]
			if p[1] == u[0] {
				p[1] = u[1]
			} else {
				ts = append(ts, p)
				p = u
			}
		}
		ts = append(ts, p)
	}

	d := make([]int, tMax+1)
	for _, p := range ts {
		s, t := p[0], p[1]
		d[s-1]++
		d[t]--
	}

	ans := 0
	im := make([]int, len(d)+1)
	for i := 0; i < len(d); i++ {
		im[i+1] = im[i] + d[i]
		if ans < im[i+1] {
			ans = im[i+1]
		}
	}

	fmt.Println(ans)
}

// Pair .
type Pair [2]int

// Pairs .
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}

func (p Pairs) Less(i, j int) bool {
	return p[i][0] < p[j][0]
}

func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}


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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

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

	string s;
	cin>>s;
	int len=s.length()-2;
	cout << s[0] << len << s[s.length()-1] << endl;

	return 0;
}

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

int32_t main()
{
    int n;cin>>n;
    int arr[n];
    
    int ex=0,val=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        ex^=arr[i];
    }

    vector<int>ans;
    for(int i=0;i<n;i++){
        val=ex^arr[i];
        ans.push_back(val);
    }
    for(auto x:ans){
        cout<<x<<" ";
    }

    cout<<endl;

    return 0;
}

Measured memory_bytes: 6928
x1, y1, x2, y2 = map(int, input().split())
vector = (x2-x1, y2-y1)

x3, y3 = x2 - vector[1], y2-(-vector[0])
x4, y4 = x3 - vector[0], y3-vector[1]

print(" ".join(map(str, [x3,y3,x4,y4])))

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

int main(){
  int n;cin>>n;
  vector<int> arr(n);
  for(int i=0;i<n;++i)cin>>arr[i];
  if(n%2==1){
    cout<<0<<endl;
  }else{
    sort(arr.begin(),arr.end());
    int l = n/2-1;
    int r = n/2;
    cout<<arr[r]-arr[l]<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 640
using System;
using System.Windows;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        //入力を受け取る
        int N = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        for(int i = 0; i < N; i++)
        {
          int v = A[i];
          int j = i -1;
          while(j>= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
          }
          A[j+1] = v;
          Console.WriteLine(string.Join(" ",A));
        } 
    }
}


Measured memory_bytes: 18320
#include<stdio.h>
#include<math.h>
int main()
{
    long long a,b,fac=1;
    scanf("%lld",&a);

    for(b=a;b>=1;b--)
    {
        fac=fac*b;



    }

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


return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<stdlib.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main(void)
{
  int i=0,N=IN(),r=0,w=0;
  char *stones=(char*)malloc(sizeof(char)*(N+1));if(!scanf("%s",stones))return -1;
  while(N--){if(stones[N]=='R')r++;}while(r--){if(stones[i++]=='W')w++;}
  printf("%d\n",w);return free(stones),0;
}

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

	else if (a < b){
		if (b < c){
			printf("Yes\n");
		}
		else { printf("No\n"); }
	}
	else 	 {
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 2688
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 51;
const LL INF = 1LL << 55;
int A[N], B[N];
LL dp[N][N];

int bit(LL x, int y) {
  return (x >> y) & 1;
}

LL ans;

LL f(int a, int b) {
  if(a == b) {
    return 0;
  }
  if(2 * b >= a) {
    return -1;
  }
  LL &res = dp[a][b];
  if(res != -1) {
    return res;
  }
  res = INF;
  for(int i = b + 1; i <= a; i++) {
    LL val = f(a % i, b);
    if(val == -1 || val == INF) continue;
    if(!bit(ans, i)) {
      val |= 1LL << i;
    }
    res = min(res, val);
  }
  return res;
}

int main() {
  int n;
  S(n);
  rep(i,0,n) {
    S(A[i]);
  }
  rep(i,0,n) {
    S(B[i]);
    if(B[i] > A[i] || (B[i] < A[i] && 2 * B[i] >= A[i])) {
      P(-1);
      return 0;
    }
  }
  while(1) {
    LL res = 0;
    memset(dp, -1, sizeof(dp));
    rep(i,0,n) {
      res = max(f(A[i], B[i]), res);
    }
    if(!res) break;
    for(int i = 50; i >= 0; i--) if(bit(res, i)) {
      ans |= 1LL << i;
      break;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<ll,ll>;

/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}



const int INF = 1001001001;



int main() {
	int a, b;
	cin >> a >> b;
	ll h = 0,x=-1,y=-1,ans;
	for (int i = 1; i <= 999; i++) {
		h += i;
		if (h >= a) {
			x = h-i;
		}
		if (h >= b) {
			y = h;
		}
		if (x - a == y - b) {
			ans = x - a;
			break;
		}
	}
	cout << ans;
	return 0;
}













Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define pb push_back
#define ALL(v) v.begin(),v.end()
const long long INF = 1LL << 60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P = pair<int, int>;
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; }
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b)
{
    if(b == 0) return a;
    return gcd(b, a%b);
}
int main()
{
    ll N, X;
    cin >> N >> X;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    A.pb(X);
    sort(ALL(A));

    vector<ll> B(N);
    rep(i, N)
    {
        B[i] = A[i+1]-A[i];
    }
    ll ans = 0;
    rep(i, N)
    {
        ans = gcd(B[i], ans);
    }
    cout << ans  << endl;

    return 0;
}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(exp, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+1;
ll N;


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    cout << (N*(N-1))/2;
    return 0;
}


Measured memory_bytes: 256
//ABC95B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int n, x;
    cin >> n >> x;
    int cnt = n;
    vector<int>vec(n,0);
    rep(i, n) cin >> vec[i];
    sort(vec.begin(), vec.end());
    x -= accumulate(vec.begin(), vec.end(),0);
    //cout << x << endl;
    while(true){
        x-=vec[0];
        if(x>=0){
            cnt +=1;
        }else break;
        
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))


r,d,x = m()

for i in range(10):
	x = r * x - d
	print(x)


Measured memory_bytes: 38256
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    fun f(a: Int, b: Int): Int = if (b > 0) f(b, a % b) else a
    val ans = A.reduce { acc, value -> f(acc, value) }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

Measured memory_bytes: 51992
#include<set>
#include<list>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
    char a,b,c;
    char a1,b1,c1;
    cin>>a>>b>>c>>a1>>b1>>c1;
    int ans=0;
    if(a==a1)
        ans++;
    if(b==b1)
        ans++;
    if(c==c1)
        ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



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

int main(){
  string S,T;
  cin >> S >> T;
  for(int i=0;i<S.size();i++){
    if(S==T){
      cout << "Yes" << endl;
      return 0;
    }
    S.insert(S.begin(),S.back());
    S.pop_back();
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
    using namespace std;
    int main(){
      int N;
      cin >>N;
      int A[N];
      for(int i=0;i<N;i++){cin>>A[i];}
      int cnt,flag=0;
      while(true)
      {
        for(int i=0;i<N;i++)
        {
          if(A[i]%2==0)A[i]=(A[i]/2);
          else flag=1;
        }
        if(flag==1)break;
        cnt++;
      }
      cout<<cnt<<endl;
    }

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
namespace ITP1_6_C
{
    class Problem
    {

        public static List<string[]> getinputdata (){

            List<string[]> list_temp = new List<string[]>();
            string strdata = Console.ReadLine ();

            while (strdata!=null) {

                string[] s_temp = strdata.Split (' ');

                list_temp.Add (s_temp);

                strdata = Console.ReadLine ();

            }
            return list_temp;
        }
        public static void RoomCheck (int b,int f,int r,int v,ref Dictionary<int,Dictionary<int,Dictionary<int,int>>>  dict){

//            Console.WriteLine("b={0} f={1} r={2} v={3}",b,f,r,v);

            dict[b][f][r] += v;
     

        }

        public static void RoomDisplay (Dictionary<int,Dictionary<int,Dictionary<int,int>>> dict)
        {
            string str = new string ('#',20);
        

            for (int i = 1; i <= 4; i++)
            {
                for (int j = 1; j <= 3; j++)
                {
                    for (int k = 1; k <= 10; k++)
                    {
                        Console.Write(" {0}",dict[i][j][k]);
                    }
                    Console.WriteLine();
                }

                if (i != 4)
                {
                    Console.WriteLine(str);
                }
            }


        }

        public static Dictionary<int,Dictionary<int,Dictionary<int,int>>> RoomInitialize (){

            Dictionary<int,Dictionary<int,Dictionary<int,int>>> mydict = new Dictionary<int,Dictionary<int,Dictionary<int,int>>>{};

            //?£???°????????????
            for (int i = 1; i <= 4; i++)
            {

                Dictionary<int,Dictionary<int,int>> mydict_temp1 = new Dictionary<int,Dictionary<int,int>>{ };
   
                //?????°????????????
                for (int j = 1; j <= 3; j++)
                {

                    Dictionary<int,int> mydict_temp2 = new Dictionary<int,int>{ };

                    //??¨?±???°????????????
                    for (int k = 1; k <= 10; k++)
                    {
                        mydict_temp2.Add(k, 0);
                    }

                    mydict_temp1.Add(j, mydict_temp2);

                }

                mydict.Add(i, mydict_temp1);

            }

            return mydict;

        }

        public static void Main (string[] args)
        {
            List<string[]> list_result = new List<string[]>{};

            list_result = getinputdata ();

            Dictionary<int,Dictionary<int,Dictionary<int,int>>> dictroom = new Dictionary<int,Dictionary<int,Dictionary<int,int>>>{};
            dictroom = RoomInitialize();

            int n= int.Parse(list_result[0][0]);


            for (int i = 1; i <= n; i++)
            {
                RoomCheck(int.Parse(list_result[i][0]),int.Parse(list_result[i][1]),int.Parse(list_result[i][2]),int.Parse(list_result[i][3]),ref dictroom);
            }

            RoomDisplay(dictroom);

         }
    }
}

Measured memory_bytes: 9940
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

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

  ll a, b;

  for (ll i = -1000; i <= 1000; i++){
    for (ll j = -1000; j <= 1000; j++){
      if (i*i*i*i*i - j*j*j*j*j == x){
        a = i;
        b = j;
        break;
      }
    }
  }
  cout << a << " " << b << endl;
  

  return 0;
}


Measured memory_bytes: 3624
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	int mn = 1e9, mx=-1e9;
	for(int i = 0; i < n; i++) {
		mn = min(mn, a[i]);
		mx = max(mx, a[i]);
	}

	if(mx <= 0) {
		cout << n - 1 << "\n";
		for(int i = n; i >= 2; i--) {
			cout << i << " " << i - 1 << "\n";
		}
		exit(0);
	}

	if(mn >= 0) {
		cout << n - 1 << "\n";
		for(int i = 1; i < n; i++) {
			cout << i << " " << i + 1 << "\n";
		}
		exit(0);
	}

	assert(mn < 0 && mx > 0);

	if(abs(mn) > mx) {
		int ind = -1;
		for(int i = 0; i < n; i++) if(a[i] == mn) ind = i;

		cout << 2*n-2 << "\n";
		for(int i = 1; i <= n; i++) {
			if(i == ind + 1) continue;
			cout << ind + 1 << " " << i << "\n";
		}
		// hepsi negatif oldu
		for(int i = n; i >= 2; i--) {
			cout << i << " " << i - 1 << "\n";
		}
	}
	else {
		int ind = -1;
		for(int i = 0; i < n; i++) if(a[i] == mx) ind = i;

		cout << 2*n-2 << "\n";
		for(int i = 1; i <= n; i++) {
			if(i == ind + 1) continue;
			cout << ind + 1 << " " << i << "\n";
		}
		// hepsi pozitif oldu
		for(int i = 1; i < n; i++) {
			cout << i << " " << i + 1 << "\n";
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c == 17) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int v[100][100];


int main() {
	int n,u,k,i,j;
	int id;
	for(i=0;i<100;i++){
		for(j=0;j<100;j++){

			v[i][j]=0;

		}
		
	}
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d", &u, &k);
		for (j = 0; j < k; j++) {
			scanf("%d", &id);
			v[u][id] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			printf("%d", v[i][j]);
			if (j != n)printf(" ");
		}
		printf("\n");
	}

	return 0;
}


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

#define PI 3.1415926535

int main(){
    int n, x = 0;
    cin >> n;
    vector<char> s(n);
    vector<int> ans(n);
    for (int i = 0; i < n; i++){
        cin >> s.at(i);
        if(s.at(i)=='I')
            x++;
        else
            x--;
        ans.at(i) = x;
    }
    sort(ans.begin(), ans.end(),greater<int>());
    if(ans.at(0)>=0)
        cout << ans.at(0) << endl;
    else
        cout << 0 << endl;

    return 0;
}


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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/05  Problem: 077_arc_b / Link: https://arc077.contest.atcoder.jp/tasks/arc077_b?lang=en  ----- */
/* ------問題------

1,…,n の n 個の整数からなる長さ n+1 の数列 a1,a2,…,an+1 が与えられます。 この数列には 1,…,n のどの整数もかならず 1 回以上出現することが分かっています。
k=1,…,n+1 のそれぞれについて、与えられた数列の長さ k の（連続とは限らない）部分列の個数を求め、 109+7 で割ったあまりを出力して下さい。
注意
2 つの部分列が数列として同じであれば、元の数列での位置が異なっていたとしても、1 通りと数えます。
数列 a の長さ k の部分列とは、a の要素のうち k 個を選んで、 それらを順番を変えずに取り出して並べた数列のことを指します。 例えば、数列 1,2,3,4,5 の長さ 3 の部分列には、 1,3,5 や 1,2,3 などがあります。 一方で、3,1,2 や 1,10,100 はこの数列の部分列ではありません。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;


const long long mod = 1e9 + 7;

long long modpow(long long a, long long b) {
	if (b == 0) return 1;
	return modpow(a * a % mod, b / 2) * (b & 1 ? a : 1) % mod;
}

long long modinv(long long a) {
	return modpow(a, mod - 2);
}

vector<long long> fact, inv_fact;

void init_fact(int n) {
	fact.resize(n);
	fact[0] = 1;
	for (int i = 1; i < n; i++) {
		fact[i] = i * fact[i - 1] % mod;
	}
	inv_fact.resize(n);
	inv_fact[n - 1] = modinv(fact[n - 1]);
	for (int i = n - 2; i >= 0; i--) {
		inv_fact[i] = (i + 1) * inv_fact[i + 1] % mod;
	}
}

long long nPr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fact[n] * inv_fact[n - r] % mod;
}

long long nCr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return fact[n] * inv_fact[r] % mod * inv_fact[n - r] % mod;
}

long long nHr(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return nCr(n + r - 1, r);
}

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

	cin >> N;
	VL a(N + 1);
	map<int, int>cnt;
	int posL, posR;
	FOR(i, 0, N + 1) {
		cin >> a[i];
		if (cnt[a[i]]) {
			posR = i + 1;
		}
		cnt[a[i]]++;
	}
	FOR(i, 0, N + 1) {
		if (cnt[a[i]] == 2) {
			posL = i + 1;
			break;
		}
	}
	//cout << posL << " " << posR << endl;
	init_fact(3 * N);
	FOR(i, 0, N + 1) {
		int k = i + 1;
		//debug(nCr(N + 1, k));
		//debug(nCr((posL - 1) + ((N + 1) - (posR )), k - 1));
		ans = nCr(N + 1, k) - nCr((posL-1 ) + ((N + 1) - (posR )), k - 1);
		cout << (ans+ mod)%mod << endl;
	}


	return 0;
}


Measured memory_bytes: 11392
#include <cstdio>
int n,k,i;
int main(){
	scanf("%d%d",&n,&k);
	if(2*k>n+1)puts("-1");
	else for(;i<n;i++)printf("%d %d %d\n", k+i,k+(i<(n+1)/2)*n+n/2+i,k+2*n+i*2-(i>=(n+1)/2)*((n+1)/2*2-1));
}

Measured memory_bytes: 2176
#include <stdio.h>

int main(void) {
	int A[3],N5=0,N7=0;
	int i=0;

	for(i=0;i<3;i++) {
		scanf("%d",&A[i]);
		if(A[i]==5){
			N5++;
		}
		else if (A[i]==7) {
			N7++;
		}
	 }

	 if(N5==2 && N7==1) {
		printf("YES\n");
	 }
	 else {
		 printf("NO\n");
	 }
}


Measured memory_bytes: 128