akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;


int main(void){
    int x,y;
    while(1){
        cin >> x;
        cin >> y;
        if (x == 0 && y == 0) {
            break;
        }else{
            if (x < y) {
                cout << x << " " << y << endl;
            }else{
                cout << y << " " << x << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    vector<long long> a(N+1, 0);
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        a[i] += a[i-1];
    }
    long long ans;
    for (int i = 1; i+1 <= N; i++) {
        long long x = a[i];
        long long y = a[N]-a[i];
        if (i == 1) {
            ans = abs(x-y);
        }
        else {
            ans = min(ans, abs(x-y));
        }
    }
    cout << ans << endl;
}

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

#define MAX 1000000
int m,n;
int caves[1000][1000];

int isPrime[MAX+1];
void sieve(){
  isPrime[0] = isPrime[1] = false;
  for(int i=2;i<=MAX;i++)
    isPrime[i] = true;
  for(int i=2;i<=MAX;i++)
    if(isPrime[i])
      for(int j=i*2;j<=MAX;j+=i)
	isPrime[j]=false;
}

int Pow[1000];
void mkcaves(){
  Pow[0]=1;
  for(int i=1;i<1000;i++)
    Pow[i] = Pow[i-1] + 2*i + 1;
  int x=499,y=500;
  for(int i=1;i<=1000;i++){
    if(i%2){
      for(int j=Pow[i-1]-2*i+2;j<=Pow[i-1]-i;j++)
	caves[x][y++]=isPrime[j]?j:j*-1;
      for(int j=Pow[i-1]-i+1;j<=Pow[i-1];j++)
	caves[x++][y]=isPrime[j]?j:j*-1;
    }
    else{
      for(int j=Pow[i-1]+-2*i+2;j<=Pow[i-1]-i;j++)
	caves[x][y--]=isPrime[j]?j:j*-1;
      for(int j=Pow[i-1]-i+1;j<=Pow[i-1];j++)
	caves[x--][y]=isPrime[j]?j:j*-1;
    }
  }
}

void print(int ary[1000][1000]){
    for(int i=500-sqrt(m)/2+1;i<500+sqrt(m)/2;i++){
      for(int j=500-sqrt(m)/2;j<500+sqrt(m)/2-1;j++)
	printf("%3d ",ary[j][i]);
      putchar('\n');
    } 
}

int max3(int a,int b,int c){
  int max = a;
  if (b > max) max = b;
  if (c > max) max = c;
  return max;
}

int dp[1000][1000];
int cp[1000][1000];
void solve(){
  //copy caves
  rep(i,1000)
    rep(j,1000)
      cp[j][i] = (0<caves[j][i] && caves[j][i]<=m);

  //print(cp);

  //reset dp
  rep(i,1000)
    rep(j,1000)
      dp[j][i]=0;
  
  if(!isPrime[n])
    n*=-1;

  int sx,sy;
  bool f = false;
  rep(i,1000){
    rep(j,1000){
      if(caves[j][i]==n){
	sx = j;
	sy = i;
	f = true;
	break;
      }
    }
    if(f)
      break;
  }
  //printf("start = (%d,%d)\n",sx,sy);

  dp[sx][sy] = cp[sx][sy];
  int nmax=0;
  for(int i=1;i<=sqrt(m)+1 && sy+i < 1000; i++){
    int jmin=-i,jmax=i;
    if(sx+jmin<=0){
      dp[0][sy+i] = cp[0][sy+i]	+ max(dp[0][sy+i-1], dp[1][sy+i-1]);
      if(dp[0][sy+i] > nmax)
	nmax = dp[0][sy+i];
      jmin=1-sx;
    }
    if(sx+jmax>=999){
      dp[999][sy+i] = cp[999][sy+i]+ max(dp[998][sy+i-1], dp[999][sy+i-1]);
      if(dp[999][sy+i] > nmax)
	nmax = dp[999][sy+i];
      jmax=998-sx;
    }
    for(int j=jmin;j<=jmax;j++){
      dp[sx+j][sy+i] = cp[sx+j][sy+i]
	+ max3(dp[sx+j-1][sy+i-1], dp[sx+j][sy+i-1], dp[sx+j+1][sy+i-1]);
      if(dp[sx+j][sy+i] > nmax)
	nmax = dp[sx+j][sy+i];
    }
  }
  //puts("~nmax");

  int pmax=0;
  for(int i=0; i<sqrt(m)+1 && sy+i<1000; i++){
    int jmin=-i,jmax=i;
    if(sx+jmin<=0){
      //      dp[0][sy+i] = cp[0][sy+i]
      //	+ max(dp[0][sy+i-1], dp[1][sy+i-1]);
      jmin=1-sx;
    }
    if(sx+jmax>=999){
      //dp[999][sy+i] = cp[999][sy+i]
      //	+ max(dp[998][sy+i-1], dp[999][sy+i-1]);
      jmax=998-sx;
    }
    for(int j=jmin;j<=jmax;j++){
      if(cp[sx+j][sy+i] && dp[sx+j][sy+i]==nmax && pmax<caves[sx+j][sy+i])
	pmax = caves[sx+j][sy+i];
    }
  }
  //puts("~pmax");
  
  //print(dp);
  
  printf("%d %d\n",nmax,pmax);
}

int main(){
  sieve();
  mkcaves();
  for(;;){
    scanf("%d %d",&m,&n);
    if(!(m+n)) break;
    solve();
  }
  return 0;
}

Measured memory_bytes: 16820
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();

            int ans = 0;
            for(int i = 0; i < N-2; i++)
            {
                if(S[i] == 'A')
                {
                    if (S[i + 1] == 'B')
                    {
                        if(S[i+2] == 'C')
                        {
                            ans++;
                        }
                    }
                }
            }

            Console.WriteLine(ans);
        }
       
    }
}
/*
long a, b, c;
a = long.Parse(Console.ReadLine()); //標準入力
string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
b = long.Parse(str[0]);  //数値で受け取りたい場合は変換する
c = long.Parse(str[1]);
string S = Console.ReadLine();
char[] C = new char[N];
C = S.ToCharArray();
Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
Member = ReadLine().Split(' ').Select(long.Parse).ToArray();

string[] str = Console.ReadLine().Split(' ');
long[] a = new long[N];
for(long i = 0; i < N; i++) a[i] = long.Parse(str[i]);
 */
/*
      static long func(long n)
      {
          long d = 0;
          for (long i = 0; i < 10; i++)
          {
              if (n / longPow(10, i) == 0)
              {
                  d = i;
                  break;
              }
          }
          long ret = A * n + B * d;
          return ret;
      }
      static long longPow(long a, long n)
      {
          long b = 1;
          for (long i = 0; i < n; i++) b = b * a;
          return b;
      }
      */


Measured memory_bytes: 11092
#include<stdio.h>
int main()
{
  int n,i,j,k=0,c=0,a[51],temp;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
    scanf("%d",&a[i]);
  }
   for(i=1;i<=n;i++)
  {
    if(a[i]!=i)
    {
      c++; 
    }
  }
  if(c==0 || c==2)
  {
    printf("YES");
  }
  else
  {
    printf("NO");
  }
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<set>
#include<cstring>
#define mp(a,b) make_pair(a,b)
using namespace std;
typedef long long ll;
struct P{
	ll x,y;
	bool operator <(const P&tmp)const{return x==tmp.x?y<tmp.y:x<tmp.x;}
}a[55];
int main()
{
	int n,i,j,k,ans,anst;
	int vis[55];
	ll dx,dy;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%lld%lld",&a[i].x,&a[i].y);
	if(n==1)
	{
		printf("1\n");return 0;
	}
	sort(a+1,a+1+n);
	ans=n;
	pair<ll,ll>pr;
	memset(vis,0,sizeof(vis));
	for(i=1;i<=n;i++)
	{
		vis[i]=1;
		for(j=i+1;j<=n;j++)
		{
			vis[j]=1;
			dx=a[j].x-a[i].x;dy=a[j].y-a[i].y;anst=1;
			set<pair<ll,ll> > se;
			se.insert(mp(a[j].x,a[j].y));
			for(k=1;k<=n;k++)
			{
				if(vis[k])continue;
				pr=mp(a[k].x-dx,a[k].y-dy);
				if(!se.count(pr))anst++;
				se.insert(mp(a[k].x,a[k].y));
			}
			se.clear();//printf("anst:%d ans%d\n",anst,ans);
			if(anst<ans)ans=anst;
			vis[j]=0;
		}
		vis[i]=0;
	}
	printf("%d\n",ans);
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


ll gcd(ll x, ll y){ return y? gcd(y, x%y): x; }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n);
	rep(i, n) cin >>a[i];
	
	VI lf(n+1) , rg(n+1);
	rep(i, n) lf[i+1] = gcd(a[i], lf[i]);
	repr(i, n-1, 0) rg[i] = gcd(a[i], rg[i+1] );
	
	//for(auto x :lf) printf("%d, ",x); puts("");
	//for(auto x :rg) printf("%d, ",x); puts("");
	ll ans = 0;
	rep(i, n) ans = max(ans, gcd(lf[i], rg[i+1]));
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include <string.h>
int main(void)
{
  char S[11];
  int flag=0;
  scanf("%s",S);
  if((strcmp(S,"hi")==0)||(strcmp(S,"hihi")==0)||(strcmp(S,"hihihi")==0)||(strcmp(S,"hihihihi")==0)||(strcmp(S,"hihihihihi")==0))
  {
    flag=1;
  }
  if(flag==0){
    printf("No");
  }
  else{
    printf("Yes");
  }
  return 0;
}

  


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def dist(i, j, X, Y):
    a = j - i
    b = abs(X - i) + 1 + abs(j - Y)
    return min(a, b)


def solve():
    N, X, Y = Scanner.map_int()
    ans = [0 for _ in range(1, N + 1)]
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            d = dist(i, j, X, Y)
            ans[d] += 1

    print(*ans[1:], sep='\n')


def main():
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 5460
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int l[];
		l = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = Integer.parseInt(sc.next());
		}

		int result = 0;
		for (int i = 0; i < n; i++) {

			for (int j = 0; j < n; j++) {

				for (int k = 0; k < n; k++) {

					if (i < j && j < k && l[i] != l[j] && l[j] != l[k] && l[i] != l[k]) {

//						System.out.println((i + 1) + " " + (j + 1) + " "
//								+ (k + 1));

						int x[];
						x = new int[3];
						x[0] = l[i];
						x[1] = l[j];
						x[2] = l[k];
						Arrays.sort(x);
//						System.out.println(x[0] + " " + x[1] + " " + x[2]);

						if (x[0] + x[1] > x[2]) {
							result++;
//							System.out.println("yes");
						} else {
//							System.out.println("no");
						}
					}

				}
			}
		}
		System.out.println(result);

	}
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> C(5, 0);

	for (int i = 0; i < N; ++i)
	{
		string s;
		cin >> s;

		char c = s[0];
		if (c == 'M')
		{
			++C[0];
		}
		else if (c == 'A')
		{
			++C[1];
		}
		else if (c == 'R')
		{
			++C[2];
		}
		else if (c == 'C')
		{
			++C[3];
		}
		else if (c == 'H')
		{
			++C[4];
		}
	}

	int64_t count = 0;
	for (unsigned int i = 0; i < 1 << 5; ++i)
	{
		if (__builtin_popcount(i) != 3)
		{
			continue;
		}

		int64_t count_c = 1;
		for (int j = 0; j < 5; ++j)
		{
			if ((i & (1 << j)) != 0)
			{
				count_c *= C[j];
			}
		}

		count += count_c;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, m;
lli e[51][51];
lli vi[51];

void dfs(lli i) {
  vi[i] = 1;
  for (lli j=1; j<=n; ++j)
    if (e[i][j] == 1 && vi[j] == 0)
      dfs(j);
}

int main() {
  cin >> n >> m;
  fill(&e[0][0], &e[50][50]+1, 0);
  for (lli i=0; i<m; ++i) {
    lli a, b; cin >> a >> b;
    e[a][b] = e[b][a] = 1;
  }
  lli ans = 0;
  for (lli j=1; j<=n; ++j) {
    for (lli i=j+1; i<=n; ++i) {
      if (e[j][i] == 1) {
        e[j][i] = e[i][j] = 0;
        fill(begin(vi), end(vi), 0);
        dfs(i);
        if (vi[j] == 0) ++ans;
        e[j][i] = e[i][j] = 1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,A;cin>>N>>A;
  vector<long>X(N);for(long i=0;i<N;i++)cin>>X[i];
  vector<vector<vector<long>>>DP(N,vector<vector<long>>(N+1,vector<long>(A*N+1,0)));
  //i番目までj枚使って合計をkにするような個数
  DP[0][1][X[0]]=1;
  for(long i=0;i<N;i++)DP[i][0][0]=1;
  
  for(long i=1;i<N;i++)for(long j=1;j<=N;j++)for(long k=1;k<=A*N;k++){
    DP[i][j][k]=(k>=X[i] ? DP[i-1][j-1][k-X[i]]:0)
      +DP[i-1][j][k];
  }  
  long ans=0;
  for(long j=1;j<=N;j++){
    ans+=DP[N-1][j][A*j];
  }
  cout<<ans;
}

Measured memory_bytes: 51200
#include <cmath>
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> dp(10000, numeric_limits<int>::max());
    vector<pair<int, int>> v;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        v.push_back({a, b});
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < n; ++j) {
            dp[i] = min(dp[i], v[j].second +
                                   (i >= v[j].first ? dp[i - v[j].first] : 0));
        }
    }
    cout << dp[h - 1] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

lli n;

int main(void){
	cin >> n;
	vector<lli> a(n), b(n);
	rep(i, n){
		cin >> a[i];
		cin >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	lli ans;
	if(n%2 == 1){
		ans = b[n/2]-a[n/2]+1;
	}else{
		ans = b[n/2-1]+b[n/2]-(a[n/2-1]+a[n/2])+1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6336
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<bool> X;
  X.reserve(N);

  int groupW=0, groupE=0;

  for (int ii=0; ii<N; ++ii) {
    char c;
    cin >> c;
    bool isE = (c=='E');
    X.push_back(isE);
    if (isE)
      ++groupE;
    else
      ;//++groupE;
  }

  //cerr << groupW << ' ' << groupE << endl;

  if (X.front())
    --groupE;//++groupE;
  else
    ;//--groupE;

  //cerr << groupW << ' ' << groupE << endl;

  int min_turn = groupE+groupW;
  
  for (int ii=1; ii<N-1; ++ii) {
    if (X[ii-1])
      ;//++groupW;
    else
      ++groupW;//--groupW;

    if (X[ii])
      --groupE;
    else
      ;
    
    // if (X[ii+1])
    //   --groupE;
    // else
    //   ++groupE;

    //cerr << groupW << ' ' << groupE << endl;

    min_turn = min(min_turn, groupE+groupW);
  }

  if (X.back())
    --groupW;
  else
    ++groupW;
  min_turn = min(min_turn, groupE+groupW);

  cout << min_turn << endl;
  
  return 0;
}


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] L = new long[100];
            L[0] = 2;
            L[1] = 1;
            for (int i = 2; i < 89; i++)
            {
                L[i] = L[i - 1] + L[i - 2];
            }
            Console.WriteLine(L[int.Parse(Console.ReadLine())]);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define change(a,b) do{ll c=a; a=b; b=c;}while(0)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        change(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll A,B;
  ll ans=100000;
  cin>>A>>B;
  rep(i,1001){
    if((i*2)/25==A&&i/10==B)ans=min(ans,i);
  }
  if(ans==100000)cout<<-1<<endl;
  else cout<<ans<<endl;
}

Measured memory_bytes: 256
n,m=gets.chomp.split.map(&:to_i)

ans = 0
1.upto(Math.sqrt(m).to_i) do |i|
    next if(m%i != 0);
    
    if m/n >= i
        ans = i if ans < i
    end

   if m/n >= m/i
        ans = m/i if ans < m/i
    end

end
puts ans

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int c;
  cin >> c;
  if (c >= 30) cout << "Yes";
  else cout << "No";
}



Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
#define fs first
#define sc second
#define mp make_pair
#define L(x) (1<<x)
#define next Next
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=100+10;
const int maxm=1e4+10;
const int mod=1e9+7;
int n;
int main()
{
    //freopen("in.txt","r",stdin);
    //int T;
    //scanf("%d",&T);
    int val[10][maxn];
    int dp[10][maxn];
    while(~scanf("%d",&n))
    {
        cls(val,0);
        cls(dp,0);
        for(int i=1;i<=2;i++)
            for(int j=1;j<=n;j++)
            scanf("%d",&val[i][j]);
        for(int i=1;i<=2;i++)
            for(int j=1;j<=n;j++)
                dp[i][j]=max(dp[i-1][j]+val[i][j],dp[i][j-1]+val[i][j]);
        printf("%d\n",dp[2][n]);
    }
	return 0;
}


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

#define ll long long
#define fr first
#define se second

using namespace std;

const long long N = 2e6 + 7;

ll res, n, m, x, a[N], cnt, q = 1;
string s, str;
set < ll > st;
map < ll, ll > mp;
vector< string > v;
int main()
{
    /// freopen( "input.txt", "r", stdin );
    /// freopen( "output.txt", "w", stdout );
	cin >> n;
	for ( int i=0; i<n; i++ ) {
		cin >> a[i];
		cnt += mp[ i - a[i] ];
		mp[ a[i] + i ]++;
	}
	cout << cnt;
}


Measured memory_bytes: 27904
#include <stdio.h>
 
int main(){
  int rank1,rank2;
  int get=0;
  scanf("%d %d",&rank1,&rank2);
  switch(rank1) {
    case 1:
        get=get+300000;
        break;
    case 2:
        get=get+200000;
        break;
    case 3:
      	get=get+100000;
    default:
        get=get+0;
	}
  switch(rank2) {
    case 1:
        get=get+300000;
        break;
    case 2:
        get=get+200000;
        break;
    case 3:
      	get=get+100000;
    default:
        get=get+0;
	}
  if(get==600000){
    get=1000000;
  }
  printf("%d",get);
  return 0;
}

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

using namespace std;

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

  int count = 0;
  for(int i = 0; i < s.length(); i++) {
    if(s[i] == '+') {
      count++;
    }
    else {
      count--;
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1LL << 60;

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> B(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B.begin(), B.end());
    
    int Med = N / 2;
    long long MedD = B[Med - 1];
    long long MedU = B[Med];
    
    for(int i = 0; i < N; i++){
        if(A[i] <= MedD)cout << MedU << endl;
        else cout << MedD << endl;
    }
}

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//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();}


int main(){
  ll n;
  cin >> n;
  VVLL dp(n,VLL(3,0));
  rep(i,n){
    ll a,b,c;
    cin >> a >> b >> c;
    if(i == 0){
      dp[0][0] = a;
      dp[0][1] = b;
      dp[0][2] = c;
    }else{
      dp[i][0] = a + max(dp[i-1][1],dp[i-1][2]);
      dp[i][1] = b + max(dp[i-1][0],dp[i-1][2]);
      dp[i][2] = c + max(dp[i-1][0],dp[i-1][1]);
    }
  }
  ll ans = 0;
  rep(i,3) ans = max(ans,dp[n-1][i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5760
//be naame khodaa
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define F first
#define S second
#define pb push_back
#define sz(x) ((int)(x).size())

inline int in(){ int x, y; y = scanf("%d", &x); return x; }

const int N = 2000*100 + 100;
const int mod = 1e9 + 7;

int sum(int a, int b) { 
    int c = (a+b); 
    if( c >= mod ) c -= mod; 
    return c;
}

int mul(int a, int b) { 
    return 1ll*a*b % mod; 
}

int dp[N];
int sump[N]; 

int a[N]; 

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

    int n;
    cin >> n;

    for(int i = 0; i < n; i++)
        cin >> a[i]; 
    n = unique(a, a + n) - a;

    dp[0] = 1; 
    for(int i = 0; i < n; i++) { 
        dp[i+1] = sum(dp[i], sump[a[i]]);
        sump[a[i]] = sum(sump[a[i]], dp[i]);
    }
    cout << dp[n] << endl;
}


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

int main(){
  int n;
  int a,b;
  cin >> n >> a >> b;
  int c;
  if(a > b){
    cout << b << '\n';
  }else{
    cout << a << '\n';
  }
  c = a + b;
  if(n < c){
    cout << c - n;
  }else{
    cout << 0;
  }
  return 0;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
c,i=0,0
while(i<n and x>0):
  if a[i]<=x:
    x-=a[i]
    c+=1
  else:
    break
  if i==n-1 and x!=0:
    c-=1
  i+=1
print(c)

Measured memory_bytes: 3060
#include<stdio.h>
#define N 36

typedef struct{
  int num;
  int val;
  char pic;
} CARD;

typedef struct{
  CARD c[36];
} DECK;

void Bsort(DECK,int);
void Ssort(DECK,int);
int Stable(DECK,int);

int main(){
  DECK d;
  int n,i;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf(" %c", &(d.c[i].pic) );
    scanf("%d", &(d.c[i].val) );
    d.c[i].num=i;
  }

  Bsort(d,n);
  Ssort(d,n);

  return 0;
}
void Bsort(DECK d,int n){
  int i,j,f=1,c=0;
  CARD swap;

   while(f!=0){
    f=0;
    
    for(i=n-1;i>=c+1;i--){      
      if(d.c[i].val<d.c[i-1].val){	
	swap=d.c[i-1];
	d.c[i-1]=d.c[i];
	d.c[i]=swap;
	f=1;
      }
    }
    
    c++;
  }
  
  for(i=0;i<n;i++){
    printf("%c%d",d.c[i].pic,d.c[i].val);
    if(i!=n-1) printf(" ");
  }
  printf("\n");

  if( Stable(d,n)==1 ) printf("Not stable\n");
  else printf("Stable\n");
	 }

void Ssort(DECK d,int n){
  int i,j,min;
  CARD swap;
    
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){      
      if(d.c[j].val<d.c[min].val){
	min=j;	
      }      
    }
          
    if(min!=i){
      swap=d.c[i];
      d.c[i]=d.c[min];
      d.c[min]=swap;  
    }
    
  }

  for(i=0;i<n;i++){
    printf("%c%d",d.c[i].pic,d.c[i].val);
    if(i!=n-1) printf(" ");
  }
  printf("\n");

  if( Stable(d,n)==1 ) printf("Not stable\n");
  else printf("Stable\n");
	 }

int Stable(DECK d,int n){
  int i,j;
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(d.c[i].val==d.c[j].val && d.c[i].num>d.c[j].num) return 1;
    }
  }
  return 0;
}
	  

    



Measured memory_bytes: 2068
S = input()
S = [s for s in S]

out = [0] * len(S)

if S[0] == 'R':
    top_R = True
    top_L = False
else:
    top_R = False
    top_L = True

for i, n in enumerate(S):
    if n == 'R':
        if top_R:
            found = False
            cnt = 1
            while not found:
                if S[i + cnt] == 'L':
                    found = True
                else:
                    cnt += 1
            top_R = False
        else:
            cnt -= 1

        if cnt % 2 == 0:
            out[i + cnt] += 1
        else:
            out[i + cnt - 1] += 1

        if cnt != 1:
            top_R = False
        else:
            top_L = True
    else:
        if top_L:
            found = False
            cnt = 1
            while not found:
                if S[i - cnt] == 'R':
                    found = True
                else:
                    cnt += 1
            top_L = False
        else:
            cnt += 1

        if cnt % 2 == 0:
            out[i - cnt] += 1
        else:
            out[i - cnt + 1] += 1

        if cnt != 1:
            top_L = False
        else:
            top_R = True

out1 = [str(n) for n in out]
print(' '.join(out1))


Measured memory_bytes: 11548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using int64 = long long;
string _D;

//[i][two][three][five][seven][less][sum]
//[i][less][greater][sum][flag]
map<int64, int64> dp[15][2][2][140];

map<int, int> factorize(int x) {
	map<int, int> res;
	for (int y = 2; y * y <= x; y++) {
		while (x % y == 0) {
			x /= y;
			res[y]++;
		}
	}
	if (x > 1)
		res[x]++;
	return res;
}

int main() {
	cin >> _D;
	vector<int> D;
	for (char d : _D)
		D.push_back(d - '0');
	int64 dsum = 0;
	int64 dprod = 1;

	for (int d : D) {
		dsum += d;
		dprod *= d + 1;
	}

	dp[0][0][0][0][1] = 1;
	for (int i = 0; i < D.size(); i++) {
		for (int less = 0; less <= 1; less++) {
			for (int gr = 0; gr <= 1; gr++) {
				for (int sum = 0; sum <= i * 9; sum++) {
					for (auto p : dp[i][less][gr][sum]) {
						for (int d = 0; d < 10; d++) {
							int nsum = sum + d;
							int64 nprod = p.first * (d + 1);
							int nless = less | (!gr & (d < D[i]));
							int ngr = gr | (!less & (d > D[i]));

							if (nsum > dsum)
								continue;
							if (nsum == dsum and nprod > dprod)
								continue;
							if (nsum == dsum and nprod == dprod and ngr)
								continue;

							dp[i + 1][nless][ngr][nsum][nprod] += p.second;
						}
					}
				}
			}
		}
	}

	int64 ans = 0;
	for (int less = 0; less <= 1; less++) {
		for (int gr = 0; gr <= 1; gr++) {
			for (int sum = 0; sum <= dsum; sum++) {
				for (auto p : dp[D.size()][less][gr][sum]) {
					if (sum < dsum) {
						ans += p.second;
					} else if (p.first < dprod) {
						ans += p.second;
					} else if (less) {
						ans += p.second;
					}

					/*
					 if (nsum > dsum)
					 continue;
					 if (nsum == dsum and nprod > dprod)
					 continue;
					 if (nsum == dsum and nprod == dprod and ngr)
					 continue;
					 */
				}
			}
		}
	}
	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 55660
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N = int(input())
    for i in range(int(N**0.5)+1,0,-1):
        if N % i == 0 :
            print(i+N//i-2)
            return

if __name__ == '__main__':
    main()

Measured memory_bytes: 38896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, p;
int w[100];

int main(){
	while (cin >> n >> p&&n + p){
		fill(w, w + 100, 0);
		int co = 0;
		int wan = 0;
		while (1){
			if (wan == p){
				wan -= w[co];
				w[co] = 0;
				co++;
				if (co == n)co = 0;
				continue;
			}
			w[co]++;
			if (w[co] == p)break;
			co++;
			wan++;
			if (co == n)co = 0;
		}
		cout << co << endl;
	}
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

int h, w;
vector<vector<vvi>> used;
vs rooml, roomr;
pii ls, lg, rs, rg;
vi dx = {0, 1, 0, -1}, dy = {1, 0, -1, 0};

bool isin(pii a){
  return 0 <= a.fst and a.fst < h and 0 <= a.snd and a.snd < w;
}

int bfs(pii lp, pii rp){ // sを根としてbfs
  queue<pair<pii,pii>> q;
  used[lp.fst][lp.snd][rp.fst][rp.snd] = 1;
  q.push(make_pair(lp,rp));
  
  while(!q.empty()){
    pair<pii,pii> now = q.front();
    q.pop();
    
    rep(i, 4){
      pair<pii,pii> next = now;
      next.fst.fst += dx[i];
      //dump(next.fst.fst);
      if(dx[i] != 0 and (next.fst.fst < 0 or h <= next.fst.fst or rooml[next.fst.fst][next.fst.snd] == '#')){ // 移動できない
	next.fst.fst -= dx[i];
      }
      next.fst.snd += dy[i];
      //dump(next.fst.snd);
      if(dy[i] != 0 and (next.fst.snd < 0 or w <= next.fst.snd or rooml[next.fst.fst][next.fst.snd] == '#')){ // 移動できない
	next.fst.snd -= dy[i];
      }
      next.snd.fst += dx[i];
      //dump(next.snd.fst);
      if(dx[i] != 0 and (next.snd.fst < 0 or h <= next.snd.fst or roomr[next.snd.fst][next.snd.snd] == '#')){ // 移動できない
	next.snd.fst -= dx[i];
      }
      next.snd.snd += dy[i];
      //dump(next.snd.snd);
      if(dy[i] != 0 and (next.snd.snd < 0 or w <= next.snd.snd or roomr[next.snd.fst][next.snd.snd] == '#')){ // 移動できない
	next.snd.snd -= dy[i];
      }
      if(next == now) continue;
      if(next.fst == lg and next.snd == rg) return 1;
      if(used[next.fst.fst][next.fst.snd][next.snd.fst][next.snd.snd] == 0 and next.fst != lg and next.snd != rg){
	used[next.fst.fst][next.fst.snd][next.snd.fst][next.snd.snd] = 1;
	q.push(next);
      }
    }
  }
  return 0;
}

signed main(){
  while(cin >> w >> h, w){
    used.clear();
    used.resize(h,vector<vvi>(w, vvi(h, vi(w))));
    rooml.resize(h), roomr.resize(h);
    rep(i,h){
      cin >> rooml[i] >> roomr[i];
      reverse(all(roomr[i])); // 同じ向きに動く
    }
    //dump(rooml, roomr);
    rep(i,h) rep(j,w){
      if(rooml[i][j] == 'L') ls = pii(i,j);
      if(rooml[i][j] == '%') lg = pii(i,j);
      if(roomr[i][j] == 'R') rs = pii(i,j);
      if(roomr[i][j] == '%') rg = pii(i,j);
    }
    //dump(ls,lg,rs,rg);
    if(bfs(ls, rs)) cout << "Yes\n";
    else cout << "No\n";
  }
}



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

int main(){
    int N; cin >> N;
    long long arr[N+1];
    for(int i=0; i<N+1; ++i) arr[i]=0;
    for(int i=0; i<N; ++i){
        long long a; cin >> a;
        arr[i+1] = arr[i]+a;
    }
    long long ans=10000000000;
    for(int i=1; i<N; ++i){
        ans = min(ans, abs(arr[N]-2*arr[i]));
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
	string s;
	cin >> s;
	bool ch = false;
	for(int i = 0; i < (int)s.size()-1; i++){
		for(int j = i; j < (int)s.size(); j++){
			string t = s;
			t.erase(t.begin()+i, t.begin()+j);
			if(t == "keyence")ch = true;
		}
	}
	if(ch)cout << "YES" << endl;
	else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=105;
const int INF=0x3f3f3f3f;
bool vis[MAXN];
int a[MAXN][MAXN], dp[MAXN][MAXN];
queue<int> Q;
void spfa(int s,int n){
    memset(vis,0,sizeof vis);
    while(!Q.empty()) Q.pop();
    Q.push(s);
    dp[1][0]=0;
    vis[s]=true;
    while(!Q.empty()){
        int u=Q.front(); Q.pop();
        vis[u]=false;
        for(int i=1; i<=n; i++){
            if(a[u][i]!=-1){
                for(int j=0; j<=n; j++){
                    if(dp[u][j]+a[u][i]<dp[i][j]){
                        dp[i][j]=dp[u][j]+a[u][i];
                        if(!vis[i]){
                            Q.push(i); vis[i]=true;
                        }
                    }
                    if(j&&dp[i][j]>dp[u][j-1]){
                        dp[i][j]=dp[u][j-1];
                        if(!vis[i]){
                            Q.push(i); vis[i]=true;
                        }
                    }
                }
            }
        }
    }
}
int main(){
    int n, m, c, x, y, w;
    while(cin>>n>>m>>c&&n){
        memset(a,-1,sizeof a);
        memset(dp,0x3f,sizeof dp);
        for(int i=0; i<m; i++){
            cin>>x>>y>>w;
            a[x][y]=w;
        }
        spfa(1,n);
        for(int i=0; i<=n; i++){
            if(dp[n][i]<=c){
                printf("%d\n",i);
                goto next;
            }
        }
        next:;
    }
    return 0;
}

Measured memory_bytes: 1276
defmodule Main do
  def main do
    IO.gets("")
    |> String.trim()
    |> String.split()
    |> Enum.map(&String.to_integer/1)
    |> process()
    |> IO.puts()
  end
  
  defp process([a, b]) when a == b, do: "Draw"
  defp process([a, _]) when a == 1, do: "Alice"
  defp process([_, b]) when b == 1, do: "Bob"
  defp process([a, b]) do
    case a > b do
      true -> "Alice"
      false -> "Bob"
    end
  end
end

Measured memory_bytes: 30648
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N; cin >> N;
  int K; cin >> K;
  vector<int> H(N);
  for(auto& h : H) cin >> h;
  boost::sort(H);

  auto it = boost::lower_bound(H, K);
  auto dame = std::distance(H.begin(), it);
  cout << (N - dame) << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    int x,a;
    cin>>x>>a;
    if(x<a)cout << 0 << endl;
    else cout << 10 << endl;
}

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

int main()
{
  int n;
  int t,a;
  int ans;
  cin >> n;
  vector<int> x(n,0);
  pair<double,int>temp[n];
  
  cin >> t >> a;
  for(int i=0;i < n;i++){
    cin >> x[i];
    temp[i].first = abs((t-x[i]*0.006) - a);
    temp[i].second = i+1;
  }

  sort(temp, temp + n);

  cout << temp[0].second << endl;

  /*
  int mini=99999999;
  for(int i=0;i < n;i++){
    if( abs(temp[i].first-a) >= 0 ){
      mini = min(abs(temp[i].first-a),mini);
      if(mini == abs(temp[i].first-a)){
	ans = temp[i].second;
      }
    }
  }
  cout << ans << endl;
  */
  return 0;
}

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

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3, y3, x4, y4;
  x3 = x2 - y2 + y1;
  y3 = y2 + x2 - x1;
  x4 = x1 - y2 + y1;
  y4 = y1 + x2 - x1;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


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

using namespace std;

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

	if (s.size() <= k) { cout << s << endl; }
	else { cout << s.substr(0, k) + "...\n"; }

	return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main(void)
{
	int s[3];
	int i,j,temp;
	scanf("%d%d%d",&s[0],&s[1],&s[2]);
	for(i=1;i>=0;i--)
		{
		for(j=0;j<=i;j++)
			{
			if(s[j]<s[j+1])
				{
				temp=s[j];
				s[j]=s[j+1];
				s[j+1]=temp;
				}
			}
		}
	printf("%d",10*s[0]+s[1]+s[2]);
return 0;
}




Measured memory_bytes: 128
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
const int MOD = 998244353;
// const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	int h,w;
	cin >> h >> w;

	if(h == 1 || w == 1){
		cout << 1 << endl;
		return 0;
	}

	cout << h*w - h*w/2 << endl;
	


	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://panasonic2020.contest.atcoder.jp/tasks/panasonic2020_b

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

int main(){
  int N,X;
  cin >> N >> X;
  
  vector<int> L(N);
  
  rep(i,N) cin >> L[i];
  
  int ans = 1;
  int len = 0;
  rep(i,N){
    len += L[i];
    if(len > X) break;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
#define M 1001
#define MAX 10000

int n,A[M],s;
int B[M],T[MAX+1];
bool V[M];

int solve(){
	int ans = 0;
	int i;
	for( i=0 ; i < n; i++ ){
		B[i]=A[i];
	}
	sort(B,B+n);
	for( i = 0; i < n; i++ ) T[B[i]]=i;
	for( i = 0; i < n; i++ ){
		if(V[i]) continue;
		int cur = i;
		int S = 0;
		int m = MAX;
		int an = 0;
		while(!V[cur]){
			V[cur] = true;
			an++;
			int v = A[cur];
			m = min(m,v);
			S += v;
			cur = T[v];
		}
		ans += min(S+(an-2)*m,S+m+(an+1)*s);
	}
	return ans;
}

int main(){
	scanf("%d",&n);
	s = MAX;
	for(int i = 0; i < n; i++){
		scanf("%d",&A[i]);
		s = min(s,A[i]);
	}
	printf("%d\n",solve());
}


Measured memory_bytes: 3312
#include <iostream>
using namespace std;
int main()
{
    int A, B;
    std::cin >> A >> B;
    if ((A + B) % 3 == 0 || A % 3 == 0 || B % 3 == 0)
    {
        cout << "Possible" << endl;
    }
    else
    {
        cout << "Impossible" << endl;
    }
}


Measured memory_bytes: 256
/* #pragma GCC optimize("O3") */
/* #pragma GCC target ("avx2") */
/* #pragma GCC optimize("Ofast") */
/* #pragma GCC optimize("unroll-loops") */
/* #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T, typename cmp=less<T>>
using ordered_set=tree<T,null_type,cmp,rb_tree_tag,tree_order_statistics_node_update>;
template<typename K, typename V, typename cmp=less<K>>
using ordered_map=tree<K, V, cmp, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
using ll = long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax = 1000*1007;
#define ar array
#define len(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define tT template<typename T
#define tV typename V
#define ins inline string
#ifdef LOCAL
tT>ins to_string(T& t);
ins to_string(string s) {return '"' + s + '"';}
ins to_string(char c){string res="'";res.push_back(c);return res+"'";}
ins to_string(const char* s) {return to_string((string)s);}
ins to_string(char* s) {return to_string((string)s);}
template <size_t N>ins to_string(bitset<N> v) {string res="";for(size_t i = 0; i < N; i++){
res += static_cast<char>('0' + v[i]);}return res;}
ins to_string(bool b) {return (b ? "true" : "false");}
tT,tV>ins to_string(pair<T, V>& p){return "("+ to_string(p.first)+", "+to_string(p.second)+")";}
tT>ins to_string(T& v){string res="{";for(auto& i:v){res+=to_string(i)+',';} return res+'}';}
#define log(...) cerr<< "[" << #__VA_ARGS__ << " : "<< to_string(__VA_ARGS__) << "]"<<endl
#else
#define log(...) 0x30
#endif

vector<int> h;
int dp[100001];

/* int solve(int n, int k){ */
/*     if(n==1) return 0; */
/*     if(n==2) return abs(h[1]-h[0]); */
/*     if(dp[n] != -1) return dp[n]; */
/*     dp[n] = INT_MAX; */
/*     for(int i=1; i<=k; i++){ */
/*         dp[n] = min(dp[n], abs(h[n-1]-h[n-i-1])+solve(n-i, k)); */
/*     } */
/*     return dp[n]; */
/* } */

int solve(int n, int k){
    dp[1] = 0;
    dp[2] = abs(h[1]-h[0]);
    for(int i=3; i<=n; i++){
        dp[i] = abs(h[i-1]-h[i-2])+dp[i-1];
        for(int j=2; j<=k; j++){
            if(i-j >= 1) dp[i] = min(dp[i], abs(h[i-1]-h[i-j-1]) + dp[i-j]);
        }
    }
    return dp[n];
}


inline void test_case(){
    memset(dp, 0, sizeof dp);
    int n,k;
    cin>>n>>k;
    h.resize(n);
    for(int& i : h) cin>>i;
    cout<<solve(n, k)<<"\n";
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    tt = 1;
    for(int qq=1; qq<=tt; qq++){
        /* cout<<"Case #"<<qq<<": "; */
        test_case();
    }
}   



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const double PI=acos(-1.0);

int main()
{   
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        if(sqrt(x*x+y*y) <= d) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3688