akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

ll cost[30][30];
ll org[500][500];

int make_factorial(int num){
    int factorial = 1;
    for(int i=1;i<num+1;i++){
        factorial *= i;
    }
    return factorial;
}
vector<vector<int>> generate_permutation(vector<int> &v){
    sort(v.begin(), v.end());
    int factorial = make_factorial(v.size());
    int  cnt = 0;
    vector<vector<int>> permutation(factorial, vector<int>(v.size()));
    do{
        for(int i=0;i!=v.size();i++){
            permutation[cnt][i] = v[i];
        }
        cnt++;
    }while(next_permutation(v.begin(), v.end()));
    return permutation;
}



int main() {
    int n,c;
    cin >> n >> c;
    for(int i = 0; i < c; i++){
        for(int j = 0; j < c; j++){
            cin >> cost[i][j];
        }
    }
    ll memo[3][30] ={0,};
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> org[i][j];
            memo[(i+j)%3][org[i][j]-1]++;
        }
    }


    vector<int> data(3);
    ll ans = 1e16;
    for(int i = 0; i < c; i++){
        for(int j = i+1; j < c; j++){
            for(int k = j+1; k < c; k++){
                data[0] = i;
                data[1] = j;
                data[2] = k;
                vector<vector<int>> target_color = generate_permutation(data);
                for(int i2 = 0; i2 < 6; i2++){
                    ll tmpsum = 0;
                    for(int org_color = 0; org_color < c; org_color++){
                        tmpsum += cost[org_color][target_color[i2][0]]*memo[0][org_color];
                        tmpsum += cost[org_color][target_color[i2][1]]*memo[1][org_color];
                        tmpsum += cost[org_color][target_color[i2][2]]*memo[2][org_color];
                    }
                    ans = min(ans,tmpsum);
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2304
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    val cnt = Array(10) {IntArray(10){0} }
    for (i in 1..n) {
        val first = i.toString().first().toString().toInt()
        val last = i.toString().last().toString().toInt()
        cnt[first][last]++
    }
    var ans = 0
    for (i in 1..n) {
        val first = i.toString().first().toString().toInt()
        val last = i.toString().last().toString().toInt()
        ans += cnt[last][first]
    }
    println(ans)
}


Measured memory_bytes: 54736
import java.util.Scanner;

fun main(args : Array<String>) {
  val input = Scanner(System.`in`)
  val sum = 1 + 2 + 3
  
  while (input.hasNext()) {
    val A = input.nextInt()
    val B = input.nextInt()
    
    println(sum - A - B)
  }
}

Measured memory_bytes: 36356
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,x=0;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        a[i]-=i+1;
    }
    sort(a,a+n);
    for(ll i=0;i<n;i++)
    {
         x+=abs(a[i]-(a[n/2]));
    }
    cout<<x;

}


Measured memory_bytes: 5200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair
#define mod 1000000007
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000000000000LL
#define i64 long long int
#define xx first
#define yy second
#define ln 17
#define off 2


using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 3005

string str[maxn] ;
int Time[maxn] ;

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

    int n ;
    cin>>n ;

    for(int i=1 ; i<=n ; i++)
    {
        cin>>str[i]>>Time[i] ;
    }

    string start ;
    cin>>start ;

    int fl = 0 ;

    int ans = 0 ;

    for(int i=1 ; i<=n ; i++)
    {
        ans += fl*Time[i] ;
        if( str[i] == start ) fl = 1 ;
    }

    cout<<ans<<endl ;

    return 0 ;
}
/*
a
aa
aab
aabc
a
ab
abc
b
bc
c



*/


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char c,str[1000],order[10],buf[1000],data[1000];
	int q,a,b,i,j,k=0;
	char *res;
	scanf("%s",str);
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%s",order);
		if(strcmp(order,"print")==0)
		{
			scanf("%d %d",&a,&b);
			strncpy(buf,a+str,b-a+1);
			buf[b-a+1]='\0';
			puts(buf);
		}
		

		if(strcmp(order,"replace")==0)
		{
			scanf("%d %d %s",&a,&b,data);
			strncpy(a+str,data,b-a+1);
			data[0]='\0';
		}

		if(strcmp(order,"reverse")==0)
		{
			scanf("%d %d",&a,&b);
			while(a<b)
			{
               			c=str[a];
                		str[a]=str[b];
                		str[b]=c;
                		a++;
                		b--;
			}
		}
	}
	return 0;
}

//まぐろーりん離散数学
//アルゴリズムパズル

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e18
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
 

ll N,ans;
ll A[112345];
signed main(){
    cin>>N;
    rep(i,N){
        cin>>A[i];
        ans+=abs(A[i]);
    }

    bool flag=false;
    int cnt=0;
    rep(i,N){

        if(A[i]<0){
            cnt++;
        }
        
    }
    if(cnt%2==1)flag=true;

    if(flag){
        ll mm=INF;
        rep(i,N){
            mm=min(mm,abs(A[i]));
        }
        ans-=abs(mm)*2;
    }
    cout<<ans<<endl;
 
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define EACH(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

struct HeavyLight {
  int pathCount,n;
  vector<int>size,parent,in,out,path,pathSize,pathPos,pathRoot;
  vector<vector<int> > tree;

  HeavyLight(int n,vector<vector<int> > t)
    :pathCount(0),n(n),size(n),parent(n),in(n),out(n),
     path(n),pathSize(n),pathPos(n),pathRoot(n),tree(t){
    int time=0;
    dfs(0,-1,time);
    buildPaths(0,newPath(0));
  }

  void dfs(int u, int p, int &k){
    in[u]=k++, parent[u]=p, size[u]=1;
    EACH(v,tree[u])if(*v!=p)dfs(*v, u, k),size[u]+=size[*v];
    out[u]=k++;
  }

  int newPath(int u){ pathRoot[pathCount]=u; return pathCount++; }

  void buildPaths(int u, int pt){
    path[u]=pt, pathPos[u]=pathSize[pt]++;
    EACH(v,tree[u])if(*v != parent[u])
      buildPaths(*v, 2*size[*v] >= size[u] ? pt : newPath(*v));
  }

  bool isAncestor(int p, int ch){
    return in[p] <= in[ch] && out[ch] <= out[p];
  }

  int lca(int a,int b){
    for(int root; !isAncestor(root=pathRoot[path[a]],b);a=parent[root]);
    for(int root; !isAncestor(root=pathRoot[path[b]],a);b=parent[root]);
    return isAncestor(a,b)?a:b;
  }
};

//Usage: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C
int main(void){
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<vector<int> >tree(n);
  
  REP(i,n){
    int k;
    cin >> k;
    REP(j,k){
      int ch;
      cin >> ch;
      tree[i].push_back(ch);
    }
  }

  HeavyLight hl = HeavyLight(n,tree);

  int q;
  cin >> q;
  while(q--){
    int u,v;
    cin >> u >> v;
    cout << hl.lca(u,v) << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 24500
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
// long long C(int a,int b){
// 	if(a<b||b<0)return 0;
// 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
// }
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ

int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	if(a<=c&&c<=a+b)printf("YES\n");else printf("NO\n");
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (A>=13) {
			System.out.println(B);
		} else if (A>=6) {
			System.out.println(B/2);
		} else {
			System.out.println(0);
		}

	}
}


Measured memory_bytes: 19796
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

(N, x) = reads()
a = [0] + reads()

result = 0

for i in range(1, N+1):
  if a[i] + a[i-1] >= x:
    result += max(a[i] + a[i-1] - x, 0)
    a[i] = min(x - a[i-1], a[i])

print(result)


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


class UnionFind:
    def __init__(self, size):
        self.parent = list(range(size))
        self.rank = [0] * size

    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


N, M = map(int, input().split())
AB = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(M)]
uf = UnionFind(N)
size = [1] * N
ans = [0] * M
connected = 0
for i, ab in list(enumerate(AB))[::-1]:
    a, b = ab
    ans[i] = N*(N-1)//2 - connected
    if not uf.same(a, b):
        sa = size[uf.find(a)]
        sb = size[uf.find(b)]
        connected += sa * sb
        uf.unite(a, b)
        size[uf.find(a)] = sa + sb
for a in ans:
    print(a)


Measured memory_bytes: 121052
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    string s;
    cin >> s;
    ll len = s.size();
    string a = "keyence";
    ll pre = 0;
    ll suf = 0;
    REP(i, 0, 7) {
        if (s[i] == a[i]) {
            pre++;
        } else {
            break;
        }
    }
    REP(i, 0, 7) {
        if (s[len - 1 - i] == a[6 - i]) {
            suf++;
        } else {
            break;
        }
    }
    if (pre + suf >= 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
int main(void){
    int n;cin>>n;vector<vector<int>>v(n);
    ll x,y;
    rep(i,n-1){
        cin>>x>>y;
        x--;y--;
        v[x].push_back(y);v[y].push_back(x);
    }
    ll A=0;
    priority_queue<ll>C;
    rep(i,n){cin>>x;A+=x;C.push(x);}
    vector<ll>ans(n,-1);
    queue<int>q;
    q.push(0);
    ans[0]=C.top();
    
    A=A-ans[0];
    C.pop();
    while(!q.empty()){
        int x=q.front();q.pop();
        rep(i,v[x].size()){
            y=v[x][i];
            if(ans[y]==-1){
                ans[y]=C.top();C.pop();q.push(y);
            }
        }
    }
    cout<<A<<endl;
    rep(i,n-1)cout<<ans[i]<<' ';
    cout<<ans[n-1]<<endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
const int N=2e5+5;
int n,a[N],freq[N];
ll ans;
int main(){
	scanf("%d",&n);
	for (int i = 0; i < n; ++i){
		scanf("%d",a+i);
		freq[a[i]]++;
	}
	for (int i = 1; i <= n; ++i){
		int x=freq[i];
		ans+=1LL*x*(x-1)/2;
	}
	for (int i = 0; i < n; ++i){
		int x=freq[a[i]];
		ans-=1LL*x*(x-1)/2;
		ans+=1LL*(x-1)*(x-2)/2;
		cout<<ans<<endl;
		ans-=1LL*(x-1)*(x-2)/2;
		ans+=1LL*x*(x-1)/2;
	}
	
}	

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> A;
  A.push_back(abs(a-b));
  A.push_back(abs(b-c));
  A.push_back(abs(c-a));
  sort(A.begin(),A.end());
  cout << A[0]+A[1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {

  int N;
  double D;
  cin >> N >> D;
  int result = 0;
  for (int i = 0; i < N; i++) {
    double x;
    double y;
    cin >> x >> y;
    double t = sqrt(pow(x,2)+pow(y,2));
    if (t <= D) {
      result++;
    }
  }
  cout << result;

  return 0;
}


Measured memory_bytes: 3192
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split("\n");

const N = parseInt(input[0], 10);
const S = input[1];

let R = 0;
let B = 0;

for (let i = 0; i < N; i++) {
  if (S.charAt(i) === "R") { R++; }
  else { B++; }
}

console.log(R > B ? "Yes" : "No");


Measured memory_bytes: 21956
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	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 pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////
vll ht;
vll bg;


ll ans(ll N, ll X) {
	//cout << N << X << endl;

	if (N == 0) {
		if (X == 0) { return 0; }
		if (X == 1) { return 1; }
	}

	
	if (X <= 1) { return 0; }
	if (X <= 1 + ht[N-1]) { return ans(N - 1, X - 1); }

	
	if (X <= ht[N - 1] + 2 + ht[N - 1]) { return bg[N - 1] +1+ ans(N - 1, X - ht[N - 1] - 2); }
	return bg[N];

}

int main() {
	ll N, X;
	cin >> N >> X;
	ht.assign(N + 1, 0);
	bg.assign(N + 1, 0);

	ht[0] = 1;
	repn(i, N)ht[i] = 2 * ht[i - 1] + 3;

	bg[0] = 1;
	repn(i, N)bg[i] = 2 * bg[i - 1] + 1;

	
	cout << ans(N, X) << endl;
}


Measured memory_bytes: 3608
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = getStringParam();
            string t = getStringParam();

            char[] tArray = t.ToCharArray();
            char startChar = tArray[0];
            int ret = tArray.Length;

            int foundIndex = 0;
            while (0 <= foundIndex)
            {
                char[] sArray = s.Substring(foundIndex, t.Length).ToCharArray();

                int temp = checkChar(sArray, tArray);
                ret = (temp < ret) ? temp : ret;

                foundIndex++;
                if (foundIndex + t.Length < s.Length)
                {
                    continue;
                }
                else
                {
                    break;
                }
            }
            Console.WriteLine(ret);
        }

        static int checkChar(char[] source, char[] target)
        {
            int x = 0;
            for (int i = 0; i < source.Length; i++)
            {
                if (source[i] != target[i])
                {
                    x++;
                }
            }
            return x;
        }

        //↓↓↓ shared function ↓↓↓
        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
    }
}


Measured memory_bytes: 26604
#include <iostream>
#include <math.h>
using namespace std;

int main(){
	int d, e;
	while (1){
		cin >> d >> e;
		double min = 100000;
		if (d == 0 && e == 0) break;
		for (int i = 0; i <= d; i++){

			for (int j = i; j <= d; j++){
				if (i + j == d){
					double cost = sqrt(i*i + j*j);
					double gap = sqrt((cost - e) * (cost - e));

					if (gap < min){
						min = gap;
					}
				}
			}

		}
		cout << min << endl;
	}

	return 0;
}

Measured memory_bytes: 3224
import sys
import numba
from numba import jit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@jit
def main(n, x, t):
  if n%x == 0:
    return (n//x)*t
  else:
    return (n//x+1)*t

n, x, t = map(int, readline().split())
print(main(n, x, t))


Measured memory_bytes: 108052
#include <cstdio>

using namespace std;

typedef long long ll;

int main()
{
    ll a, b;
    scanf("%lld %lld", &a, &b);
    ll prod = a * b;
    if ( prod <= 0 ) {
	printf("Zero\n");
    }
    else if ( a > 0 ) {
	printf("Positive\n");	
    }
    else {
	ll num = b - a + 1;
	if ( ( num % 2 ) == 1 ) { 
	    printf("Negative\n");
	}
	else {
	    printf("Positive\n");	
	}
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;

int main(){
    string n; cin >> n;
    bool flag=0;
    rep(i,n.size()/2){
        if(n[i]!=n[n.size()-i-1]) flag=1;
    }

    if (flag==1) out("No");
    else out("Yes");
}


Measured memory_bytes: 256
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())

    if N == 0:
        print('0')
        return

    ans = ''
    base = 2
    while N != 1:
        ans = str(abs(N % base)) + ans
        N = N // base
        N = -1 * N
    print('1' + ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
# encoding: utf-8
S = input()

A = 0
C = S.count("C") # N
q = 0

q_max = S.count("?") # N

ABC = 0
div = 10 ** 9 + 7
B_base = 3 ** (q_max - 2) % div
q_base = 3 ** (q_max - 3) % div
for si in S: # N
    if si == "A": A += 1
    elif si == "C": C -= 1
    elif si == "B":
        # ABC = (ABC + (A * C) * (3 ** q_max)) % div
        # ABC = (ABC + (q * C) * (3 ** (q_max - 1))) % div
        # ABC = (ABC + (A * (q_max - q)) * (3 ** (q_max - 1))) % div
        # ABC = (ABC + (q * (q_max - q)) * (3 ** (q_max - 2))) % div
        ABC = (ABC + (3 * A + q) * (3 * C + q_max - q) * B_base) % div
    else: # "?"
        # ABC = (ABC + (A * C) * (3 ** (q_max - 1))) % div
        # ABC = (ABC + (q * C) * (3 ** (q_max - 2))) % div
        # ABC = (ABC + (A * (q_max - q - 1)) * (3 ** (q_max - 2))) % div
        # ABC = (ABC + (q * (q_max - q - 1)) * (3 ** (q_max - 3))) % div        
        ABC = (ABC + (3 * A + q) * (3 * C + q_max - q - 1) * q_base) % div
        q += 1
    # print(si, ABC)
    
print(int(ABC))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n; cin >> n;
	vector<string> s(n); REP(i, n)cin >> s[i];
	sort(ALL(s));
	vector<pair<int, string>> p;
	int c = 0;
	REP(i, n-1) {
		if (s[i] != s[i + 1]) {
			p.push_back({ -c, s[i] });
			c = 0;
		}
		else {
			c++;
		}
	}
	p.push_back({ -c, s[n-1] });
	sort(ALL(p));
	REP(i, p.size()) {
		if (p[0].first == p[i].first)
			cout << p[i].second << endl;
		else
			break;
	}
	return 0;
}

Measured memory_bytes: 18420
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

const ll mod=1e9+7;

ll modcom(ll N, ll K, ll L) {
  if(N<=0||K<=0||L<=0) return 0;
  ll d=1,e = (L*K)%mod, m_ = mod-2;
  while(m_ != 0) {
    if (m_&1) d = (d*e)%mod;
    e = e*e%mod;
    m_ = m_ >> 1;
  }
  return (N*d)%mod;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k,mx,mn,ans=0;cin>>n>>k;
  lvector A(n,0);rep(i,n) cin>>A[i];
  sort(A.begin(),A.end());
  lvector V(n+1,1);
  for(ll i=1;i<=n;++i) V[i]=i*V[i-1]%mod;
  for(ll i=0;i<n;++i) {
    mx=0, mn=0;
    if(i>0&&i-k+1>=0) mx=modcom(V[i],V[i-k+1],V[k-1]);
    if(n-1-i>0&&n-i-k>=0) mn=modcom(V[n-1-i],V[n-i-k],V[k-1]);
    ans=(ans+A[i]*(mx-mn)%mod)%mod;
  }
  print(ans);
  return 0;
}


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

int main() {
  int K;
  int64_t iSeven=0;
  cin>>K;

  if(K%2==0){
    cout<<-1<<endl;
    return 0;
  }

  for(int i=1;i<1000010;i++){
    iSeven=(iSeven*10+7)%K;
    if(iSeven==0){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

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

#define FOR(i, a, b)  for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define ll long long

using namespace std;

int dp[100010][3];

int main() {
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;

  int last1 = 0, last2 = 0;
  REP(i, n) {
    int a;
    cin >> a;
    int b = a, tr = -1, fl = 1;

    while (a) {
      a = (a >> 1);
      tr++;
    }
    if ((1 << tr) == b) {
      fl = 0;
    }

    dp[i + 1][0] = min( dp[i][0] + (tr + fl) - min(last1, tr),      dp[i][1] + (tr + fl) - min(last2, tr) );
    dp[i + 1][1] = min( dp[i][0] + (tr + fl) - min(last1, tr + fl), dp[i][1] + (tr + fl) - min(last2, tr + fl) );

    last1 = tr + fl;
    last2 = tr;
  }
  cout << min(dp[n][0], dp[n][1]) << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int x,a;
	cin >> x >> a;
	x < a ? cout << 0 : cout << 10;
}

Measured memory_bytes: 3608
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

N, M = map(int, readline().split())
m = map(int, read().split())
AB = list(zip(m, m))
graph = [[] for _ in range(N+1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)

root = 1
q = [root]
checked = [0] * (N + 1)
checked[root] = 1
order = []
D = [0 for _ in range(N+1)]
d = 0
while q:
    x = q.pop(0)
    d = D[x]
    for y in graph[x]:
        if checked[y]:
            continue
        D[y] = d + 1
        checked[y] = 1
        q.append(y)

ans = [0 for _ in range(N+1)]
for a, b in AB:
    d_a, d_b = D[a], D[b]
    if d_a < d_b:
        ans[b] = a
    elif d_a > d_b:
        ans[a] = b

print('Yes')
print('\n'.join(map(str, ans[2:])))

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

ll dp[2][101010];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,c;
  cin >> n >>  c;
  VLL x(n), v(n);
  rep(i,n){
    cin >> x[i] >> v[i];
  }

  /*
    本当は、時計回り側が長くなる最大の距離の地点と、
    反時計回りが長くなる時の最大値を比較するだけでよい。
    どうしよう.....
    右側の回った時の最大値と
    左から回った時の最大値を計算
  */
  ll ans = 0;

  VLL maxLeft(n,0);
  ll cal = 0;
  rep(i,n){
    if(i != 0) cal += -x[i] + x[i-1];
    else cal -= x[i];
    cal += v[i];
    if(i != 0) maxLeft[i] = max(maxLeft[i-1],cal);
    else maxLeft[i] = max(0LL,cal);
    ans = max(maxLeft[i],ans);
  }
  //cout << ans << endl;
  cal = 0;
  VLL maxRight(n,0);
  for(ll i = n-1; i >= 0; i --){
    if(i != n-1) cal += x[i] - x[i+1];
    else cal -= c - x[i];
    cal += v[i];
    if(i != n-1) maxRight[i] = max(maxRight[i+1],cal);
    else maxRight[i] = max(0LL,cal);
    ans = max(maxRight[i],ans);
  }
  //cout << ans << endl;


  rep(i,n-1){
    ans = max(ans,maxLeft[i] + maxRight[i+1] - x[i]);
    ans = max(ans, maxLeft[i] + maxRight[i+1] - c + x[i+1]);
  }

  cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  string c;
  cin >> s;
  if(s=="Sunny"){
    c="Cloudy";
  }else if(s=="Cloudy"){
    c="Rainy";
  }else if(s=="Rainy"){
    c="Sunny";
  }
  cout << c << endl;
}


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

int main() {

    string o,e;

    cin >> o >> e;

    for(int i=0; i<e.size(); i++){
        cout << o[i] << e[i];
    }

    if(e.size() != o.size()){
        cout << o[o.size()-1];
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

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

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

    int X, Y;

    cin >> X >> Y;

    cout << X + Y/2 << endl;


    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [0]*n
for i in range(n):
    s[i] = "".join(sorted(list(input())))
s.sort()

i = 0
ans = 0
start = 0
while i<n:
    if s[start]!=s[i]:
        # 1からend-startまでの和(例えば1+2+3+4+5のように)
        end = i-1
        ans += (1+end-start)*(end-start)//2
        start = i
    i += 1
ans += (n-start)*(n-1-start)//2
print(ans)


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;

int main(void){

	int N; cin >> N;
	cout << (N+2-1) / 2 << endl;


	return 0;

}


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

int main() {
  int64_t r, d, x;
  cin >> r >> d >> x;
  int64_t y = 0;
  for(int i = 0; i < 10; i++){
    if(i == 0){
      y = r * x - d;
      cout << y << endl;
      continue;
    }
    y = r * y - d;
    cout << y << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a,b,c;
	int count = 0;

	scanf("%d%d%d",&a,&b,&c);
	while (a <= b) {
		if (c%a++ == 0) {
			++count;
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 596
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    x = II()
    for i in range(-int(x ** 0.2)*2 - 1, int(x ** 0.2) + 1):
        for j in range(-int(x ** 0.2) * 2 - 1, int(x ** 0.2) * 2 + 1):
            if i ** 5 - j ** 5 == x:
                print(i , j)
                return
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 76712
#include<bits/stdc++.h>
using namespace std;
int len;
string a,b,c;
int main() {
    cin>>a;
	len=a.length();
    for(int i=len-1;i>=0;i--)
		b=b+a[i];
    for(int i=0;i<len;i++){
        if(b[i]=='b')
			c=c+'d';
        if(b[i]=='d')
			c=c+'b';
        if(b[i]=='p')
			c=c+'q';
        if(b[i]=='q')
			c=c+'p';
    }
    if(a==c)
		printf("Yes\n");
    else 
		printf("No\n");
    return 0;
}

Measured memory_bytes: 1004
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

int main(){
    int h,w;
    while(1){
        cin >> h >> w;
        if(h==0 && w==0) break;
        rep(i,h){
            rep(j,w){
            if(i==0 || j==0 || i==h-1 || j==w-1)
                cout << '#';
            else
                cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3000
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;
bool a[101];
int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	

	int n, k; cin >> n >> k;
	for (int i = 0; i < k; i++) {
		int t; cin >> t;
		while (t--) {
			int x; cin >> x;
			a[x] = true;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (!a[i]) {
			ans += 1;
		}
	}

	cout << ans << '\n';


}

Measured memory_bytes: 3196
<?php
     
    $input_line = "";
    while (($buffer = fgets(STDIN)) !== false) {
        $input_line.= $buffer;
    }
     
    $input_line = trim($input_line);
    $input_array =  explode("\n", $input_line);
    preg_match("/([0-9]+)/", array_shift($input_array), $number);
     
    if ($number[1] % 2 == 0) {
        echo "0.5";
    } else {
        $odd = $number[1];
        $probability = (($number[1] - 1) / 2 +1) / $number[1];
        echo $probability;
    }

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

int main(){
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(), v.end());
  if(v[0]+v[1]==v[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N, M , K = map(int, input().split())
X = [0] + list(map(int, input().split()))
Y = list(map(int, input().split()))
R,sY,j,t= 0,sum(Y),M,0
for i in range(N+1):
    t += X[i]
    if t > K: break
    while j and sY+t > K:
        j-=1
        sY -= Y[j]
    R = max(R, j+i)
print(R)


Measured memory_bytes: 120304
#include<stdio.h>
int main(){
    
    int x, a, b;
    int diffa, diffb;
    scanf("%d%d%d", &x, &a, &b);
    diffa = x-a;
    if(diffa<0){
    	diffa *= -1;
	}
    diffb = x-b;
    if(diffb<0){
    	diffb *= -1;
	}
    if(diffa>diffb){
    	printf("B");
	} else {
		printf("A");
	}
    
    
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ll infll=(1ull<<63)-1,mod=1e9+7;
const int inf=(1ull<<31)-1;
int n,s=0,a[6]={1,10,100,1000,10000,100000};

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n;
	int x=n;
	for (;x;x/=10,s++);
	if (!(s&1)){
		if (s==2)
			cout<<"9";
		else if (s==4)
			cout<<"909";
		else 
			cout<<"90909";
	}
	else {
		int b=0;
		s--;
		if (s==2)
			b+=9;
		else if (s==4)
			b+=909;
		cout<<n-a[s]+1+b;
	}
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#define rep(i,n) for(int i=0;i<n;++i)
int a[1<<18],v[1<<18][3],n,m,q,c;
main(){scanf("%d%d%d",&n,&m,&q);rep(i,n)rep(j,2)v[i][j]=(i+n+1-2*j)%n;rep(i,m){scanf("%d",a+i);rep(j,a[i])c=v[c][a[i]&1];v[c][2]=1;rep(j,2)v[v[c][j^1]][j]=v[c][j];c=v[c][0];}rep(i,q) scanf("%d",&c),printf("%d\n",1-v[c][2]);}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;
typedef vector<int> VI;
#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    vector<tuple<pair<double, double>, pair<double, double>, pair<double, double>>> triangles;
    int n;
    cin >> n;
    REP(i, 0, n) {
        pair<double, double> a, b, c;
        cin >> a.first >> a.second >> b.first >> b.second >> c.first >> c.second;
        tuple<pair<double, double>, pair<double, double>, pair<double, double>> triangle(a, b, c);
        triangles.push_back(triangle);
    }

    for (auto tri : triangles) {
        double a1, a2, b1, b2, c1, c2;
        a1 = 2 * (get<1>(tri).first - get<0>(tri).first);
        b1 = 2 * (get<1>(tri).second - get<0>(tri).second);
        c1 = pow(get<0>(tri).first, 2.0) - pow(get<1>(tri).first, 2.0) + pow(get<0>(tri).second, 2.0) - pow(get<1>(tri).second, 2.0);
        a2 = 2 * (get<2>(tri).first - get<0>(tri).first);
        b2 = 2 * (get<2>(tri).second - get<0>(tri).second);
        c2 = pow(get<0>(tri).first, 2.0) - pow(get<2>(tri).first, 2.0) + pow(get<0>(tri).second, 2.0) - pow(get<2>(tri).second, 2.0);

        double x = (b1*c2 - b2*c1) / (a1*b2 - a2*b1);
        double y = (c1*a2 - c2*a1) / (a1*b2 - a2*b1);
        double r = sqrt(pow(x-get<0>(tri).first, 2.0) + pow(y-get<0>(tri).second, 2.0));

        cout.setf(ios::fixed, ios::floatfield);
        cout.precision(3);
        cout << x << " " << y << " " << r << endl;
    }

    return 0;
}

Measured memory_bytes: 1304
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#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())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

int main(){
	while(1){
		static int h,w,n;
		static int a[1005][1005] = {};
		
		scanf("%d%d%d",&h,&w,&n); if(h==0)break;
		rep1(i,h){
			rep1(j,w){
				scanf("%d",&a[i][j]);
			}
		}
		
		static int dp[1005][1005];
		rep(i,1005)rep(j,1005)dp[i][j] = 0;
		dp[1][1] = n-1;
		
		for(int i = 2 ; i <= w+h ; i ++){
			rep1(j,h){
				if(i-j < 1)break;
				if(i-j > w)continue;
				dp[j+1][i-j] += dp[j][i-j]/2;
				dp[j][i-j+1] += dp[j][i-j]/2;
				if(dp[j][i-j]&1){
					dp[j+dir_4[a[j][i-j]][0]][i-j+dir_4[a[j][i-j]][1]] ++;
					a[j][i-j] ^= 1;
				}
			}
		}
		
		int x = 1,y = 1;
		while(x <= h && y <= w){
			if(a[x][y]){
				y ++;
			}
			else x ++;
		}
		
		printf("%d %d\n",x,y);
	}
}

Measured memory_bytes: 9060
#include <iostream>
#include <string>

using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;

int main()
{
  string s, t;
  cin >> s >> t;
  bool ans = true;
  if(t.length() == s.length() + 1)
  {
    rep(i, s.length())
    {
      ans = ans && (s[i] == t[i]);
    }
    if(ans)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

//組み合わせの数nCrを計算
long long int calcNumOfCombination(int n, int r){
    long long int num = 1;
    for(int i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

int main(void){
    int N;
    cin >> N;
    
    vector<string> s;
    for(int i=0; i<N; i++) {
        string si;
        cin >> si;
        sort(si.begin(), si.end());
        s.push_back(si);
    }
    sort(s.begin(), s.end());
    
    long long int sum = 0;
    int suc = 1;
    string last = s[0];
    for(int i=1; i<N-1; i++) {
        if(last == s[i]) {
            suc++;
        }else {
            sum += calcNumOfCombination(suc, 2);
            suc = 1;
            last = s[i];
        }
    }
    if(last == s[N-1]) suc++;
    sum += calcNumOfCombination(suc, 2);
    cout << sum << endl;
    return 0;    
}


Measured memory_bytes: 5748
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int n, m;
int main() {
	cin >> n >> m;
	vector<vector<int> > g(n + 1);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
	}
	int s = 1;
	queue<int> q;
	q.push (s);
	vector<bool> used (n + 1);
	vector<int> d (n + 1), p (n + 1);
	used[s] = true;
	p[s] = -1;
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (size_t i=0; i<g[v].size(); ++i) {
			int to = g[v][i];
			if (!used[to]) {
				used[to] = true;
				q.push (to);
				d[to] = d[v] + 1;
				p[to] = v;
			}
		}
	}
	if (d[n] == 1 || d[n] == 2) {
		cout << "POSSIBLE";
	} else {
		cout << "IMPOSSIBLE";
	}
	
	
	return 0;
}

Measured memory_bytes: 10488
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

fn minf(x: f64, y: f64) -> f64 {
  use std::cmp::Ordering::*;
  match x.partial_cmp(&y) {
    Some(Less) => x,
    Some(Equal) => x,
    Some(Greater) => y,
    _ => unreachable!(),
  }
}

fn main() {
  input! {
    n: usize,
    ts: [usize; n],
    vs: [f64; n],
  }
  let total: usize = ts.iter().sum();
  let mut ranges = vec![(0.0, 0.0, 0.0)];
  {
    let mut prev = 0;
    for (&t, &v) in ts.iter().zip(&vs) {
      ranges.push((prev as f64, (prev + t) as f64, v));
      prev = prev + t;
    }
  }
  ranges.push((total as f64, total as f64, 0.0));
  let mut v_val = vec![0.0];
  for i in 0 .. 2 * total {
    let x = (i + 1) as f64 / 2.0;
    let mut minv = 1e18;
    for &(l, r, v) in &ranges {
      if x < l {
        minv = minf(minv, v + (l - x));
      } else if x > r {
        minv = minf(minv, v + (x - r));
      } else {
        minv = minf(minv, v);
      }
    }
    v_val.push(minv);
  }
  let mut ans = 0.0;
  for i in 0 .. v_val.len() - 1 {
    ans += (v_val[i] + v_val[i+1]) / 4.0;
  }

  println!("{:.10}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
int out=0;
void print( int x )
{
     if( x <= 9 )
         out++;
     else
        out++;
 }
void change( int n,int r )
{
     if( n )
     {
         change( n / r, r );
         print( n % r );
     }
 }
int main()
{
    int n,k;
    cin>>n>>k;
    change(n,k);
    cout<<out<<endl;
}


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


YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(a: int, b: int, c: int):
    print(YES if b - a == c - b else NO)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    solve(a, b, c)


if __name__ == '__main__':
    main()


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

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


// ***************************CODE**********************//


int H,W;
char s[51][51];
int table[51][51];
int gx = H-1, gy = W-1;
int black = 0;

int main(){
        cin >> H >> W;
        for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){
                        cin >> s[i][j];
                        if(s[i][j] == '#') black++;
                        table[i][j] = 1e9;
                }
        }

        queue<P> q;
        q.push(make_pair(0,0));
        table[0][0] = 0;

        while(!q.empty()){
                P p = q.front();
                q.pop();

                if(p.first == gx && p.second == gy) break;

                for(int i = 0; i < 4; i++){
                        int nx = p.first + dx[i];
                        int ny = p.second + dy[i];

                        if(nx >= 0 && nx < H && ny >= 0 && ny < W && s[nx][ny] != '#' && table[nx][ny] == 1e9){
                                table[nx][ny] = table[p.first][p.second] + 1;
                                q.push(make_pair(nx,ny));
                        }
                }
        }




        if(table[H-1][W-1] == 1e9) cout << -1 << endl;
        else{
                cout << H*W - (table[H-1][W-1]+1) - black << endl;
        }

        return 0;


}


Measured memory_bytes: 256