akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };
int n;
vector<int>V[100010];
int d[100010], d2[100010];
bool used[100010], used2[100010];
void dfs(int x) {
	used[x] = true;
	rep(i, V[x].size()) {
		if (!used[V[x][i]]) {
			d[V[x][i]] = d[x] + 1;
			dfs(V[x][i]);
		}
	}
}
void dfs2(int x) {
	used2[x] = true;
	rep(i, V[x].size()) {
		if (!used2[V[x][i]]) {
			d2[V[x][i]] = d2[x] + 1;
			dfs2(V[x][i]);
		}
	}
}
signed main() {
	cin >> n;
	rep(i, n - 1) {
		int a, b; 
		cin >> a >> b;
		a--; b--;
		V[a].push_back(b);
		V[b].push_back(a);
	}
	dfs(0); dfs2(n - 1);
	int ans = 0, ans2 = 0;
	rep(i, n) {
		if (d[i] > d2[i])ans2++;
		else ans++;
	}
	if (ans > ans2) cout << "Fennec" << endl;
	else {
		cout << "Snuke" << endl;
	}
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
int f[100005];
int p;
long long cost;

struct edge{
	int x,y,w;
	bool operator < (edge e){
		return w<e.w;
	}
}e[200005];

struct node{
	int id,x,y;
}a[100005];
int N;

bool cmp1(node x,node y){
	return x.x<y.x;
}

bool cmp2(node x,node y){
	return x.y<y.y;
}

bool cmp3(edge x,edge y){
	return x.w<y.w;
}

int getfa(int x){
	if(f[x]==x)return x;
	return f[x]=getfa(f[x]);
}

int main(){
	cin>>N;
	int i,j;
	for(i=1;i<=N;i++)
	f[i]=i;
	
	for(i=1;i<=N;i++){
		cin>>a[i].x>>a[i].y;
		a[i].id=i;
	}
	
	sort(a+1,a+N+1,cmp1);

	
	for(i=1;i<N;i++){
		e[i].x=a[i].id;
		e[i].y=a[i+1].id;
		e[i].w=a[i+1].x-a[i].x;
	}
	
	sort(a+1,a+N+1,cmp2);
	
	for(i=1;i<N;i++){
		e[i+N-1].x=a[i].id;
		e[i+N-1].y=a[i+1].id;
		e[i+N-1].w=a[i+1].y-a[i].y;
	}
	
	sort(e+1,e+2*N-1,cmp3);
	
	for(i=1;i<N;i++){
		while(p<2*N-2){
			p++;
			int fx=getfa(e[p].x),fy=getfa(e[p].y);
			if(fx!=fy){
				f[fy]=fx;
				cost+=e[p].w;
				break;
			}
		}
	}
	cout<<cost<<endl;
	return 0;
} 

Measured memory_bytes: 4096
# coding: utf-8
# Here your code !
from collections import deque

n = int(input())
A = [x for x in input().split()]
B = deque()
 
if n % 2 == 0:
    for i in range(n):
        if i % 2 == 0:
            B.append(A[i])
        else:
            B.appendleft(A[i])
else:
    for i in range(n):
        if i % 2 == 0:
            B.appendleft(A[i])
        else:
            B.append(A[i])
print(" ".join(B))

Measured memory_bytes: 26692
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 100000

double dp[NUM+1][20];
double p[20];
double ruisekiwa[NUM+1];

int main(){

	p[0] = 1.0;
	for(int i = 1; i < 20; i++){
		p[i] = p[i-1]*0.5;
	}

	for(int i = 0; i <= NUM; i++){
		for(int k = 0; k < 20; k++){
			dp[i][k] = 0;
		}
	}

	dp[1][1] = 1.0;
	dp[2][0] = 0.5;
	dp[2][2] = 0.5;

	for(int day = 3; day <= NUM; day++){
		dp[day][1] += dp[day-1][0];

		for(int renzoku_num = 1; renzoku_num < 19; renzoku_num++){
			dp[day][renzoku_num+1] += dp[day-1][renzoku_num]*p[renzoku_num];
			dp[day][0] += dp[day-1][renzoku_num]*(1-p[renzoku_num]);
		}
		dp[day][0] += dp[day-1][19]*(1-p[19]);
	}

	ruisekiwa[0] = 0;
	for(int day = 1; day <= NUM; day++){
		ruisekiwa[day] = 0;
		for(int i = 1; i < 20; i++){
			ruisekiwa[day] += dp[day][i];
		}
		ruisekiwa[day] += ruisekiwa[day-1];
	}

	int N;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		printf("%.10lf\n",ruisekiwa[N]);
	}
}

Measured memory_bytes: 19492
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(input())
    A = np.array(input().split(), np.int64)
    B = np.append(0, A.cumsum())
    C = A[::-1].cumsum()
    C = np.append(C[::-1], 0)
    print(np.abs(B-C).min())



if __name__ == '__main__':
    main()

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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long X) {
    __int128_t m = 100;
    rep (i, 100000000) {
        m += m / 100;
        if (X <= m) {
            cout << i + 1 << endl;
            return;
        }
    }
}

int main() {
    long long X;
    scanf("%lld", &X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

std::string s;
std::vector<ll> vs;
ll ans;

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

  ll p = 0;
  char abc = 'A';
  while( p < s.size() || abc != 'A' )
  {
    ll cnt = 0;

    while( s[p] == abc )
      ++cnt, ++p;

    abc = (abc-'A'+1)%3+'A';
    vs.push_back( cnt );
  }

  bool prv = false;
  ll prvA = 0;

  for( int i = 1; i+1 < vs.size(); i += 3 )
  {
    if( vs[i] == 1 )
    { 
      //if( vs[i-1] > 0 && prv )
        //ans += prvA;
      
      if( vs[i+1] > 0 )
      {
        ans += (prv?prvA:0)+vs[i-1];

        if( vs[i+1] == 1 )
          prv = true, prvA += vs[i-1];
        else
          prv = false, prvA = 0;
      }
      else
      {
        prv = false, prvA = 0;
      }
    }
    else
    {
      prv = false;
      prvA = 0;
    }
  }

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

  return 0;
}

// ABCCCCCAAAABCBCAABC
// BCBCAAAAAABC 8+6 = 14

Measured memory_bytes: 2680
import math
import collections
from sys import exit
from itertools import product

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m  = mi()
ab = [li() for _ in range(n)]
cd = [li() for _ in range(m)]

for i in range(n):
    length = 10**10
    ans = 0
    for j in range(m):
        if abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]) < length:
            length = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
            ans = j
    print(ans+1)

Measured memory_bytes: 9420
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int h[n];
  int mx = 0;
  rep(i,n) {
    cin>>h[i];
    mx = max(mx,h[i]);
  }
  int cnt = 0;
  while(true) {
    bool f = true;
    rep(k,n) {
      if(h[k] != 0) f = false;
    }
    if(f) {
      break;
    }
    int pre = 0;
    rep(j,n) {
      if(pre == 0 && h[j] != 0) {
        cnt++;
      }
      pre = h[j];
      if(h[j] != 0) h[j]--;
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;

int to_m(int n)
{
	return n/100*60 + n%100;
}
int main()
{
	while (true)
	{
		int n, p, q;
		scanf("%d %d %d", &n, &p, &q);
		if (n == 0 && p == 0 && q == 0)
			break;
	
		vector<queue<pair<int, int> > > cm;
		for (int i = 0; i < n; ++i)
		{
			queue<pair<int, int > > c;
			int t;
			scanf("%d", &t);
			for (int j = 0; j < t; ++j)
			{
				int s, e;
				scanf("%d %d", &s, &e);
				c.push(make_pair(to_m(s), to_m(e)));
			}
			c.push(make_pair(to_m(q), 1000000));
			cm.push_back(c);
		}

		int maxDuration = 0;
		int prevEnd = to_m(p);
		while (prevEnd < to_m(q))
		{
			int latestStart = -1;
			bool canChangeChannel = true;
			while (canChangeChannel)
			{
				canChangeChannel = false;
				for (int i = 0; i < cm.size(); ++i)
				{
					while (cm[i].front().second <= prevEnd)
						cm[i].pop();
					latestStart = max(latestStart, cm[i].front().first);
				}
				for (int i = 0; i < cm.size(); ++i)
				{
					while (cm[i].front().second <= latestStart)
					{
						cm[i].pop();
						canChangeChannel = true;
					}
				}
			}
			maxDuration = max(maxDuration, latestStart - prevEnd);
			int earliestEnd = 10000000;
			for (int i = 0; i < cm.size(); ++i)
				earliestEnd = min(earliestEnd, cm[i].front().second);

			prevEnd = earliestEnd;
		}

		printf("%d\n", maxDuration);
	}

	return 0;
}

Measured memory_bytes: 0
class Dice:
    def __init__(self,label):
        self.W = label[3]
        self.S = label[1]
        self.E = label[2]
        self.N = label[4]
        self.u = label[0]
        self.l = label[5]
    def rotate(self,direction):
        if direction =='S':
            dummy = self.S
            self.S = self.u
            self.u = self.N
            self.N = self.l
            self.l = dummy
        elif direction == 'N':
            dummy = self.S
            self.S = self.l
            self.l = self.N
            self.N = self.u
            self.u = dummy
        elif direction == 'W':
            dummy = self.W
            self.W = self.u
            self.u = self.E
            self.E = self.l
            self.l = dummy
        else:
            dummy = self.W
            self.W = self.l
            self.l = self.E
            self.E = self.u
            self.u = dummy

D = Dice(input().split())
for i in input():
    D.rotate(i)
print(D.u)


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

#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef vector<ll> dlist;
typedef vector<dlist> matrix;

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

    int t, n, m;
    cin >> n >> m;



    cout << ((n * (n - 1)) / 2)  +(m * (m - 1))/2 << "\n";


    return 0;
}//RUL0


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 main()
{   ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int q;
    cin>>q;
    bool flag = false;
    deque<char> dq;
    for(int i =0; i<s.size(); i++){
        dq.push_back(s[i]);
    }
    while(q--){
        int type;
        cin>>type;
        if(type == 1)flag = !flag;
        else{
            int sc;
            char toadd;
            cin>>sc>>toadd;
            if(sc == 1){
            if(flag)dq.push_back(toadd);
            else dq.push_front(toadd);
            }else{
           if(!flag)dq.push_back(toadd);
            else dq.push_front(toadd);
            }
        }
    }
    string t="";
    if(flag){
        while(!dq.empty())
            t+=dq.back(),dq.pop_back();
    }else{
    while(!dq.empty())
            t+=dq.front(),dq.pop_front();

    }
    cout<<t<<endl;


    return 0;
}


Measured memory_bytes: 1368
#include<stdio.h>

int main(void)
{
  int n,a,b,c,d;
  int count;
  
  while(scanf("%d",&n)!=EOF)
    {

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int n;
const int max_n = 200010;
int a[max_n];
int A;

int main()
{
    cin >> n;
    int ans = 0;
    int cur = 1;
    for (int i = 1; i <= n; i++)
    {
        cin >> A;
        if (A != cur)
        {
            ans++;
        }
        else
        {
            cur++;
        }
    }

    if (ans == n)
    {
        cout << -1 << endl;
        return 0;
    }

    cout << ans << endl;
}


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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = list(map(int,list(str(n))))
if n % sum(s) == 0:
    print('Yes')
else:
    print('No')

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

int main(){
  int p=0,m=0;
  string s;
  cin >> s;

  rep(i,4){
    if(s[i]=='+') p++;
    if(s[i]=='-') m++;
  }
  cout << p-m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int a, b;
  cin >> a >> b;
  int sum = a + b;
  int ave = (sum + 2 - 1) / 2;

  cout << ave << endl;
}

Measured memory_bytes: 3560
n, k = map(int, input().split(" "))
houses = list(map(int, input().split(" ")))
dif_houses = [houses[x+1]-houses[x] for x in range(k-1)]
dif_houses.append(houses[0]-houses[k-1]+n)

max_dif = max(dif_houses)
print(n-max_dif)

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

double dp[301][301][301];
double solve(int x,int y,int z,int &n)
{
    if(x<0 || y<0 || z<0){return 0;}
    if(x==0 && y==0 && z==0){return 0;}
    if(dp[x][y][z] > -0.9){return dp[x][y][z];}
    double exp = n+x*solve(x-1,y,z,n)+y*solve(x+1,y-1,z,n)+z*solve(x,y+1,z-1,n);
    return dp[x][y][z] = exp/(x+y+z);
}

int32_t main()
{
    int n,x;cin>>n;
    memset(dp,-1,sizeof dp);
    int one = 0,two = 0,three = 0;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(x==1){one++;}
        else if(x==2){two++;}
        else three++;
       
    }
     cout<<fixed<<setprecision(9)<<solve(one,two,three,n);
    
    
}




Measured memory_bytes: 216880
#include <cstdio>

const char S[5] = "SHCD";

int main(){
    bool h[4][13];
    for(int i = 0; i<52; i++){
        h[i/13][i%13] = false;
    }
    int n, x;
    char c;
    scanf("%d", &n);
    for(int i = 0; i<n; i++){
        scanf(" %c %d", &c, &x);
        for(int j = 0; j<4; j++){
            if(S[j] == c){
                h[j][x-1] = true;
            }
        }
    }
    for(int i = 0; i<4; i++){
        for(int j = 0; j < 13; j++){
            if(!h[i][j]){
                printf("%c %d\n", S[i], j+1);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2696
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    string s; cin >> s;

    vector< pair<char, int> > rle;
    for(int i=0; i<N; i++) {
        if(rle.empty() or rle.back().first != s[i]) {
            rle.emplace_back(s[i], 1);
        }
        else rle.back().second++;
    }
    cout << rle.size() << endl;
    return 0;
}


Measured memory_bytes: 1528
N,K=map(int,input().split())
S=input()
flag=False
cnt=[]
l=0
r=0
cnt.append([0,0])
for i in range(N):
    if flag:
        if S[i]=='0':
            r=i
            cnt.append([l,r])
            flag=False
    else:
        if S[i]=='1':
            l=i
            flag=True
if flag:
    cnt.append([l,N])
cnt.append([N,N])
ans=0
n=len(cnt)
for i in range(n):
    j=min(n-1,i+K)
    ans=max(cnt[j][1]-cnt[i][0],ans)
print(ans)


Measured memory_bytes: 16708
def go_to_school(n, ali):

    ans = [0]*n

    for i in range(n):
        ans[ali[i]-1] = i+1

    return ans

def main():
    n = int(input())
    ali = list(map(int, input().split()))
    print(*go_to_school(n, ali))

if __name__ == '__main__':
    main()

Measured memory_bytes: 14004
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int maxn=2e5+100;
char s[maxn];
int nxt[maxn],lst[maxn],num;
int nxt_2[maxn],lst_2[maxn];
int dp[maxn][2],n,vis[maxn*2];
int dfs(int x,int sta){
	if(x<=0||x>n)return 0;
	int &ans=dp[x][sta];
	if(~ans)return ans;
	if(s[x]=='x'){
		if(sta)
			return ans=dfs(nxt[x],sta);
		else return ans=dfs(lst[x],sta);
	}
	if(sta)
		return ans=dfs(nxt_2[x],sta)+(s[x]=='o');
	else return ans=dfs(lst_2[x],sta)+(s[x]=='o');
}
void solve(){
	int k,c;
	scddd(n,k,c);
	scanf("%s",s+1);
	int now=n+1;
	for(int i=n;i;i--){
		nxt[i]=now;
		if(s[i]=='o'){
			now=i;
			num++;
		}
	}
	now=0;
	rep1(i,n){
		lst[i]=now;
		if(s[i]=='o'){
			now=i;
		}
	}
	rep1(i,n){
		if(i>c)lst_2[i]=lst[i-c];
		else lst_2[i]=0;
		if(i+c<=n)nxt_2[i]=nxt[i+c];
		else nxt_2[i]=n+1;
	}
	mst(dp,-1);
	rep1(i,n){
		if(s[i]=='o'){
			if(dfs(i-c-1,0)+dfs(i+c+1,1)+1>=k&&c)
				vis[i+1]++,vis[i+c+1]--,vis[max(1,i-c)]++,vis[i]--;
		}
	}
	if(!c){
		if(num==k){
			rep1(i,n)
				if(s[i]=='o')
					printf("%d\n",i);
		}
		return ;
	}
	rep1(i,n){
		vis[i]+=vis[i-1];
		if(s[i]=='o'){
			//if(dfs(i+1,1)>=k)continue;
			//if(dfs(i-1,0)>=k)continue;
			if(vis[i])continue;
			printf("%d\n",i);
		}
	}
}
int main(){
    //IOS;
    //freopen("D://data.txt","r",stdin);
    solve();
    
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;                                             ;;
	;;         ;;            ;;;;;;;;;       ;;    ;;
	;;        ;; ;;        ;;                ;;    ;;
	;;       ;;   ;;       ;;                ;;    ;;
	;;      ;;;;;;;;;      ;;                ;;    ;;
	;;     ;;       ;;     ;;                      ;;
    ;;    ;;         ;;      ;;;;;;;;;       ;;    ;;
    ;;                                             ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    return 0;
}

Measured memory_bytes: 12672
import java.util.Scanner;

public class Main{
  static int a, b;

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    a = sc.nextInt();  b = sc.nextInt();
    if(a == 1){
      a = 14;
    }
    if(b == 1){
      b = 14;
    }

    if(a < b){
      System.out.println("Bob");
    }
    else if(a > b){
      System.out.println("Alice");
    }
    else{
      System.out.println("Draw");
    }
  }
}


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

using namespace std;


int main(){

    long long  x;
    cin >> x;

    for(long long i = -200; i < 200; i++){
	for(long long j = -200; j < 200; j++){
	    if(pow(i,5.0) - pow(j,5.0) == x){
		cout << i << " " << j << endl;
		return 0;
	    }
	}
    }
 
    return  0;
}



Measured memory_bytes: 4020
import math
import sys
N, A, B = map(int, input().split())

v = list(map(int, input().split()))
v.sort()
    
def reduce(x):
  a = x[0]
  b = x[1]
  c = math.gcd(a,b)
  return (a//c, b//c)

def add_dict(dic, a, s):
  if a in dic:
    dic[a] += s
  else:   
    dic[a] = s
    
def comb(a, b):
  b = min(b, a-b)
  ans = 1
  for i in range(a,a-b,-1):
    ans *= i
  for j in range(1,b+1):
    ans //= j
  return ans

ct = {}
v.reverse()
sm = 0 #価値の和
i_prv = -1 #前回のvの値がでてくる最後の項数を示す
i_nxt = 0
search = True
dict_keys_list = []
for i in range(B):
  if search: # i_nxtを探す
    j = i
    while j < N-1 and v[j] == v[j+1]:
      j += 1
    i_nxt = j
    search = False
    
  sm += v[i]
  if A-1 <= i <= B-1: #品物はA個以上B個以下選ぶ
    add_dict(ct, reduce((sm, i+1)), comb(i_nxt-i_prv, i-i_prv))
    dict_keys_list.append(reduce((sm, i+1)))
    
  if i == i_nxt: #値が次に減る時は、i_prvを更新
    i_prv = i_nxt
    search = True
    

dict_keys_list.sort(key = lambda x: x[0]/x[1])
print(dict_keys_list[-1][0] / dict_keys_list[-1][1])
#print(dict_keys_list)
#print(ct)
print(ct[dict_keys_list[-1]])
  
    



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

N = int(input())
A = [int(x) for x in input().split()]

A.sort(reverse=True)
alip = sum(A[i] for i in range(len(A)) if i % 2 == 0)
bobp = sum(A[i] for i in range(len(A)) if i % 2 == 1)
diff = alip - bobp
print(diff)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int a[26];

int d(int l, int r)
{
	if(l>r) swap(l,r);
	return min(r-l,24-(r-l));
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	vector<int> ppl;
	int n; cin>>n;
	ppl.pb(0); 
	for(int i=0;i<n;i++)
	{
		int x; cin>>x; ppl.pb(x);
		if(x==0)
		{
			cout<<0<<'\n';
			return 0;
		}
	}
	sort(ppl.begin(),ppl.end());
	vector<int> v;
	for(int i=0;i<ppl.size();i++)
	{
		if(i>=2&&ppl[i]==ppl[i-1]&&ppl[i]==ppl[i-2])
		{
			cout<<0<<'\n';
			return 0;
		}
		else
		{
			v.pb(ppl[i]);
		}
	}
	n=v.size();
	assert(n<=25);
	int ans=0;
	for(int i=0;i<(1<<n);i++)
	{
		bool pos=1;
		for(int j=0;j<n;j++)
		{
			if(i&(1<<j))
			{
				a[j]=v[j];
			}
			else
			{
				a[j]=(24-v[j])%24;
			}
			if(j>0&&d(a[j],a[j-1])<=ans)
			{
				pos=0; break;
			}
		}
		if(!pos) continue;
		sort(a,a+n);
		int res=1000;
		for(int j=0;j<n;j++)
		{
			res=min(res,d(a[j],a[(j+1)%n]));
			if(res<=ans) break;
		}
		ans=max(ans,res);
	}
	cout<<ans<<'\n';
}	


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

const int MN = 1e5+5;
int deg[MN], n, m, i, x, y, cnt, c, a[MN], vs[MN];
vector<int >adj[MN];
queue<int> q;

int main(){
    for(scanf("%d%d",&n,&m),i=1;i<=m;i++){
        scanf("%d%d",&x,&y);
        deg[x]++, deg[y]++;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for(i=1;i<=n;i++){
        if(deg[i]%2){
            printf("No\n");
            return 0;
        }
        deg[i] -= 2;
        if(deg[i]) a[++c]=i;
        cnt += (deg[i]/2);
    }
    if(c==2&&cnt==2){
        int lol = 0;
        q.push(a[1]); vs[a[1]]=vs[a[2]]=1;
        while(q.size()){
            int cur = q.front(); q.pop();
            for(auto v : adj[cur]){
                if(v==a[2]) lol++;
                if(!vs[v]){vs[v]=1; q.push(v);}
            }
        }
        if(lol==4) printf("No\n");
        else printf("Yes\n");
        return 0;
    }
    printf("%s\n",cnt>=2?"Yes":"No");
    return 0;
}


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

int main() {
		
	int n, k; cin >> n >> k;
	vector<char> d(k);
	for (int i = 0; i < k; i++) {
		char c; cin >> c;
		d[i] = c;
	}
	int ans;
	for (int i = n; i <= 10 * n; i++) {
		bool ok = true;
		string tmp_i = to_string(i);
		for (int j = 0; j < tmp_i.size(); j++) {
			for (int x = 0; x < k; x++) {
				if (tmp_i[j] == d[x]) {
					ok = false;
				}
			}
		}
		if (ok) {
			ans = i;
			break;
		}
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>

using namespace std;

const int MOD = 1000000007;


inline int add(int a, int b)
{ 
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}

inline int sub(int a, int b)
{ 
  a -= b;
  if (a < 0) a += MOD;
  return a;
}

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

  int N, K;

  std::cin >> N >> K;

  vector<vector<int>> prefix = vector<vector<int>>(N+1, vector<int>(K+1, 0));
  prefix[0] = vector<int>(K+1, 1);

  for (int i = 1; i <= N; ++i)
  { 
    int kid;
    cin >> kid;

    for (int sum = 0; sum <= K; ++sum)
    { 
      const int R = min(kid, sum);
      const int res = sub(prefix[i - 1][sum], (sum - R > 0 ? prefix[i - 1][sum - R - 1] : 0));
      prefix[i][sum] = add(res, (sum > 0 ? prefix[i][sum - 1] : 0));
    }
  }

  std::cout << sub(prefix[N][K], prefix[N][K - 1]);

  return 0;
}

Measured memory_bytes: 40192
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    
    ll n;
    cin >> n;
    string t;
    cin >> t;
    ll i = 0;
    while (i < t.size())
    {
        char temp = t[i] + n;
        if (temp > 'Z'){
            temp -= 'Z';
            temp += 'A' - 1;
        }

        cout << temp;
        i++;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vli vector<pair<ll,int>>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

vector<ll> parent, rak;

void make_set(int f){
    fo(i,f+1)parent.pb(i);
    rak.assign(f+1,1);
}

ll find_set(ll v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

ll union_sets(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rak[a]+=rak[b];
        return (rak[a]-rak[b])*(rak[b]);
    }
    return 0;
}

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>n;
    cout<<"Christmas ";
    n=25-n;
    while(n--)cout<<"Eve ";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;


void solve(){
    lli n,m,s=0; cin>>n>>m;
    vi a(m); NA(i,0,m) cin>>a[i], s+=a[i];
    if(s>n) {cout<<(-1); return;}
    cout<<(n-s); 
    return ;
}
int main(){
    fastIO;
    lli t = 1; 
    // cin>>t;
    NA(i,0,t) solve();
    return 0;
}

Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	int C = sc.nextInt();
    	int N = sc.nextInt();
    	sc.close();
    	int ans = 0;
    	for(int i = 0; i <= A; i++){
    		for(int j = 0; j <= B; j++){
    			for(int k = 0; k <= C; k++){
    				if((i * 500 + j * 100 + k * 50) == N){
    					ans++;
    				}
    			}
    		}

    	}
    	System.out.println(ans);
    }

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

void solve(){
    int n;cin>>n;
    int i=1;
    while(i*i<=n) i++;
    i--;
    cout << i*i <<endl;
}

int main(){
    solve();
    return 0;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    string s;cin>>s;
    //s = '0' + s;
    reverse(s.begin(), s.end());
    s += '0';
    //dump(s)

    LL result = 0;

    REP(i,SIZE(s)){
        int now = s[i] - '0';
        if(now < 5){
            result += now;
            //s[i] = '0';
        }
        else if(now == 5){
            if(s[i+1] < '5'){
                result += now;
                //s[i] = '0';
            }
            else{
                result += 10-now;
                int j=1;
                while(s[i+j] == '9'){
                    //s[i] = '0';
                    s[i+j] = '0';
                    j++;
                }
                s[i+j] ++ ;
            }
        }
        else{
            result += 10-now;
            s[i] = '0';
            int j=1;
            while(s[i+j] == '9'){
                s[i+j] = '0';
                j++;
            }
            s[i+j] ++ ;
        }
        //dump(result)
        //dump(s)
    }
    cout << result << endl;



    


    


	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        vector<int> a(n);
        for(int i = 0; i < n; i++)  cin >> a[i];
        sort(a.begin(), a.end());
        if(a[0]+a[1] > m){
            cout << "NONE" << endl;
            continue;
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            if(a[i] >= m)    break;
            int j = lower_bound(a.begin(), a.end(), m-a[i])-a.begin();
            if(j >= n || a[j]+a[i] > m)   j--;
            if(j >= 0 && i != j)  ans = max(ans, a[i]+a[j]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3164
import java.util.*;

public class Main {
	Scanner sc;
	int N, M, P;
	int[][] nodes;
	int[][] edges;
	
	public Main() {
		sc = new Scanner(System.in);
	}
	
	private void calc() {
		N = sc.nextInt();
		M = sc.nextInt();
		P = sc.nextInt();
		
		nodes = new int[N+1][2];
		for (int i = 1; i <= N; i++) nodes[i][0] = Integer.MIN_VALUE;
		
		edges = new int[M+1][3];
		for (int i = 1; i <= M; i++) {
			edges[i][0] = sc.nextInt();
			edges[i][1] = sc.nextInt();
			edges[i][2] = sc.nextInt() - P;
		}
		
		nodes[1][0] = 0;
		nodes[N][1] = 1;
		boolean infinite = false;
		for (int i = 0; i < N; i++) {
			infinite = false;
			for (int j = 1; j <= M; j++) {
				nodes[edges[j][0]][1] |= nodes[edges[j][1]][1];
				int s = nodes[edges[j][0]][0];
				if (s == Integer.MIN_VALUE) continue;
				int p = s + edges[j][2];
				if (nodes[edges[j][1]][0] < p) {
					nodes[edges[j][1]][0] = p;
					if (nodes[edges[j][1]][1] > 0) infinite = true;
				}
			}
		}
		
		if (infinite) System.out.println(-1);
		else System.out.println(Math.max(0, nodes[N][0]));
		System.out.flush();
	}

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


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

char X[1000 + 1], Y[1000 + 1];
int lcs[1000 + 1][1000 + 1];

void calc_lcs(int lx, int ly);

int main(int argc, char *argv[])
{
  int q, i, j, k, lx, ly;

  scanf("%d", &q);

  for (i = 0; i < q; i++) {
    scanf("%s", X);
    scanf("%s", Y);

    lx = strlen(X);
    ly = strlen(Y);
    for (j = 0; j <= lx; j++) {
      for (k = 0; k <= ly; k++) calc_lcs(j, k);
    }
    printf("%d\n", lcs[lx][ly]);
  }

  return 0;
}


void calc_lcs(int lx, int ly)
{
  if (lx == 0 || ly == 0) {
    lcs[lx][ly] = 0;
    return;
  }

  if (X[lx-1] == Y[ly-1]) lcs[lx][ly] = lcs[lx-1][ly-1] + 1;
  else lcs[lx][ly] = (int)fmax(lcs[lx][ly-1], lcs[lx-1][ly]);
}

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

namespace abc112_c
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			Tuple<int, int, int>[] tuples = new Tuple<int, int, int>[n];
			Tuple<int, int, int> sample=new Tuple<int, int, int>(0,0,0);
			for (int i = 0; i < n; i++)
			{
				int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
				tuples[i] = new Tuple<int, int, int>(x[0], x[1], x[2]);
				if (x[2] != 0) sample = new Tuple<int, int, int>(x[0], x[1], x[2]);
			}
			for (int i = 0; i <= 100; i++)
			{
				for (int j = 0; j <= 100; j++)
				{
					int high = sample.Item3 + Math.Abs(i - sample.Item1) + Math.Abs(j - sample.Item2);
					bool ok = true;
					for(int k = 0; k < n; k++)
					{
						int a = Math.Max(0, high - Math.Abs(i - tuples[k].Item1) - Math.Abs(j - tuples[k].Item2));
						if (a != tuples[k].Item3) ok = false;
					}
					if (ok) Console.WriteLine(i + " " + j + " " + high);
				}
			}
		}
	}
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int a,b,c;

	cin>>a>>b>>c;
	cout<<(a+b)*c/2<<endl;

	return 0;
}


Measured memory_bytes: 256
url = "https://atcoder.jp/contests/abc163/tasks/abc163_b"

def main():
    t = list(map(int, input().split()))
    ans = 0

    li = []
    for i in range(3):
        tmp = 0
        if t[i] <= t[-1]:
            tmp = t[i]
            t[-1] -= t[i]
        elif t[i] > t[-1]:
            tmp = t[-1]
            t[-1] -= t[-1]
        li.append(tmp)
    print((li[0] * 1) + (li[1] * 0) + (li[2] * -1))









if __name__ == '__main__':
    main()


Measured memory_bytes: 61880
#!/usr/bin/env lua

s = io.read("*line")
nlist = {}
j = 1
for i in string.gmatch(s, "%S+") do
    nlist[j] = tonumber(i)
    j = j + 1
end

if nlist[1] + nlist[2] >= 10 then
        print("error")
else
        print(nlist[1]+nlist[2])
end

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}

const int INF = 1e9, MOD = 998244353; /// think
const ll LINF = 1e15;

const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if (s[0] == 'S') {
        cout << "Cloudy\n";
    }
    else if (s[0] == 'R') {
        cout << "Sunny\n";
    }
    else  {
        cout << "Rainy\n";
    }
}


Measured memory_bytes: 3656
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#define rep(i,rept) for(long long i = 0; i <(long long)rept;i++)
using namespace std;
int main() {
	int a = 0, b = 0, c = 0, d[100000], e[100000], f = 0, g = 0, h = 0, count = 0,x=0,y=0,z=0;
	char rikka, toka[100000];
	string saya, homu, kyok, mami, mado[50];
	bool gg = true;
	int manji, nk[26] = { false };
	cin >> saya;
	for (int i = saya.length(); i >0 ; i--) {
		
        if (i == saya.length()) { count++; }
		if (i % 2 == 0) { count++; }
		if (count == 0) {
			if (saya.substr(0, i / 2) == saya.substr(i / 2 , i / 2)) {
				cout << i-1 << endl;
				return 0;
			}
		}
		count = 0;

	}
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
srray = gets.split("").map(&:to_s)
# answer.push(srray.count("."))
i=0
brray = []
crray = srray
subanswer = brray.count("#")+crray.count(".")
answer = subanswer
while i<n
  tmp = crray.shift
  if tmp == '#' then
    subanswer += 1
  elsif tmp == '.' then
    subanswer -= 1
  end
  answer = [answer,subanswer].min
  # j=0
  # while j<i+1
  #   brray.push(srray[j])
  #   j+=1
  # end
  # while j>i && j<n
  #   crray.push(srray[j])
  #   j+=1
  # end
  # answer.push(brray.count("#")+crray.count("."))
  i+=1
end
puts answer

Measured memory_bytes: 18172
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define INF 3e9
#define mod 1000000007
#define abs(x) ((x)>=0?(x):-(x))
#define y1 solai
#define fi first
#define se second
typedef long long ll;
void read(ll &x)
{
	scanf("%lld",&x);
}
void read(ll &x, ll &y)
{
	scanf("%lld%lld",&x,&y);
}
void read(ll &x, ll &y, ll &z)
{
	scanf("%lld%lld%lld",&x,&y,&z);
}
void print(ll x)
{
	printf("%lld ",x);
}
void println(ll x)
{
	printf("%lld\n",x);
}
const ll N=200000;
ll n,m,w[N+10],b[N+10],sz,ch,pos[N+10];
vector<ll>v[N+10],c[N+10];
struct item
{
	ll l,r,d;
}a[N+10];
void dfs(ll x)
{
	w[x]=1;
	for(ll i=0;i<v[x].size();i++)
	{
		ll to=v[x][i];
		if(!w[to])
			dfs(to);
	}
	b[sz--]=x;
}
void dfs1(ll x, ll pr)
{
	w[x]=1;
	if(v[x].empty()&&pos[x]==0)
		pos[x]=INF;
	for(ll i=0;i<v[x].size();i++)
	{
		ll to=v[x][i],dist=c[x][i];
		if(!w[to])
		{
			if(pos[x])
			{
				if(pos[to]&&pos[to]!=pos[x]+dist)
					ch=1;
				pos[to]=pos[x]+dist;
			}
			dfs1(to,x);
		}
		else if(w[to]==1)
			ch=1;
		if(pos[x]&&pos[to]!=pos[x]+dist)
			ch=1;
		else if(!pos[x])
			pos[x]=pos[to]-dist;
	}
	w[x]=2;
}
int main()
{
	//freopen("c.cpp","r",stdin);
 
	cin>>n>>m;
	sz=n;
	for(ll i=1;i<=m;i++)
		read(a[i].l,a[i].r,a[i].d),v[a[i].l].pb(a[i].r),c[a[i].l].pb(a[i].d);
	for(ll i=1;i<=n;i++)
		if(!w[i])
			dfs(i);
	for(ll i=1;i<=n;i++)
		w[i]=0;
	for(ll i=1;i<=n;i++)
		if(!w[b[i]])
			dfs1(b[i],0);
	if(ch)
		cout<<"No";
	else
		cout<<"Yes";
}

Measured memory_bytes: 32768
import sys
import collections

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def check_path(mp, is_archive, wi, hi):
	w = len(mp[0])
	h = len(mp)
	nb = 0
	nw = 0
	qq=collections.deque()
	st_color = mp[hi][wi]
	nb+=1
	qq.append((wi, hi, st_color))
	is_archive[hi][wi] = 1
	while qq:
		pw, ph, pc = qq.popleft()
		for dw, dh in ((1,0), (-1,0), (0,1),(0,-1)):
			if pw+dw<0 or pw+dw>=w or ph+dh < 0 or ph+dh >= h:
				continue
			if is_archive[ph+dh][pw+dw]>0:
				continue
			if mp[ph+dh][pw+dw]==pc:
				continue
			nc = mp[ph+dh][pw+dw]
			if nc == st_color:
				nb += 1
			else:
				nw += 1
			
			qq.append((pw+dw, ph+dh, nc))
			is_archive[ph+dh][pw+dw]=1
	
	return nb*nw

def main():
	#a = int(input())
	h, w = tin()
	#s = input()
	mp = [input() for _ in range(h)]
	is_archive = [[-1]*w for _ in range(h)]
	ret = 0
	for wi in range(w):
		for hi in range(h):
			if is_archive[hi][wi] != -1:
				continue
			nn = check_path(mp, is_archive, wi, hi)
			ret += nn
	print(ret)
			
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 10900