akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;




int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << ' ' << max(0, a + b - n) << endl;

}


Measured memory_bytes: 256
//stackとqueueのちがい
//char ''
//for --
//調べながら20分

import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.nextLine();

		Stack stack = new Stack();

		for(int i=0;i<s.length();i++) {

			char c = s.charAt(i);

			if(c == '0') {

				stack.push(0);

			}else if(c == '1') {

				stack.push(1);

			}else if(!stack.isEmpty()) {

				stack.pop();

			}
		}

		int size = stack.size();

		String str = "";

		for(int i=0;i<size;i++) {

			str += stack.pop();

		}

		for(int i=size-1;i>=0;i--) {

			System.out.print(str.charAt(i));
		}
	}

}


Measured memory_bytes: 22740
N,M = map(int,input().split())
A = [int(_) for _  in input().split()]
BC = []
count = 0
s = 0
D = []
for i in range(M):
    x,y = map(int,input().split())
    BC.append([x,y])
A.sort()
BC.sort(key = lambda x:-x[1])
while s+BC[count][0] <= N:
    s += BC[count][0]
    for i in range(BC[count][0]):
        D.append(BC[count][1])
    if count == M-1:
        break
    else:
        count += 1
if count != M-1:
    for i in range(N-s):
        D.append(BC[count][1])
index = 0
while D[index] - A[index] > 0 :
    A[index] = D[index]
    if index == len(D)-1:
        break
    else:
        index += 1
print(sum(A))

Measured memory_bytes: 28728
import itertools
n=map(int,input().split())
a=[[int(i) for i in input().split()] for j in range(2)]
dp1=list(itertools.accumulate(a[0]))
dp2=list(itertools.accumulate(a[1][::-1]))[::-1]
print(max([x+y for x,y in zip(dp1,dp2)]))

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

int main(){

const int MAX_NO=100000;
int m[MAX_NO],f[MAX_NO],r[MAX_NO];
char hyouka[MAX_NO];
int a=0;
int b=0;
int c=0;

for(int i=1;i<MAX_NO;i++){

cin>>m[i]>>f[i]>>r[i];

a++;

for(int j=1;j<2000000000;j++){
b++;
b--;
b++;
if(b%2==0){
c++;
}
}

if(m[i]==-1 && f[i]==-1 && r[i]==-1){
goto aa;
}

if(m[i]==-1 || f[i]==-1){
hyouka[i]='F';
}

else if((m[i]+f[i])>=80){
hyouka[i]='A';
}
else if((m[i]+f[i])>=65){
hyouka[i]='B';
}

else if((m[i]+f[i])>=50){
hyouka[i]='C';
}

else if((m[i]+f[i])>=30 && r[i]<50){
hyouka[i]='D';
}
else if((m[i]+f[i])>=30 && r[i]>=50){
hyouka[i]='C';
}

else if((m[i]+f[i])<30){
hyouka[i]='F';
}

}

aa:;

for(int i=1;i<a;i++){

cout<<hyouka[i]<<endl;

}

return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define Rapido ios::sync_with_stdio(0); cin.tie(0)
const int maxS = 1e5 + 5;

void code_idhr_h() {
    string S; cin >> S;
    int N = S.size();
    if(S[N - 1] == 's') {
        S.push_back('e');
        S.push_back('s');
    }
    else S.push_back('s');
    cout << S << endl;
}

int32_t main() {
    Rapido;
    int T = 1; //cin >> T;
    for(int t = 1; t <= T; t++) {
        code_idhr_h();
    }
    return 0;
}

Measured memory_bytes: 3664
from collections import deque

N_red_toEat, N_green_toEat, N_red, N_green, N_white = map(int, input().split())

delicious_red = list(map(int, input().split()))
delicious_green = list(map(int, input().split()))
delicious_white = list(map(int, input().split()))

delicious_red.sort(reverse=True)
delicious_green.sort(reverse=True)
delicious_white.sort(reverse=True)

delicious_red = delicious_red[:N_red_toEat]
delicious_green = delicious_green[:N_green_toEat]

Q_red = deque(delicious_red)
Q_green = deque(delicious_green)
Q_white = deque(delicious_white)

summ = 0

for n in range(N_red_toEat + N_green_toEat):
    if (len(Q_red) > 0):
        r_tmp = Q_red.popleft()
    else:
        r_tmp = 0
    
    if (len(Q_green) > 0):
        g_tmp = Q_green.popleft()
    else:
        g_tmp = 0
    
    if (len(Q_white) > 0):
        w_tmp = Q_white.popleft()
    else:
        w_tmp = 0
    
    MAX_tmp = max(r_tmp, g_tmp, w_tmp)
    
    if (MAX_tmp == r_tmp):
        eat = r_tmp
        Q_green.appendleft(g_tmp)
        Q_white.appendleft(w_tmp)
    
    elif (MAX_tmp == g_tmp):
        eat = g_tmp
        Q_red.appendleft(r_tmp)
        Q_white.appendleft(w_tmp)
    
    else:
        eat = w_tmp
        Q_red.appendleft(r_tmp)
        Q_green.appendleft(g_tmp)
    
    summ += eat
    

print(summ)

Measured memory_bytes: 23616
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=(1<<21);

int main()
{
	int x; scn(x);

	if(x>=30)
	cout<<"Yes";
	else
	cout<<"No";

	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    char b;
    cin >> b;
    map<char, char> mp{{'A', 'T'}, {'T', 'A'}, {'C', 'G'}, {'G', 'C'}};
    cout << mp[b] << endl;
}


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int d;
    cin >> d;
    int c[26],s[370][26],t[370],u[26] = {0};
    for (int i = 0;i < 26;++i) cin >> c[i];
    for (int i = 0;i < d;++i) for (int j = 0;j < 26;++j) cin >> s[i][j];
    for (int i = 0;i < d;++i) cin >> t[i],t[i]--;
    ll ans = 0;
    /*
    for (int i = 0;i < d;++i) {
        ans += s[i][t[i]]-(i-u[t[i]])*(i-u[t[i]]+1)/2*c[t[i]];
        u[t[i]] = i+1;
    }
    for (int i = 0;i < 26;++i) ans -= (d-u[i])*(d-u[i]+1)/2*c[i];
    */
    for (int i = 0;i < d;++i) {
        ans += s[i][t[i]];
        u[t[i]] = i+1;
        for (int j = 0;j < 26;++j) ans -= (i+1-u[j])*c[j];
        cout << ans << newl;
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#define ll long long int

using namespace std;


int main()
{
    string s;
    cin >> s;
    char res[100001];
    int j = -1;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'B') 
        {
            if (j < 0);
            else j--;
        }
        else if (s[i] == '0') res[++j] = '0';
        else if (s[i] == '1') res[++j] = '1'; 
        
        //cout << i << " " << j << endl;
    }
    res[j + 1] = '\0';
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
const int MAX = 300005;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ll Pow(ll a , ll b){
	if(b == 0) return 1 ;
	ll c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c)% mod )) % mod ;
	return (c * c) % mod ;
}

//check modulo
int main(){
	IOS;
	cout.precision(50) ;
	int n , k ; cin >> n >> k ;
	string s ; cin >> s ;
	int nb1 = 0 , nb2 = 0 ;
	for(int i = 0 ; i < n - 1 ; i++){
		if(s[i] == s[i + 1]) nb1++ ;
		else nb2++ ;
	}
	for(int i = 0 ; i < k ; i++){
		if(nb2 == 0) break ;
		if(nb2 >= 2){
			nb1 += 2 ;
			nb2 -= 2 ;
		}
		else {
			nb1++ ;
			nb2-- ;
		}
	}
	cout << nb1 << endl ;
					
	
	return 0;
}


Measured memory_bytes: 512
#include <iostream>

#include <math.h>

using namespace std;

int main() {
	int num;
	cin >> num;
	
	int result = 1;
	for (int i = 2; i < num; ++i) {
		for (int j = 2; pow(i, j) <= num; ++j) {
			if (result < pow(i, j)) {
				result = pow(i, j);
			}
		}
	}
	
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 640
N = int(input())
W = []
for _ in range(N):
    W.append(list(map(int, input().split())))

W = sorted(W, key=lambda x:x[1])

keika_time = 0
for work in W:   #wは仕事のリスト[0]でかかる時間、[1]で締め切り
    if work[1] - keika_time <= 0:   #今見てる仕事の締め切りが経過時間を超えている時
        print('No')
        break
    elif work[1] - keika_time  >= work[0]:
        keika_time += work[0]
    elif work[1] - keika_time  < work[0]:
        print('No')
        break
else:   #forの正常終了
    print('Yes')
    

Measured memory_bytes: 55256
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
using namespace std;

typedef struct{
	string name;
	int popularity;
	bool scene[30];
}character;

int main(){
	while(1){
		int n;
		character c[20];
		
		for(int i=0; i<20; ++i){
			c[i].popularity=0;
			for(int j=0; j<30; ++j) c[i].scene[j]=false;
		}
		
		scanf(" %d", &n);
		if(n==0) break;	
		
		for(int i=0; i<n; ++i){
			int m;
			
			cin >> c[i].name;
			scanf(" %d", &m);
			
			for(int j=0; j<m; ++j){
				int a;
				scanf(" %d", &a);
				c[i].scene[a]=true;	
			}		
		}
		
		for(int i=0; i<30; ++i){ //シーン数
			int count=0;
			for(int j=0; j<n; ++j){
				if(c[j].scene[i]) ++count;	
			}
			for(int j=0; j<n; ++j){
				if(c[j].scene[i]){
					c[j].popularity+=n-count+1;	
				}	
			}
		}
		
		for(int i=0; i<n; ++i){
			for(int j=i; j<n; ++j){
				if(c[i].popularity > c[j].popularity) swap(c[i], c[j]);
				else if(c[i].popularity == c[j].popularity){
					if(c[i].name > c[j].name) swap(c[i], c[j]);	
				}
			}
		}
		
		cout << c[0].popularity << " " << c[0].name << endl;
	}
}

Measured memory_bytes: 1248
INF = 123456789

def main():
    n,m = map(int,input().split())

    d = [ [INF for i in range(n)] for j in range(n) ]
    for i in range(n):
        d[i][i] = 0

    a = [0 for _ in range(m)]
    b = [0 for _ in range(m)]
    c = [0 for _ in range(m)]
    for i in range(m):
        a[i],b[i],c[i] = map(int,input().split())
        a[i] -= 1
        b[i] -= 1
        d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i])
        d[b[i]][a[i]] = min(d[b[i]][a[i]], c[i])

    # Warshall-Floyd
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k]+d[k][j])

    ans = 0
    for i in range(m):
        found = 1
        for j in range(n):
            if d[j][a[i]] + c[i] == d[j][b[i]]:
                found = 0
                break
        ans += found
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
import qualified Data.ByteString.Char8 as BS
import Data.Function
import Data.List

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

countChar :: String -> Char -> Int -> Int -> (Char, Int)
countChar [] c a m = (c, maximum [a, m])
countChar (s : ss) c a m
  | s == c = countChar ss c 0 (maximum [a, m])
  | s /= c = countChar ss c (a + 1) m

main = do
  [s] <- getString
  let as = map (\c -> countChar s c 0 0) (map head (group (sort s)))
  print $ snd (head (sortBy (compare `on` snd) as))


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n;
    vector<bool> prime(1000000,true);
    prime[0]=false;
    prime[1]=false;
    for(int i=2;i<1000000;i++){
        if(prime[i]==false)continue;
        for(int j=2*i;j<1000000;j+=i){
            prime[j]=false;
        }
    }
    while(scanf("%d",&n)!=EOF){
        int ans=0;
        for(int i=2;i<=n;i++){
            if(prime[i])ans++;
        }
        out(ans);
    }
}


Measured memory_bytes: 3240
#include<cstdio>
#define sacnf scanf
#define pritnf printf
#define srnad srand
#define rnad rand
#define sl(sl_a) strlen(sl_a)
#define gt(gt_a) goto gt_a
#define mst(mst_a,mst_b) memset(mst_a,mst_b,sizeof(mst_a))
#define fora(fora_x,fora_a,fora_b) for(re nti (fora_x)=(fora_a);(fora_x)<=(fora_b);++(fora_x))
#define forb(forb_x,forb_a,forb_b) for(re nit (forb_x)=(forb_a);(forb_x)>=(forb_b);--(forb_x))
#define foral(foral_x,foral_a,foral_b) for(re ll (foral_x)=(foral_a);(foral_x)<=(foral_b);++(foral_x))
#define forbl(forbl_x,forbl_a,forbl_b) for(re ll (forbl_x)=(forbl_a);(forbl_x)>=(forbl_b);--(forbl_x))
#define re register
#define inl inline
#define br break
#define con continue
#define stt struct
#define nms namespace
#define gc getchar
#define rt return
#define infa (0x3f3f3f3f)
#define infb (0x7fffffff)
#define infd (0x7f)
#define in(in_a) freopen("F:/""/in"in_a".in","r",stdin)
#define out(out_a) freopen("F:/""/out"out_a".out","w",stdout)
#define fin(filein_a) freopen(filein_a".in","r",stdin)
#define fout(fileout_a) freopen(fileout_a".out","w",stdout)
typedef long long ll;
typedef int itn,nti,tin,tni,nit;
using namespace std;
const nit maxa=100004;
const nit maxb=54;
const nit maxc=4;
const tni maxd=104;

tni n,m,x[maxd]={0},p,ls,sum=0;

tin main()
{
    scanf("%d",&n);
    fora(i,1,n)
	{
        scanf("%d",&x[i]);
        sum+=x[i];
    }
    //
    scanf("%d",&m);
    fora(i,1,m)
	{
        scanf("%d%d",&p,&ls);
        //
        printf("%d\n",sum-x[p]+ls);
    }
    //
    rt 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(min(a,b),c)<<" "<<max(max(a,b),c)<<"\n";
}


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

int main() {
  int i=0,j,g,a;
  int A,B;
  int answer=0;
  
  cin >> A >> B ;

  answer=A-B*2;

  if (answer<0)
  {
      answer=0;
  }
  

  cout << answer <<endl;
  
  
  return 0;
}

Measured memory_bytes: 256
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let k: usize = sc.read();
    let mut s = sc.chars();

    let mut ctr = 0;
    let fix = s[0];
    let mut chg = false;
    for c in &mut s {
        if *c == fix {
            if chg {
                if ctr == k-1 {
                    break;
                } else {
                    chg = false;
                    ctr += 1;
                }
            }
        } else {
            chg = true;
            *c = fix;
        }
    }
    let mut ans = 0;
    for i in 0..n {
        match s[i] {
            'L' => {
                if i > 0 && s[i - 1] == 'L' {
                    ans += 1;
                }
            }
            'R' => {
                if i < n - 1 && s[i + 1] == 'R' {
                    ans += 1;
                }
            }
            _ => unreachable!(),
        }
    }

    format!("{}\n", ans)
}
#[test]
fn test_solve() {
    assert_eq!(solve("6 1\nLRLRRL\n"), "3\n");
    assert_eq!(solve("13 3\nLRRLRLRRLRLLR\n"), "9\n");
    assert_eq!(solve("10 1\nLLLLLRRRRR\n"), "9\n");
    assert_eq!(solve("9 2\nRRRLRLRLL\n"), "7\n");
}
fn main() {
    let mut buf = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut buf).unwrap();
    use std::io::Write;
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<I> {
    src: I,
}
impl<'a> Scanner<std::str::SplitWhitespace<'a>> {
    fn from_str(src: &'a str) -> Self {
        Scanner {
            src: src.split_whitespace(),
        }
    }
}
#[allow(dead_code)]
impl<'a, I> Scanner<I>
where
    I: std::iter::Iterator<Item = &'a str>,
{
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.src.next().unwrap().parse().ok().expect("Parse error")
    }
    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    fn chars(&mut self) -> Vec<char> {
        self.src.next().unwrap().chars().collect()
    }
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int64_t A;
    long double B;
    cin >> A >> B;
    cout << (int64_t)(A * B) << endl;
    return 0;
}

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

typedef long long ll;

using namespace std;

int main() {
  int n;
  cin >> n;
  ll ma = 0;
  ll ans = 0;
  for(int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    if(ma < a) {
      ma = a;
      ans = b;
    }
  }

  cout << ma + ans <<endl;
}



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

const int MOD = 1000000007;

int main()
{
    int card[3][3];
    for (int i = 0; i < 3;i++){
        for (int j = 0; j < 3;j++){
            cin >> card[i][j];
        }
    }
    int n;
    cin >> n;
    int num[10] = {0};
    for (int i = 0; i < n;i++){
        cin >> num[i];
    }
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < n;k++){
                if(card[i][j] == num[k]){
                    card[i][j] = -1;
                }
            }
        }
    }
    bool ans = false;
    for (int i = 0; i < 3; i++)
    {
        if (card[i][0] == -1 && card[i][1] == -1 &&card[i][2] == -1){
            ans = true;
        }
        if (card[0][i] == -1 && card[1][i] == -1 && card[2][i] == -1)
        {
            ans = true;
        }
        if(card[0][0] == -1 && card[1][1] == -1 && card[2][2] == -1){
            ans = true;
        }
        if (card[0][2] == -1 && card[1][1] == -1 && card[2][0] == -1)
        {
            ans = true;
        }
    }
    if(ans)
        cout << "Yes";
        else
            cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main(int argc, char const* argv[]) {
   int n, m;
   cin >> n >> m;
   vector<int> broken(n + 1);
   rep(i, m) {
      int a;
      cin >> a;
      broken[a] = 1;
   }
   vector<int> dp(n + 2);
   dp[n] = 1;
   for (int i = n - 1; i >= 0; i--) {
      if (broken[i]) {
         dp[i] = 0;
         continue;
      }
      dp[i] = dp[i + 1] + dp[i + 2];
      dp[i] %= mod;
   }
   cout << dp[0] << endl;
   return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  int n,k,r,s,p;
  cin >> n >> k >> r >> s >> p;
  string t;
  cin >> t;
  ll ans=0;
  vector<bool> is(t.size(),true);
  for(int i=k;i<t.size();i++){
    if(t.at(i)==t.at(i-k) && is.at(i-k)==true){
      is.at(i)=false;
    }
  }
  rep(i,n){
    if(is.at(i)==true && t.at(i)=='r'){
      ans+=p;
    }
    if(is.at(i)==true && t.at(i)=='s'){
      ans+=r;
    }
    if(is.at(i)==true && t.at(i)=='p'){
      ans+=s;
    }
  }
  cout << ans;
}

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

int main() {
	int h, w;
	cin >> h >> w;
	ll ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char c;
			cin >> c;
			if (c == '#')ans++;
		}
	}
	if (ans == h + w - 1)cout << "Possible" << endl;
	else cout << "Impossible" << endl;

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)

{
    int H, W, N, i, a, b;
    cin>>H>>W>>N;
    if(H>W){
        a = H;
        b = W;
    }
    else{
        a = W;
        b = H;
    }
    for(i = 1; i <= b; i++){
        if(a*i >= N){
            break;
        }
    }
    cout<<i<<"\n";
    return 0;
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    if (a > b) {
        cout << 0 << endl;
        return 0;
    }
    if (n == 1) {
        if (a == b) cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    cout << ((n - 1) * b + a) - ((n - 1) * a + b) + 1 << endl;
    
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
N, K = map(int, input().split())
A = list(map(int, input().split()))

num = [0] * 200001
for a in A:
    num[a] += 1

num = list(filter(lambda x: x != 0, num))
num.sort()
print(sum(num[:len(num) - K]) if (len(num) > K) else 0)


Measured memory_bytes: 25748
#include<bits/stdc++.h>
using namespace std;
#define MAX 200005

int N,M,K,a,d;
int x[MAX],y[MAX],z[MAX];

int main(){
  scanf("%d %d %d %d",&N,&a,&d,&M);
  for(int i=0;i<M;i++)scanf("%d %d %d",&x[i],&y[i],&z[i]);
  scanf("%d",&K);
  stack<int> st;
  for(int i=M-1;i>=0;i--){
    if(K<y[i]||z[i]<K)continue;
    if(x[i]==0)K=z[i]+y[i]-K; 
    else st.push(x[i]);
  }
  int ans=a+d*(K-1);
  while(!st.empty()){
    if(st.top()==1)ans++;
    else ans/=2;
    st.pop();
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 5464
//
//  164.cpp
//  
//
//  Created by Minote Tomoki on 2015/06/01.
//
//

#include <stdio.h>

#define INITIAL 32

int number=INITIAL;
int seq[25]={0};
int n;

int step=0;

void turn() {
    if(number-1>0) {
        number-=((number-1)%5);
    }else{
        number--;
        return;
    }
    
    printf("%d\n",number);
    
    int tmp = (step++)%n;
    
    number-=seq[tmp];
}

int main(void) {
    
    for(;;) {
        number=INITIAL;
        step=0;
        scanf("%d",&n);
        if(n==0)break;
        for(int i=0;i<n;i++){
            scanf("%d",&seq[i]);
        }
        
        while(number>0) {
            turn();
            if(number>0)printf("%d\n",number);
        }
        printf("0\n");
        
    }
    return 0;
}

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

using namespace std;
#define int long long
#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

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

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

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int a, b;

void f(int x) {
    a = x % 10;
    b = 0;
    while (x) {
        b = x;
        x /= 10;
    }
}

signed main() {
    int K;
    cin >> K;
    int ans = 0;
    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            for (int c = 1; c <= K; c++) {
                int ab = gcd(a, b);
                ans += gcd(ab, c);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int Q;
int N[101];
int ct(int num){
    int cnt=0;
    while(num>9){
        num/=10;
        cnt++;
    }
    return cnt;
}
int eiei(int num){
    int rec=1;
    for(int i=0;i<num;i++) rec*=10;
    return rec;
}
int change(int num){
    int mx=0;
    for(int i=0;i<ct(num);i++){
        mx=max(mx,(num/eiei(i+1))*(num%eiei(i+1)));
    }
    return mx;
}
int ans(int num){
    int cnt=0;
    vector<int> vec;
    int rec=num;
    if(rec>9) cnt++;
    bool flag=true;
    while(flag){
        rec=change(rec);
        if(rec<10) break;
        cnt++;
        vec.push_back(rec);
        for(int i=0;i<vec.size();i++){
            for(int j=i+1;j<vec.size();j++){
                if(vec[i]==vec[j]){
                    cnt=-1;
                    flag=false;
                    break;
                }
            }
            if(!flag) break;
        }
    }
    
    return cnt;
}
int main(){
    cin>>Q;
    for(int i=0;i<Q;i++) cin>>N[i];
    
    for(int i=0;i<Q;i++){
        cout<<ans(N[i])<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1000000007;

ll rui(int x, int y){
  if(y == 1) return (ll)x;
  ll xy = rui(x, y/2);
  if(y%2) return xy*xy%MOD*(ll)x%MOD;
  else return xy*xy%MOD;
}

ll comb(int x, int y){
  ll ans=1;
  for(int i=0; i<y; ++i){
    ans *= x-i;
    ans %= MOD;
    //cout << 'a' << ans << endl;
    ans *= rui(i+1,MOD-2);
    ans %= MOD;
    //cout << 'b' << ans << endl;
  }
  return ans;
}

int main(){
  int x, y;
  cin >> x >> y;
  if((x+y)%3 != 0){
    cout << 0 << endl;
    return 0;
  }
  int xy = (x+y)/3;
  x -= xy; y -= xy;
  if(x < 0 || y<0){
    cout << 0 << endl;
    return 0;
  }
  cout << comb(x+y,y) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define REP(i, a, b, c) for(int i = a; i <= b; i+=c)
#define pb push_back
#define int long long int
#define MOD 1000000007
using namespace std;

char grid[1005][1005];
int dp[1005][1005];

int solve(int h, int w) {

  for (int i = 1; i <= h; i++)
  {
    for (int j = 1; j <= w; j++)
    {
      if (i == 1)
      {
        if (grid[i][j] == '#') {
          for (int k = j; k <= w; k++)
            dp[1][k] = -1;
        }
      }
      if (j == 1)
      {
        if (grid[i][j] == '#') {
          for (int k = i; k <= h; k++)
            dp[k][1] = -1;
        }
      }
    }
  }

  for (int i = 1; i <= h; i++)
  {
    for (int j = 1; j <= w; j++)
    {
      if (i == 1 or j == 1)
        dp[i][j] += 1;
      else if (grid[i][j] == '#')
        dp[i][j] = 0;
      else {
        dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
      }
    }
  }
 return dp[h][w] % MOD;
}

int32_t main()
{
  ios :: sync_with_stdio(false); cin.tie(0);
  int t = 1;
  memset(dp, -1, sizeof(dp));
  for (int i9 = 1; i9 <= t; i9++)
  {
    memset(dp, 0, sizeof(dp));
    int h, w;
    cin >> h >> w;
    for (int i = 1; i <= h; i++)
    {
      for (int j = 1; j <= w; j++)
      {
        cin >> grid[i][j];
      }
    }
    cout << solve(h, w);
  }
}



Measured memory_bytes: 12568
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int H, N;
	cin >> H >> N;
	int sum = 0;
	vector<int> vec(N);
	rep(i , N)
	{
		cin >> vec[i];
		sum += vec[i];
	}

	if (sum < H)
	{
		cout << "No" << '\n';
	}
	else
	{
		cout << "Yes" << '\n';
	}

	return 0;
}


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

int N;
string dfs(string s){
	string r;
	int i=0;
	long long n=-1;
	for(;i<s.size();){
		if('0'<=s[i]&&s[i]<='9'){
			if(n<0)
				n=s[i]-'0';
			else
				n=n*10+s[i]-'0';
			i++;
		}else if(s[i]=='('){
			if(n<0)n=1;
			int cnt=1,j=i+1;
			for(;cnt;){
				if(s[j]=='(')
					cnt++;
				else if(s[j]==')')
					cnt--;
				j++;
			}
			string r0=dfs(s.substr(i+1,j-1-i-1));
			for(int _=0;_<n;_++){
				r+=r0;
				if(r.size()>N)return r;
			}
			n=-1;
			i=j;
		}else{
			if(n<0)n=1;
			r+=string(n,s[i]);
			n=-1;
			i++;
		}
	}
	return r;
}

int main(){
	for(;;){
		string s;
		cin>>s>>N;
		if(s=="0")break;
		string r=dfs(s);
		printf("%c\n",r.size()>N?r[N]:'0');
	}
}

Measured memory_bytes: 6900
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func palindrome(s string) bool {
	b := []byte(s)
	return len(s) == 5 && b[0] == b[4] && b[1] == b[3]
}

func main() {
	defer stdout.Flush()
	a := readInt()
	b := readInt()
	var ans int
	for i := a; i <= b; i++ {
		if palindrome(fmt.Sprintf("%d", i)) {
			ans++
		}
	}
	println(ans)

}


Measured memory_bytes: 2048
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(400).
01 maxlen     PIC 9(10) VALUE 100 COMP.
01 cur        PIC 9(10) VALUE 1 COMP.
01 i          PIC 9(10) VALUE 1 COMP.
01 j          PIC 9(10) COMP.
01 len        PIC 9(10) COMP.
01 ans        PIC 9(10).
01 zs         PIC Z(9)9.
01 N          PIC 9(10).
01 num        PIC 9(10).
01 A1.
   03 A11 OCCURS 100 DEPENDING ON N.
      05 A    PIC S9(10).
01 B1.
   03 B11 OCCURS 100 DEPENDING ON N.
      05 B    PIC S9(10).
01 C1.
   03 C11 OCCURS 100 DEPENDING ON num.
      05 C    PIC S9(10).

PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT ln.
  MOVE N TO maxlen.
  COMPUTE num = N - 1.
  PERFORM maxlen TIMES
    PERFORM VARYING j FROM cur BY 1 UNTIL ln(j:1) = SPACE
    END-PERFORM
    COMPUTE len = j - cur
    MOVE ln(cur:len) TO A(i)
    COMPUTE cur = j + 1
    ADD 1 TO i
  END-PERFORM.
  ACCEPT ln.
  MOVE 1 TO cur.
  MOVE 1 TO i.
  PERFORM maxlen TIMES
    PERFORM VARYING j FROM cur BY 1 UNTIL ln(j:1) = SPACE
    END-PERFORM
    COMPUTE len = j - cur
    MOVE ln(cur:len) TO B(i)
    COMPUTE ans = ans + B(i)
    COMPUTE cur = j + 1
    ADD 1 TO i
  END-PERFORM.
  ACCEPT ln.
  MOVE num TO maxlen.
  MOVE 1 TO cur.
  MOVE 1 TO i.
  PERFORM maxlen TIMES
    PERFORM VARYING j FROM cur BY 1 UNTIL ln(j:1) = SPACE
    END-PERFORM
    COMPUTE len = j - cur
    MOVE ln(cur:len) TO C(i)
    COMPUTE cur = j + 1
    ADD 1 TO i
  END-PERFORM.
  MOVE N TO maxlen.
  MOVE 1 TO cur.
  MOVE 1 TO i.
  PERFORM VARYING i FROM 1 BY 1 UNTIL N < i
    IF 1 < i
      IF A(i - 1) + 1 = A(i)
        COMPUTE ans = ans + C(A(i - 1))
      END-IF
    END-IF
  END-PERFORM.
  MOVE ans TO zs.
  DISPLAY FUNCTION TRIM(zs).
  STOP RUN.


Measured memory_bytes: 3872
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a,b,c,k = LI()
    r = min(a,k)
    k -= a
    k -= b
    if k > 0:
        r -= k

    return r

print(main())





Measured memory_bytes: 10972
#include <bits/stdc++.h>
#define int long long
using namespace std;
int solve(vector<int> &v, int l){
    deque<int> kek;
    int n = v.size();
    int ind = n-1, here=0;
    while (2*kek.size() < n){
        kek.push_back((l-v[ind])-here);
        here = l - v[ind];
        ind--;
    }
    deque<int> sas;
    here = 0;
    for (int i=0;i<=ind; i++){
        sas.push_back(v[i]-here);
        here = v[i];
    }
    int mv = 0;
    if (kek.size() > sas.size()){
        mv += kek[0];
        sas[0] += kek[0];
        kek.pop_front();
    }
    int aa = 0, bb=0, s1=0, s2=0;
    int mn = 2*kek.size();
    for (int i=0; i < kek.size(); i++){
        s1 += kek[i], s2 += sas[i];
        aa += mn*kek[i], bb += mn*sas[i];
        mn-=2;
    }
    int res = mv + aa+bb - min(s1, s2);
    int sz = kek.size();
//    for (int i=0; i < kek.size(); i++) cout << kek[i] << " ";
//    cout << endl;
//    for (int i=0; i <sas.size(); i++) cout << sas[i] << " ";
//    cout << endl;
//    cout << endl;
    for (int i=0; i < sz-1; i++){
        int V = kek.front();
        kek.pop_front();
        int P = kek.front();
        kek.pop_front();
        mv += V+P;
        s1 -= V+P;
        aa -= 2*((sz-i)*V + (sz-i-1)*P);
        bb += 2*(sz-i)*(V+P);
        s2 += V+P;
        sas[0] += V+P;
        int hh = sas.back();
        sas.pop_back();
        int index = sz-i-1;
        int rl = v[index+1] - v[index];
        bb -= 2*hh;
        s2 -= hh;
        bb -= 2*s2;
        aa += 2*s1;
        s1 += rl;
        aa += 2*rl;
        kek.push_back(rl);
        res = max(res, mv + aa+bb - min(s1, s2));
//        for (int i=0; i < kek.size(); i++) cout << kek[i] << " ";
//        cout << endl;
//        for (int i=0; i <sas.size(); i++) cout << sas[i] << " ";
//        cout << endl;
//        cout << endl;
//        cout << mv << " " << aa << " " << bb << " " << s1 << " " << s2 << endl;
    }
    return res;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int l, n;
    cin >> l >> n;
    vector<int> v(n);
    for (int i=0; i < n; i++) cin >> v[i];
    int A = solve(v, l);
    reverse(v.begin(), v.end());
    for (int i=0; i < n; i++) v[i] = l-v[i];
    A = max(A, solve(v, l));
    A = max(A, l-v[0]);
    A = max(A, l-v.back());
    A = max(A, v.back());
    A = max(A, v[0]);
    cout << A;
    return 0;
}




Measured memory_bytes: 3472
import std.stdio, std.array, std.conv, std.string;

void main()
{
	string[] input;
	solve: while(!stdin.eof()) {
		input = readln.split(",");
		if(input.length != 8) return;
		auto inx = new double[](4);
		auto iny = new double[](4);
		for(int i = 0; i < 4; i++)
		{
			inx[i] = input[2 * i].chomp.to!double;
			iny[i] = input[2 * i + 1].chomp.to!double;
		}
		for(int xi = 0; xi < 4; xi++)
		{
			double[] x;
			double[] y;
			double xp, yp;
			for(int i = 0; i < 4; i++)
			{
				if(i == xi)
				{
					xp = inx[i];
					yp = iny[i];
					continue;
				}
					
				x ~= inx[i];
				y ~= iny[i];
			}
			bool l;
			bool r;
			l = r = false;
		
			x ~= x[0];
			y ~= y[0];
		
			bool isConvex = false;
			for(int i = 0; i < 3; i++) {
				double ax = x[i+1] - x[i];
				double ay = y[i+1] - y[i];
				double px = xp - x[i];
				double py = yp - y[i];
				if(ax*py - ay*px < 0)
					r = true;
				else
					l = true;
			}
			if(l != r)
			{
				"NO".writeln;
				continue solve;
			}
				
		}
		"YES".writeln;
		
    }
}

Measured memory_bytes: 1096
/*  -*- coding: utf-8 -*-
 *
 * 2938.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

bool ts[MAX_N];

/* subroutines */

inline bool m(bool a, bool b) { return (! a || b); }

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    char s[4];
    scanf("%s", s);
    ts[i] = (s[0] == 'T');
  }

  bool t = ts[0];
  for (int i = 1; i < n; i++) t = m(t, ts[i]);

  putchar(t ? 'T' : 'F');
  putchar('\n');
  return 0;
}



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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]
                || s[0] == s[3] && s[1] == s[2] && s[0] != s[1]
                || s[0] == s[2] && s[1] == s[3] && s[0] != s[1])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
X,Y,Z,K = map(int,input().split(' '))
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))

list.sort(A, reverse=True)
list.sort(B, reverse=True)
list.sort(C, reverse=True)

sums = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) > K:
                break
            sums.append(A[i]+B[j]+C[k])

for a in sorted(sums, reverse=True)[:K]:
    print(a)

Measured memory_bytes: 9544
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define F first
#define S second
#define pb push_back
#define bit __builtin_popcount
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define mkp make_pair
#define ffs fflush(stdout)

using namespace std;
using namespace __gnu_pbds;

//order_of_key(k) : Number of items strictly smaller than k
//find_by_order(k) : K-th element in a set (counting from 0)

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

const int N = (int)1e6 + 5;
const int MOD = (int)1e9 + 7;
const int inf = (int)1e18;
const int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
const ld eps = 1e9 - 7;
const int pp[] = {29, 31, 53, 67, 71};
const double pi = acos(-1.0);

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());
int n, a[22];
int solve(int l, int r, int cl, int cr) {
  if (l + 1 == r)
    return 0;
  int ret = inf;
  for (int i = l + 1; i <= r - 1; ++i)
     ret = min(ret, a[i] * (cl + cr) + solve(l, i, cl, cr + cl) + solve(i, r, cl + cr, cr));
  return ret;
}
signed main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  cout << a[1] + a[n] + solve(1, n, 1, 1);
  return 0;
}


Measured memory_bytes: 256
#include <atcoder/all>
using namespace atcoder;

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int, Int> P;

int op(int a, int b) { return max(a,b); }
int e(){ return 0; }

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

    // dp[i]: 最終要素がiとなるような部分列の長さの最大値
    segtree<int,op,e> dp(300010);

    int ans = 0;
    rep(i,N){
        int a; cin >> a;
        int L = max(a-K,0), R = min(a+K,300000);
        int tmp = dp.prod(L,R+1) + 1;
        ans = max(ans, tmp);
        dp.set(a, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 8568
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll N = 100007;
ll n  , u , v , w;

vector<pll> G[N];
bool color[N];

void dfs(int s , int p , ll dis){
    
    color[s] = (dis&1);
    for(auto it : G[s]){
        if(it.F != p)
            dfs(it.F , s , dis+it.S);
    }
}




int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    cin >> n;
    for(int i = 0 ;i < n-1 ; i++){
        cin >> u >> v >> w;
        
        G[u].pb(mp(v , w));
        G[v].pb(mp(u , w));
    }
    dfs(1 , -1 , 0);
    for(int i = 1 ;i <= n ; i++)
        cout << color[i] << endl;
    

    return 0;
}   

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[100000];
  int b[100000];
  rep(i,n){
    cin>>a[i];
    b[a[i]-1]=i+1;
  }
  rep(i,n){
    cout<<b[i];
    if(i!=n-1) cout<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2432