akhauriyash/Code-Regression huggingface dataset:
n, l, t = map(int, input().split())
cor_0 = [list(map(int, input().split())) for _ in range(n)]
cor_t = [(x+t)%l if w == 1 else (x-t)%l for x,w in cor_0]
x0, w0 = cor_0[0]
xt = cor_t[0]
cor_t.sort()


marker = 0
for i in range(1,n):
    if w0 == cor_0[i][1]:
        continue
    
    dist = 2 * t
    if w0 == 1:
        if dist - (cor_0[i][0] - x0) % l >= 0:
            marker += 1
            dist -= (cor_0[i][0] - x0) % l
            marker += dist // l
            if dist % l == 0:
                marker -= 1
    else:
        if dist - (x0 - cor_0[i][0]) % l >= 0:
            marker -= 1
            dist -= (x0 - cor_0[i][0]) % l
            marker -= dist // l

marker %= n
pos_x0 = (cor_t.index(xt) - marker) % n
for i in range(pos_x0, pos_x0+n):
    print(cor_t[i%n])

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

int main(){
  
   string a;
   cin >> a;
  
   sort( a.begin(),a.end() );
  
   for(int i=0;i<a.size()-1;i++){
     
    if( a.at(i) == a.at(i+1) ){
      
      cout << "no" << endl;
      return 0;
    }
     
   }
  
     cout << "yes" << endl;
  
}
  
  


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

int main() {
	int n, a[100000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 1, type = 0;
	for (int i = 1; i < n; i++) {
		if (type == 1 && a[i] < a[i - 1]) {
			type = 0; ans++;
		}
		else if (type == 2 && a[i] > a[i - 1]) {
			type = 0; ans++;
		}
		else if (type == 0 && a[i] < a[i - 1]) {
			type = 2;
		}
		else if (type == 0 && a[i] > a[i - 1]) {
			type = 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;

int main(void)
{
  string s;
  cin >> s;

  if (s == "SUN") {
	  printf("%d", 7);
  }
  else if(s == "MON"){
	  printf("%d",6);
  }
  else if (s == "TUE") {
	  printf("%d",5);
  }
  else if (s == "WED") {
	  printf("%d",4);
  }
  else if (s == "THU") {
	  printf("%d",3);
  }
  else if (s == "FRI") {
	  printf("%d",2);
  }
  else if (s == "SAT") {
	  printf("%d",1);
  }
  return 0;
}

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

answer = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for i in range(N):
    s = input()
    answer[s] = answer.get(s, 0) + 1

print('AC x ' + str(answer['AC']))
print('WA x ' + str(answer['WA']))
print('TLE x ' + str(answer['TLE']))
print('RE x ' + str(answer['RE']))

Measured memory_bytes: 9088
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int n,pre[300005],nex[300005],a[300005];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		if ((a[i]^i)&1) { printf("No\n");return 0; }
	pre[0]=0,nex[n+1]=1000000000;
	for (int i=1;i<=n;i++) pre[i]=max(pre[i-1],a[i]);
	for (int i=n;i>=1;i--) nex[i]=min(nex[i+1],a[i]);
	for (int i=2;i<n;i++)
		if (a[i]!=i && nex[i+1]<a[i] && pre[i-1]>a[i]) { printf("No\n");return 0; }
	for (int i=1;i<=n-1;i++)
		if( ((a[i]==i)==(a[i+1]==i+1)) && pre[i]!=i) { printf("No\n");return 0; }
	printf("Yes\n");
	return 0;
}


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

using namespace std;
typedef long long int ll;

#define endl '\n'


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

    ll n,d;
    cin>>n>>d;

    vector <ll> vec[n];

    for(ll i=0;i<n;i++){
        for(ll j=0;j<d;j++){
            ll x;
            cin>>x;
            vec[i].push_back(x);
        }
    }

    ll ans = 0;

    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
            ll val = 0;
            for(ll k=0;k<d;k++)
            {
                val += (vec[i][k]-vec[j][k])*(vec[i][k]-vec[j][k]);
            }
            long double h = sqrt(val);
            if(ceil(h)==floor(h))
            {
                ans++;
            }
        }
    }
    cout<<ans<<endl;

}









Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int num;

    cin >> num;

    if ((num/10)%111 == 0 || (num%1000)%111 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl; 
    }

    return 0;
}

Measured memory_bytes: 256
#!python3.8
# -*- coding: utf-8 -*-
# abc170/abc170_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    x = i2nn()
    for i in range(5):
        if x[i] == 0:
            print(i + 1)
            return
    return

main()


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

int main() {
    int a, b, c = -1e9;
    scanf("%d %d", &a, &b);
    c = max(c, a + b);
    c = max(c, a - b);
    c = max(c, a * b);
    cout << c << endl;
    return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

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

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF= 1e20;

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();

int main() {
	char c[3][3];
  REP(i,3){
    REP(j,3)cin>>c[i][j];
  }
  cout<<c[0][0]<<c[1][1]<<c[2][2];
	return 0;
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}


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

public class Program
{
    public static void Main()
    {
        string strData = Console.ReadLine();
        int count = int.Parse(Console.ReadLine());

        for (int i = 0; i < count; i++)
        {
            string[] tmp = Console.ReadLine().Split(' ');

            int startNum = int.Parse(tmp[1]);
            int endNum = int.Parse(tmp[2]);
            int len = endNum - startNum + 1;

            if ("print" == tmp[0])
            {
                Console.WriteLine(strData.Substring(startNum, len));
            }
            else if ("reverse" == tmp[0])
            {
                string t = new string(strData.Substring(startNum, len).Reverse().ToArray());
                strData = strData.Substring(0, startNum) + t + strData.Substring(endNum + 1);
            }
            else if ("replace" == tmp[0])
            {
                strData = strData.Substring(0, startNum) + tmp[3] + strData.Substring(endNum + 1);
            }
        }
    }
}

Measured memory_bytes: 9544
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int,input().split()))
for i in range(n):
  if i % 2 == 0 and A[i] % 2 == 1:
    count += 1
print(count)

Measured memory_bytes: 65416
"use strict"
let fs = require('fs');
let input = fs.readFileSync("/dev/stdin", "utf8").split(/\s/);

let args: number[] = input.map(mp => +mp);
let current = args[1];
let ans = 0;

for(let i=0; i<args[2]; i++) {
  if( current >= args[0] ) {
    current -= args[0];
    ans++;
  } else {
    break;
  }
}

console.log(ans);

Measured memory_bytes: 7500
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] h = new int[n];
        for(int i=0;i<n;i++){
            h[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        int count = 0;
        int maxCount = -1;
        for(int i=n-2;i>=0;i--){
            if(h[i] >= h[i+1]){
                count++;
            }else{
                if(count > maxCount){
                    maxCount = count;
                   
                }
               count = 0;
            }
        }
        maxCount = Math.max(maxCount,count);
        System.out.println(maxCount);
    }
}


Measured memory_bytes: 48136
import java.io.PrintWriter;
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        long MOD = (long) 1e9 + 7;
        int n = sc.nextInt();

        if (n == 1) {
            System.out.println(0);
            return;
        }
        long total = 1;
        long ex0 = 1;
        long ex9 = 1;
        long ex09 = 1;
        for (int i = 0; i < n; i++) {
            total = total * 10 % MOD;
            ex0 = ex0 * 9 % MOD;
            ex9 = ex9 * 9 % MOD;
            ex09 = ex09 * 8 % MOD;
        }

        long hoge = (total - (ex0 + ex9 - ex09)) % MOD;
        System.out.println(hoge < 0 ? hoge + MOD : hoge);


        // out.println("Hello World");
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


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

int n, m, x;
int res = 0;

int main(){
  cin >> n >> x;
  int sum = 0, low = 1000000;
  rep(i, n){
    cin >> m;
    sum += m;
    low = min(low, m);
    cerr << i;
  }
  x -= sum;
  int tmp = x / low;
  res = tmp + n;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
#define For(i,a,b) for(i=(a);i<=(b);++i)
using namespace std;
template<typename T>void read(T &x)
{
    T s=0,f=1;char k=getchar();
    while(!isdigit(k)&&k!='-')k=getchar();
    if(!isdigit(k)){f=-1;k=getchar();}
    while(isdigit(k)){s=s*10+k-'0';k=getchar();}
    x=s*f;
}
const int MAXN=200010;
int n,k;
map<int,int>G;
int main(void)
{
	read(n);
	int i;
	For(i,1,n)
	{
		read(k);
		if(!G[k])G[k]=1;
		else ++G[k];
	}
	read(n);
	For(i,1,n)
	{
		read(k);
		if(!G[k])
		{
			printf("NO\n");
			return 0;
		}
		else --G[k];
	}
	printf("YES\n");
    return 0;
}


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

int main(void){
  string s;
  cin >> s;
  int b, w;
  b = w = 0;
  for(int i = 0; i < s.length(); i++){
    if(i % 2 == 0){
      if(s[i] == '1') b++;
    }else{
      if(s[i] == '0') b++;
    }
  }
  for(int i = 0; i < s.length(); i++){
    if(i % 2 == 0){
      if(s[i] == '0') w++;
    }else{
      if(s[i] == '1') w++;
    }
  }
  cout << min(b, w) << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(m,v) memset(m,v,sizeof(m))
#define pr(a,s) printf("Case #%lld: %lld\n",a,s)
#define mod 1000000007
#define mp make_pair
#define all(a)                a.begin(),a.end()
#define pb push_back
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define se second
#define fi first
#define pi 3.14159265358979323
#define pii pair<ll,ll>
 
const ll inf = 1e15;
const int MAXM = 1e5+4;
const int MAXN = 1e4+10;

int n;
int arr[MAXM][4], dp[MAXM][4];

int solve(int idx, int prevk) 
{
	if (idx == n+1)	return 0;
	if (dp[idx][prevk] != -1)	return dp[idx][prevk];
	int ret = 0;
	if (idx == 0) {
		ret = max(ret, arr[idx+1][1] + solve(idx+1, 1));
		ret = max(ret, arr[idx+1][2] + solve(idx+1, 2));
		ret = max(ret, arr[idx+1][3] + solve(idx+1, 3));
	} else {
		if (prevk == 1){
			ret = max(ret, arr[idx+1][2] + solve(idx+1, 2));
			ret = max(ret, arr[idx+1][3] + solve(idx+1, 3));
		} else if (prevk == 2) {
			ret = max(ret, arr[idx+1][1] + solve(idx+1, 1));
			ret = max(ret, arr[idx+1][3] + solve(idx+1, 3));
		} else {
			ret = max(ret, arr[idx+1][1] + solve(idx+1, 1));
			ret = max(ret, arr[idx+1][2] + solve(idx+1, 2));
		}
	}
	return dp[idx][prevk] = ret;
}

int main() 
{
	cin>>n;
	for (int i=1;i<=n;i++){
		dp[i][1] = dp[i][2] = dp[i][3] = -1;
		cin>>arr[i][1]>>arr[i][2]>>arr[i][3];
	}
	dp[0][0] = -1;
	cout << solve(0,0) << endl;
	return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int q,h,s,d,n;
    cin>>q>>h>>s>>d>>n;
    int one=min({4*q,2*h,s});
    int two=min(2*one,d);
    cout<<n/2*two+(n%2)*one<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	char s[200010];
	scanf("%s",s);
	int a;
	for(int i=0;s[i]!=0;i++){
		a+=s[i]-'0';
	}
	if(a%9==0)printf("Yes");
	else printf("No");
	
}

Measured memory_bytes: 1896
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<vector>
#define pi 2*acos(0)
#define SF scanf
#define SFd1(a) scanf("%d",&a)
#define SFd2(a,b) scanf("%d%d",&a,&b)
#define SFd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define PF printf
#define inf 99999999
#define eps 0.00000001
#define ll long long
#define ull long long unsigned
#define fr(i,n) for(i=0;i<n;i++)
#define dist(x1,y1,x2,y2) sqrt( ((x2-x1)*(x2-x1)) + ((y2-y1)*(y2-y1)) )
using namespace std;
//int rr[]={1,2,-1,-2,1,2,-1,-2};
//int cc[]={2,1,2,1,-2,-1,-2,-1};


main()
{
    int a,b,k;
    while(cin>>a>>b)
    {
        a+=b;
        k=0;
        while(a!=0)
        {
            a/=10;
            k++;
        }
        printf("%d\n",max(k,1));
    }
    return 0;
}

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

int main()
{
    int n, q;
    cin >> n >> q;
    
    string s;
    cin >> s;

    int a[n+1]; a[0] = 0;
    
    int ct = 0;
    for (int i = 0; i < n - 1; i++){
        if (s[i]=='A' && s[i+1] == 'C'){
            ct++;
        }
        a[i+1] = ct;
    }

    for (int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        int ans = a[r-1] - a[l-1];
        cout << ans << endl;
    }    
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <deque>
#include <string>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <map>
#include <unordered_map>
#include <bitset>

#define _crt_secure_no_warnings
#define FREEELO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define INF 0x3F3F3F3F3F3F3F3F
#define MAX 300001
#define ALPHABET 128
#define loop(i, n) for (int i = 1; i <= (n); i++)
#define loop0(i, n) for (int i = 0; i < (n); i++)
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll, ll> llll;
typedef pair<int, int> ii;
typedef unordered_map<int, int> umii;
typedef unordered_map<ll, ll> umll;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    loop0(i, n) cin >> a[i];
    int cnt = 0;
    loop0(i, n){
        for (int j = i + 1; j < n; j++){
            for (int k = j + 1; k < n; k++){
                if (a[i] == a[j] || a[j] == a[k] || a[i] == a[k]) continue;
                if (a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i]) cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3160
#pragma GCC optimize("Ofast")
#include <cstdio>
using namespace std;

inline int getint()
{
    int x = 0, c = getchar();
    while (c > 47 && c < 58)
    {
        x = x * 10 + c - 48;
        c = getchar();
    }
    return x;
}

constexpr int MAX = 300000;
constexpr int mask = (1 << 20) - 1;
long bomb[MAX];
long pos[MAX];

int main()
{
    int H = getint();
    int W = getint();
    int M = getint();

    int h;
    long w;
    int ans, x, y;
    int mxr = 0;
    int mxc = 0;
    int ctrow = 0;
    int ctcol = 0;
    for (int i = 0; i < M; ++i)
    {
        h = getint() - 1, w = getint() - 1;
        bomb[i] = h + (w << 20);
        ++pos[h], pos[w] += 1 << 20;

        x = pos[h] & mask;
        y = pos[w] >> 20;

        if (x == mxr) ++ctrow;
        else if (x > mxr) mxr = x, ctrow = 1;

        if (y == mxc) ++ctcol;
        else if(y > mxc) mxc = y, ctcol = 1;
    }
    ans = mxr + mxc;

    long ct = ctrow;
    ct *= ctcol;
    if (ct > M)
    {
        printf("%d\n", ans);
        return 0;
    }

    for (int i = 0; i < M; ++i) ct -= ((pos[bomb[i] & mask] & mask) == mxr) && ((pos[bomb[i] >> 20] >> 20) == mxc);
    printf("%d\n", ans - (ct <= 0));
    return 0;
}


Measured memory_bytes: 6272
#include<stdio.h>
int main(void){
   int high[10];
   int i;
   int ans[] = {0,0,0};
   for(i=0;i<10;i++){
      scanf("%d",&high[i]);
   }
   ans[0] = high[0];
   
   for(i=1;i<10;i++){
      if(high[i] > ans[0]){
         ans[2] = ans[1];
         ans[1] = ans[0];
         ans[0] = high[i];
      }
      else if(high[i] > ans[1]){
         ans[2] = ans[1];
         ans[1] = high[i];
      }
      else if(high[i] > ans[2]){
         ans[2] = high[i];
      }
   }
   for(i=0;i<3;i++){
      printf("%d\n",ans[i]);
   }
   return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include  <set>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(i=0;i<n;i++)

int main() {
	ll a, b, c, d, e, f, g, h, i, j, n, m, l, sum = 0,aa[10];
	string s;
	cin >> s;
	l = s.size() - 1;
	//rep(i, size(s))(cout << s[i]);
	rep(i, (1 << l)) {
		c = 0;
		d = int(s[0])-'0';
		rep(j,l){
			if (i & (1 << j)) {
		//		cout << d << "  ";
				c =c+ d;
				d = int(s[j + 1]) - '0';

			}
			else d = 10 * d + int(s[j + 1]) - '0';
			}

	//	cout << d << " "<< c+d<< "\n";
		sum = sum+ c + d;
	}

	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int i,j,k,n,x,tot=0;
    vector<long long int>v,u;
    cin>>n;
    v.push_back(0);
    for(i=0;i<n;i++)
    {
        cin>>k;
        v.push_back(k);
    }
    v.push_back(0);
    for(i=1;i<=n+1;i++)
    {
        tot+=abs(v[i]-v[i-1]);
    }
    //cout<<tot<<endl;
    for(i=1;i<=n;i++)
    {
        cout<<tot-abs(v[i]-v[i-1])-abs(v[i]-v[i+1])+abs(v[i-1]-v[i+1])<<endl;
    }
    return 0;
}


Measured memory_bytes: 2164
main=print.solve.map read.words=<<getContents
solve(_:a:b:c:ls)=f(0,0,0)ls where
  f(i,j,k)[]
    |all(/=0)[i,j,k]=(abs$i-a)+(abs$j-b)+(abs$k-c)-30
    |otherwise=maxBound`div`2::Int
  f(i,j,k)(l:ls)=minimum[f(i,j,k)ls,f(i+l,j,k)ls+10,f(i,j+l,k)ls+10,f(i,j,k+l)ls+10]

Measured memory_bytes: 4940
n = int(input())
s = input()
cnt = 0
if n % 2 == 0:
    for i in range(n//2):
        if s[i] == s[i + n // 2]:
            cnt += 1

if n % 2 == 1:
    print('No')
else:
    if cnt == n // 2:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 2940
void main() {
	auto S = readln.to!(char[]);
	S[3] = '8';
	S.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define mod 1000000007

struct state{
  int i,j,s,k;
};

int H,W,S;
int si,sj,gi,gj;
string b[100];
bool sw[10][100][100];
int dist[50][50][1<<10][2];
int dd[]={-1,0,1,0,-1};

int main(){
  cin>>W>>H;
  rep(i,H){
    cin>>b[i];
    rep(j,W){
      if(b[i][j]=='%'){
        si=i; sj=j;
      }
      if(b[i][j]=='&'){
        gi=i; gj=j;
      }
    }
  }
  cin>>S;
  rep(s,S){
    rep(i,H){
      string in;
      cin>>in;
      rep(j,W){
        if(in[j]=='*'){
          sw[s][i][j]=true;
        }
      }
    }
  }
  queue<state> que;
  rep(i,H)rep(j,W)rep(s,1<<S)rep(k,2)dist[i][j][s][k]=INF;
  que.push((state){si,sj,0,0});
  dist[si][sj][0][0]=0;
  while(que.size()){
    state s=que.front(); que.pop();
    int crtd=dist[s.i][s.j][s.s][s.k];
    if(s.i==gi&&s.j==gj){
      cout<<crtd<<endl;
      return 0;
    }
    rep(dir,4){ // move
      int ni=s.i+dd[dir],nj=s.j+dd[dir+1];
      if(ni<0||ni>=H||nj<0||nj>=W||b[ni][nj]=='#'||dist[ni][nj][s.s][s.k]!=INF)continue;
      if(b[ni][nj]=='|'){
        dist[ni][nj][s.s][s.k]=crtd+1;
        que.push((state){ni,nj,s.s,s.k});
        continue;
      }
      bool oneortwo=('A'<=b[ni][nj]&&b[ni][nj]<='J')||(b[ni][nj]=='^');
      rep(i,S){
        if(((s.s>>i)&1)&&(sw[i][ni][nj]))oneortwo^=true;
      }
      if(s.k!=oneortwo)continue;
      dist[ni][nj][s.s][s.k]=crtd+1;
      que.push((state){ni,nj,s.s,s.k});
    }
    if(b[s.i][s.j]=='|'){ // updown
      if(dist[s.i][s.j][s.s][1-s.k]==INF){
        dist[s.i][s.j][s.s][1-s.k]=crtd+1;
        que.push((state){s.i,s.j,s.s,1-s.k});
      }
    }
    if(isalpha(b[s.i][s.j])){ // switch
      int knd=b[s.i][s.j]-(b[s.i][s.j]>='a'?'a':'A');
      int nxtk=(sw[knd][s.i][s.j]?1-s.k:s.k);
      int nxts=s.s^(1<<knd);
      if(dist[s.i][s.j][nxts][nxtk]==INF){
        dist[s.i][s.j][nxts][nxtk]=crtd+1;
        que.push((state){s.i,s.j,nxts,nxtk});
      }
    }
  }
  cout<<-1<<endl;
  return 0;
}



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

using namespace std;

#define Rep(i,a,b)  for (int i=(a);i<(b);i++)
#define rep(i,n)    for (int i=0;i<(n);i++)
#define all(x)      (x).begin(), (x).end()

#define ll long long

int main()
{
	int n;
	cin >> n;
	ll x[n+1], y[n+1], h[n+1];
	tuple<ll, ll, ll> g = make_tuple(-1, -1, -1);
	vector<tuple<ll, ll, ll>> ans;

	Rep (i, 1, n+1) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] > 0)
			g = make_tuple(x[i], y[i], h[i]);
	}

	rep (i, 101) {
		rep (j, 101) {
			ll v = get<2>(g) + abs(get<0>(g) - i) + abs(get<1>(g) - j);
			v = max(v, 0LL);
			bool flag = true;
			Rep (k, 1, n+1) {
				ll vv = v - abs(x[k] - i) - abs(y[k] - j);
				vv = max(vv, 0LL);
				if (h[k] != vv) {
					flag = false;
					break;
				}
			}
			if (flag)
				ans.push_back(make_tuple(i, j, v));
		}
	}

	if (ans.size() == 1)
		cout << get<0>(ans[0]) << " " << get<1>(ans[0]) << " " << get<2>(ans[0]) << endl;



}



Measured memory_bytes: 256
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
    int N, H, W;
    cin >> N >> H >> W;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    int ans = 0;
    rep(i, N) {
        if (H <= A[i] && W <= B[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        string N;
        cin >> N;
        int ans = 700;
        rep(i, 3)
        {
                if (N[i] == 'o')
                        ans+=100;
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		if (N<=9) {
			System.out.println(N);
		} else if (10<=N && N<=99) {
			System.out.println(9);
		} else if (100<=N && N<=999) {
			System.out.println(9 + (N-99));
		} else if (1000<=N && N<=9999) {
			System.out.println(909);
		} else if (10000<=N && N<=99999) {
			System.out.println(9 + 900 + (N-9999));
		} else {
			System.out.println(90909);
		}
	}
}

Measured memory_bytes: 23636
S = str(input())
Q = int(input())

isreverse = False
head=[]
tail=[]

for i in range(Q):
    query = input()
    if str(query)[0]=="1":
        isreverse = isreverse^True
    else:
        F = int(query.split()[1])
        C = str(query.split()[2])
        if (F==1 and isreverse==False) or (F==2 and isreverse==True):
            head.append(C)
        else:
            tail.append(C)


if isreverse==False:
    print("".join(reversed(head))+S+"".join(tail))
else:
    print("".join(reversed(tail))+S[::-1]+"".join(head))

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 1e5+1;
int n, m, k, mark[N], res[N], cnt;
vector <int> memo, a[N], b[N];

void dfs(int u){
  mark[u] = cnt;
  memo.push_back(u);
  for (int v : a[u]){
    if (!mark[v]) dfs(v);
  }

}

int main()
{
  fastio;
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++){
    int u, v; cin >> u >> v;
    a[u].push_back(v); a[v].push_back(u);
  }
  for (int i = 1; i <= k; i++){
    int u, v; cin >> u >> v;
    b[u].push_back(v); b[v].push_back(u);
  }
  for (int i = 1; i <= n; i++){
    if (!mark[i]){
      cnt++; dfs(i);
      for (int u : memo) res[u] += memo.size() - 1;
      memo.clear();
    }
  }
  for (int u = 1; u <= n; u++){
    for (int v : a[u]){
      if (u > v) continue;
      res[u]--; res[v]--;
    }  
  }
  for (int u = 1; u <= n; u++){
    for (int v : b[u]){
      if (u > v) continue;
      if (mark[u] == mark[v]){
        res[u]--; res[v]--;  
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << res[i] << ' '; 
  return 0;
}

Measured memory_bytes: 13436
#include<cstdio>
#include<algorithm>
using namespace std;
 
int dp[10001];
int N,W;
int main() {
    scanf("%d%d",&N,&W);
 
    for(int i = 0;i < N;i++) {
        int v,w;
        scanf("%d%d",&v,&w);
        for(int j = W;j >= w;j--) {
            dp[j] = max(dp[j],dp[j - w] + v);
        }
    }
    printf("%d\n",dp[W]);
    return 0;
}


Measured memory_bytes: 2792
#include <bits/stdc++.h>
using namespace std;
char s;
int n,high,Max;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(s=='I') high++;
		if(s=='D') high--;
		Max=max(high,Max);
	}
	cout<<Max<<"\n";
}

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

using namespace std;

int main()
{
    string S;
    cin >> S;
    int ans = 0;

    for (int i = 1; i <= S.size(); i++)
    {
        string pS = "";
        for (int j = 0; j < i; j++)
        {
            pS = pS + "R";
        }
        if (S.find(pS) != string::npos)
        {
            ans = i;
        }
    }

    cout << ans << endl;
}

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

using namespace std;

int main() {
	int N, K; cin >> N >> K;

	vector<int> arr;
	
	int t;
	while (N--) {
		cin >> t;
		arr.push_back(t);
	}

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

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

	cout << sum << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
char a[99][99];
int H, W;
int main()
{
    scanf("%d%d", &H, &W);
    for(int i=1; i<=H; ++i)
        for(int j=1; j<=W; ++j)
            scanf(" %c", &a[i][j]);
    for(int i=1; i<=H; ++i)
        for(int j=1; j<=W; ++j)
            if(a[i][j] == '.')
            {
                char cnt = '0';
                for(int d=-1; d<=1; ++d)
                    for(int e=-1; e<=1; ++e)
                        if(a[i+d][j+e] == '#')
                            ++cnt;
                a[i][j] = cnt;
            }
    for(int i=1; i<=H; ++i)
        puts(a[i]+1);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

const int MaxM = 200005, MaxK = 12, MaxN = 531550, MaxS = 266666;

int n, Pow3[MaxK + 1];
char str[MaxM];

int nd = 0, rt, _to[3][MaxS], *to[3];

void build(int &u, int dep, int val) {
	if (dep == n) {
		u = val; return;
	}
	u = ++nd;
	for (int i = 0; i < 3; ++i) {
		build(to[i][u], dep + 1, val + i * Pow3[dep]);
	}
}

void shift() {
	int u = rt, tmp[3];
	for (int dep = 0; dep < n; ++dep) {
		for (int i = 0; i < 3; ++i) tmp[i] = to[(i + 2) % 3][u];
		for (int i = 0; i < 3; ++i) to[i][u] = tmp[i];
		u = tmp[0];
	}
}

int pos[MaxN];

void dfs(int u, int dep, int val) {
	if (dep == n) {
		pos[u] = val; return;
	}
	for (int i = 0; i < 3; ++i) {
		dfs(to[i][u], dep + 1, val + i * Pow3[dep]);
	}
}

int main() {
	scanf("%d%s", &n, str);
	for (int i = 0; i < 3; ++i) to[i] = _to[i];
	Pow3[0] = 1;
	for (int i = 1; i <= n; ++i) Pow3[i] = Pow3[i - 1] * 3;
	build(rt, 0, 0);
	for (char *ptr = str; *ptr; ++ptr) {
		if (*ptr == 'S') {
			std::swap(to[1], to[2]);
		} else {
			shift();
		}
	}
	dfs(rt, 0, 0);
	for (int i = 0; i < Pow3[n]; ++i) printf("%d ", pos[i]);
	return 0;
}

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

#define MAX_N 100000

typedef pair<int, int> P;

int n, m, r, d[MAX_N];
vector<P> E[MAX_N];

void dijkstra(){
    bool seen[n];
    fill(seen, seen + n, false);
    fill(d, d + n, INT_MAX);
    priority_queue<P> todo;
    d[r] = 0;
    todo.push(P(-1 * d[r], r));
    
    while(!todo.empty()){
        int v = todo.top().second, D = -1 * todo.top().first;
        todo.pop();
        seen[v] = true;
        for(int i = 0; i < E[v].size(); i++){
            int u = E[v][i].first, c = E[v][i].second;
            if(!seen[u] && D + c < d[u]){
                d[u] = D + c;
                todo.push(P(-1 * d[u], u));
            }
        }
    }
}

int main(){
    cin >> n >> m >> r;
    for(int i = 0; i < m; i++){
        int s, t, c;
        cin >> s >> t >> c;
        E[s].push_back(P(t, c));
    }
    dijkstra();
    for(int i = 0; i < n; i++)
        cout << (d[i] == INT_MAX ? "INF" : to_string(d[i])) << endl;
    
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	rep(i,n) cin >> s[i];
	int ans = 0;
	int end_A, start_B, haji_AB;
	end_A = 0, start_B = 0, haji_AB = 0;
	rep(i,n) {
		int len = s[i].size();
		rep(j,len-1) if (s[i][j]=='A' && s[i][j+1]=='B') ans++;
		if (s[i][len-1]=='A') {
			if (s[i][0]=='B') haji_AB++;
			else end_A++;
		}
		else if(s[i][0]=='B') start_B++;
	}
	if (haji_AB>=1) {
		ans += haji_AB-1;
		if (end_A>=1) {
			ans++;
			end_A--;
		}
		if (start_B>=1) {
			ans++;
			start_B--;
		}
	}
	ans += min(end_A, start_B);
	/*
	ans += min(end_A, start_B) + max(haji_AB-1,0);
	if ((end_A!=start_B) && haji_AB>=1) ans++;
	*/
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
 
int main(){

  int n,a,i;
 
  (void) scanf("%d",&n);
  
  for(i=0;i<n;i++)
  {
  (void) scanf("%d",&a);
  
    if (a % 2 ==0)
    {
    	if ( (a % 3 != 0 ) && (a % 5 != 0 ) )
        {
        	printf("DENIED");
          	return 0;
        }   
    }
  }
  
  printf("APPROVED");
  
 return 0; 
}

Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {

	double x1, y1;
	double x2, y2;

	cin >> x1 >> y1 >> x2 >> y2;

	double dx = x2 - x1;
	double dy = y2 - y1;

	double dst = sqrt(pow(dx, 2) + pow(dy, 2));

	cout << fixed;
	cout << setprecision(6) << dst << endl;

	return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
int k;
int a[50];
vector<int> v;

int main() {
    cin >> n >> k;
    rep(i,n) cin >> a[i];
    int pre = -1;
    for (int i = 0; i <= k; i++) {
        int mp = -1, mv = 10000;
        for (int j = 0; j < n; j++) {
            if (j == pre) continue;
            if (mv >= a[j]) {
                mv = a[j];
                mp = j;
            }
        }
        if (mv == 0) {
            cout << -1 << endl;
            return 0;
        }
        for (int j = 0; j < n; j++) {
            if (j != pre && j != mp) {
                v.push_back(j);
                a[j]--;
            }
        }
        v.push_back(mp);
        a[mp]--;
        pre = mp;
    }
    cout << v.size() << endl;
    rep(i,v.size()) {
        cout << v[i]+1 << " ";
    }
    cout << endl;
}



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

int main() {
	int A, B;
	cin >> A >> B;

	double a, b;

	int value = 1;

	while (1) {
		a = value * 2.0 / 25;
		b = value / 10.0;

		if ((int)a == A && (int)b == B) {
			printf("%d\n", value);
			return 0;
		}
		if (value == 1000) {
			printf("-1\n");
			return 0;
		}
		value++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;
    if(v>w&&abs(a-b)<=(v-w)*t) cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 3640
#include <stdio.h>
int main(void){
    int h,w,n;
    scanf("%d%d%d",&w,&h,&n);
    int square[h][w];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            square[i][j] = 1;
        }
    }
    
    
    for(int i=0;i<n;i++)
    {
        int a,b,c,d,e,f,g;
        scanf("%d%d%d",&a,&b,&c);
        switch(c)
        {
            case 1:
                d=0;e=h;f=0;g=a;
            break;
            
            case 2:
                d=0;e=h;f=a;g=w;
            break;
            
            case 3:
                d=0;e=b;f=0;g=w;
            break;
            
            case 4:
                d=b;e=h;f=0;g=w;
            break;
        }
        
        for(int j=d;j<e;j++)
        {
            for(int k=f;k<g;k++)
            {
                square[j][k] = 0;
            }
        }
    }
    
    
    
    int ans = 0;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            ans += square[i][j];
        }
    }
    
    printf("%d\n",ans);
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;

void main()
{
    auto input = readln.chomp.split(' ').to!(long[]);
    long A = input[0];
    long B = input[1];

    long result;
    foreach (n; 0 .. 1000)
    {
        string s = n.to!string().rightJustify(3,'0');
        long i = (s ~ s[1] ~ s[0]).to!long;
        if (A <= i && i <= B)
            result++;
    }
    result.writeln();
}


Measured memory_bytes: 380
from collections import defaultdict
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ad = defaultdict(lambda: -1)
i, j = 0, 0
while i < N and j < N:
    if A[i] < B[j]:
        ad[i] = j
        i += 1
    else:
        j += 1
bd = defaultdict(lambda: -1)
i, j = 0, 0
while i < N and j < N:
    if B[i] < C[j]:
        bd[i] = j
        i += 1
    else:
        j += 1
csum = [0] * N
for i in range(N):
    if bd[i] >= 0:
        csum[i] = N-bd[i]
bsum = [0]* N
cnt = 0
for i in range(N):
    cnt += csum[N-1-i]
    bsum[N-1-i] = cnt
ans = 0
for i in range(N):
    if ad[i] >= 0:
        ans += bsum[ad[i]]
print(ans)

Measured memory_bytes: 54256
//
//  main.cpp
//  test3
//
//  Created by 黒田浩揮 on 2019/04/21.
//  Copyright © 2019 黒田浩揮. All rights reserved.
//

#include <iostream>
using namespace std;
int main() {
    // insert code here...
    int a,b,c,d;
    d=0;
    
    cin>>a>>b;
    int number[a+1][b+1];
    int number2[a+1];
    int number3[b];
    for (int u=0; u<a; u++) {
        number2[u]=0;
    }
    for (int u=0; u<b; u++) {
        number3[u]=0;
    }
    for(int v=0;v<a;v++){
        for(int l=0;l<b;l++){
            cin>>c;
            
            number[v][l]=c;
            number2[v]+=c;
            number3[l]+=c;
            
            
        }
    }
    for(int n=0;n<a;n++){
        number[n][b]=number2[n];
    }
    for(int y=0;y<b;y++){
        number[a][y]=number3[y];
    }
    for(int y=0;y<b;y++){
        d+=number3[y];
    }
    number[a][b]=d;
    for(int v=0;v<a+1;v++){
        for(int l=0;l<b+1;l++){
            if(l==0){
                cout<<number[v][l];
            }else{
                cout<<" "<<number[v][l];
            }
            if(l==b){
                cout<<endl;
            }
        }
    }
}



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

typedef long long int ll;
typedef unsigned long long int ull;

int main(void) {
  int I, O, T, J, L, S, Z;
  cin >> I >> O >> T >> J >> L >> S >> Z;

  ll sum = O;
  ll res = 0;

  if (I >= 1 && J >= 1 && L >= 1) {
    sum += 3;
    sum += (I - 1) / 2 * 2;
    sum += (J - 1) / 2 * 2;
    sum += (L - 1) / 2 * 2;
    res = max(sum, res);
  }

  sum = O;
  sum += I / 2 * 2;
  sum += J / 2 * 2;
  sum += L / 2 * 2;
  res = max(sum, res);

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
import java.lang.*;

// import java.text.DecimalFormat; 
// import java.text.DecimalFormatSymbols; 
/*
 
 
 
 */

public class Main {

    public static void main(String args[] ) throws Exception {
        PrintWriter pw=new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
        int t=1;
        //t = sc.ni();
        while(t-->0) {
        	solve(pw,sc);
        }
       
        pw.close();
    }
    
    private static void solve(PrintWriter pw, FastScanner sc) {
    	long a=sc.ni(),b = sc.ni(),c = sc.ni(),d = sc.ni();
    	long ans=0;
    	if(a>=0&&b>=0&&c>=0&&d>=0)
    		ans = b*d;
    	else if(a<0&&b>=0&&c>=0&&d>=0)
    		ans = b*d;
    	else if(a>=0&&b>=0&&c<0&&d>=0)
    		ans = b*d;
    	
    	else if(a<0&&b<0&&c<0&&d<0)
    		ans = a*c;
    	else if(a<0&&b<0&&c<0&&d>=0)
    		ans = a*c;
    	else if(a<0&&b>=0&&c<0&&d<0)
    		ans = a*c;
    	
    	else if(a>=0&&b>=0&&c<0&&d<0)
    		ans = a*d;
    	else if(a>=0&&b>=0&&c<0&&d>=0)
    		ans = b*d;
    	else if(a<0&&b>=0&&c<0&&d<0)
    		ans = a*c;
    	
    	else if(a<0&&b<0&&c>=0&&d>=0)
    		ans = b*c;
    	else if(a<0&&b<0&&c<0&&d>=0)
    		ans = a*c;
    	else if(a<0&&b>=0&&c>=0&&d>=0)
    		ans = b*d;
    	else if(a<0&&b>=0&&c<0&&d>=0)
    		ans = Math.max(a*c, b*d);
    	
    	pw.print(ans);
    	
	}
    

	static <T> void deb(T x,int o){
       System.out.print(x);
       if(o==0) {
    	   System.out.println();
    	   
       }
    }
   
   
   static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String ne() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		public String ne(int k) {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return "Not able to read";
		}
		
		int ni() {
			return Integer.parseInt(ne());
		}
		
		long nl() {
			return Long.parseLong(ne());
		}
		
		double nd() {
			return Double.parseDouble(ne());
		}
		
	    
	}
   
}

Measured memory_bytes: 32900
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio
{

	template <class T> istream &operator>>(istream &os, vector<T> & vec)
	{
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec)
	{
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p)
	{
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p)
	{
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con)
	{
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail)
	{
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x)
	{
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail)
	{
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail)
	{
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	int n;
	cin>>n;
	long long int arr[n], sum=0, sum1=0;
	for(int i=0; i<n; i++)
	{
		cin>>arr[i];
		sum+=arr[i];	
	}
	long long int dif = 0, sum2 = sum;
	for(int i=0; i+1<n; i++)
	{
		sum1+=arr[i];
		sum-=arr[i];
		dif = abs(sum-sum1);
		if(dif < sum2) sum2  = dif;
		else  break;
	}
	prln(sum2);
}




Measured memory_bytes: 1792
fun main(args: Array<String>) {
  val (A, B, K) = readLongs()
  println(
    when {
      K <= A -> "${A - K} $B"
      K <= A + B -> "0 ${A + B - K}"
      else -> "0 0"
    }
  )
}

fun readStrings() = readLine()!!.split(" ")
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 38032
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

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

/* -- template -- */

int main() {
    string S, T; cin >> S >>T;
    rep(i, S.size()) {
        if(S[i] != T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
int main()
{
	int a[5];
	for (int i = 0; i < 5; i++)
		std::cin >> a[i];
	int mins = 0;
	for (int i = 1; i < 5; i++)
		if (a[i] % 10)
			if (a[mins] % 10)
				mins = (a[mins] % 10 < a[i] % 10) ? mins : i;
			else
				mins = i;
	int sum = 0;
	for (int i = 0; i < 5; i++)
		sum += (a[i] % 10) ? (10 * (a[i] / 10 + 1)) : a[i];
	sum -= (10 - a[mins] % 10) % 10;
	std::cout << sum;
	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<long long> a(n);
    long long ans=0, cnt=0, mi=1000000010;
    for(int i=0;i<n;++i){
        cin >> a[i];
        if(a[i]<=0) ++cnt;
        if(mi > abs(a[i])) mi = abs(a[i]);
    }
    if(cnt%2==0){
        for(int i=0;i<n;++i) ans += abs(a[i]);
    }else{
        for(int i=0;i<n;++i) ans += abs(a[i]);
        ans -= abs(mi)*2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

int main()
{
  
      while(1)
   {
       string str, str1, str2;
       int m, h;
       cin >> str;
       cin >> m;
       
           if(str == "-"){break;}
       
       for(int i = 0; i < m; i++)
       {
           cin >> h;
           
            str1 = str.substr(0, h);
            str2 = str.substr(h, str.size() -h);
            str = str2 + str1;
        }
       
       cout << str << endl;
   }
   
   return 0;
}


Measured memory_bytes: 3208