akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cassert>
#include<climits>
#include<cstring>
#include<cassert>
#include<algorithm>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>

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

using namespace std;

#define MAX 51
int N,M;
string c[MAX];
bool visited[MAX][MAX][4];
bool path[MAX][MAX][4];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

inline bool isValid(int x,int y) { return 0 <= x && x < M && 0 <= y && y < N; }

inline bool check(int x,int y) { rep(i,4) if( path[y][x][i] ) return true; return false; }

struct Point { int x,y; };

void normalize() {
  deque<Point> deq;
  rep(i,N) rep(j,M) {
    int cnt = 0;
    int dir = -1;
    rep(k,4) {
      int nx = j + dx[k], ny = i + dy[k];
      if( !isValid(nx,ny) ) continue;
      if( c[ny][nx] == '#' ) continue;
      ++cnt;
      dir = k;
    }
    if( cnt == 1 ) {
      c[i][j] = '#';
      deq.push_back((Point){j+dx[dir],i+dy[dir]});
    }
  }
  while( !deq.empty() ) {
    Point p = deq.front(); deq.pop_front();
    int cnt = 0;
    int dir = -1;
    rep(i,4) {
      int nx = p.x + dx[i], ny = p.y + dy[i];
      if( !isValid(nx,ny) ) continue;
      if( c[ny][nx] == '#' ) continue;
      ++cnt;
      dir = i;
    }
    if( cnt == 1 ) {
      c[p.y][p.x] = '#';
      deq.push_back((Point){p.x+dx[dir],p.y+dy[dir]});
    }
  }
}

bool dfs(int x,int y,int dir) {
  if( x == 1 && y == 0 ) {
    if( !check(M-1,0) || !check(0,N-1) || !check(M-1,N-1) ) return false;
    return true;
  }
  rep(i,4) {
    int xdir = ( dir + i ) % 4;
    int nx = x + dx[xdir], ny = y + dy[xdir], ndir = xdir;
    if( !isValid(nx,ny) ) {
      nx = x, ny = y;
      ( ndir += 1 ) %= 4;
    } else {
      if( c[ny][nx] == '#' ) {
	( ndir += 1 ) %= 4;
	nx = x, ny = y;
      } else {
	int lx = nx + dx[(ndir+3)%4], ly = ny + dy[(ndir+3)%4];
	if( isValid(lx,ly) && c[ly][lx] != '#' ) ( ndir += 3 ) %= 4;
      }
    }
    if( !( x == nx && y == ny ) && check(nx,ny) ) continue;
    if( visited[ny][nx][ndir] ) continue;
    visited[ny][nx][ndir] = true;
    path[ny][nx][ndir] = true;
    //return dfs(nx,ny,ndir);
    if( dfs(nx,ny,ndir) ) return true;
    path[ny][nx][ndir] = false;
  }  
  return false;
}

bool compute() {
  //normalize();

  memset(visited, false, sizeof visited);
  memset(path, false, sizeof path);
  int x=0,y=0;
  int dir = 0;
  visited[0][0][0] = true;
  path[0][0][0] = true;
  return dfs(0,0,0);
}

int main() {
  while( cin >> N >> M, N|M ) {
    rep(i,N) cin >> c[i];
    puts(compute()?"YES":"NO");
  }
  return 0;
}

Measured memory_bytes: 3392
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;
int dp[2][2020];
int main()
{
    int n,i,ct,j;
    string v;
    cin>>v;
    n=v.size();
    if(n<=4)
    {
        printf("0");
        return 0;
    }
    int x=((v[3]-'0')+(v[2]-'0')*10+(v[1]-'0')*100+(v[0]-'0')*1000);
    dp[0][((v[3]-'0')+(v[2]-'0')*10+(v[1]-'0')*100+(v[0]-'0')*1000)%2019]++;
    dp[0][(v[3]-'0')+(v[2]-'0')*10+(v[1]-'0')*100]++;
    dp[0][(v[3]-'0')+(v[2]-'0')*10]++;
    dp[0][(v[3]-'0')]++;
    long long rez=0;
    for(i=4,ct=1; i<n; i++,ct=1-ct)
    {
        for(j=0; j<=2019; j++)
            dp[ct][j]=0;
        for(j=0; j<=2019; j++)
            dp[ct][(j*10+v[i]-'0')%2019]+=dp[1-ct][j];
        dp[ct][v[i]-'0']++;
        rez+=dp[ct][0];
    }
    printf("%I64d",rez);

    return 0;
}


Measured memory_bytes: 3800
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
 
class Program {
    static int[,] Step;
    static long H;
    static long W;
    static string[] grid;
    static void Main(string[] args) {
        var HW  = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray();
        H = HW[0];
        W = HW[1];
        
        //マスの合計値
        var sum = H*W;
       
        //マスの情報を記録する
        grid = new string[H];
        for(int i = 0; i < H;i++){
          grid[i] = Console.ReadLine();
        }
      
        //通行不可能なマスの数を調べる
        var imp = 0; 
        for(int i = 0; i < H;i++){
          for(int j = 0; j < W;j++){
            if(grid[i][j] == '#'){
              imp++;
            }
          }
        }
        //通行可能なマスの総数
        var avl = sum-imp; 

        //幅優先探索でゴールまでの最短距離を求める
        Step = new int[H+1,W+1];
        WidthFirstSearch(1,1);
        var MinStep = Step[H,W];
        if(MinStep > 0){
          Console.WriteLine(avl-(MinStep));
        }else{
          Console.WriteLine(-1);
        }
        
  }
  
  static void WidthFirstSearch(long H1,long W1){
    var queue = new MyQueue();
    if(grid[0][0] == '.'){
      queue.Enque(H1,W1);
    }
    Step[H1,W1] = 1;
    
    while (!(queue.isEmpty())){
      var top = queue.Deque();
      var tH = top.H;
      var tW = top.W;
      
      //上をキューに登録
      if(tH > 1 && Step[tH-1,tW] == 0&& grid[(int)(tH-2)][(int)(tW-1)] == '.'
        ){
        
        Step[tH-1,tW] = Step[tH,tW]+1;
        queue.Enque(tH-1,tW);
      }
      //下をキューに登録
      if(tH < H && Step[tH+1,tW] == 0 && grid[(int)(tH)][(int)(tW-1)] == '.'){
        Step[tH+1,tW] = Step[tH,tW]+1;
        queue.Enque(tH+1,tW);
      }
      //右をキューに登録
      if(tW < W && Step[tH,tW+1] == 0 && grid[(int)(tH-1)][(int)(tW)] == '.'){
        Step[tH,tW+1] = Step[tH,tW]+1;
        queue.Enque(tH,tW+1);
      }
      //左をキューに登録
      if(tW > 1 && Step[tH,tW-1] == 0 && grid[(int)(tH-1)][(int)(tW-2)] == '.'){
        Step[tH,tW-1] = Step[tH,tW]+1;
        queue.Enque(tH,tW-1);
      }
      
      
    }
  }
         
}

class MyQueue
{
    public Masu[] datas = new Masu[5000];
    public int enpoint = -1;
    public int depoint = -1;
    public void Enque(long H,long W)
    {
        this.enpoint++;
        var data = new Masu(H,W);
        datas[this.enpoint] = data;
    }
    public Masu Deque()
    {
        this.depoint++;
        return datas[this.depoint];
    }
 
    public bool isEmpty()
    {
        return (this.depoint == this.enpoint);
    }
}

class Masu
{
  public long H;
  public long W;
  public Masu(long H,long W){
    this.H = H;
    this.W = W;
  }
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    rep(i,N){
        cin >> A[i];
    }
    rep(i,M){
        cin >> B[i];
    }
    deque<ll> que;
    bool flag = false;
    ll sum = 0;
    ll ind = -1;
    rep(i,N){
        if(sum + A[i] > K){
            flag = true;
            ind = i;
            break;
        }
        que.push_back(A[i]);
        sum += A[i];
    }
    bool flag2 = false;
    ll ind2 = 0;
    if(!flag){
        rep(i,M){
            if(sum + B[i] > K){
                flag2 = true;
                ind2 = i;
                break;
            }
            //que.push_back(B[i]);
            sum += B[i];
        }
    }
    ll ans;
    if(!flag){
        if(!flag2){
            cout << N+M << endl;
            return 0;
        }else{
            ans = N + ind2;
        }
    }else{
        ans = ind;
    }
    //cout << ans << endl;
    //cout << sum << endl;
    ll num = ans;
    REP(i,ind2,M){
        num++;
        //que.push_back(B[i]);
        sum += B[i];
        while(sum > K && !que.empty()){
            ll t = que.back();
            que.pop_back();
            sum -= t;
            num--;
        }
        if(sum > K) break;
        cmax(ans,num);
    }
    cout << ans << endl;
}


Measured memory_bytes: 8008
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    string S, T; cin >> S >> T;
    int ans = 0;
    rep(i, S.length()) {
        if (S[i] != T[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3836
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    a = list(map(int, input().split()))

    rank = [400*(i+1) for i in range(8)] + [10000]
    count = [0] * len(rank)

    for i in range(N):
        for j in range(len(rank)):
            if a[i] < rank[j]:
                count[j] += 1
                break
    ans = 0
    for i in range(len(count) - 1):
        if count[i] > 0:
            ans += 1
    if ans == 0:
        print(1, count[-1])
    else:
        print(ans, ans+count[-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> a(n + 1);
  vector<bool> b(n + 1, false);
  REP(i, 0, n) cin >> a[i + 1];
  int idx = 1, cnt = 0;
  while (!b[idx]) {
    b[idx] = true;
    idx = a[idx];
    cnt++;
    if (idx == 2) {
      cout << cnt << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 640
#define ll long long
#include <bits/stdc++.h>
int dp[100005][4];
int n,k,trace = 0;
int value[100005][4];
int weight[100005];
using namespace std;
ll solve(int i, int o)
{
    //int trace2=trace;
    if(i>n)
        return 0;
    if(dp[i][o] != -1)
        return dp[i][o];
    ll sum  = 0,temp  =0;
   for(int j = 1 ; j<= 3 ; j++ )
   {
    if(j!=o)
    {
        //trace = j ;
   // cout<<"trace is "<<i<<" "<<o<<endl;
    sum = value[i][j] + solve(i+1,j);
    temp = max(temp,sum);

    }

   }
   //trace=trace2;
   dp[i][o] = temp;
   return temp;
}
int main()
{
    int w;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=3;j++)
        cin>>value[i][j];
    }
    int answer = max(max( solve(1,1), solve(1,2)), solve(1, 3));
    cout<<answer<<endl;
   /* for( int i = 1; i <= n ; i++ )
    {

    for(int j=1 ; j <= 3 ; j++ )
    {
        cout<<dp[i][j]<<" ";
    }
    cout<<endl;
    }*/
    /*int maxs = 0,val;
    for(int j = 1 ; j <= 3 ; j++ )
    {
        if(maxs<a[n][j]){
            maxs  = a[n][j];
            val  =j;
        }
    }
    trace[val]++;
    dp[n] = maxs;
    for(int i = n-1;i>=1;i--){
    maxs = 0;
    for(int j = 1 ; j <= 3 ; j++ )
    {
        if(maxs<a[i][j]){
            maxs  = a[i][j];
            val= j;
        }
    }
    trace[val]++;
   // cout<<"trace of current "<<val<<" is : "<<trace[val];
    if(trace[val] < 2 )
    dp[i] = maxs + dp[i+1];
    else
    {
        int out = val;
        trace[val] = 0;
        maxs = 0;
        for(int j=1;j<=3;j++)
        {
            if(out!=j && maxs<a[i][j])
            {
                maxs = a[i][j];
                val  = j;
     //           cout<<"in here ";
            }
        }
        trace[val]++;
        dp[i] = maxs + dp[i+1];
   //     cout<<endl<<"current maxs is "<<maxs;
    }
    cout<<dp[i]<<" ";
    }
    /*
    for(int i=1;i<=n;i++)
    {
        cout<<dp[i]<<" ";
    }
    cout<<endl;*/
    //cout<<solve(1);
   // cout<<dp[1];
}


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

int main()
{
    int a,b;
    cin >> a >> b;
    if( int(a/10) < 1 && int(b/10) < 1 ){
        cout << a*b << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>

const int INF = 1001001000;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

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

  int tmp = n;
  f = 0;
  while( tmp > 0){
    f += tmp%10;
    tmp /= 10;
  }
  if( n%f == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

int main(){
  int N, Q;
  cin >> N >> Q;
  dsu ds(N);
  for(int i=0; i<Q; i++){
    int t, u, v;
    cin >> t >> u >> v;
    if(t == 0){
      ds.merge(u, v);
    }
    else{
      cout << ds.same(u, v) << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3988
aris_card , bob_card = map(int, input(). split())

if aris_card == 1:
    aris_card += 13
if bob_card == 1:
    bob_card += 13

if aris_card == bob_card:
    print( "Draw" )
elif aris_card > bob_card:
    print( "Alice" )
elif aris_card < bob_card:
    print( "Bob" )

Measured memory_bytes: 9112
#include "bits/stdc++.h"
using namespace std;
/*
long long min4(long long &w,long long &x,long long &y,long long &z) {
	return min(w,min(x,min(y,z)));
}

long long max4(long long &w, long long &x, long long &y, long long &z) {
	return max(w, max(x, max(y, z)));
}*/
long long min4(long long w, long long x, long long y, long long z) {
	return min(w, min(x, min(y, z)));
}

long long max4(long long w, long long x, long long y, long long z) {
	return max(w, max(x, max(y, z)));
}
int main() {
	int N;
	cin >> N;
	vector<long long>A(N);
	vector<long long>Sum(N + 1);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		Sum[i + 1] = Sum[i] + A[i];
	}
	int l = 0;
	int r = 2;
	long long ans = 1e18;
	for (int c = 1; c <= N - 3; ++c) {
		{
			long long absl = 1e18;
			for (int i = l; i < c; ++i) {
				long long x = Sum[i + 1] - Sum[0];
				long long y = Sum[c + 1] - Sum[i + 1];
				if (absl >  abs(x-y)) {
					absl = abs(x-y);
					l = i;
				}
				else {
					break;
				}
			}
		}
		{
			long long absr = 1e18;
			for (int j=r; j < N-1; ++j) {
				long long x = Sum[j + 1] - Sum[c + 1];
				long long y = Sum[N] - Sum[j + 1];
				if (absr > abs(x - y)) {
					absr = abs(x - y);
					r = j;
				}
				else {
					break;
				}
			}
		}
		long long ll = Sum[l + 1] - Sum[0];
		long long lr = Sum[c + 1] - Sum[l + 1];
		long long rl = Sum[r + 1] - Sum[c + 1];
		long long rr = Sum[N] - Sum[r + 1];
		//cout << l << "_" << c << "_" << r << endl;
		//cout << ll<<"_"<<lr<<"_"<<rl<<"_"<<rr<< endl;
		ans = min(ans,max4(ll,lr,rl,rr)-min4(ll,lr,rl,rr));
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 6400
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val s = readLine()!!
    val count = IntArray(2019)
    count[0] = 1
    var tmp = 0L
    var i = 1L
    for (c in s.reversed()) {
        tmp = (tmp + i * (c - '0')) % 2019
        count[tmp.toInt()]++
        i = (i * 10) % 2019
    }
    var ans = 0L
    for (j in count) {
        ans += j * (j - 1) / 2
    }
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


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

using namespace std;
const int MAX_T = 100100;
const long long INF = 1LL << 60;

template<class T> void chmin(T & a, T b) {
	if (a > b) a = b;
}

template<class T> void chmax(T & a, T b) {
	if (a < b) a = b;
}

int main() {
	int N; cin >> N;
	long long h[MAX_T];
	long long dp[MAX_T];
	for (int i = 0; i < N; i++) scanf("%lld", &h[i]);

	for (int i = 0; i < N; i++) {
		dp[i] = INF;
	}

	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
	}

	cout << dp[N-1] << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;

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

int main() {

	ll x, k, d;
	cin >> x >> k >> d;
	if (x < 0)x = -x;
	ll a, b, c;
	a = x % d;
	b = d - (x % d);
	c = x / d;
	ll ans;
	if (c > k) ans = x - k * d;
	else if ((k - c) % 2 == 0) ans = a;
	else ans = b;
	cout << ans;
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	int N;
	cin >> N;

	vector<int> H(N);
	for (auto&i:H) {
		cin >> i;
	}

	int result = 0;
	int max = 0;
	for (auto&i : H) {
		if (max <= i) {
			max = i;
			result++;
		}
	}

	cout << result << "\n";

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]"):
    c = dict([(0, 1)])
    total = 0
    res = 0
    for a in A:
        total = (total + a) % M
        c[total] = c.get(total, 0) + 1
        res += c[total] - 1
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19896
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll x; cin >> x;
    reprr(a, -1e3, 1e3) {
        reprr(b, -1e3, 1e3) {
            if (powl(a, 5) - pow(b, 5) == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4100
use std::io;
fn main(){
    let stdin = io::stdin();
    const MAX: i128 = 1000000000000000000;

    let _first_line = {
	let mut buf = String::new();
	stdin.read_line(&mut buf).unwrap();
	buf.retain(|c| c!='\n');
	buf.parse::<usize>().unwrap()
    };

    let second_line = {
	let mut buf = String::new();
	stdin.read_line(&mut buf).unwrap();
	buf.retain(|c| c!='\n');
	buf.split_whitespace().map(|n| n.parse::<i128>().unwrap()).collect::<Vec::<i128>>()
    };
    
    let mut res : i128 = 1;
    
    for n in second_line.iter(){
	let n = *n;
	res = if n == 0{
	    0
	}else if n * res > MAX || res == -1{
	    -1
	}else{
	    res * n
	};
	if res == 0{
	    break;
	}
    }
    
    println!("{}",res);
}


Measured memory_bytes: 5540
#include "bits/stdc++.h"
#include <random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
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; }
const lint MOD = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };

string s;
lint sum = 0;
int main() {
	cin >> s;
	REP(i, SZ(s)) {
		sum += (s[i] - '0');
	}
	if (sum % 9 == 0) {
		cout << "Yes" << endk;
	}
	else {
		cout << "No" << endk;
	}
}


Measured memory_bytes: 3740
#include <iostream>
#include <algorithm>
#define MAX 200005
using namespace std;

int n;
pair <int,int> y[MAX];
int rez[MAX];
int main()
{
    cin>>n;
    for (int i=1; i<=n; i++)
    {
        cin>>y[i].first;
        y[i].second=i;
    }

    sort(y+1,y+n+1);
    for (int i=1; i<=n; i++)
    {
        if (i<=n/2)
            rez[y[i].second]=y[n/2+1].first;
        else
            rez[y[i].second]=y[n/2].first;
    }
    for (int i=1; i<=n; i++)
        cout<<rez[i]<<"\n";

    return 0;
}


Measured memory_bytes: 4480
import java.util.Scanner;

public final class Main {
        public static void main(String[] args) {
                Scanner s = new Scanner(System.in);
                int h = s.nextInt();
                int w = s.nextInt();

                String[] img = new String[h];

                for (int i=0; i<h; i++) {
                        img[i] = s.next();
                }

                // print top border
                for (int i=0; i<w+2; i++)
                        System.out.print("#");
                System.out.println();

                //print main section
                for (int i=0; i<h; i++)
                        System.out.println("#"+img[i]+"#");

                for (int i=0; i<w+2; i++)
                        System.out.print("#");
                System.out.println();

        }       
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

struct person {
    string tefuda_s;
    queue<char> tefuda_q = parseString();

    char fetchTop() {
        if (tefuda_q.empty()) {
            return 0;
        }
        char res = (tefuda_q).front();
        (tefuda_q).pop();
        return res;
    }
    queue<char> parseString() {
        queue<char> q;
        for (int i = 0; i < tefuda_s.length(); ++i) {
            q.push(tefuda_s[i]);
        }
        return q;
    }
};

char upper(char c){
    if('a' <= c && c <= 'z'){
        c = c - ('a' - 'A');
    }
    return c;
}

int main(void){
    // input
    string a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;
    struct person A = {a};
    struct person B = {b};
    struct person C = {c};

    char now_person = 'a';
    char next_person;
    while (1) {
        if (now_person == 'a') next_person = A.fetchTop();
        else if (now_person == 'b') next_person = B.fetchTop();
        else if (now_person == 'c') next_person = C.fetchTop();
        
        // cout << "now : " << now_person << ", next : " << next_person << endl;
        
        if (next_person == 0) {
            cout << upper(now_person) << endl;
            break;
        } else {
            now_person = next_person;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
n=int(input())
li=list(map(int,input().split()))
li.sort()
if li[0]==0:
  print(0)
  sys.exit()
else:
  ans=1
  for i in li:
    ans*=i
    if ans>1000000000000000000:
        print(-1)
        sys.exit()
    else:
        continue
    
  if ans>1000000000000000000:
      print(-1)
  else:
      print(ans)

Measured memory_bytes: 21652
n=int(input())
a=list(map(int,input().split()))
c=0
d=0
for i in range(n):
    if a[i]%4==0:
        c+=1
    if a[i]%2!=0:
        d+=1
else:
    if (n%2==1 and c==n//2) or c>=d:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 14252
A,B=map(int,input().split())
print(100, 100)
resmap = [['.']*100 for _ in range(100)]

for i in range(A-1):
    from_btm = (i // 50)*2
    from_lft = (i % 50)*2
    resmap[99-from_btm][from_lft] = "."
    resmap[99-from_btm][from_lft+1] = "#"
    resmap[99-from_btm-1][from_lft] = "#"
    resmap[99-from_btm-1][from_lft+1] = "#"

for i in range(B-1+(A==1)):
    from_top = (i // 50)*2
    from_lft = (i % 50)*2
    resmap[from_top][from_lft] = "#"


for line in resmap:
    print(*line, sep="")


Measured memory_bytes: 4468
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
#define clr0(a) memset(a,0,sizeof(a))
#define clr1(a) memset(a,-1,sizeof(a))
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
int divisible[1000010],mp[1000010];
main()
{
    timesave;
    int n,a,i,cnt=0,mx=0,j;
    cin>>n;
    int ar[200005]={0};
    for(i=1;i<=n;i++)
    {
        cin>>a;
        ar[i]=a;;
        mp[a]++;
    }
    for(i=1;i<1000010;i++)
    {
        if(mp[i]>0)
        {
            for(j=i;j<1000010;j+=i)
            {
                divisible[j]+=mp[i];
            }
        }
    }
    for(i=1;i<=n;i++)
    {
       // cout<<ar[i]<<" "<<divisible[ar[i]]<<endl;
        if(divisible[ar[i]]<=1)
            {
                cnt++;
            }
    }
    cout<<cnt<<endl;
}




Measured memory_bytes: 12248
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
vector<ll> a,f;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    a.resize(n); f.resize(n);
    rep(i,0,n) cin>>a[i];
    rep(i,0,n) cin>>f[i];
    sor(a); sor(f); rev(f);
    ll ok=1e13, ng=-1;
    while(ok-ng>1){
        ll mid=(ok+ng)/2;
        ll res=0;
        rep(i,0,n){
            res+=max(0LL, a[i]-mid/f[i]);
        }
        if(res<=k) ok=mid;
        else ng=mid;
    }
    cout <<ok<<"\n";
}

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

int main(){
  int N, K, C; cin >> N >> K >> C;
  C++;
  string S;
  cin >> S;

  vector<pair<int, int>> L(N + 2), R(N + 2);
  int cnt = 0, last = -C;
  rep(i, N) {
    if (i - last >= C and S[i] == 'o') {
      cnt++;
      last = i;
    }
    L[i + 1] = make_pair(cnt, last);
  }

  cnt = 0;
  last = N + C;
  for (int i = N - 1; i >= 0; i--) {
    if (last - i >= C and S[i] == 'o') {
      cnt++;
      last = i;
    }
    R[i + 1] = make_pair(cnt, last);
  }

  L[0] = make_pair(0, -C);
  R[N + 1] = make_pair(0, N + C);

  int ans = 0;
  rep(i, N) {
    int num = L[i].first + R[i + 2].first;
    if (num > K) continue;
    if (num == K and R[i + 2].second - L[i].second >= C) continue;
    cout << i + 1 << endl;
  }
}


Measured memory_bytes: 4996
#include <bits/stdc++.h>
using namespace  std;
int main()
{
    int n;
    cin >> n;
    vector <int> dp;dp.resize(3);
    int a, b, c;
    cin >> a >> b >> c;
    dp[0] = a; dp[1] = b; dp[2] = c;
    for(int i = 1; i < n; i++){
        vector <int> new_dp;new_dp.resize(3);
        cin >> a >> b >> c;
        new_dp[0] = a + max(dp[1], dp[2]);
        new_dp[1] = b + max(dp[0], dp[2]);
        new_dp[2] = c + max(dp[0], dp[1]);
        dp = new_dp;
    }
    cout << max(dp[0], max(dp[1], dp[2])) << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char c;
  cin>>c;
  string str="abcdefghijklmnopqrstuvwxyz";
  for(int i=0;i<26;i++){
    if(c==str.at(i)){
      cout<<str.at(i+1)<<endl;
      return 0;
    }
  }
    return 0;
  }
  

Measured memory_bytes: 256
<?php
class Queue {
    private $q; 
    private $head; 
    private $tail; 
    private $max;

    public function __construct($max) {
	$this->q = array();
	$this->head = 0;
	$this->tail = 0;
	$this->max = $max;
	$this->count = 0;
    }

    public function isFull() {
	return $this->count >= $this->max;
    }

    public function isEmpty() {
	return $this->count == 0;
    }

    public function enqueue($v) {
	if ($this->isFull()) {echo "The queue is full.\n"; return false;}
	$this->q[$this->tail] = $v;

	if ($this->tail + 1 == $this->max) {
	    $this->tail = 0;
	} else {
	    $this->tail++;
	}
	$this->count++;
    }

    public function dequeue() {
	if ($this->isEmpty()) {echo "The queue is empty.\n"; return false;}
	$x = $this->q[$this->head];

	if ($this->head + 1 == $this->max) {
	    $this->head = 0;
	} else {
	    $this->head++;
	}
	$this->count--;
	
	return $x;
    }

    public function getQ() {
	return $this->q;
    }
    public function getHead() {
	return $this->head;
    }

    public function getTail() {
	return $this->tail;
    }
    public function getMax() {
	return $this->max;
    }
    public function getCount() {
	return $this->count;
    }
    public function setQ($q) {
	return $this->q = $q;
    }
    public function setHead($head) {
	return $this->head = $head;
    }

    public function setTail($tail) {
	return $this->tail = $tail;
    }
    public function setMax($max) {
	return $this->max = $max;
    }
    public function setCount($count) {
	return $this->count = $count;
    }
    public function setNewProcess($sec) {
	$this->q[$this->head]['sec'] = $sec;
    }
}

fscanf(STDIN, "%d %d", $n, $quantum);
$processes = new Queue($n);
for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%s %d", $name, $sec);
    $processes->enqueue(array('name' => $name, 'sec' => $sec));
}
$requiredSec = 0;

while ($processes->getCount() != 0) {
    $sec = $processes->getQ()[$processes->getHead()]['sec'];
    $remainingSec = $sec - $quantum;
    if ($remainingSec <= 0) {
	$requiredSec += $sec;
	$x = $processes->dequeue();
	echo $x['name'] . " " . $requiredSec;
	if (!$processes->isEmpty()) {
	    echo "\n";
	} 

    } else {
	$requiredSec += $quantum;
        $processes->setNewProcess($processes->getQ()[$processes->getHead()]['sec'] - $quantum);
	$x = $processes->dequeue();
	$processes->enqueue($x);
    }
}
?>



Measured memory_bytes: 40252
// this code is moriizumi's code

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  while(cin >> n, n) {
    vector<string> a(n); FOR(i,0,n) cin >> a[i];
    int maxi = 1e9+2, mini = -1e9-2;
    FOR(i,0,n) {
      if (a[i][0] == 'x') {
        if(i > 0) {
          if(a[i-1][0] == 'x') {
            maxi = -1e9, mini = 1e9;
            break;
          }
          if(i % 2) mini = max(mini, stoi(a[i-1]) + 1);
          else maxi = min(maxi, stoi(a[i-1]) - 1);
        }
        if(i < n - 1) {
          if(a[i+1][0] == 'x') {
            maxi = -1e9, mini = 1e9;
            break;
          }
          if(i % 2) mini = max(mini, stoi(a[i+1]) + 1);
          else maxi = min(maxi, stoi(a[i+1]) - 1);
        }
      } else {
        int p = stoi(a[i]);
        if(i > 0 && a[i-1][0] != 'x') {
          int q = stoi(a[i-1]);
          if((i % 2 && p <= q) || (!(i % 2) && p >= q)) {
            maxi = -1e9, mini = 1e9;
            break;
          }
        }
      }
    }
    if(maxi < mini) cout << "none" << endl;
    else if(maxi > mini) cout << "ambiguous" << endl;
    else cout << maxi << endl;
  }
  return 0;
}

Measured memory_bytes: 3208
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
 
using namespace std;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, K;

	cin >> N >> K;

	vector<double> p(N);

	double sum = 0;

	for(int i = 0; i < K; i++) {
		cin >> p[i];
		p[i]++;
		sum += p[i];
	}

	double max = sum;

	for(int i = K; i < N; i++) {
		cin >> p[i];
		p[i]++;
		sum += p[i];
		sum -= p[i - K];
		if(sum > max) max = sum;
	}

	cout << fixed;
	cout << setprecision(8) << max / 2.0 << endl;
}

Measured memory_bytes: 1792
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int N;
inline void solve(){
  IN(N);
  OUT(N/10==9||N%10==9?"Yes":"No");
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


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

int main ()
{
	int N, L;
    cin >> N >> L;
    string array[N];
    for(int i = 0; i < N; i++){
        cin >> array[i];
    }

    sort(array, array + N);
    
    for(int i = 0; i < N; i++){
        cout << array[i];
    }
    cout << endl;
}

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

using namespace std;

const int max_n = 200222, inf = 1000111222;
const int max_lev = 18;

int n, k, q, a[max_n];
int nxt[2][max_n][max_lev];
long long sum[2][max_n][max_lev];

void calc_nxt(int tp) {
    nxt[tp][n][0] = n;
    for (int i = n - 1; i >= 0; --i) {
        nxt[tp][i][0] = nxt[tp][i + 1][0];
        sum[tp][i][0] = i;
        if (tp) {
            sum[tp][i][0] = n - i;
        }
        while (a[nxt[tp][i][0] - 1] - a[i] >= k) {
            --nxt[tp][i][0];
        }
    }
    for (int lev = 1; lev < max_lev; ++lev) {
        for (int i = 0; i <= n; ++i) {
            nxt[tp][i][lev] = nxt[tp][nxt[tp][i][lev - 1]][lev - 1];
            sum[tp][i][lev] = sum[tp][i][lev - 1] + sum[tp][nxt[tp][i][lev - 1]][lev - 1];
        }
    }
}

void rev() {
    reverse(a, a + n);
    for (int i = 0; i < n; ++i) {
        a[i] *= -1;
    }
}

long long get_sum(int tp, int pos, int r) {
    long long res = 0;
    for (int i = max_lev - 1; i >= 0; --i) {
        if (nxt[tp][pos][i] <= r) {
            res += sum[tp][pos][i];
            pos = nxt[tp][pos][i];
        }
    }
    res += sum[tp][pos][0];
    return res;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    calc_nxt(0);
    rev();
    calc_nxt(1);
    rev();
    scanf("%d", &q);
    while (q--) {
        int l, r;
        scanf("%d%d", &l, &r);
        --l;
        --r;
        long long s1 = get_sum(0, l, r);
        long long s2 = get_sum(1, n - r - 1, n - l - 1);
        //cout << s1 << " " << s2 << ": ";
        int ans = s2 - s1;
        printf("%d\n", ans);
    }
    return 0;
}


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<long> A(N), counter(N);
	for (long &a : A) {
		cin >> a;
		counter[a - 1] += 1;
	}
	long allsum = 0;
	for (int i = 0; i < N; i++)
	{
		allsum += counter[i] * (counter[i] - 1) / 2;
	}
	for (int k = 0; k < N; k++)
	{
		cout << allsum - (counter[A[k] - 1] - 1) << endl;
	}

	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
int main(void){
    map<int,int> m;
    int x,n;
    cin>>x>>n;
    for(int i=0;i<n;i++){
        int p;
        cin>>p;
        m[p]++;
    }
    for(int i=0;1;i++){
        if(!m[x-i]>0){
            cout<<x-i<<endl;
            return 0;
        }
        if(!m[x+i]>0){
            cout<<x+i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int H, W;
vector< string > map;

int INF = 55*55*9;

int dp[55];

void solve() {
	fill(dp, dp+55, INF);
	
	dp[0] = 0;
	for (int i = 0; i < H; i++) {
		
		for (int j = 0; j < W; j++) {
			if (j>0) dp[j] = min( dp[j] + (map[i][j]-'0'), dp[j-1] + (map[i][j]-'0') );
			else dp[j] = dp[j] + (map[i][j] - '0');
		}
	}
	
	cout << dp[W-1] << endl;
}

int main() {
	cin >> H >> W;
	for (int i=0; i<H; i++) {
		string s; cin >> s;
		map.push_back(s);
	}
	
	solve();
	
	return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int main(){
	ll n;
	cin >> n;
	vector<ll>h(n);
	rep(i, n)cin >> h[i];

	int ans = 0;
	rep(i, n - 1) {
		int temp = 0;
		while (h[i] >= h[i + 1]) {
			temp++;
			i++;
			if (i == n - 1)break;
		}
		ans = max(ans, temp);
	}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int maxn = 10010;
int n, x, y, cnt[maxn];

int main() {
    scanf("%d %d %d", &n, &x, &y);
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            int dis = min(j - i, min(abs(x - i) + abs(y - j) + 1, abs(y - i) + abs(x - j) + 1));
            cnt[dis]++;
        }
    }
    for (int i = 1; i <= n - 1; ++i) {
        printf("%d\n", cnt[i]);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
mint modp(int a,int p)
{
  mint x=a;
  mint y=(p%2==0)?1:a;
  p/=2;
  while(p!=0)
  {
    x=x*x;
    if(p%2==1)
    {
      y=(y.x==1)? x : x*y;
    }   
     p/=2;
  }
   return y;
}
int main()
{
  int x,y;
  cin>>x>>y;
  if((x+y)%3!=0)
  {
    cout<<0<<endl;
    return 0;
  }
  int m=((2*x)-y)/3;
  int n=((2*y)-x)/3;
  if(m<0 || n<0)
  {
    cout<<0<<endl;
    return 0;
  }
  
  int g=n+m;
  mint d=1;
  int a=(n+m-max(m,n));
  
  mint u=1;
  while(g>(n+m-a))
  {
    u*=g;
    g--;
  }
  for(int i=1;i<=a;i++)d*=i;
  
 
  d=modp(d.x,mod-2);
  mint ans=d*u;
  cout<<ans.x<<endl;
 	return 0;
}

Measured memory_bytes: 3644
ABCD = str(input())
A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])
X = ["+","-"]
def func(a,b,c):
  if(a==0):
    return b+c
  else:
    return b-c
  
for i in range(2):
  for j in range(2):
    for k in range(2):
      if(func(k,func(j,func(i,A,B),C),D)==7):
        I = i
        J = j
        K = k
        break;
              
ans = str(A)+X[I]+str(B)+X[J]+str(C)+X[K]+str(D)+"=7"
print(ans)

Measured memory_bytes: 3064
from collections import defaultdict

def main():
    num, weigh = map(int, input().split())
    dp = [defaultdict(int) for i in range(num + 1)]
    dp[0][0] = 0

    for i in range(1, num + 1):
        data = list(map(int, input().split()))
        for pre_value in dp[i - 1].keys():
            dp[i][pre_value] = max(dp[i - 1][pre_value], dp[i][pre_value])
            if pre_value + data[0] <= weigh:
                dp[i][pre_value + data[0]] = max(dp[i - 1][pre_value] + data[1], dp[i][pre_value + data[0]])

    print(max(list(dp[-1].values())))


if __name__ == '__main__':
    main()


Measured memory_bytes: 656728
xy = gets.chop.split.map(&:to_i)
ans = 0


xy.each do |x|
  if x == 3
    ans += 100000
  elsif x == 2
    ans += 200000
  elsif x == 1
    ans += 300000
  end
end

if xy[0] + xy[1] == 2
  ans += 400000
end

p ans




Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, k;
  long long res = 0;
  scanf("%d %d", &n, &k);
  if(k >= n){
    printf("%d", res);
    return 0;
  } 
  int h[n];
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  sort(h, h + n, greater<int>());
  for(int i = k; i < n; i++){
    res += (long long)h[i];
  }
  printf("%lld", res);
}


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

map<string, int> mp;
int N;
string S[110000];

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> S[i];
        sort(S[i].begin(), S[i].end());
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += mp[S[i]];
        mp[S[i]]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 18304
#include <bits/stdc++.h>
#define ll long long int


using namespace std;

int main()
{
    ll t,n,item,temp,a,b,c,x,y,z,sum,flag,k;
    string s,s1,s2;
    vector<ll>v;
    vector<string>vs;
    map<ll,ll>mp;
    map<ll,ll>check;

    cin>>a>>b;
    item=0;
    while(item<=a)
    {
        if((item*4+(a-item)*2)==b)
           {
                cout<<"Yes"<<endl;
                return 0;
           }
           item++;

    }
    cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 3640
import math

while True:
    number_of_input = int(raw_input())
    if number_of_input == 0:
        break
    values = [float(x) for x in raw_input().split()]
    second_moment = sum([x ** 2.0 for x in values]) / number_of_input
    first_moment = sum([x for x in values]) / number_of_input
    print math.sqrt(second_moment - first_moment ** 2.0)

Measured memory_bytes: 6536
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        long x=fsc.nextLong(), y=fsc.nextLong();
        fsc.close();
        if(Math.abs(x-y)>=2) System.out.println("Alice");
        else System.out.println("Brown");
    }
    static 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());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> N(n);
  while(!k == 0) {
    int d;
    cin >> d;
    vector<int> v(d);
    for(int i = 0; i < d; i++) {
      int a;
      cin >> a;
      v.at(i) = a;
      N.at(v.at(i) - 1) = v.at(i);
    }
    k--;
  }
  int ans = 0;
  for(int i = 0; i < N.size(); i++) {
    if(N.at(i) == 0) ans++;
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 3628
//I miss you...

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define nxvarep(n,x,a) ll n,x;cin>>n>>x;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    string s;cin>>s;
    rep(i,0,s.size()){
        cout<<"x";
    }
    cout<<nnn;
    return 0;
}

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

string a = "CODEFESTIVAL2016";
int main() {
	string s;
	cin >> s;
	int res = 0;
	for(int i=0; i < 16; i++) {
		if(s[i] != a[i]) res++;
	}
	cout << res << endl;
}


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

int main() {
  string s,t,ans;
  cin >> s >> t;
  ans = t+s;
  cout << ans << endl;
}

Measured memory_bytes: 3600