akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    string s1;
    cin >> s1;
    deque<char> s (s1.begin(), s1.end());
    int q;
    cin >> q;
    bool rev = 0;
    while(q--){
        int t;
        cin >> t;
        if(t == 1){
            rev = 1 - rev;
        }
        else{
            int f;
            char c;
            cin >> f >> c;
            if(f == 1){
                if(rev){
                    s.push_back(c);
                    
                }
                else{
                    s.push_front(c);
                }
            }
            else{
                if(!rev){
                    s.push_back(c);
                    
                }
                else{
                    s.push_front(c);
                }
            }
        }
    }
    if(rev){
        for(int i = s.size() - 1; i >= 0; --i)
            cout << s[i];
    }
    else{
        for(int i = 0; i < s.size(); ++i)
            cout << s[i];
    }
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

Measured memory_bytes: 976
log = console.log;

var stdin = require("fs").readFileSync("/dev/stdin", "UTF-8");
var lines = stdin.split("\n");
var N = lines[0].split(" ").map(Number)[0];
var ABs = lines
  .slice(1)
  .filter(v => v !== "")
  .map(v => v.split(" ").map(Number));

ABs.sort((a,b)=>{
  return a[1] - b[1] 
})

var flag = "Yes"
var sum = 0
for(var i=0;i<N;i++){
  sum += ABs[i][0];
  if(sum > ABs[i][1]){
    flag = "No"
    break;
  }
}

log(flag);

Measured memory_bytes: 71024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
const int INF = 1e9;
using namespace std;

signed main() {
    string S; cin >> S;
    vector<int> v;
    if(S[0]=='>') S='<'+S;
    if(S[S.size()-1]=='<') S=S+'>';
    int cnt1=0,cnt2=0;
    rep(i,S.size()){
        if(S[i]=='<') {
            cnt1++; if(cnt2)v.push_back(cnt2); cnt2=0;
        }
        else {
            cnt2++; if(cnt1)v.push_back(cnt1); cnt1=0;
        }
    }
    if(cnt2>0) v.push_back(cnt2);
    else if(cnt1>0)v.push_back(cnt1);
    int ans=0;
    rep(i,v.size()/2){
        if(v[i*2]>v[i*2+1]){
            ans+=((v[i*2]+1)*v[i*2]+v[i*2+1]*(v[i*2+1]-1))/2; 
        }else{
            ans+=((v[i*2])*(v[i*2]-1)+(v[i*2+1]+1)*v[i*2+1])/2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3240
N=1e7,a[10010000];main(i,j){for(i=j=2;i*i<N;a[i]||j>N?j=++i:a[j+=i]++);for(;i=~scanf("%d",&j);j&&printf("%d\n",j))for(;a[j]+a[j-2]+a[j-6]+a[j-8]&&j--;);}

Measured memory_bytes: 0
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>

using namespace std;

char orin[100005];

int main(void)
{
	int grades = 0, ok = 0;
	scanf("%s", orin);
	for (int i = 0; orin[i]; ++i)
	{
		if (orin[i] == 'g')
		{
			if (ok)
			{
				++grades;
				--ok;
			}
			else
				++ok;
		}
		else
		{
			if (ok)
				--ok;
			else
			{
				--grades;
				++ok;
			}
		}
	}
	printf("%d", grades);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(reader.readLine());
        String[] lo =reader.readLine().split(" ");
        int[] list = new int[N];
        for (int i = 0; i <N ; i++) {
            list[i] = Integer.parseInt(lo[i]);
        }
        long[][] dp = new long[N][N];
        for (int i = N-1; i>=0 ; i--) {
            for (int j =i; j <N ; j++) {
                dp[i][j] = i==j?list[j]:Math.max(list[j]-dp[i][j-1],list[i]-dp[i+1][j]);
            }
        }

        System.out.println(dp[0][N-1]);
    }
}


Measured memory_bytes: 127824
S = input()
left = int(S[:2])
right = int(S[2:])

if 0 < left <= 12:
    if 0 < right <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < right <= 12:
        print('YYMM')
    else:
        print('NA')

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

#define F                   first
#define S                   second
#define int                 long long int
#define pb                  push_back
#define mp                  make_pair
#define pii                 pair<int,int>
#define vi                  vector<int>
#define mii                 map<int,int>
#define pqb                 priority_queue<int>
#define pqs                 priority_queue<int,vi,greater<int> >
#define mod                 1000000007
#define endl                '\n'
#define rep(i,a,b)            for(int i=a;i<b;i++)
void solve() {
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    int mx = 0;
    rep(i, 0, n) {
        if (s[i] == 'S') {
            mx = max(ans, mx);
            ans = 0;
        }
        else {
            ans++;
        }
    }
    mx = max(mx, ans);
    cout << mx << endl;
}

void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
    //c_p_c();
    int t;
    //cin >> t;
    t = 1;
    while (t--) {
        solve();
    }


    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>

int A[100000], n;

/*２分探索*/
int binarySearch(int key){
    int left =0;
    int right =n;
    int mid;

    while(left<right){
        mid=(left + right)/2;
        if(key==A[mid]) return 1;
        if(key > A[mid]) left = mid +1;
        else if ( key < A[mid]) right = mid;
    }
    return 0;
}

int main(){
    int i, q, k, sum =0;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for( i=0; i<q; i++){
        scanf("%d", &k);
        if(binarySearch(k))sum++;
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 2156
#include <iostream>

using namespace std;

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

	int mini = 1e9  + 1;
	int maxi = 0;

	for (int i = 0; i < n; i++) {
		cin >> a;
		mini = min(mini, a);
		maxi = max(maxi, a);
	}

	cout << maxi - mini << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int x[100];
int y[100];
int z[100];
int x1[50];
int x2[50];
int y1[50];
int y2[50];
int z1[50];
int z2[50];
int table[100][100][100];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d%d%d%d%d%d",x1+i,y1+i,z1+i,x2+i,y2+i,z2+i);
		x[i*2]=x1[i];x[i*2+1]=x2[i];
		y[i*2]=y1[i];y[i*2+1]=y2[i];
		z[i*2]=z1[i];z[i*2+1]=z2[i];
	}
	std::sort(x,x+a*2);std::sort(y,y+a*2);std::sort(z,z+a*2);
	for(int i=0;i<a;i++){
		int X1=lower_bound(x,x+a*2,x1[i])-x;
		int Y1=lower_bound(y,y+a*2,y1[i])-y;
		int Z1=lower_bound(z,z+a*2,z1[i])-z;
		int X2=lower_bound(x,x+a*2,x2[i])-x;
		int Y2=lower_bound(y,y+a*2,y2[i])-y;
		int Z2=lower_bound(z,z+a*2,z2[i])-z;
		table[X1][Y1][Z1]++;
		table[X1][Y1][Z2]--;
		table[X1][Y2][Z1]--;
		table[X2][Y1][Z1]--;
		table[X1][Y2][Z2]++;
		table[X2][Y1][Z2]++;
		table[X2][Y2][Z1]++;
		table[X2][Y2][Z2]--;
	}
	for(int i=0;i<a*2;i++)
		for(int j=0;j<a*2;j++)
			for(int k=1;k<a*2;k++){
				table[i][j][k]=table[i][j][k]+table[i][j][k-1];
			}
	for(int k=0;k<a*2;k++)
		for(int j=0;j<a*2;j++)
			for(int i=1;i<a*2;i++){
				table[i][j][k]=table[i][j][k]+table[i-1][j][k];
			}
	for(int k=0;k<a*2;k++)
		for(int i=0;i<a*2;i++)
			for(int j=1;j<a*2;j++){
				table[i][j][k]=table[i][j][k]+table[i][j-1][k];
			}
	long long ret=0;
	for(int i=0;i<a*2;i++)
		for(int j=0;j<a*2;j++)
			for(int k=0;k<a*2;k++)
				if(table[i][j][k]>=b)ret+=(long long)(x[i+1]-x[i])*(y[j+1]-y[j])*(z[k+1]-z[k]);
	printf("%lld\n",ret);
}

Measured memory_bytes: 4956
N=int(input())
D=[]
count=0
ans=0
for i in range(N):
    a,b=map(int,input().split())
    D.append([a,b])
    if a==b:
        count+=1
    else:
        count=0
    if count==3:
        ans+=1
if ans>=1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62356
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    cout<<n*800-(n/15*200)<<endl;

    return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int ans=700;
	string s;
	cin>>s;
	for(int i=0;i<3;i++)
	{
		if(s[i]=='o')ans+=100;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}


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

    int n, q;
    char s[100001];
    cin >> n >> q;
    cin >> s;

    bool flg = false;
    int marker[100001];

    for(int i=0; i<n; i++){
        if(s[i]=='A'){
            flg=true;
            continue;
        }
        if(s[i]=='C' && flg){
            marker[i] = 1;
            flg=false;
            continue;
        }
        flg = false;
        marker[i] = 0;
    }

    int t[100001];
    t[0] = marker[0];
    for(int i=1; i<n; i++){
        t[i] = t[i-1] + marker[i];
    }

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

    return 0;
}

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

int main() {
	int k;
	cin >> k;
	if(k%2==0) {
		cout << (k/2)*(k/2) << endl;
	}
	else
		cout << (k/2)*(k/2+1) << endl;
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int k; cin >> k;
	int mod = 7;
	int ans = 1;
	while (mod % k) {
		mod = (mod * 10 + 7) % k;
		++ans;
		if (ans > k) {
			ans = -1;
			break;
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3632
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int N;
	int[] x, y;
	List<Tuple> list;
	int[] counts;

	static class Tuple {
		int id, x, y, gid;
		Set<Integer> conns;

		Tuple(int id, int x, int y) {
			this.gid = -1;
			this.id = id;
			this.x = x;
			this.y = y;
			this.conns = new HashSet<>();
		}

	}

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		x = new int[N];
		y = new int[N];
		for (int i = 0; i < N; ++i) {
			String[] tokens = in.readLine().split(" ");
			x[i] = Integer.parseInt(tokens[0]);
			y[i] = Integer.parseInt(tokens[1]);
		}
		list = new ArrayList<>(N);
		for (int i = 0; i < N; ++i) {
			list.add(new Tuple(i, x[i], y[i]));
		}
		Collections.sort(list, new Comparator<Tuple>() {
			@Override
			public int compare(Tuple o1, Tuple o2) {
				return Integer.compare(o1.x, o2.x);
			}
		});
	}

	void mark(int id, int gid, int parent) {
		list.get(id).gid = gid;
		for (Integer conn : list.get(id).conns) {
			if (conn != parent) {
				mark(conn, gid, id);
			}
		}
	}

	void update(Tuple tuple, Deque<Tuple> deque) {
		List<Tuple> list = new ArrayList<>();
		while (!deque.isEmpty() && deque.peek().y < tuple.y) {
			list.add(deque.poll());
		}

		// tupleとlistの各要素間にedgeを張る
		for (Tuple elem : list) {
			tuple.conns.add(elem.id);
			elem.conns.add(tuple.id);
		}
		if (list.isEmpty()) {
			deque.addFirst(tuple);
		} else {
			deque.addFirst(list.get(0));
		}
	}

	void calc() {
		Deque<Tuple> deque = new ArrayDeque<>();
		deque.add(list.get(0));
		for (int i = 1; i < list.size(); ++i) {
			update(list.get(i), deque);
		}

		Collections.sort(list, new Comparator<Tuple>() {
			@Override
			public int compare(Tuple o1, Tuple o2) {
				return Integer.compare(o1.id, o2.id);
			}
		});

		// gidをmarkする
		int gid = 0;
		for (int i = 0; i < list.size(); ++i) {
			if (list.get(i).gid < 0) {
				mark(i, gid, -1);
				++gid;
			}
		}

		counts = new int[gid + 1];
		Arrays.fill(counts, 0);
		for (int i = 0; i < list.size(); ++i) {
			counts[list.get(i).gid]++;
		}
	}

	void showResult() {
		for (int i = 0; i < list.size(); ++i) {
			System.out.println(counts[list.get(i).gid]);
		}
	}
}


Measured memory_bytes: 120816
#include <bits/stdc++.h>
using namespace std;
#define N_MAX 100000

int main(){
//入力
int a,b,c,x,y;
int ans=-1;

    cin >>a>>b>>c>>x>>y ;

    for(int i=0;i<=max(2*x,2*y);i++){
        if(i%2==0){
            int ae,be;
            ae=max(0,x-i/2);
            be=max(0,y-i/2);
            
            int tmp;
            tmp=a*ae+b*be+c*i;

            if(ans==-1) ans=tmp;
            else ans=min(ans,tmp);
        }
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 3640
n,d=[int(x) for x in input().rstrip().split()]

l=[]
for i in range(n):
  X=[int(x) for x in input().rstrip().split()]
  l.append(X)

ans=0
for i in range(n):
  ni=l[i]
  for j in range(i+1,n):
    nj=l[j]
    now=0
    for s in range(d):
      now+=(ni[s]-nj[s])**2
    now=now**0.5
    if now.is_integer():
        ans+=1
print(ans)

Measured memory_bytes: 9376
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,i;
    cin>>n>>m;
    int point[n];//その点がどこにつながっているのかのフラグ
    for(i=0;i<n;i++)
    point[i]=0;
    int num = 0;
    for(i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        int c = a-1;
        int d = b-1;
        point[c]|=(1<<d);
        point[d]|=(1<<c);
    }
    stack<pair<int,int>>q;
    q.push(make_pair(0,1));//(注目点、行ったことがあるかのフラグ)
    while(q.empty()==false)
    {
        pair<int,int>tmp=q.top();
        q.pop();
        int current_position=tmp.first;
        int path=tmp.second;
        int checker=0;
        for(i=0;i<n;i++)
        {
            if(point[current_position]&(1<<i)&&!(path&(1<<i)))
            {
                int tmppath=path;
                tmppath|=(1<<i);
                q.push(make_pair(i,tmppath));
            }
            else if(path&(1<<i))
            checker++;
        }
        if(checker==n)
        num++;
    }
    cout<<num<<endl;
    return 0;
    
}


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

using namespace std;

int main(){
    string s,t;
    int n,i,k=100010,c=0;
    cin >> s;
    n = s.size();

    for(i=0;i<n-1;i++){
        if(s[i]==s[i+1]){
            k = i;
        }
    }
    if(k!=100010){
        cout << k+1 << " " << k+2 << endl;
        return 0;
    }else{
        for(i=0;i<n;i+=2){
            if(s[i] == s[i+2]){
                cout << i+1 << " " << i+3 << endl ;
                return 0;
            }
        }
        for(i=1;i<n;i+=2){
            if(s[i] == s[i+2]){
                cout << i+1 << " "<< i+3 << endl;
                return 0;
            }
        }
    }
    cout << -1 << " "<< -1 << endl;
}

Measured memory_bytes: 512
/*
TASK: <Task>
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define EPS 1e-9
#define ALL(x) (x).begin(),(x).end()
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define FOR(i,st,ed) for(int (i)=(st);(i)<(ed);(i)++)
typedef pair<int,int> PII;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long LL;

int N,M,T;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//freopen("xxx.in","r",stdin);
	//freopen("xxx.out","w",stdout);
	int i,j,k;
	map<int,int> mp;
	map<int,int>::iterator it;
	cin >> N;
	while(N--) {
        cin >> k;
        mp[k]++;
	}
	cin >> N;
	while(N--) {
        cin >> k;
        mp[k]--;
	}

	for(it=mp.begin();it!=mp.end();it++)
        if((*it).Y<0) {
            cout << "NO\n";
            return 0;
        }
    cout << "YES\n";
	return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, k; string s;
    cin >> n >> k;
    cin >> s;
    
    int ans=0;
    rep(i, n){
        if (s[i] == 'R' && i < n-1){
            if (s[i] == s[i+1]){
                ans++;
            }
        }
        if (s[i] == 'L' && i > 0){
            if (s[i] == s[i-1]){
                ans++;
            }
        }
    }
    ans = min(n-1, ans + k * 2);
    cout << ans << endl;
}


Measured memory_bytes: 512
1# F問題
import math

N = int(input())
P = []
for _ in range(N):
    P.append([int(n) for n in input().split()])

R2 = 0

for i in range(360):
    theta = 2 * math.pi * i / 360
    a, b = math.cos(theta), math.sin(theta)
    X, Y = 0, 0
    for x, y in P: 
        if a*x+b*y > 0: # 内積が正 ( = なす角度が鋭角 = そのベクトルを加えると距離が増加)
            X += x
            Y += y
    r2 = X**2+Y**2
    if r2 > R2:
        R2 = r2

print(math.sqrt(R2))

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

class Prog{
  static void Main(){
    int n = int.Parse(Console.ReadLine());
    int[] ls = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    int j = 0;
    var capacity = n;
    var value = 0;
    var a = new List<int>(capacity);
    for (int i = 0; i < capacity; i++) a.Add(value);
    for (int i = 0;i < n;i++){
      a[i] = i+1;
      if(a[i] != ls[i]){
        j++;
      }
    }
    if(j <= 2){
      Console.WriteLine("YES");
    }else{
      Console.WriteLine("NO");
    }
  }
}

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

int main(){
  int n; cin >> n;
  int ans;
  if(n == 1){
    printf("%s", "Hello World");
    return 0;
  }else if(n == 2){
    int a, b; cin >> a >> b;
    ans = a+b;
    cout << ans << endl;
  	return 0;
  }
}

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

int S[10001];

int main(){
  int N;
  //vector<int> s;

  S[0]=1;

  cin>>N;
  for(int i=0;i<N;i++){
    int si;
    cin>>si;
    for(int j=10000;j>=0;j--){
      if(S[j]!=0){
        S[j+si]++;
      }
    }
  }

  int max_score=0;
  for(int s=10000;s>0&&max_score==0;s--){
    if((s%10)!=0&&S[s]!=0){
      max_score=s;
    }
  }
  cout<<max_score<<endl;
  return 0;
}


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

int main() {
	int N, K; cin >> N >> K;
	vector<long> a(N);
	for(int i=0; i<N; ++i) cin >> a[i];
	long ans=1e15;
	for(int bit=1; !(bit&(1<<N)); bit += 2){
	    long h=0, now=0;
	    int cnt=0;
	    for(int i=0; i<N; ++i){
	        if(bit&(1<<i)){
	            if(h<a[i]) h=a[i];
	            else{
	                now += h+1-a[i];
	                ++h;
	            }
	            ++cnt;
	        }
	        else h=max(h, a[i]);
	    }
	    if(cnt>=K) ans=min(ans, now);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int r = scanner.nextInt();
		int g = scanner.nextInt();
		int b = scanner.nextInt();

		String res = (r*100+g*10+b)%4==0 ? "YES":"NO";

		System.out.println(res);
	}

}

Measured memory_bytes: 23764
def main(a: int, b: int, n: int):
    ans = 0
    for i in (1, min(n, b - 1)):
        f = int((a * i) / b) - a * int(i / b)

        if ans < f:
            ans = f

    print(ans)


if __name__ == "__main__":
    a, b, n = map(int, input().split())
    main(a, b, n)


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

int main(){
 int n; cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    b.at(a.at(i)-1) = i+1;
    
  }
  for(int i=0;i<n;i++){
    cout << b.at(i);
    if(i == n-1){
      cout << endl;
    }
    else{
      cout << ' ';
    }
  }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int dp[(1 << 18)][18];
int A[18], B[18];

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, N) cin >> B[i];

	rep(bit, 0, (1 << 18)) {
		rep(i, 0, N) dp[bit][i] = inf;
	}

	dp[0][0] = 0;

	rep(bit, 0, (1 << N)) {
		rep(i, 0, N) {
			if(dp[bit][i] == inf) continue;
			int cnt = 0;
			rep(j, 0, N) {
				if(bit & (1 << j)) continue;
				int v = (__builtin_popcount(bit) - j + 50) % 2 == 0 ? A[j] : B[j];
				int pv = bit == 0 ? -1 : (__builtin_popcount(bit) - 1 - i + 50) % 2 == 0 ? A[i] : B[i];
				// debug(bitset<3>(bit), i, j, pv, v, dp[bit][i]);
				if(pv <= v) MIN(dp[bit | (1 << j)][j], dp[bit][i] + cnt);


				cnt += ((bit & (1 << j)) == 0);
			}
		}
	}
	int res = inf;
	rep(i, 0, N) MIN(res, dp[(1 << N) - 1][i]);
	if(res == inf) cout << -1 << "\n";
	else cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

string solve() {
  int a, b;
  cin >> a >> b;
  if(a > 0) return "Positive";
  if(b < 0) {
    if((b-a)%2 == 0) return "Negative";
    else return "Positive";
  }
  return "Zero";
}

int main() {
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n;
	int b,f,r,v;
	int x[4][3][10]={};
	
	scanf("%d",&n);
	
	int t;
	for(t=0;t<n;t++){
		do{
			printf("");
			scanf("%d %d %d %d",&b,&f,&r,&v);
			b--;
			f--;
			r--;
		}while(!(x[b][f][r]+v>=0 && x[b][f][r]+v<=9));
		x[b][f][r]+=v;
	}
	
	for(b=0;b<4;b++){
		for(f=0;f<3;f++){
			for(r=0;r<10;r++){
				printf(" %d",x[b][f][r]);
			}
			printf("\n");
		}
		if(b!=3){
			for(t=1;t<=20;t++){
				printf("#");
			}
			printf("\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


int main(){
	LL A[3];
	cin>>A[0]>>A[1]>>A[2];
	sort(A,A+3);
	LL a=A[0]*A[1]*(A[2]/2);
	LL b=A[0]*A[1]*A[2]-a;
	cout<<abs(a-b)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string S;
	cin >> S;
	bool ans = true;
	for (int i = 0; i < S.size() - 1; ++i) {
		for (int j = i + 1; j < S.size(); ++j) {
			if (S[i] == S[j])
				ans = false;
		}
	}
	if (ans)
		cout << "yes" << endl;
	else
		cout << "no" << endl;
	return 0;
}

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

int D[110][2];

int main() {
    int N, res = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> D[i][0];
        cin >> D[i][1];
    }

    for (int i = 0; i < N; i++) {
        if (D[i][0] == D[i][1]) {
            res++;
            if (res >= 3) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        else res = 0;
    }

    cout << "No" << endl;
    return 0;
}


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

#define M_PI 3.14159265358979323846

using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
//#define MOD 1000000007

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;

#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

#define MOD 1000000007
class UnionFind
{
public:
    vector<int> par;
    vector<int> siz;

    UnionFind(int sz_) : par(sz_), siz(sz_, 1)
    {
        for (int i = 0; i < sz_; ++i)
            par[i] = i;
    }
    void init(int sz_)
    {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i)
            par[i] = i;
    }

    int root(int x)
    {
        while (par[x] != x)
        {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(int x, int y)
    {
        return root(x) == root(y);
    }

    int size(int x)
    {
        return siz[root(x)];
    }
};

ll modPow(ll x, ll n, ll mod = MOD)
{
    if (n == 0)
        return 1;
    ll res = 1;
    while (n)
    {
        if (n & 1)
            res = (res * x) % mod;

        res %= mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(6);

    ll N;
    cin >> N;

    int mx = 0;
    vector<int> ans;
    for (int i = 1; i <= N; i++)
    {
        if (i * (i + 1) / 2 >= N)
        {
            mx = i;
            ans.push_back(i);
            break;
        }
    }

    ll sum = N - mx;

    for (int i = mx - 1; i >= 1; i--)
    {
        if (sum == 0)
            break;

        if (sum >= i)
        {
            sum -= i;
            ans.push_back(i);
        }
    }
    sort(all(ans));
    for (int i = 0; i < ans.size(); i++)
    {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 384
N = int(input())
S = input()
for p in ("SS", "SW", "WS", "WW"):  # N-1と0
    ans = p[1]
    ip = p
    for i in range(N):
        if S[i] == "o":
            if p[0] == p[1]:
                p = p[1] + "S"
            else:
                p = p[1] + "W"
        else:
            if p[0] == p[1]:
                p = p[1] + "W"
            else:
                p = p[1] + "S"
        ans += p[-1]
    if ans[-2:] == ip:
        print(ans[:-1])
        exit()
print(-1)


Measured memory_bytes: 3444
import heapq
N,M = map(int, input().split())
works = {}
for _ in range(N):
    a, b = map(int, input().split())
    if a not in works:
        works[a] = [b]
    else:
        works[a].append(b)
rewards = []
reward_sum = 0
for k in range(M+1):
    if k in works:
        print()
        for j in works[k]:
            heapq.heappush(rewards, -j)
    if len(rewards) != 0:
        reward_sum -= heapq.heappop(rewards)
print(reward_sum)

Measured memory_bytes: 26064
using System;

public class Hello
{
    public static void Main()
    {
        Console.ReadLine();
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Console.ReadLine();
        line = Console.ReadLine().Trim().Split(' ');
        var b = Array.ConvertAll(line, int.Parse);
        var ok = true;
        foreach (var x in b)
            if (Array.BinarySearch(a, x) < 0) { ok = false; break; }
        Console.WriteLine(ok ? 1 : 0);
    }
}



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

int main(){
int a;
int b;
int c;
int d;
int e;
int f;
int g;
int h;
int i;
int j;
cin >> a;
cin >> b;
cin >> c;
cin >> d;
cin >> e;
cin >> f;
cin >> g;
cin >> h;
i=a+b+c+d;
j=e+f+g+h;
if(i<j){i=j;}
cout << i <<endl;
}

Measured memory_bytes: 1164
n = int(input())
s = input()
res = ''
for let in s:
    if ord(let) + n <= 90:
        newS = chr(ord(let)+n)
        res += newS
    elif ord(let) + n > 90:
        newS = chr((ord(let) + n) - 26)
        res += newS
print(res)

Measured memory_bytes: 3060
package main

import (
    "fmt"
    "strings"
)

func main() {
    var s string
    fmt.Scanf("%s", &s)

    if strings.Contains(s, "a") && strings.Contains(s, "b") && strings.Contains(s, "c") {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  int n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  vll a(n);
  int cu=0;
  rep(i,n-1){
    a[i]=cu;
    if(s[i]=='A' && s[i+1]=='C'){
      cu++;
    }
  }
  a[n-1]=cu;
  rep(i,q){
    int j,b;
    cin>>j>>b;
    j--;
    b--;
    cout<<a[b]-a[j]<<endl;
  }
}
    


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);     /* 入力 */
        if(a*b*c == 5*5*7)      {printf("YES\n");}
        else                    {printf("NO\n");}
        return 0;
}



Measured memory_bytes: 128
N = int(input())
array = list(map(int,input().split()))
expense = [0] * (N+1)
expense[0] = abs(array[0])
for i in range(N-1):
    expense[i+1] = abs(array[i+1] - array[i])
expense[N] = abs(array[N-1])
total = sum(expense)
for i in range(N):
    tmp = total
    tmp -= expense[i]+expense[i+1]
    tmp += (abs(array[i+1] - array[i-1]) if i != 0 else abs(array[i+1])) if i != N-1 else abs(array[N-2])
    print(tmp)

Measured memory_bytes: 14048
N  = int(input())
v = [int(i) for i in input().split()]
s = 0

for i in range(N-1):
  a = min(v)
  v.remove(a)
  b = min(v)
  v.remove(b)
  s = (a + b)/2
  v.append(s)
  

print(s)




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

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

struct Node
{
    int node, len;
    Node() {node = len = 0;}
    Node(int node, int len) {this -> node = node, this -> len = len;}
};
typedef vector<Node> vg;

#define MAX 200001
#define NON 0
#define MOD 1000000007

#define FOR(type, i, a, b) for(type i = a; i < b; i++)
#define FORR(type, i, b, a) for(type i = b; i > a; i--)
#define FORE(type, i, a, b) for(type i = a; i <= b; i++)
#define FORRE(type, i, b, a) for(type i = b; i >= a; i--)

#define testBit(n, bit) ((n >> bit) & 1)
#define flipBit(n, bit) (n ^ (1ll << bit))

main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n, k; cin >> n >> k;
    ll answer = 0;
    FORE(ll, i, k, n + 1){
        ll mi = i * (i + 1) / 2;
        ll ma = (2 * n + 3 - i) * i / 2;
        answer += ma - mi + 1;
        answer %= MOD;
    }
    cout << answer;
}

Measured memory_bytes: 3652
N, P = map(int, input().split())
A = list(map(int, input().split()))

dp = [[0,0] for i in range(N+1)]
dp[0][0] = 1

for i in range(N):
    rem = A[i] % 2
    if rem == 0:
        dp[i+1][0] = dp[i][0] * 2
        dp[i+1][1] = dp[i][1] * 2
    else:
        dp[i+1][0] = dp[i][0] + dp[i][1]
        dp[i+1][1] = dp[i][1] + dp[i][0]

print(dp[N][P])


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
  int n;
  cin >> n;
  
  string s;
  cin >> s;
  
  bool f = true;
  
  if(n % 2 != 0) f = false;
  else{
    if(s.substr(0,n / 2) + s.substr(0,n / 2) != s) f = false;
  }
  
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
  
}


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

using namespace std;

typedef long long ll;

int main() {
    int n, k; cin >> n >> k;
    set<int> s;
    for (int i = 0; i < k; i++) {
        int d; cin >> d;
        for (int l = 0; l < d; l++) {
            int a; cin >> a;
            s.insert(a);
        }
    }
    cout << n - (int)s.size();
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main(void){
  int x,y;
  while(1){
    cin>>x>>y;
    if(x==0&&y==0)break;
    if(x>y){
      cout<<y<<" "<<x<<endl;
    }else{
      cout<<x<<" "<<y<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>

int main() {
  int n, y;
  std::cin >> n >> y;

  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n - i; ++j) {
      for (int k = 0; k <= n - i - j; ++k) {
        int sum = 10000 * i + 5000 * j + 1000 * k;
        if (sum == y && i + j + k == n) {
          std::cout << i << " " << j << " " << k;
          return 0;
        }
      }
    }
  }
  std::cout << -1 << " " << -1 << " " << -1;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL n,t,a[200200]={};
	cin>>n>>t;
	LL s=0,e=0,nxt=0,ans=0LL;
	FOR(i,0,n){
		cin>>a[i];
		if(i==0)nxt=a[i];
		if(nxt>=a[i]){
			ans+=t-(nxt-a[i]);
			nxt=a[i]+t;
		}else{
			ans+=t;
			nxt=a[i]+t;
		}
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
flag = True
grid = []
for i in range(3):
    grid.append(list(map(int,(input()).split())))

po = [[0,1],[0,2],[1,2]]
for m in po:
    tmp = [0,0,0]
    for i in range(3):
        tmp[i] = grid[m[1]][i] - grid[m[0]][i]

    if tmp[0] == tmp[1] == tmp[2]:
        pass
    else:
        flag = False
        break

for m in po:
    tmp = [0,0,0]
    for i in range(3):
        tmp[i] = grid[i][m[1]] - grid[i][m[0]]

    if tmp[0] == tmp[1] == tmp[2]:
        pass
    else:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
N =int(input())
a =list(map(int,input().split()))

#print(a)
count = 0

D = []
for i in range(N):
    if i % 2 == 0:
        D.append(i)

#print(D)   

for j in D:
    if a[j] % 2 != 0:
        count += 1
        

print(count)


Measured memory_bytes: 8940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,n;
int main(){
    cin >> n >> a >> b;
    if ((b-a)&1){
        cout << min(((a-1)+(b-1)+1)/2,((n-a)+(n-b)+1)/2) << endl;
    } else {
        cout << (b-a)/2 << endl;
    }
    return 0;
}


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

vector<ll> V[2], G[N];
ll ans[N];

void DFS(ll u, ll p, ll c){
	V[c].pb(u);
	for(auto adj : G[u]) if(adj != p) DFS(adj, u, c ^ 1);
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	ll u, v;
	for(int i = 1; i < n; i++){
		cin >> u >> v;
		G[u].pb(v);
		G[v].pb(u);
	}
	DFS(1, -1, 0);
	ll c0 = n/3;
	ll c1 = n/3;
	ll c2 = n/3;
	if(n % 3 > 0) c1 ++;
	if(n % 3 > 1) c2 ++;
	debug(c0);
	debug(c1);
	debug(c2);
	if(V[0].size() < V[1].size()) V[0].swap(V[1]);
	memset(ans, -1, sizeof ans);
	if(V[1].size() <= c0){
		for(auto x : V[1]){
			ans[x] = 0;
			c0 --;
		}
		for(int i = 1; i <= n; i++){
			if(ans[i] != -1) continue;
			if(c0) ans[i] = 0, c0--;
			else if(c1) ans[i] = 1, c1--;
			else ans[i] = 2, c2--;
		}
	} else {
		for(auto x : V[0]){
			if(c1 == 0) break;
			ans[x] = 1;
			c1 --;
		}
		for(auto x : V[1]){
			if(c2 == 0) break;
			ans[x] = 2;
			c2 --;
		}
		for(int i = 1; i <= n; i++){
			if(ans[i] != -1) continue;
			if(c0) ans[i] = 0, c0--;
			else if(c1) ans[i] = 1, c1--;
			else ans[i] = 2, c2--;
		}
	}
	debug(c2);
	debug(c1);
	debug(c0);
	ll p0 = 0;
	ll p1 = -2;
	ll p2 = -1;

	for(int i = 1; i <= n; i++){
		if(ans[i] == 1) cout << (p1 += 3) << " ";
		if(ans[i] == 2) cout << (p2 += 3) << " ";
		if(ans[i] == 0) cout << (p0 += 3) << " ";
	}
	return 0;
}


Measured memory_bytes: 23148
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }





int main() {
    char s[200001];
    scanf("%s", &s);
    ll ans = 0;
    int p = 0;
    for(int i = 0; s[i] != '\0'; i++){
        if(s[i] == 'W'){
            ans += i - p++;
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 384
N, M = list(map(int, input().split()))
data = list(map(int, input().split()))
result = 10**9
for i in range(N-M+1):
  if data[i] < 0 and data[i+M-1] >= 0:
    result = min([data[i+M-1]-data[i]*2, 
                  data[i+M-1]*2-data[i],
                  result])
  elif data[i+M-1] >= 0:
    result = min([data[i+M-1], result])
  else:
    result = min([-data[i], result])
print(result)

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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define fff ff
#define sss ss.ff
#define ttt ss.ss
#define INF (1 << 30)
#define LLF (1ll << 60)
#define PRIME (1000000007)
#define FASTIO                      \
  std::ios::sync_with_stdio(false); \
  cin.tie(0)
#ifdef DEBUG
#define debug(x) cerr << #x << " = " << x << endl
#else
#define debug(x)
#endif
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define FILE_INPUT                  \
  freopen("input.txt", "r", stdin); \
  freopen("output.txt", "w", stdout)

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<string> vs;

/*-----------------END TEMPLATE-----------------*/

int main() {
  FASTIO;
  int n;
  cin >> n;
  vii a(n);
  rep(i, 0, n) { cin >> a[i].ff >> a[i].ss; }
  sort(a.begin(), a.end());

  long double total = 0;
  ll c = 0;
  do {
    c++;
    for (int i = 1; i < n; i++) {
      long double xdiff = abs(a[i].ff - a[i - 1].ff);
      long double ydiff = abs(a[i].ss - a[i - 1].ss);
      long double dst = sqrtl(xdiff * xdiff + ydiff * ydiff);
      total += dst;
    }
  } while (next_permutation(a.begin(), a.end()));
  cout << fixed << setprecision(15) << total / c << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.abs

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (a, v) = readLongList()
    val (b, w) = readLongList()
    val t = readLong()

    val ans = if (abs(a - b) <= t * (v - w)) "YES" else "NO"
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 36456
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

int main() {
	int sum;
	while (cin >> sum, sum) {
		int tmp;
		REP(i, 9) {
			cin >> tmp;
			sum -= tmp;
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <limits.h>
using namespace std;

int main(){
 int n;
  cin>>n;
  int arr[n];
  for (int i=0;i<n;i++)
    cin>>arr[i];
  int temp1[n],temp2[n];
  temp1[0]=arr[0];
  for (int i=1;i<n;i++)
	temp1[i] = temp1[i-1]+arr[i];
  temp2[n-1] = arr[n-1];
  for (int i=n-2;i>=0;i--)
    temp2[i] = temp2[i+1]+arr[i];
  int minl=INT_MAX;
  for (int i=0;i<n-1;i++){
    minl = min(abs(temp1[i]-temp2[i+1]),minl);
  	
  }
  cout<<minl<<endl;
  
  
  
  return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int n;
    cin >> n;
    double p[n];
    rep(i, n) cin >> p[i];

    double dp[n + 1][n + 1];

    rep(i, n + 1) rep(j, n + 1) dp[i][j] = 0.0;
    dp[0][0] = 1.0;

    rep(i, n)
    {
        for (int j = 0; j <= i; j++)
        {
            dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
            dp[i + 1][j + 1] += dp[i][j] * p[i];
        }
    }

    double ans = 0.0;
    for (int j = (n + 1) / 2; j <= n; j++)
    {
        ans += dp[n][j];
    }

    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 70528