akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
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)*}
    };
}

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: usize,
        k: usize,
    }
    let mut ans = k;
    for i in 1..n {
        ans *= k - 1;
    }
    println!("{}", ans);
}

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

ll f(ll x) {
  if (x == 1) return 1;
  ll a = f(x/2);
  return a*2+1;
}

int main() {
  ll h;
  cin >> h;
  cout << f(h) << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}
ll dp[55][2505][55];
signed main(void)
{
  int i,j,k;
  in(int,n,a);
  int x[100]={};
  ll ans=0;
  dp[0][0][0]=1;
  rep(i,n)cin>>x[i];
  rep(i,n)rep(j,2505)rep(k,n+1)
    {
      dp[i+1][j][k]+=dp[i][j][k];
      if(k-1>=0&&j-x[i]>=0)
	dp[i+1][j][k]+=dp[i][j-x[i]][k-1];
    }
  rep(j,3000)
    for(k=1;k<n+1;k++)
      if(j==k*a)ans+=dp[n][j][k];

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 54400
// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }

using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef DEBUG_MODE

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 100005
#define MAX_M 100005
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
int p[MAX_N];
/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
//  WF("output.txt");
	DF("err.txt");

	int N;
	scanf("%d", &N);
	int continuous = 0;
	int swap = 0;
	for (int i = 1; i <= N; i++) {
		int val;
		scanf("%d", &val);
		if (val == i)
			continuous++;
		else {
			swap += (continuous + 1) >> 1;
			continuous = 0;
		}
	}
	swap += (continuous + 1) >> 1;
	printf("%d\n", swap);
}

Measured memory_bytes: 256
import sys
from sys import stdin

n, x = map(int, stdin.readline().split())
count = 1
num = 0
num_list = [0]

l = list(map(int, stdin.readline().split()))

for i in l:
  num += i
  num_list.append(num)
  if(num > x):
    print(count)
    sys.exit()
  else:
    count += 1 

print(count)   


Measured memory_bytes: 3060
s = input()

n = len(s)

s_head= s[:int((n-1)/2)]
s_tail= s[int((n+3)/2)-1:]

# print(s_head)
# print(s_tail)
# print(s_tail)
s_tailr = ''.join(list(reversed(s_tail)))
if s_head == s_tail  and s_head == s_tailr:
    print('Yes')
else:
    print('No')

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

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

  vector<int> h(n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
    if (h[i] >= k) {
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    if (a%10==9 || a/10==9) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n, c = f.read_int_list()
    x = [f.read_int_list() for _ in xrange(n)]

    sl = [0] * n
    mal = [None] * n
    sr = [0] * n
    mar = [None] * n

    pos = 0
    for i in xrange(n):
        if i > 0: sl[i] = sl[i-1]
        sl[i] += x[i][1] - (x[i][0] - pos)
        pos = x[i][0]
        if i > 0:
            if sl[i] > mal[i-1][0]:
                mal[i] = (sl[i], i)
            else:
                mal[i] = mal[i-1]
        else:
            mal[i] = (sl[i], i)

    pos = c
    for i in xrange(n-1,-1,-1):
        if i < n-1: sr[i] = sr[i+1]
        sr[i] += x[i][1] - (pos - x[i][0])
        pos = x[i][0]
        if i < n-1:
            if sr[i] > mar[i+1][0]:
                mar[i] = (sr[i], i)
            else:
                mar[i] = mar[i+1]
        else:
            mar[i] = (sr[i], i)

    # print sl, mal, sr, mar

    ans = 0
    for i in xrange(n):
        ans = max(ans, sl[i])
        if n > 1 and i < n-1: ans = max(ans, sl[i] - x[i][0] + mar[i+1][0])
    for i in xrange(n-1,-1,-1):
        ans = max(ans, sr[i])
        if n > 1 and i > 0: ans = max(ans, sr[i] - (c-x[i][0]) + mal[i-1][0])

    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 47132
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vecll var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl
#define prtseq(var, n)   rep(i,n){cout << var[i] << " ";} cout << endl;

//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arrll(a,n);
  vecll ans(n);

  rep(i,n){
    ans[0] += a[i];
  }

  rep(i,(n+1)/2-1){
    ans[0] -= 2 * a[2*i+1];
  }

  rep(i,n-1){
    ans[i+1] = 2*a[i] - ans[i];
  }

  prtseq(ans,n);

}


Measured memory_bytes: 2944
_ = input()
l = list(map(int, input().split()))
br = 0
cn = 1
for i, n in enumerate(l):
	#print([i,n,cn])
	if n != cn:
		br += 1
	else:
		cn += 1
if br == len(l):
	print(-1)
else:
	print(br)

Measured memory_bytes: 26268
def solve():
  INF = 100000
  while True:
    n = int(input())
    if not n: break
    lst = [int(input()) for _ in range(n)]
  
    def check(x):
      c = lst[x]
      l = r = x
      b = 0
      for i in range(r, n):
        if lst[i] != c:
          r = i - 1
          break
      else:
        r = n - 1
  
      for i in range(l, -1, -1):
        if lst[i] != c:
          l = i + 1
          break
      else:
        l = 0
  
      if r - l - b < 3:
        return n
      else:
        b = r - l
  
      while l > 0 and r < n - 1:
        c = lst[l - 1]
        if c != lst[r + 1]:
          break
        else:
          for i in range(r + 1,n):
            if lst[i] != c:
              r = i - 1
              break
          else:
            r = n - 1
             
          for i in range(l - 1, -1, -1):
            if lst[i] != c:
              l = i + 1
              break
          else:
            l = 0
  
          if r - l - b < 4:
            break
          else:
            b = r - l
      return n - (b + 1)
  
    ans = INF
    for i in range(n):
      lst[i] = (lst[i]) % 3 + 1
      ans = min(ans, check(i))
      lst[i] = (lst[i]) % 3 + 1
      ans = min(ans, check(i))
      lst[i] = (lst[i]) % 3 + 1
    print(ans)
solve()


Measured memory_bytes: 5736
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<1000000007>;
int N;
string s;
mint dp[3010][3010];
int main(){
	cin>>N>>s;
	dp[1][0] = 1;
	for(int i=1;i<N;i++){
		bool bigger = s[i-1]=='<';
		V<mint> tmp(i+1);
		rep(p,i){
			if(bigger) tmp[p+1] += dp[i][p];
			else tmp[0] += dp[i][p], tmp[p+1] -= dp[i][p];
		}
		rep(j,i) tmp[j+1] += tmp[j];
		rep(j,i+1) dp[i+1][j] = tmp[j];
	}
	mint ans = 0;
	rep(j,N) ans += dp[N][j];
	cout<<ans<<endl;
}

Measured memory_bytes: 35712
// D.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char *argv[])
{
	int n, ans = 0;
	cin >> n;
	int a[100001];
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; ++i) {
		if (a[i] == i) {
			++ans;
			if (i == n || (i > 1 && a[i - 1] == i - 1)) {
				swap(a[i - 1], a[i]);
			} else {
				swap(a[i], a[i + 1]);
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int l,r;
int main(){
	scanf("%d%d",&l,&r);
	if(l>r)swap(l,r);
	if(l<=0&&0<=r)puts("Zero");
	else if(l>0||(r-l)&1)puts("Positive");
	else puts("Negative");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int A,B;
    cin >> A >> B;
    if (A + B >= 24){
        cout << A + B - 24 << endl;
    }
    else{
        cout << A + B << endl;
    }
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Queue;

public class Main implements Runnable{

	public static void main(String[] args) {
		new Thread(null,new Main(), "" ,Runtime.getRuntime().maxMemory()).start();
	}
	
	int gcd(int a,int b) {
		return a==0?b:gcd(b%a,a);
	}
	
	public void run() {
		FastScanner sc=new FastScanner();
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		if(C%gcd(A,B)!=0) {
			System.out.println("NO");
		}else {
			System.out.println("YES");
		}
		
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 23252
#include<iostream>

using namespace std;

bool isPrime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n!=1;
}

int main() {
	long long int n, ans = 1, a[1000] = {},c=0,p;
	cin >> n;
	for (int i = 2; i <= n; i++) {
		if (isPrime(i)) {
			for (int j = 2; j <= n; j++) {
				if (j%i == 0){
					p = j;
					while (1) {
						
						if (p%i != 0)break;
						p = p / i;
						a[c]++;
					}
				}
			}
			c++;
		}
		
	}
	for (int i = 0; i < 1000; i++) {
		if (a[i] == 0)break;
		ans = ans*(a[i] + 1)%1000000007;
		
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
### constant

INF = 1 << 30

BLK_X = -1
BLK_T = 10

LEG_L = 0
LEG_R = 1

DXYS = [
  [[1, -2],
   [1, -1], [2, -1],
   [1,  0], [2,  0], [3, 0],
   [1,  1], [2,  1],
   [1,  2]],
  [[-1, -2],
   [-1, -1], [-2, -1],
   [-1,  0], [-2,  0], [-3, 0],
   [-1,  1], [-2,  1],
   [-1,  2]]
]

### main

loop do
  w, h = gets.split.map(&:to_i)
  break if (w | h) == 0

  blks = h.times.map{[]}
  starts = []

  for y in (0...h)
    line = gets.strip.split
    for x in (0...w)
      case line[x]
      when 'S'
        starts << [x, y]
        blks[y][x] = 0
      when 'T'
        blks[y][x] = BLK_T
      when 'X'
        blks[y][x] = BLK_X
      else
        blks[y][x] = line[x].to_i
      end
    end
  end
  #p blks
  #p starts

  dists = h.times.map{w.times.map{2.times.map{INF}}}
  q = []

  starts.each do |x, y|
    dists[y][x][LEG_L] = dists[y][x][LEG_R] = 0
    q += [[x, y, LEG_L], [x, y, LEG_R]]
  end

  min_dist = INF

  while ! q.empty?
    u = q.min{|a, b| dists[a[1]][a[0]][a[2]] <=> dists[b[1]][b[0]][b[2]]}
    q.delete(u)

    ux, uy, ulr = u
    ud = dists[uy][ux][ulr]
    vlr = (ulr ^ 1)

    DXYS[ulr].each do |dx, dy|
      vx = ux + dx
      vy = uy + dy

      if vx >= 0 && vx < w && vy >= 0 && vy < h
        blk = blks[vy][vx]
        next if blk == BLK_X

        if blk == BLK_T
          min_dist = ud if min_dist > ud
          next
        end

        vd = dists[vy][vx][vlr]
        nvd = ud + blk

        if vd > nvd
          q << [vx, vy, vlr] if dists[vy][vx][vlr] >= INF
          dists[vy][vx][vlr] = nvd
        end
      end
    end
  end

  puts (min_dist >= INF ? -1 : min_dist)
end

Measured memory_bytes: 6128
#include<iostream>
using namespace std;
string s,t;
int main(){
    int i,c=0;
    cin >> s;
    cin >> t;
    for(i=0;(i<s.size())&&(i<t.size());++i){
        if(s.at(i)!=t.at(i)){
            ++c;
        }
    }
    cout << c << endl;


 

}

Measured memory_bytes: 3876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,t;cin>>n>>t;
  ll a[n],i,j,k,m,ans=0;
  for(i=n;i>0;i--) cin >> a[i-1]; 
  m=a[0];k=0;
  for(i=1;i<n;i++){
    if(a[i]>m){
      m=a[i];
    }else{
      if(m-a[i]>k){
	ans=1;
	k=m-a[i];
      }else if(m-a[i]==k){
	ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int i,n,count=0,flag=0;
    char s[100000];
    gets(s);
    for(n=0;s[n]!='\0';n++);
    for(i=0;i<n;i+=2)
        if(s[i]!='0')
        count++;
    for(i=1;i<n;i+=2)
        if(s[i]!='1')
        count++;
    for(i=0;i<n;i+=2)
        if(s[i]!='1')
        flag++;
    for(i=1;i<n;i+=2)
        if(s[i]!='0')
        flag++;
    if(count<flag)
        printf("%d",count);
    else
        printf("%d",flag);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

int t[300][300] = {};

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

    int h, w, k;
    cin >> h >> w >> k;

    int b0 = 0;
    char s[301];
    for (int i = 0; i < h; i++) {
        cin >> s;

        int b = 0;
        for (int j = 0; j < w; j++) {
            if (s[j] == '#') {
                b = 1;
                break;
            }
        }
        if (b) {
            b = 0;
            for (int j = 0; j < w; j++) {
                if (s[j] == '#') {
                    if (b == 0) b = 1; else k--;
                }
                t[i][j] = k;
            }
            k--;
            b0 = 1;
        } else {
            if (b0) {
                for (int j = 0; j < w; j++) {
                    t[i][j] = t[i - 1][j];
                }
            }
        }
    }
    for (int i = h - 1; i >= 0; i--) {
        if (t[i][0] == 0) {
            for (int j = 0; j < w; j++) {
                t[i][j] = t[i + 1][j];
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << t[i][j] << ' ';
        }
        cout << '\n';
    }

    return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

#define MAX 100001
#define ZERO -1 //親なし

typedef struct Node{
  int parent; 
  int left;
  int right;
}Tree;

Tree tree[MAX];

void Treeprint(int); //print関数

int main(){
  int n; //節点の個数
  int i,j; //ループカウンタ
  int id,k,child; //
  int l;

  scanf("%d", &n); //個数入力

  for(i = 0;i < n;i++){
    tree[i].parent = tree[i].left = tree[i].right = ZERO; //初期化
  }
  
  for(i = 0;i < n;i++){
    scanf("%d%d",&id,&k); //id・kの入力
    
    for(j = 0;j < k;j++){
      scanf("%d",&child); //子供・葉の入力
      tree[child].parent = id; 

      if(j == 0){
	tree[id].left = child; //左下の子供
      }
      else if(j > 0){
	tree[l].right = child; //兄弟
      }
      l = child; //兄弟
    }
  }
  for(i = 0;i < n;i++){ //出力
    Treeprint(i);
  }
  return 0;
}

void Treeprint(int n){ 

  int i = tree[n].parent; //親idの代入
  int depth = 0;
  while(i != ZERO){
    i = tree[i].parent;
    depth++;
  }
  if(depth == 0){
    printf("node %d: parent = %d, depth = %d, root, ",n,tree[n].parent,depth);
  }
  else if(tree[n].left == ZERO){
    printf("node %d: parent = %d, depth = %d, leaf, ",n,tree[n].parent,depth);
  }
  else{
    printf("node %d: parent = %d, depth = %d, internal node, ",n,tree[n].parent,depth);
  }

  i = tree[n].left;
  printf("[");
  if(i != ZERO){ //兄弟の表示
    printf("%d",i);
  }
  while(i != ZERO){ 
    i = tree[i].right;

    if(i != ZERO){
      printf(", %d", i);
    }
  }
  printf("]\n");
}

Measured memory_bytes: 1788
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cassert>
#include <string.h>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  rrep(i,n) for(int i=n-1;i>=0;i--)///n-1番目からn回
#define  REP(i,a,b) for(int i=a;i<b;i++) ///a番目からb回
#define  RREP(i,a,b) for(int i=a;i<b;i--)
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;



//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());
///*min_element(hoge.begin(),hoge.end();　最小値　　　最大値はmax_element();

#define Ru(n)  ( ((n)+9)/10*10  ) //切りあげ
#define Rd(n)  ( ((n)-10)/10*10 +10 )	切り捨て

int gcd(int a,int b);
int main() {
	int ans=0;
	vi a(10);
	rep(i,5){
		cin>>a[i];
		ans+=Ru(a[i]);
	}
	int max=(a[0])*(-1)%10,t=0;
	rep(i,5){
		if(max<(10-(a[i]%10))%10){
			max =(10-(a[i]%10))%10 ;
			t = i;

		}
	}


		cout<<ans-max;
}







int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}


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

public class Main {

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

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String op;
      String[] words;
      Tree tree = new Tree();

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        op  = words[k++];
        if ( op.equals("insert") ) { 
          tree.insert(Integer.parseInt(words[k++]));
        }
        else {
          tree.dispRoundPath();
        }
      }

    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final BTreeNode NIL = new BTreeNode(-1);
  BTreeNode root;
  StringBuilder buf;

  public Tree() {
    root = NIL;
    buf = new StringBuilder();
  }

  public void insert(int val) {
    BTreeNode y = NIL;
    BTreeNode x = root;
    BTreeNode z = new BTreeNode(val);

    while( !x.equals(NIL) ) {
      y = x;
      if( z.key < x.key )
        x = x.left;
      else
        x = x.right;
    }
    z.parent = y;

    if( y.equals(NIL) ){
      root = z;
    }
    else if( z.key < y.key )
      y.left = z;
    else
      y.right = z;
  } 
  void preParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      buf.append(" ").append(u.key);
      preParse(u.left);
      preParse(u.right);
    }
  }
  void inParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      inParse(u.left);
      buf.append(" ").append(u.key);
      inParse(u.right);
    }
  }

  void dispRoundPath() {

    inParse(root);
    buf.append("\n");
    preParse(root);
    buf.append("\n");

    System.out.print(buf);
    buf.setLength(0);
  }
}

class BTreeNode {
  int key;
  BTreeNode parent,left,right;

  public BTreeNode(int key) {
    this.key = key;
    this.parent =
    this.left =
    this.right = Tree.NIL;
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof BTreeNode)) return false;

    BTreeNode node = (BTreeNode)o;
    if(!(this.key == node.key)) return false;

    return true;
  }
}


Measured memory_bytes: 125944
#include<bits//stdc++.h>
using namespace std;
int main(){
	double a,b;
	while(cin>>a>>b,a||b){
		double c=a*a;
		a/=2;
		double d=sqrt(b*b+a*a);
		c+=a*d*4;
		printf("%.10lf\n",c);
	}
}

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

int main(){
  int N,X;
  cin >> N >> X;
  int m;
  int a;
  for (int i=0;i<N;i++){
    cin >> m;
    a= i==0?m:min(m,a);
    X-=m;
  }
  cout << N+X/a << endl;
}


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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int r = 0;
  int w = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'R')
      r++;
    else
      w++;
  }
  string t = "";
  while (r--) t += "R";
  while (w--) t += "W";
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    cnt += (s[i] != t[i]);
  }
  cout << cnt / 2 << endl;
  return 0;
}

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

int XX(int a, int d){
	return a * a * d;
}

int main(){
	int d;
	while (true){
		int sum = 0;
		cin >> d;
		if (cin.eof()) { break; }
		for (int i = 0;i<600/d;i++){
			sum += XX(i*d, d);
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
# 初期入力
import sys
input = sys.stdin.readline
N,M = (int(i) for i in input().split())
X = list(map(int, input().split()))
if N >=M:
    ans =0
else:
    X.sort()
    dif =[-1]*(M-1)
    for i in range(M-1):
        dif[i] =X[i+1] -X[i]
    dif.sort()
    ans =dif[:M-N]
    ans =sum(ans)
print(ans)

Measured memory_bytes: 20644
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define in auto&it
#define out auto it
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
const double pi = acos(-1);
#define error(x) cerr<<#x<<" = "<<x<<'\n';
int main() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
		freopen("error.txt", "w", stderr);
	#endif
	fastio
	double n,x,t;
	cin>>n>>x>>t;
	int ans=ceil(n/x)*t;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3752
#include<iostream>
using namespace std;
int main(){
    int a;
    cin>>a;
    int k=0;
    for(int i=1;i<=a;i++){
        int x,y;
        cin>>x>>y;
        if(x==y)
        k++;
        else {
            if(k>=3)
            continue;
            else k=0;
        }
    }
    if(k>=3)
    cout<<"Yes"<<endl;
    else {
        cout<<"No"<<endl;
    }
    system("pause");
}

Measured memory_bytes: 3140
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r;};

Node T[MAX];
int n, D[MAX];

void Print(int u)
{
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if ( T[u].p == NIL) cout << "root, ";
    else if( T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r)
    {
        if (i > 0) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

void rec(int u, int p)
{
    D[u] = p;
    if (T[u].r != NIL) rec(T[u].r, p);
    if (T[u].l != NIL) rec(T[u].l, p + 1);
}

int main()
{
    int i, j, d, v, c, l, r;
    cin >> n;
    for (i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;

    for (i = 0; i < n; i++)
    {
        cin >> v >> d;
        for (j = 0; j < d; j++)
        {
            cin >> c;
            if ( j == 0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for (i = 0; i < n; i++)
    {
        if (T[i].p == NIL) r = i;
    }

    rec(r, 0);

    for (i = 0; i < n; i++) Print(i);

    return 0;
}


Measured memory_bytes: 7744
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define ld long double
typedef pair<ll,ll> pll;
typedef pair<pll,pll> ppll;
typedef vector <ll> vi;
#define out(x) return cout<<x,0;
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define lc(n) 2*n+1
#define rc(n) 2*n+2
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

int main(){
	FAST;
    ll n, k, m, z = 0, ans = 0, j, t = 0, x = 0, y = 0, c = 0, i;
   	cin >> n >> k;
   	if ( n*500 >= k ) cout << "Yes\n";
   	else cout << "No\n";
}

Measured memory_bytes: 256
# 締切が近い順に処理する（締め切り時間が同じならかける時間は関係ない）

n = int(input())

# こういう処理pythonでうまくやる方法ないのかな ...
hash = {}
for _ in range(n):
    a, b = map(int, input().split())
    if b in hash:
        hash[b].append(a)
    else:
        hash[b] = [a]
arr = []
for k, v in hash.items():
    arr.append([k, v])
arr = list(sorted(arr, key=lambda x: x[0]))

count = 0
for a in arr:
    for ai in a[1]:
        if count + ai > a[0]:
            print("No")
            exit()
        else:
            count += ai
print("Yes")


Measured memory_bytes: 72004
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    K, X = LI()

    ans = list(range(X - K + 1, X + K))
    print(*ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9996
N, M = map(int, input().split())
A = sorted([int(i) for i in input().split()])
C = sorted([[int(i) for i in input().split()] for i in range(M)], reverse = True, 
           key = lambda x: x[1])
 
cnt = 0
B = []
for i in range(M):
    if cnt > N:
        break
    B += [C[i][1]] * C[i][0]
    cnt += C[i][0]
    
x = min(N, len(B))

for i in range(x):
    A[i] = max(A[i], B[i])
    
print(sum(A))

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

bool frag(int N,std::vector<int> v){
  while(N>0){
    int num = N%10;
    if(v[num] == 1){
      return false;
    }
    N/=10;
  }
  return true;
}
int main() {
  int N,K,D;
  vector<int> v(10);
  cin >> N >> K;
  rep(i,K){
    cin >> D;
    v[D]++;
  }
  for(;;N++){
    if(frag(N,v)){
      break;
    }
  }
  cout  << N << endl;
  return 0;
}


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

c = 0
f = 25
s = 14
flag = "No"

for i in range(1,f):
  c = N - (i * 4)
  for j in range(1,s):
    if c >= 0 and c % (7 * j) == 0 and c >= 7 * j:
      flag = "Yes"
    
if N % 4 == 0 or N % 7 == 0:
  flag = "Yes"
  
print(flag)

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

    ll N;
    cin >> N;
    string S;
    cin >> S;

    ll sum_E[N];//i番目の人がリーダーだったトキに、Eを向く人の数
    ll sum_W[N];

    for(int i = 0; i < N; i++){
        sum_E[i] = 0;
        sum_W[i] = 0;
    }

    for(int i = 0; i < N-1; i++){
        if(S[i] == 'W'){
            sum_E[i+1] = sum_E[i]+1;
        }else{
            sum_E[i+1] = sum_E[i];
        }
    }

    for(int i = N-1; i > 0; i--){
        if(S[i] == 'E'){
            sum_W[i-1] = sum_W[i]+1;
        }else{
            sum_W[i-1] = sum_W[i];
        }
    }

    ll ans = INF;
    for(int i = 0; i < N; i++){
        chmin(ans, sum_W[i]+sum_E[i]);
    }

    cout << ans << endl;


    return 0;
}


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

int main() {
  int n, w, z;
  std::cin >> n >> z >> w;
  std::vector<int> cards(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> cards[i];
  }
  int score;
  if (n == 1) {
    score = std::abs(cards[0] - w);
  } else {
    score = std::max(std::abs(cards[n - 1] - w), std::abs(cards[n - 2] - cards[n - 1]));
  }

  std::cout << score << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 998244353
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int H,W,A,B;
  cin>>H>>W>>A>>B;
  
  for(int i=1; i<=H; ++i){
    if(i<=B){
      for(int j=1; j<=A; ++j) cout<<0;
      for(int j=A+1; j<=W; ++j) cout<<1;
    }
    else{
      for(int j=1; j<=A; ++j) cout<<1;
      for(int j=A+1; j<=W; ++j) cout<<0;
    }
    cout<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int sum=0;
  int x = n;
  int num = 1000000000;
  for(int i=0; i<10; i++){
    int s = n / num;
    n = n % num;
    num = num / 10;
    sum += s;
  }
  
  if(x % sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
f a b =
  let i = (a*10) `div` b
      o = (a*10) `mod` b
  in
    i:(f o b)

ans (a:b:n:_) =
  sum $ take n $ f (a`mod`b) b

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c
      o = map ans i
  mapM_ print o

Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 10000000005
#define NIL -1
int main(){
    ll n; cin >> n;
    ll a[n];
    bool flag = false;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        if(a[i]%2 == 1) flag = true;
    }
    if(flag) cout << "first" << endl;
    else cout << "second" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int N;
  	bool x;
    cin >> N ;
    int p[N+1][3];
    p[0][0]=p[0][1]=p[0][2]=0;
  	for (int i=1;i<N+1;i++)
    {
      for(int j=0;j<3;j++)
      {
          cin >> p[i][j];
      }
    }
  	for(int i=0;i<N;i++)
    {
      if((p[i+1][0]-p[i][0])%2==abs(p[i+1][1]+p[i+1][2]-p[i][1]-p[i][2])%2  && p[i+1][0]-p[i][0]>=abs(p[i+1][1]-p[i][1])+abs(p[i+1][2]-p[i][2]))
      x = true;
      else 
      {
          x = false;
          break;
      }
    }
	if(x)
	cout << "Yes" << endl;
	else
	cout << "No" << endl;
}


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

namespace ABC156C
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int min = x.Min();
            int max = x.Max();
            int center = (int) Math.Ceiling(x.Average());

            long ans = long.MaxValue;
            for (int i = 1; i <= center; i++)
            {
                long sum = 0;
                foreach (var item in x)
                {
                    sum += (long)Math.Pow((item - i), 2);
                }
                ans = Math.Min(ans, sum);
            }

            Console.WriteLine(ans);
        }
    }
}


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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            string result = (n + n*n + n*n*n).ToString();

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

int main(int argc, char const* argv[])
{
    int a, b;
    cin >> a;
    cin >> b;
    if (a <= 8 && b <=8) {
        cout << "Yay!" << endl;
    }
    else {
        cout << ":(" << 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 a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		// 文字列の入力
		String s = sc.next();
        String sa[];
        sa = new String[s.length()];
        int countA = 0;
        int countB = 0;
        int countY = 0;
        for(int i=0; i<s.length(); i++){
            if(i < s.length() -1){
            sa[i] = s.substring(i, i+1);
            }
            else{
            sa[i] = s.substring(i);
            }
            switch (sa[i]){
                case "a":
                    countA = countA + 1;
                    if(countY < a + b){
                        countY = countY + 1;
                        		System.out.println("Yes" + "\n");
                    }
                    else{
                                System.out.println("No" + "\n");
                    }
                    break;
                case "b":
                    countB = countB + 1;
                    
                    if(countY < a + b && countB <= b){
                        countY = countY + 1;
                                System.out.println("Yes" + "\n");
                    }
                    else{
                                System.out.println("No" + "\n");
                    }
                    break;
                case "c":
                                System.out.println("No" + "\n");
                    break;
            }
        }
		// 出力
	}
}

Measured memory_bytes: 33528
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	char a[10001]={},i;
	cin>>a;
	cout<<a[0];
	cin>>a;
	cout<<a[0];
	cin>>a;
	cout<<a[0];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if(U == S)
        cout << A - 1 << " " << B;
    else if(U == T)
        cout << A << " " << B - 1;
}

Measured memory_bytes: 256
N=int(input())
S=[input() for i in range(N)]
C0=str(S.count("AC"))
C1=str(S.count("WA"))
C2=str(S.count("TLE"))
C3=str(S.count("RE"))
print("AC x "+C0)
print("WA x "+C1)
print("TLE x "+C2)
print("RE x "+C3)

Measured memory_bytes: 79292
l,r = map(int,input().split())

def mod(x,y):
    return (x*y)%2019

ans = 2020
if l-r >= 2019:
    ans = 0
elif l-r < 2019:
    for i in range(l,r,1):
        for j in range(i+1,r+1,1):
            temp = mod(i,j)
            ans = min(temp,ans)
            if ans == 0:
                break
        else:
            continue
        break

print(ans)



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

bool has3(int x){
while(x){
if(x % 10 == 3) return true;
x /= 10;
}
return false;
}
void call (int n){
for(int x = 1; x <= n; x++){
if(x % 3==0 || has3(x) ){
cout <<" "<< x;
}
}
cout << endl;
}
int main(){
int n;
cin >> n;
call(n);
return 0;
}


Measured memory_bytes: 3088
def is_prime(x):
    if x==2:
        return 1
    if x<2 or x%2==0:
        return 0
    i=3
    while i<=x**0.5:
        if x%i==0:
            return 0
        i+=2
    return 1

n=int(input())
a=[int(input()) for i in range(n)]
c=0
for i in range(n):
    c+=is_prime(a[i])
print(c)



Measured memory_bytes: 5992
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	a := nextInts(n)

	if a[0] > 0 {
		puts(-1)
		return
	}

	ans := 0
	b := make([]int, n)
	for i := n - 1; i > 0; i-- {
		if a[i] == b[i] {
			b[i-1] = b[i] - 1
			continue
		}
		if a[i] > i {
			puts(-1)
			return
		} else if b[i] > a[i] {
			puts(-1)
			return
		}
		ans += a[i]
		b[i-1] = a[i] - 1
	}

	puts(ans)
}


Measured memory_bytes: 6516