akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

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

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;

ll func(ll a, ll b) {
    ll ret = 0;
    ret += a*a*a*a;
    ret += a*a*a*b;
    ret += a*a*b*b;
    ret += a*b*b*b;
    ret += b*b*b*b;
    return ret;
}

int main() {
//	cout << fixed << setprecision(15);
    ll x;
    cin >> x;
    vll f;
    for(ll i = 1; i*i <= x; i++) {
        if(x % i == 0) f.push_back(i);
    }
    for(auto i: f) {
        ll a = (i - 1) / 2 + 1;
        ll b = a - i;
        while(true) {
            if(x / i < func(a, b)) break;
            else if(x / i == func(a, b)) {
                cout << a << ' ' << b << endl;
                return 0;
            }
            a++;
            b++;
        }
    }
}


Measured memory_bytes: 3632
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val a = next().toMutableList()
    val b = next().toMutableList()
    val c = next().toMutableList()

    var target = a
    var next = 'a'
    while (true) {
        if (target.isEmpty()) {
            break
        }

        next = target.removeAt(0)

        target = when(next) {
            'a' -> a
            'b' -> b
            else -> c
        }
    }

    println(next.toUpperCase())
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 33908
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

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

    bool res = false;
    if ((S[2] == S[3]) && (S[4] == S[5])) {
        res = true;
    }
    cout << (res ? "Yes" : "No") << endl; 
    return 0;
}


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

struct StCoord
{
  StCoord() : m_nx(0), m_ny(0) { }

  int m_nx;
  int m_ny;
};

void fnInput(vector<StCoord>& rvoCoord)
{
  int nCrdSiz;
  cin >> nCrdSiz;
  rvoCoord.resize(nCrdSiz);

  for (StCoord& roCoord : rvoCoord)
    cin >> roCoord.m_nx >> roCoord.m_ny;
}

double fnAveDistGet(const vector<StCoord>& cnrvoCoord)
{
  vector<vector<double>> vvnDist(cnrvoCoord.size(), vector<double>(cnrvoCoord.size()));
  
  for (int i = 0; i < cnrvoCoord.size(); i++)
    for (int j = 0; j < cnrvoCoord.size(); j++)
      if (i != j)
      {
        int nDifx = cnrvoCoord[i].m_nx - cnrvoCoord[j].m_nx;
        int nDify = cnrvoCoord[i].m_ny - cnrvoCoord[j].m_ny;
        vvnDist[i][j] = vvnDist[j][i] = sqrt(nDifx * nDifx + nDify * nDify);
      }

  int nFact = 1;
  for (int n = 1; n < cnrvoCoord.size() + 1; n++)
    nFact *= n;

  double nTotalDist = 0.0;
  vector<int> vnCity(cnrvoCoord.size());
  iota(begin(vnCity), end(vnCity), 0);

  do {
    for (int i = 0; i < cnrvoCoord.size() - 1; i++)
      nTotalDist += vvnDist[ vnCity[i] ][ vnCity[i + 1] ];
  }
  while ( next_permutation(begin(vnCity), end(vnCity)) );

  return nTotalDist / nFact;
}

int main()
{
  vector<StCoord> voCoord;

  fnInput(voCoord);
  cout << fixed << setprecision(10) << fnAveDistGet(voCoord) << endl;

  return 0;
}

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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	int sum = 0;
	int x[n];
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		sum += x[i];
	}
	int p = sum / n;

	int ans0 = 0, ans1 = 0;
	for (int i = 0; i < n; i++) {
		ans0 += (x[i]-p)*(x[i]-p);
		ans1 += (x[i]-p-1)*(x[i]-p-1);
	}
	cout << min(ans0, ans1) << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
  int a,b,c,d,e,f,i,j;
  vector<int> wa,su;
  cin >> a >> b >> c >> d >> e >> f;
  for (i=0;i<=f;i+=a*100) for (j=0;i+j<=f;j+=b*100){
    if (i+j>0) wa.push_back(i+j);
  }
  
  for (i=0;i*100<=f*e;i+=c) for (j=0;(i+j)*100<=f*e;j+=d){
    su.push_back(i+j);
  }
  
  int wans,sans;
  double pmax=-0.1;
  for (i=0;i<wa.size();i++) for (j=0;j<su.size();j++){
    if (wa[i]+su[j]<=f && su[j]<=wa[i]/100*e && (double)su[j]/(wa[i]+su[j]) > pmax){
      wans=wa[i];
      sans=su[j];
      pmax=(double)su[j]/(wa[i]+su[j]);
    }
  }
  cout << wans+sans << ' ' << sans << endl;
  return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j;
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    int ans = 0;
    rep(i,n){
        if(i<n-1 && a[i] == a[i+1])i++;
        else ans++;
    }
    cout << ans << endl;
}


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

struct {
	int parent;
	int child;
	int sibling;
} typedef node;


using namespace std;
const int NIL = -1;

node tree[100000];
int D[100000];

// Calculate depth of nodes
void depth(int u, int p)
{
	D[u] = p;
	if (tree[u].sibling != NIL)
		depth(tree[u].sibling, p);
	if (tree[u].child != NIL)
		depth(tree[u].child, ++p);
}

// MAIN FUNCTION
int main(int argc, char** argv)
{
	// Input
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		tree[i].child = tree[i].parent = tree[i].sibling = NIL;
	}
	int degree;
	int v;
	int s;
	int pre;
	for (int i = 0; i < n; i++) {
		cin >> v >> degree;
		for (int j = 0; j < degree; j++) {
			cin >> s;
			if (j == 0)
				tree[v].child = s;
			else
				tree[pre].sibling = s;
			pre = s;
			tree[s].parent = v;
		}
	}

	int r = 0;
	while (tree[r].parent != NIL)
		r = tree[r].parent;
	depth(r, 0);
	// Output
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ":" << " parent = " << tree[i].parent << ", depth = " << D[i] << ", ";
		if (tree[i].parent == NIL)
			cout << "root, [";
		else if (tree[i].child == NIL)
			cout << "leaf, [";
		else
			cout << "internal node, [";
		r = tree[i].child;
		if (tree[i].child != NIL)
			cout << tree[i].child;
		while (tree[r].sibling != NIL && tree[i].child != NIL) {
			cout << ", " << tree[r].sibling;
			r = tree[r].sibling;
		}
		cout << "]" << endl;
	}

	return 0;
}

Measured memory_bytes: 7760
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    
 
    
  int main(){
      lint n;
      cin>>n;
      lint ans=0;
      string s=to_string(n);
      bool x=true;
      lint a;
      if(s.size()==1){cout<<n<<endl;
    return 0;
      }
      else{
      rep(i,s.size()){
          if(i==0)ans+=(s[i]-'0');
          else{
              if(s[i]!='9')x=false;
              ans+=9;
          }
      }
      }
      if(!x)ans--;
      cout<<ans<<endl;
     }
  
      
      
    

  
          
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<int> a(n);
	bool ans=false;
	rep(i,n){
		cin >> a.at(i);
		if(a.at(i)==k){
			ans=true;
		}
	}
	if(n==1){
		if(ans) cout << "POSSIBLE" << endl;
		else cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	sort(a.begin(),a.end());
	int g=gcd(a.at(0),a.at(1));
	rep(i,n-2){
		g=gcd(g,a.at(i+2));
	}
	if(k%g==0 && a.at(n-1)>k) ans=true;
	if(ans) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 640
from operator import itemgetter

N, M = map(int, input().split(" "))
A = []
cnt = 0
for i in range(M):
    A.append(list(map(int, input().split(" "))))

A = sorted(A, key=itemgetter(1))

endtime = 0
for i in range(M):
    if A[i][0] >= endtime:
        endtime = A[i][1]
        cnt += 1
print(cnt)


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

int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++) ans += i;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a > b){
		if (a > c){
			if (b > c)
				printf("%d %d %d\n", c, b, a);
			else
				printf("%d %d %d\n", b, c, a);
		}
		else
			printf("%d %d %d\n", b, a, c);
	}
	else if (a > c)
		printf("%d %d %d\n", c, a, b);
	else if (b > c)
		printf("%d %d %d\n", a, c, b);
	else
		printf("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 1028
import math
import fractions
import copy
def prime_factorize(n):
  d = {}
  f = 2
  while f * f <= n:
    if n % f == 0:
      n //= f
      if not f in d.keys():
        d[f] = 1
      else:
        d[f] += 1
    else:
      f += 1
  if n != 1:
    if not n in d.keys():
      d[n] = 1
    else:
      d[n] += 1 
  return d

a, b = map(int, input().split())
c = fractions.gcd(a,b)
d = prime_factorize(c)
print(len(d)+1)


Measured memory_bytes: 5044
#include <bits/stdc++.h>
#define SZ(a) int((a).size())
#define FI(i,a,b) for(int i=(a);i<=(b);++i)
#define FD(i,b,a) for(int i=(b);i>=(a);--i)
using namespace std;
using LL = long long;
using PII = pair<int, int>;

int main() {
    int n, m, d;
    cin >> n >> m >> d;
    int x = d;
    int k1, k2;
    if (2 * x > n) {
        int y = 2 * x - n;
        k1 = n - y;
        k2 = 0;
    } else {
        k2 = n - 2 * x;
        k1 = x * 2;
    }
    if (d == 0) swap(k1, k2);
    printf("%.9f\n", double(k1 + k2 * 2.) / n * (m - 1) / n);
}


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

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

  int N; cin >> N;
  vector<pair<int, int>> ans;
  if (N % 2 == 0) {
    for (int i = 1; i <= N; i++) {
      for (int j = i + 1; j <= N; j++) {
        if (i + j == N + 1) continue;
        ans.push_back(make_pair(i, j));
      }
    }
  } else {
    for (int i = 1; i <= N - 1; i++) {
      ans.push_back(make_pair(i, N));
    }
    N--;
    for (int i = 1; i <= N; i++) {
      for (int j = i + 1; j <= N; j++) {
        if (i + j == N + 1) continue;
        ans.push_back(make_pair(i, j));
      }
    }
  }

  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); i++) {
    pair<int, int> p = ans[i];
    cout << p.first << ' ' << p.second << '\n';
  }
  return 0;
}

Measured memory_bytes: 384
while True:
    h, w = map(int, input().split())
    if (h, w) == (0, 0):
        break
    for i in range(h):
        print(['#.' * (w // 2) + '#' * (w % 2),
               '.#' * (w // 2) + '.' * (w % 2)][i % 2 == 1])
    print()

Measured memory_bytes: 7692
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> p(N);
	for (int i = 0; i < N; i++)
	{
		cin >>p[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		if (i+1!=p[i])
		{
			ans++;
		}
	}
	if (ans<=2)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define M 1000000007
#define N 1000016
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define inf 9000000000000000000
ll dis[100001],cur;
vector<ll> v[N];
queue<ll> q;

void dfs(ll x, ll power) {

    if(power==0) {
        if(dis[x]>cur+1) {
            dis[x] = cur + 1;
            q.push(x);
        }
        return;
    }

    for(auto node: v[x])
        dfs(node, power-1);

}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n,m,s,t;
    cin>>n>>m;
    fill(dis, dis+n+1, inf);

    for(ll i=1; i<=m; i++) {
        ll a,b;
        cin>>a>>b;
        v[b].push_back(a);
    }

    cin>>s>>t;
    q.push(t);
    dis[t] = 0;

    while(!q.empty()) {
        ll x = q.front();
        q.pop();
        cur = dis[x];

        dfs(x, 3);
        if(dis[s]!=inf)
            break;
    }

    if(dis[s]==inf)
        cout<<"-1\n";
    else
        cout<<dis[s]<<"\n";


    return 0;
}


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

long long n;
string ans;

int main() {
    while (cin >> n){
        ans = "";
        while (n){
            ans = (char)('a'+((n-1+26)%26)) + ans;
            if (n % 26 == 0) n -= 26;
            n /= 26;
        }
        cout << ans << "\n";
    }
}



Measured memory_bytes: 3616
#!/usr/bin/env python


def solve(A: int, B: int, K: int):
    if A >= K:
        return f"{A-K} {B}"
    elif A + B >= K:
        return f"0 {A+B-K}"
    else:
        return "0 0"


def main():
    A, B, K = map(int, input().split())
    answer = solve(A, B, K)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9096
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
const int N=1e5+7;
char s[N];

int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	rep(i,1,n){
		if(s[i]=='W'){int ok=0;
			rep(j,1,n)if(s[j]=='E')ok=1;
			if(!ok){puts("No");return 0;}
		}
		if(s[i]=='E'){int ok=0;
			rep(j,1,n)if(s[j]=='W')ok=1;
			if(!ok){puts("No");return 0;}
		}
		if(s[i]=='N'){int ok=0;
			rep(j,1,n)if(s[j]=='S')ok=1;
			if(!ok){puts("No");return 0;}
		}
		if(s[i]=='S'){int ok=0;
			rep(j,1,n)if(s[j]=='N')ok=1;
			if(!ok){puts("No");return 0;}
		}
	}
	{puts("Yes");return 0;}
}

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

#define FOR(i,a) for(int i=0;i<(int)(a);i++)
#define pb push_back
#define clr clear()
#define sz size()
typedef unsigned int ui;

class node{
public:
  int num;
  void set(int n){
    num = n;
  }
};

class edge{
public:
  node b,e;
  int cost;
  void set(int s,int g,int c){
    b.set(s);
    e.set(g);
    cost = c;
  }
};

class graph{
public:
  vector<node> n;
  vector<edge> e;

  void set(void){
    n.clr;
    e.clr;
  }

  void Nadd(node a){
    if(!n.sz)n.pb(a);
    else{
      ui i = 0;
      while(n[i].num < a.num && i<n.sz)i++;
      n.insert(n.begin()+i,a);
    }
  }

  void Eadd(edge a){
    if(!e.sz)e.pb(a);
    else{
      ui i = 0;
      while(e[i].cost < a.cost && i<e.sz)i++;
      e.insert(e.begin()+i,a);
    }
  }

  bool Nexist(node a){
    FOR(i,n.sz){
      if(a.num == n[i].num)return true;
    }
    return false;
  }

  graph prim(void){
    graph res;

    res.set();

    if(!e.sz)return res;
    else{
      res.Eadd(e[0]);
      res.Nadd(e[0].b);
      res.Nadd(e[0].e);

      while(res.n.sz < n.sz){
	FOR(i,e.sz){
	  if(res.Nexist(e[i].b) && !res.Nexist(e[i].e)){
	    res.Eadd(e[i]);
	    res.Nadd(e[i].e);
	    i = 0;
	  }else if(!res.Nexist(e[i].b) && res.Nexist(e[i].e) ){
	    res.Eadd(e[i]);
	    res.Nadd(e[i].b);
	    i = 0;
	  }
	}
      }
      return res;
    }
  }
};

int main(){
  int n,m,ans;
  int a,b,c;
  graph g,p;
  node tmp;
  edge etmp;

  while(1){
    cin >> n >> m;
    if(!n && !m)break;

    g.set();
    for(int i=0;i<n;i++){
      tmp.set(i);
      g.Nadd(tmp);
    }
    for(int i=0;i<m;i++){
      cin >> a >> b >> c;
      etmp.set(a,b,c);
      g.Eadd(etmp);
    }

    p = g.prim();

    ans = 0;
    for(int i=0;i<p.e.size();i++)ans += p.e[i].cost;
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 
const int N = 150;

struct node{
  int h, w, len;
};

bool cmp(node a, node b){
   if (a.len == b.len) return a.h < b.h;
   return a.len < b.len;	
}

void solve(){
   	vector<node> v;
   	for (int i = 1; i <= N; i++){
	  for (int j = i + 1; j <= N; j++){
		   int length = i * i + j * j;
		   v.push_back({i, j, length});
		 }	
	  }
	sort(all(v), cmp);
	int a, b;
	node custom;
	while (cin >> a >> b && a && b){
	  custom.h = a;
	  custom.w = b;
	  custom.len = a * a + b * b;
	  auto it = upper_bound(all(v), custom, cmp);
	  cout << it->h << " " << it->w << endl; 	
	}  
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}




Measured memory_bytes: 3340
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

class UnionFind {
public:
	UnionFind(int sz) :
		parent(sz, -1) {}

	int root(int id) {
		if (parent[id] < 0)
			return id;

		return parent[id] = root(parent[id]);
	}

	int size(int id) {
		return -parent[root(id)];
	}

	bool unite(int id1, int id2) {
		id1 = root(id1);
		id2 = root(id2);

		if (id1 == id2)
			return false;

		if (parent[id2] < parent[id1])
			swap(id1, id2);

		parent[id1] += parent[id2];
		parent[id2] = id1;
		return true;
	}

private:
	vector<int> parent;
};

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

	int N, M;
	cin >> N >> M;

	vector<int> A(M), B(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];

		A[i]--;
		B[i]--;
	}
		

	reverse(A.begin(), A.end());
	reverse(B.begin(), B.end());

	UnionFind un(N);
	vector<long long> ans(M, 0);
	ans[0] = (long long)N * (N - 1) / 2;
	for (int i = 0; i < M - 1; i++) {
		ans[i + 1] = ans[i];

		if (un.root(A[i]) != un.root(B[i])) {
			ans[i+1] -= (long long)un.size(A[i]) * un.size(B[i]);
			un.unite(A[i], B[i]);
		}
	}

	reverse(ans.begin(), ans.end());

	for (int i = 0; i < M; i++)
		cout << ans[i] << endl;

	return 0;
}


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

struct edge {
  edge () {}
  edge (int to, int cost) : to(to), cost(cost) {}

  int to, cost;
};

vector<long long> Dijkstra(int s, const vector<vector<edge>> &G) {
  const long long linf = 1001001001001001001ll;
  vector<long long> d(G.size(), linf);
  priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q;

  d[s] = 0;
  q.push(make_pair(0, s));

  while (!q.empty()) {
    pair<long long, int> p = q.top();
    q.pop();

    int v = p.second;
    if (d[v] < p.first) continue;
    for (auto &e : G[v]) {
      if (d[e.to] > p.first + e.cost) {
        d[e.to] = p.first + e.cost;
        q.push(make_pair(d[e.to], e.to));
      }
    }
  }

  return d;
}

int main() {
  int n, m, r;
  cin >> n >> m >> r;

  vector<vector<edge>> G(n);
  for (int i = 0; i < m; ++i) {
    int u, v, c;
    cin >> u >> v >> c;

    G[u].push_back(edge(v, c));
    // G[v].push_back(edge(u, c));
  }

  vector<long long> d = Dijkstra(r, G);
  for (int i = 0; i < d.size(); ++i) {
    if (d[i] == 1001001001001001001ll) cout << "INF" << endl;
    else cout << d[i] << endl;
  }
}

Measured memory_bytes: 14392
while 1:
 a=b=0;n=int(input())
 if n==0:break
 for i in[0]*n:
  s,t=map(int,input().split())
  if s>t:a+=s+t
  if s<t:b+=s+t
  if s==t:a+=s;b+=t
 print(a,b)


Measured memory_bytes: 5728
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);
    vector<int> dp(1000010,1e9),odddp(1000010,1e9);
    dp[0]=0;
    odddp[0]=0;
    repr(i,1,1010) {
        int a=i*(i+1)*(i+2)/6;
        rep(j,1000010) {
            if (j>=a) dp[j]=min(dp[j],dp[j-a]+1);
            if (a%2==1 && j>=a) odddp[j]=min(odddp[j],odddp[j-a]+1); 
        }
    }
    // rep(i,50) cout << dp[i] << endl;
    while (1) {
        int n;
        cin >> n;
        if (n==0) break;
        cout << dp[n] << ' ' << odddp[n] << endl;
    }
    return 0;   
}



Measured memory_bytes: 10612
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
   freopen("inp.txt", "r", stdin);      freopen("outp.txt", "w", stdout);
#endif
   ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);

   int n;
   cin >> n;
   vector <int> mod(1e6 + 1);
   mod[0] = 1;
   for (int i = 1; i <= 1e6; i++) {
      mod[i] = (mod[i - 1] * 10) % n;
   }
   int x, ten = 0;
   for (x = 0; x <= 1e6; x++) {
      ten = (ten + mod[x]) % n;
      if ((ten * 7) % n == 0)
         break;
   }
   if (x == 1e6 + 1)
      cout << -1 << '\n';
   else
      cout << x + 1 << '\n';
  
   return 0;
}

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


public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));       
		try {
			String line;
			while(true){
				/* input */
				line = br.readLine();

				int w = Integer.parseInt(line.split(" ")[0]);
				int h = Integer.parseInt(line.split(" ")[1]);
				if(w == 0 && h == 0){
					return;
				} 
				int[][] field = new int[h][w];
				int[] pos = new int[2]; 
				for(int i=0;i<h;i++){
					String str = br.readLine();
					for(int j=0;j<w;j++){
						if(str.charAt(j)=='.'){
							field[i][j] = 1;
						} else if(str.charAt(j)=='#'){
							field[i][j] = 0;
						} else {
							field[i][j] = 2;
							pos[0] = i;
							pos[1] = j;
						}
					}
				}
				/*
				for(int i=0;i<h;i++){
					for(int j=0;j<w;j++){
						System.out.print(field[i][j]);
					}
					System.out.println();
				}
				*/
				/* processing */
				int res = search(pos[0],pos[1],field,h,w);
				
				res = 0;
				
				for(int i=0;i<h;i++){
					for(int j=0;j<w;j++){
						if(field[i][j]==2){
							res++;
						}
					}
				}
				
				/* output */
				System.out.println(res);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static int search(int posi, int posj, int[][] field,int h,int w){
		int sum = 1;
		field[posi][posj] = 2;
		
		//up
		if(posi>0&&field[posi-1][posj]==1){
			sum = 1 + search(posi-1,posj,field,h,w);
		}
		//right
		if(posj<w-1&&field[posi][posj+1]==1){
			sum = 1 + search(posi,posj+1,field,h,w);
		}
		
		//down
		if(posi<h-1&&field[posi+1][posj]==1){
			sum = 1 + search(posi+1,posj,field,h,w);
		}
		
		//left
		if(posj>0&&field[posi][posj-1]==1){			
			sum = 1 + search(posi,posj-1,field,h,w);
		}

		return sum;
	}
	
}

Measured memory_bytes: 31840
s = str(input())
n = len(s)

count = 0 #黒の数
for i in range(n):
    if s[i] == 'B':
        count = count + 1

ans = 0
c = n - count
for i in range(n):
    if s[i] == 'B':
        ans = ans + (c - i)
        c = c + 1

print(ans)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
int main() {
//freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int a, b, c;
    cin >> a >> b>> c;
    int s = a*100+b*10+c;
    if(s%4 == 0) cout <<"YES" << endl;
    else cout << "NO"<< endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
bool check_prime (int x)
{
    for (int i=2; i*i<=x; i++){
        if (x % i == 0){return false;}

}
return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    ll n;
    cin >> n; /// 20
    ll i = n; /// 20
    ll num;
    while (1){
        if (check_prime(i)){
           num = i; break;
        }
        i++;
    }
    cout << num << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int n,p,count=0;
    cin>>n;
    long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    p=sizeof(a)/sizeof(a[0]);
    sort(a,a+p);
    for(int i=0;i<n;i++)
    {

    if(a[i]==a[i+1])
    {
        count++;
        break;
    }
    }
    if(count!=0)
    {
        cout<<"NO";
    }
    else
    {
        cout<<"YES";
    }
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
	*/
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200000)

H, W = [int(_) for _ in input().split()]
S = [input() for _ in range(H)]

move = ((1, 0), (-1, 0), (0, 1), (0, -1))
visited = [[False] * W for _ in range(H)]
b, w = 0, 0

def dfs(i, j):
    global b, w

    visited[i][j] = True

    if S[i][j] == '#':
        b += 1
    else:
        w += 1

    for di, dj in move:
        ni, nj = i + di, j + dj
        if 0 <= ni < H and 0 <= nj < W:
            if S[i][j] != S[ni][nj] and not visited[ni][nj]:
                dfs(ni, nj)


result = 0
for i in range(H):
    for j in range(W):
        if visited[i][j]:
            continue
        b, w = 0, 0
        dfs(i, j)
        result += b * w
print(result)



Measured memory_bytes: 149492
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<int> x(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> x.at(i);
    }

    sort(x.begin(), x.end());

    int left = x.at(0);
    int right = x.at(n-1);


    long long minsum = 1e12;
    for(int i = left; i <= right; ++i) {
        long long sum = 0;
        int p = i;
        for(int j = 0; j < n; ++j) {
            sum += pow((abs(x.at(j)-p)), 2);
        }
        minsum = min(minsum, sum);
    }

    cout << minsum << endl;
}

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

int main() {
    int N;
    std::cin >> N;
    
    int ans = 0;
    int temp = 0;
    for (int b=1; b<1000; ++b) {
        for (int p=2; p<10; ++p) {
            temp = std::pow(b, p);
            if (temp > 1000) {
                break;
            }
            if (temp <= N && temp > ans) {
                ans = temp;
            }
        }
    }
    std::cout << ans << std::endl;
}

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

#define 	pi 				3.1415926536
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(int i = a ; i < b ; i++)
#define     repn(i, a, b)   for(int i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define 	F 				first
#define 	S 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define 	vi 				vector<int>
#define     pii              pair<int, int>
#define     pll             pair<long long int, long long int>
#define     vll             vector<long long int>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;


/*############################# DSU ##############################*/
vi parent(1e5), Size(1e5), Rank(1e5);

void make_set(int v){
    parent[v]=v;
    Size[v] = 1;
    // Rank[v] = 0;
}
 
int find_set(int v){
	return (parent[v]==v) ?  v : parent[v] = find_set(parent[v]);
}
 
void union_sets(int a, int b){
	a = find_set(a);
	b = find_set(b);
	if(a != b){
        if(Size[a] < Size[b])
            swap(a, b);
        // if(Rank[a] < Rank[b])
        //     swap(a, b);
		parent[b] = a;
        Size[a] += Size[b];
        // if(Rank[a] == Rank[b])
        //     Rank[a]++;
    }
}
/*############################# DSU ##############################*/


bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }

bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }

double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }

ll pw2[32];
void cal(){ pw2[0] = 1; rep(i, 1, 32)pw2[i] = 2*pw2[i-1]; }

/* ################################################################ */

void solve()
{
        ll x, tmp = 100; cin>>x;
        rep(i, 1, 4e4){
            tmp = floor((tmp*1.01));
            if(tmp>=x){
                cout<<i<<nl;
                break;
            }
        }
}


int main()
{
    // boost;
    cal();
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

Measured memory_bytes: 4612
import bisect,collections,copy,heapq,itertools,math,numpy,string
from operator import itemgetter
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
H,W,K = LI()
C = []
ans = 0

for l in [S() for _ in range(H)]:
	C.append(list(l))

for i in range(2**(H+W)):
	c = copy.deepcopy(C)
	sum = 0
	for j in range(H+W):
		if ((i>>j)&1):
			if j < H:
				for d in range(W):
					c[j][d] = '.'
			else:
				for d in range(H):
					c[d][j-H] = '.'
	for l in c:
		for w in l:
			if w == '#':
				sum += 1
	if sum == K:
		ans += 1
print(ans)

Measured memory_bytes: 26984
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[200005], b[200005];
vector<llint> vec;

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i] >> b[i];
	
	bool flag = true;
	for(int i = 1; i <= n; i++){
		if(a[i] != b[i]) flag = false;
	}
	if(flag){
		cout << 0 << endl;
		return 0;
	}
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		if(a[i] > b[i]) vec.push_back(b[i]);
		ans += a[i];
	}
	sort(vec.begin(), vec.end());
	
	ans -= vec.front();
	cout << ans << endl;

	return 0;
}


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

const int N = 200005;

int a, v, b, w;
int t;

int main() {
  scanf("%d %d", &a, &v);
  scanf("%d %d", &b, &w);
  scanf("%d", &t);

  if (v <= w) return 0 * printf("NO\n");

  if ((1LL*abs(b - a) + v - w - 1) / (v-w) <= t) printf("YES\n");
  else printf("NO\n");
  return 0;
}


Measured memory_bytes: 3688
#include<stdio.h>
void margesort(int *,int,int);
void marge(int *,int,int,int);
int count=0,A[100000000],L[50000001],R[50000001];
int main(){
  int n,i;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

margesort(A,0,n);
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",count);
  return 0;
  }

void margesort(int *A,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    margesort(A,left,mid);
    margesort(A,mid,right);
    marge(A,left,mid,right);
  }
}

void marge(int *A,int left,int mid,int right){
  int n1,n2,i,j=0,k;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  L[n1]=1000000000;
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  R[n2]=10000000000;
  i=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }
    else{
      A[k]=R[j];
      j++;
    }
    count++;
  }
}



Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int X, A;
    cin >> X >> A;
    if (X < A) {
        print(0);
    } else {
        print(10);
    }
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 256
N,K = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
DP = [10**10]*N
DP[0] = 0
DP[1] = abs(h[0] - h[1])
for i in range(2,N):
    for j in range(1,min(K+1,i+1)):
        DP[i] = min(DP[i],DP[i-j] + abs(h[i]-h[i-j]))
print(DP[N-1])

Measured memory_bytes: 52448
from sys import exit
n = int(input())
data = [list(map(int, input().split())) for _ in range(n)]
t = 0
x = 0
y = 0
for d in data:
  duration = d[0] - t
  distance = abs(x - d[1]) + abs(y - d[2])
  if (distance > duration) or ((duration - distance) % 2 == 1):
    print('No')
    exit()
  t = d[0]
  x = d[1]
  y = d[2]
print('Yes')


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

int main(){
    int n;
    cin >> n;
    vector<pair<double, double>> p(n);
    rep(i, n){
        int a, b;
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }
    double total = 0;
    rep(i,n){
        rep(j, n){
            if(i != j){
                int x = pow(p[i].first - p[j].first, 2.0) + pow(p[i].second - p[j].second, 2.0);
                total += 2 * sqrt(x);
            }
        }
    }
    double ans = total / (n * 2);
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 3820
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void){

	int i,mem;
	double ave,var,score[1000],var2;

	while(1){
		ave=0;
		var=0;
		scanf("%d",&mem);
		if(mem==0)
			break;
		for(i=0;i<mem;i++){
			scanf("%lf",&score[i]);
			ave+=score[i];
		}
		ave/=mem;
		for(i=0;i<mem;i++){
			var+=(score[i]-ave)*(score[i]-ave);
		}
		var/=mem;
		var2=sqrt(var);
		printf("%f\n",var2);
	}
	return 0;
}

Measured memory_bytes: 664
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#define ll longlong
using namespace std;

int main(void){
    int n;
    string s;
    stack <char> v;

    cin >> n;
    cin >> s;

    int right = 0;
    for(int i=0; i<n; i++){
        switch (s[i]) {
            case '(':
                v.push('(');
                break;

            case ')':
                if (!v.empty()) {
                    v.pop();
                } else {
                    right++;
                }
        }
    }

    while (right>0){
        cout << "(";
        right--;
    }
    cout << s;

    while (!v.empty()){
        cout << ")";
        v.pop();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n,k;
int a[N];
int b[N];
long long dp[105][N];

long long f(int idx, int weight){
  if (weight>k) return -1e9;
  if (idx>=n) return 0;
  long long &ret = dp[idx][weight];
  if (ret != -1 )return ret;
  ret = max(f(idx+1,weight+a[idx])+b[idx],f(idx+1,weight));
  return ret;
}

int main(){
   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   cin >> n >> k;
   for(int i=0; i<n; i++){
     cin >> a[i] >> b[i];
   }
   memset(dp,-1,sizeof dp);
   cout << f(0,0) << endl;
}

Measured memory_bytes: 82304
let id x = x
let (a,b,c) = Scanf.scanf "%d %d %d\n" (fun a b c -> (a,b,c))

let rec func a b c n =
  if ((a mod 2) = 1) || ((b mod 2) = 1) || ((c mod 2) = 1) then n
  else if (a = b) && (b = c) then -1 else
    func ((b+c)/2) ((a+c)/2) ((a+b)/2) (n+1)

let ans = func a b c 0

let () =
  Printf.printf "%d\n" ans


Measured memory_bytes: 384
// ゴールから逆算する。
// ゴールからすると、一番遠い距離に行くのが手数を少なくするためには最善。
// なので、ゴールからMの距離から順に到着できるところを探す。
// M 以内にスタート地点が来た場合、一手前に戻ってスタート地点から
// 2手で進む場合に1手目が一番小さい数字になる場合を探す？

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPI(i,f,n) for(int i=(f);i<(n);++i)
using namespace std;
typedef long long ll;


int main() {
  int N,M;
  string S;
  cin >> N >> M >> S;
  int now = N;
  vector<int> r;
  
  if ( N <= M ) {
    cout << min(N,M) << endl;
    return 0;
  }

  while ( now-M > 0 ) {
    int jump = 0;
    for(jump=M; jump>0; --jump) {
      if ( S[now-jump] == '1' ) continue;
      r.emplace_back( jump );
      break;
    }
    if ( jump==0 ) {
      cout << "-1" << endl;
      return 0;
    }
    now -= jump;
  }
  if ( now-M == 0 ) {
    r.emplace_back( M );
  } else {
    int &pre = r.back();
    r.pop_back();
    now += pre;
    for(int jump=1; jump<=M; ++jump) {
      if ( S[jump] == '1' ) continue;
      if ( jump+M < now ) continue;
      r.emplace_back( now-jump );
      r.emplace_back( jump );
      break;
    }
  }
  reverse( r.begin(), r.end() );
  for (auto x: r ) cout << x << " ";
  cout << endl;
}


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

public class Program
{
    #region Standard I/O
    readonly TextReader input;
    readonly TextWriter output;

    X[] ReadLine<X>(Func<string, X> func)
    {
        return input.ReadLine().Split(' ').Select(func).ToArray();
    }

    void WriteLineOne(object obj)
    {
        output.WriteLine("{0}", obj);
    }

    void WriteLineMany(params object[] objects)
    {
        output.WriteLine(string.Join(" ", objects.Select(obj => obj.ToString())));
    }
    #endregion

    static long Gcd(long x, long y)
    {
        return y == 0 ? x : Gcd(y, x % y);
    }

    static long Gcd(long[] xs)
    {
        var x = xs[0];

        for (var i = 1; i < xs.Length; i++)
        {
            x = Gcd(x, xs[i]);
        }

        return x;
    }

    long k;
    long[] xs;

    void Read()
    {
        k = ReadLine(long.Parse)[1];
        xs = ReadLine(long.Parse);
    }

    bool Solve()
    {
        var max = xs.Max();
        if (k > max) return false;

        var g = Gcd(xs);
        return k % g == 0;
    }

    public void Run()
    {
        Read();
        WriteLineOne(Solve() ? "POSSIBLE" : "IMPOSSIBLE");
    }

    public Program(TextReader input, TextWriter output)
    {
        this.input = input;
        this.output = output;
    }

    public static void Main(string[] args)
    {
        new Program(Console.In, Console.Out).Run();
    }
}


Measured memory_bytes: 20960
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint n,m;cin>>n>>m;
	llint ans=1;
	for(llint x=2;x*x<=m;x++){
		int kai=0;
		while(m%x==0){kai++;m/=x;}
		for(int i=0;i<kai;i++){
			ans*=n+i;ans%=mod;
			llint bgen=i+1;
			for(int h=0;h<30;h++){
				if((mod-2)&(1<<h)){ans*=bgen;ans%=mod;}
				bgen*=bgen;bgen%=mod;
			}
		}
	}
	if(m>1){ans*=n;ans%=mod;}
	cout<<ans<<endl;
	return 0;
}

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

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

#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 FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

#define DEBUG(x) cout<<#x<<": "<<(x)<<endl

int main(){
	string s;
	cin>>s;
	int n = s.size();
	REP(i,n){
		if(i%2==0 && s[i]=='L'){
			puts("No"); return 0;
		}
		if(i%2==1 && s[i]=='R'){
			puts("No"); return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
sread()=chomp(readline())
iread()=parse(Int,readline())
fread()=parse(Float64,readline())
sreads()=split(readline())
ireads()=parse.(Int,sreads())
freads()=parse.(float,sreads())

function main()
    h,w=ireads()
    tmp=0
    ans=[]
    for i=1:h
        a=ireads()
        r=i%2==1 ? (1:w) : (w:-1:1)
        for j=r
            a[j]+=tmp
            tmp=a[j]%2
            tmp>0 || continue
            i==h && j==r[end] && continue
            if j==r[end]
                res=join([i,j,i+1,j]," ")
            elseif i%2==1
                res=join([i,j,i,j+1]," ")
            else
                res=join([i,j,i,j-1]," ")
            end
            push!(ans,res)
        end
    end
    println(length(ans))
    println(join(ans,"\n"))
end
main()

Measured memory_bytes: 227700
use std::io::*;
use std::str::FromStr;
use std::collections::HashSet;
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
fn main() {
    let n = read::<usize>();
    let mut ds = HashSet::new();
    for _ in 0..n {
        let d = read::<i32>();
        ds.insert(d);
    }
    println!("{}", ds.len())
}

Measured memory_bytes: 4352
import itertools


N = int(input())
L = list(map(int, input().split()))
cnt = 0


cL = list(itertools.combinations(L, 3))

cLlen = len(cL)

for num in range(cLlen):
    if (
        cL[num][0] + cL[num][1] > cL[num][2]
        and cL[num][1] + cL[num][2] > cL[num][0]
        and cL[num][2] + cL[num][0] > cL[num][1]
    ):
        if (
            cL[num][0] != cL[num][1]
            and cL[num][1] != cL[num][2]
            and cL[num][2] != cL[num][0]
        ):
            cnt = cnt + 1


print(cnt)


Measured memory_bytes: 20552
from numpy import argmax
import numpy as np
from collections import defaultdict

def cross(a, b):
    return a[0]*b[1]-a[1]*b[0]

n = int(input())
H = [np.array([int(j) for j in input().split()]) for i in range(n)]

if n == 1:
    print(1)
    exit()
# else n == 2:
#     print(0.5)
#     print(0.5)
#     exit()

convex = [min(H, key=lambda x:x[1])]

for i in range(n):
    a = H[0] if (H[0] != convex[-1]).any() else H[-1]
    for b in H:
        ac = a-convex[-1]
        bc = b-convex[-1]
        cross_ = cross(ac, bc)
        if cross_ < 0 or (cross_ == 0 and np.linalg.norm(ac) < np.linalg.norm(bc)):
            a = b
    if (a == convex[0]).all():
        break
    convex.append(a)

ans = defaultdict(float)

for c, a, b in zip([convex[-1]]+convex[:-1], convex, convex[1:] + [convex[0]]):
    ca = c-a
    ba = b-a
    i = np.inner(ca, ba)
    n = np.linalg.norm(ca) * np.linalg.norm(ba)
    ans[tuple(a)] = (np.pi - np.arccos(np.clip(i/n, -1, 1))) / (2*np.pi)

for i in H:
    print(ans[tuple(i)])

Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,j;
  cin>>n;
  long long int a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  int count=0,maxi=0;
  
  for(i=0;i<n;i++)
  {
    count=0;
    while(i+1<n && a[i+1]<=a[i])
    {
      i++;
      count++;
    }
    maxi=max(maxi,count);
  }
  
  cout<<maxi;
}

Measured memory_bytes: 1024