akhauriyash/Code-Regression huggingface dataset:
//============================================================================
// Name        : template.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
#include <string.h> // for memset in CF judge.
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n; cin >> n;
	string ans;
	while (n > 0) {
		n -= 1;
		ll r = n % 26;
		ans.pb('a' + r);
		n /= 26;

	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3656
import math
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(a+1):
    for j in range(b+1):
        tmp = (x-500*i-100*j)/50
        if tmp <= c and tmp >= 0 and tmp - math.floor(tmp) == 0 :
            count += 1

print(count)

Measured memory_bytes: 3064
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    long n = Long.parseLong(br.readLine());
    long temp = Long.MAX_VALUE;
    for (int i=1; i<Math.sqrt(n)+10; i++){
      if (n%i == 0 && i+n/i-2 < temp) temp = i+n/i-2;
    }
    
    System.out.println(temp);
  }
}


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

namespace E
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var MOD = 1000000007;
            var searchPrime = 1000;

            var isPrime = new bool[searchPrime + 1];
            for (int i = 2; i < searchPrime + 1; i++) isPrime[i] = true;
            for (int i = 2; i < searchPrime + 1; i++)
            {
                if (isPrime[i])
                {
                    for (int j = i + 1; j < searchPrime + 1; j++)
                    {
                        if ((j % i) == 0) isPrime[j] = false;
                    }
                }
            }

            var primeFactor = new Dictionary<int, int>();
            for (int i = 0; i < searchPrime; i++)
            {
                if (isPrime[i]) primeFactor.Add(i, 0);
            }

            var primes = primeFactor.Keys.ToArray();
            foreach (int ai in A)
            {
                var temp = ai;
                foreach (int prime in primes)
                {
                    if (temp == 1) break;
                    var count = 0;
                    while ((temp % prime) == 0)
                    {
                        temp /= prime;
                        count++;
                    }
                    if (primeFactor[prime] < count) primeFactor[prime] = count;
                }
                if(!primeFactor.ContainsKey(temp))primeFactor.Add(temp, 1);
            }

            var lcd = 1L;
            foreach (int prime in primeFactor.Keys)
            {
                for (int i = 0; i < primeFactor[prime]; i++)
                {
                    lcd *= prime;
                    lcd %= MOD;
                }
            }

            var result = 0L;
            foreach (int ai in A)
            {
                result += (lcd * modinv(ai, MOD)) % MOD;
                result %= MOD;
            }
            Console.WriteLine(result);
        }
        static long modinv(long a, long mod)
        {
            long b = mod;
            long u = 1;
            long v = 0;
            while (b != 0)
            {
                long t = a / b;
                a -= t * b;
                var temp1 = a;
                a = b;
                b = temp1;
                u -= t * v;
                var temp2 = u;
                u = v;
                v = temp2;
            }
            u %= mod;
            if (u < 0) u += mod;
            return u;
        }
    }
}


Measured memory_bytes: 12512
#include <stdio.h>


int main()
{
	int sum;
	int nedan;
	int i;
	while(1){
		scanf("%d", &sum);
		if(sum==0){
			break;
		}
		for(i=0; i<9; i++){
			scanf("%d", &nedan);
			sum-=nedan;
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


string s;
int K;

ll memo[110][2][4];
ll dfs(int i = 0, bool smaller = false, int k = K){
    if(k == 0) return 1;
    if (i >= sz(s)) return 0;

    ll ans = 0;
    if(memo[i][(int)smaller][k]){
        return memo[i][(int)smaller][k];
    }
    if(smaller){
        ans += dfs(i + 1, true, k); //次の桁が0の時
        ans += dfs(i + 1, true, k - 1) * 9LL; //次の桁が0以外の時
    } else {
        if(s[i] == '0'){ //次の桁が0しかありえない時
            ans += dfs(i + 1, false, k);
        } else {
            ans += dfs(i + 1, true, k);                     // 次の桁が0の時
            ans += dfs(i + 1, true, k - 1) * (s[i] - '1');  // 次の桁が0でもN[i]でも無い時
            ans += dfs(i + 1, false, k - 1);                // 次の桁がN[i]の時
        }
    }
    return memo[i][(int)smaller][k] = ans;
}
int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cin >> s >> K;
    print(dfs());
    



}




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

const int N = 1e5 + 10;
int n, cnt1, cnt2, cnt4, a[N];

template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

inline void work() {
	in(n);
	for (int i = 1; i <= n; ++i) {
		in(a[i]);
		if (a[i] & 1) ++cnt1;
		else if (a[i] % 4 == 0) ++cnt4;
		else if (a[i] % 2 == 0) ++cnt2;
	}
	if (cnt2) {
		if (cnt1 > cnt4) puts("No");
		else puts("Yes");
	} else if (cnt1 > cnt4 + 1) puts("No");
	else puts("Yes");
}

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

Measured memory_bytes: 512
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        
        if(a*c<=b){
            System.out.println(c);
        }
        else{
            System.out.println(b/a);
        }
        sc.close();
    }
}

Measured memory_bytes: 21204
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//↑templete
bool func(double A, double B){
	double EPS=1e-9;
	if(abs(A-B)<EPS)
		return 1;
	return 0;
}
signed main(){
	
	double A, B;
	cin>>A>>B;

	for(int i=0;i<=100000;i++){
		if(func(floor(i*0.08), A) && func(floor(i*0.1), B)){
			cout<<i<<endl;
			return 0;
		}
	}

	cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();

        int[][]a=new int[N][2];
        for(int i=0;i<N;i++) {
        	a[i][0]=sc.nextInt();
        	a[i][1]=sc.nextInt();
        }
        
 //       Arrays.sort(a);
        Arrays.sort(a, (b, c) -> Integer.compare(b[0], c[0]));
        int[][] dp=new int[6005][N+1];
        int[] max=new int[6005];
        for(int i=0;i<6005;i++) {
        	for(int j=0;j<N;j++) {
        		if(i<a[j][0]) {
        			dp[i][j+1]=dp[i][j];
        		} else {
        			if(dp[i-a[j][0]][j]+a[j][1]>=dp[i][j]) {
        				dp[i][j+1]=dp[i-a[j][0]][j]+a[j][1];
        				max[i]=a[j][0];
        			} else {
        				dp[i][j+1]=dp[i][j];
        			}
        		}
        	}
        }
        
        long ans=0;
        for(int i=1;i<N+1;i++) {
    		ans=Math.max(ans,dp[T-1][i-1]+a[i-1][1]);
        }
        System.out.println(ans);        	
                		
    }

}

Measured memory_bytes: 125188
import math
from decimal import *

N = int(input())
_input = []
for i in range(N):
    _input.append(list(map(int,input().split())))

total_T = 1
total_A = 1

for t,a in _input:
    #n = max(math.ceil(total_T/t),math.ceil(total_A/a))
    n = max(-(-total_T//t), -(-total_A//a))
    total_T = int(t*n)
    total_A = int(a*n)

print(total_A+total_T)


Measured memory_bytes: 5076
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

int path[8][8] = {0};

int f(int arr[], int n){
  int start, end;
  start = 0;
  rep(i, n){
    end = arr[i];
    if(!path[start][end]) return 0;
    start = end;
  }
  return 1;
}

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

  rep(i, M){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    path[a][b] = 1;
    path[b][a] = 1;
  }
  int arr[8] = {0};
  rep(i, 1, N){
    arr[i - 1] = i;
  }

  int ans = 0;
  do{
    ans += f(arr, N - 1);
  }while(next_permutation(arr, arr + N - 1));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 44

int F[N];

int fibonacci(int n){
  
  if(n == 0 || n == 1){
    return F[n] = 1;
  }
  if(F[n] != 0){
    return F[n];
  }
  return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
}

int main(){

  int a, n;

  scanf("%d", &n);
  
  a = fibonacci(n);

  printf("%d\n", a);  

  return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

vector<int> dx{-1,0,1};
vector<int> dy{-1,0,1};

int main() {
    int H,W; cin >> H >> W;
    vector<vector<char>> G(H+2, vector<char>(W+2,'.'));
    REP(i,H){
        string S; cin >> S;
        REP(j,W){
            G[i+1][j+1] = S[j];
        }
    }
    FOR(i,1,H+1){
        FOR(j,1,W+1){
            int cnt = 0;
            if(G[i][j]=='#'){
                cout << '#';
            }else{
                for(int x: dx){
                    for(int y: dy){
                        if(x==0&&y==0) continue;
                        if(G[i+x][j+y] == '#') cnt++;
                    }
                }
                cout << cnt;
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

print(max(A)-min(A))


Measured memory_bytes: 3888
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){ 
long long int a;
 long long int b;
  int c;
    cin>>a>>b>>c;
  int d=a;
  rep(i,1000){
    d=(i+1)*a;
    if(d%b==c){
      cout<<"YES";
      return 0;
    }
  }
  cout<<"NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
ll N, K, T, W, H, M, C;
 
const int MAX = 5100000;
const int MOD = 1e9 + 7;
 
const double PI=3.14159265358979323846;
 
 
long long fac[MAX], finv[MAX], inv[MAX];
 
vector<double> cx, cy, c;
 ll MM = 1e12;
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}
 
ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b == 0) return a;
    if(a%b == 0) return b;
    else return gcd(b, a%b);
}
 
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
 
 
 
int main(){
    cin >> N;
    ll R = 0,G=0,B=0;
    string str;
     cin >> str;
     REP(i,N){
         if(str[i] == 'R') ++R;
         if(str[i] == 'B') ++B;
         if(str[i] == 'G') ++G;
     }
     //cout << R << " " << B <<  " " << G;
     ll ansu = R*(R-1)*(B+G)/2 + B*(B-1) * (R + G)/2 + G*(G-1) * (R+B)/2;
     ansu += R * (R-1)*(R-2)/6 + B * (B-1) * (B-2)/6 + G * (G-1) * (G-2)/6;
     for(int i = 0; i < N; ++i){
         for(int l = 1; l < N; ++l){
            if(i + 2*l >= N) continue;
            ++ansu;
            if(str[i] == str[i + l] or str[i] == str[i + 2*l] or str[i + l] == str[i + 2*l]) --ansu;
         }
     }
     cout << N * (N-1) * (N-2)/6 - ansu;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
 
signed main(){
 
	lli h,w;
	cin>>h>>w;
 
	char c;
	lli data[26]={0};
	priority_queue<lli> q;
	REP(i,0,h*w){
		cin>>c;
		data[c-'a']++;
	}
	REP(i,0,26) q.push(data[i]);
 
	priority_queue<lli> left;
 
	for(lli i=0;i<(h+1)/2;i++){
		for(lli j=0;j<(w+1)/2;j++){
			lli num=4;
			if(i==(h+1)/2-1 && h%2==1)num /= 2;
			if(j==(w+1)/2-1 && w%2==1)num /= 2;
			left.push(num);
		}
	}
 
	while(left.size()){
		lli leftNow = left.top();
		left.pop();
 
		lli dataNow = q.top();
		q.pop();
		if(leftNow>dataNow){
			/*途中で使いきれなくなったらアウト*/
			cout<<"No"<<endl;
			return 0;
		}
		dataNow -= leftNow;
		q.push(dataNow);
	}
 
	/*最後まで割り当てられればOK*/
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = 0
tmp = -1
for a in A:
    ans += B[a-1]
    if a-tmp == 1:
        ans += C[tmp-1]
    tmp = a
print(ans)


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    ll x;
    cin >> x;
    ll a = x / 500;
    ll remain = x - 500 * a;
    ll b = remain / 5;
    cout << a * 1000 + b * 5 << endl;
}


Measured memory_bytes: 256
/* ex 7_1
  bonbonc */

#include<stdio.h>
#include<string.h>

typedef struct point{
    int x_elem;
    int y_elem;
}point;

int main(void){
    point pt1,pt2,pt3,pt4;//四点の構造体を定義
    int x_diff,y_diff;//pt2とpt1の差の成分を格納する変数
    scanf("%d %d %d %d",&pt1.x_elem,&pt1.y_elem,&pt2.x_elem,&pt2.y_elem);//入力を受け取る
    
    x_diff=pt2.x_elem-pt1.x_elem;//pt2とpt1のx成分の差分
    y_diff=pt2.y_elem-pt1.y_elem;//pt2とpt1のy成分の差分
    
    //pt3の座標=pt2の座標+pt2とpt1の差分のベクトルを90度回転させたもの
    pt3.x_elem=pt2.x_elem-y_diff;
    pt3.y_elem=pt2.y_elem+x_diff;

    //pt4の座標=pt3の座標-pt2とpt1の差分
    pt4.x_elem=pt3.x_elem-x_diff;
    pt4.y_elem=pt3.y_elem-y_diff;

    printf("%d %d %d %d\n", pt3.x_elem,pt3.y_elem,pt4.x_elem,pt4.y_elem);//それぞれの値を出力
    return 0;
}

Measured memory_bytes: 1696
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int main(){
    int n;
    cin >> n;
    ll a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        a[i] = a[i]-i-1;
    }
    sort(a,a+n);
    ll value=a[n/2];
    ll ans=0;
    for(int i=0; i<n; i++){
        ans += abs(a[i]-value);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        int ans=0;
        int p[]=new int[1000001];
        int a[]=new int[N];
        for(int i=0; i<N; i++){
            a[i]=sc.nextInt();
        }
        Arrays.sort(a);
        for(int i=0; i<N; i++){
            if(p[a[i]]<2){
                for(int j=1; a[i]*j<a[N-1]+1; j++){
                    p[a[i]*j]++;
                }
            }
        }
        for(int i=0; i<N; i++){
            if(p[a[i]]<2){
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 65764
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}


int main(){
    string s;
    cin >> s;
    REP(i,s.size()){
        cout << "x";
    }
    cout << endl;
}

Measured memory_bytes: 256
from itertools import permutations

n = int(input())
t = [list(map(int, input().split())) for _ in range(n)]

perms = permutations(list(range(n)))
ans = 0
length = 0
for perm in perms:
    length += 1
    cur_i = 0
    tmp = 0
    for i in range(1, n):
        x = t[perm[cur_i]][0] - t[perm[i]][0]
        x = x**2
        y = t[perm[cur_i]][1] - t[perm[i]][1]
        y = y**2
        tmp += (x + y)**0.5
        cur_i = i
    ans += tmp
print(ans / length)


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

map<long long, long long> s;

int main() {
    int n; cin >> n;
	long long a[n], sum = 0;
	s[0] = 1;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
		s[sum]++;
	}
	long long res = 0;
	for (auto p : s)
	{
		res += p.second * (p.second-1) / 2;
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,h;
  int m=0;
  cin>>n>>k;
  for(int i=0; i<n; i++){
    cin>>h;
    if(h>=k){
      m++;}
  }
  cout<<m<<endl;
  return 0;
}
    

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String ans = "No";
    for(int i = 0; i*4 <= N; i++){
      int m = N-i*4;
      if(m%7==0){
        ans = "Yes";
        break;
      }
    }   
    System.out.println(ans);
  }
}

Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define numarr 22
using namespace std;

int main() {
	int R, G, B, N, ans = 0;
	cin >> R >> G >> B >> N;
	for (int r = 0; r <= N / R; r++)
	{
		for (int g = 0; g <= N / G; g++)
		{
			if ((N - r * R - g * G) >= 0 && (N - r * R - g * G) % B == 0)
			{
				ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())),reverse = True)
q = sorted(list(map(int, input().split())),reverse = True)
r = sorted(list(map(int, input().split())),reverse = True)

px = p[:x]
qx = q[:y]

aps = sorted(px + qx + r, reverse=True)

print(sum(aps[0:x+y]))



Measured memory_bytes: 23584
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vec vector

typedef long long ll;

const ll inf = 1LL << 60;
const int mod = 1e9 + 7;

using namespace std;

/* Input variables. */
string s;

/* Solve! */
void solve() {
  int n = s.length();
  int d1 = 0, d2 = 0;
  irep(i, 1, n + 1) {
    if ((i % 2 == 0 && s[i - 1] != '0') || (i % 2 == 1 && s[i - 1] != '1')) d1++;
  }
  irep(i, 1, n + 1) {
    if ((i % 2 == 1 && s[i - 1] != '0') || (i % 2 == 0 && s[i - 1] != '1')) d2++;
  }
  cout << min(d1, d2) << endl;
}

int main() {
  /* Input handling. */
  cin >> s;

  solve();
  return 0;
}

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

int main()
{
	int count;
	cin >> count;
	count = count % 10;
	int hon[] = {2,4,5,7,9};
	int *h;
	h = find(hon, hon + 5, count);
	if (h !=hon+5)
	{
		cout << "hon";
	}
	else {
		int pon[] = {0,1,6,8};
		int *p;
		p = find(pon, pon + 4, count);
		if (p!=pon+4)
		{
			cout << "pon";
		}
		else {
			cout << "bon";
		}
	}
    return 0;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAX=1e5+4;
LL a[MAX];
LL root[MAX];




int main(){
        int n;
        cin>>n;
        LL h,w;
        cin>>h>>w;
        LL cnt=0;
        for(int i=0;i<n;i++)
        {
                LL x,y;
                cin>>x>>y;
                if(x>=h && y>=w) cnt++;
        }
        cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const int maxn=505;
int H,W,h,w;
int a[maxn][maxn];
int main(){
	read(H);read(W);
	read(h);read(w);
	if(H%h==0&&W%w==0)puts("No");
	else{
		puts("Yes");
		rep(i,1,h)rep(j,1,w)a[i][j]=1000;
		a[h][w]=-(1000*(h*w-1)+1);
		rep(i,1,H)rep(j,1,W){
			if(i>h)a[i][j]=a[i-h][j];
			else if(j>w)a[i][j]=a[i][j-w];
		}
		rep(i,1,H){
			rep(j,1,W)printf("%d ",a[i][j]);
			puts("");
		}
	}
	return 0;
}

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

#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;

const int MAXN = 300;
double dp[MAXN + 1][MAXN + 1][MAXN + 1];

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(12);
    cin.tie(nullptr);
    int i0 = 0, j0 = 0, k0 = 0;
    double N; cin >> N;
    forn(i, N) {
        int a; cin >> a;
        if (a == 1)
            i0++;
        else if (a == 2)
            j0++;
        else
            k0++;
    }
    for (int k = 0; k <= N; k++) {
        for (int j = 0; j <= N - k; j++) {
            for (int i = 0; i <= N - k - j; i++) {
                if (i + j + k == 0)
                    continue;
                double E = 1;
                if (i > 0)
                    E += i / N * dp[i - 1][j][k];
                if (j > 0)
                    E += j / N * dp[i + 1][j - 1][k];
                if (k > 0)
                    E += k / N * dp[i][j + 1][k - 1];
                dp[i][j][k] = N / (i + j + k) * E;
            }
        }
    }
    cout << dp[i0][j0][k0] << endl;
}


Measured memory_bytes: 213248
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int r = 0, c = 0, k = 0, x = 0, y = 0; lli val = 0ll;
	cin >> r >> c >> k;
	vector<vector<lli> > a(r, vector<lli>(c, -1ll));
	for (int i = 0; i < k; ++i)
	{
		cin >> x >> y >> val; --x; --y;
		a[x][y] = val;
	}
	vector<vector<vector<lli> > > dp(4, vector<vector<lli> > (r, vector<lli>(c, -1ll)));
	dp[0][0][0] = 0ll;
	if (a[0][0] != -1ll)
		dp[1][0][0] = a[0][0];
	for (int i = 0; i < r; ++i)
		for (int j = 0; j < c; ++j)
			for (int l = 0; l < 4; ++l)
			{
				val = dp[l][i][j];
				if (i + 1 < r && dp[0][i + 1][j] < val)
					dp[0][i + 1][j] = val;
				if (i + 1 < r && a[i + 1][j] != -1ll && dp[1][i + 1][j] < val + a[i + 1][j])
					dp[1][i + 1][j] = val + a[i + 1][j];
				if (j + 1 < c && dp[l][i][j + 1] < val)
					dp[l][i][j + 1] = val;
				if (j + 1 < c && l < 3 && dp[l + 1][i][j + 1] < val + a[i][j + 1])
					dp[l + 1][i][j + 1] = val + a[i][j + 1];
			}
	cout << max({0ll, dp[0][r - 1][c - 1], dp[1][r - 1][c - 1], dp[2][r - 1][c - 1], dp[3][r - 1][c - 1]}) << endl;
}

Measured memory_bytes: 425672
fun main(args: Array<String>) {

    val N = readLine()!!.toInt()

    val money = (1..N).map {
        val l = readLine()!!.split(" ")
        Pair(l[0].toDouble(), l[1])
    }

    val total = money.map {
        when(it.second) {
            "JPY"->{
                it.first
            }
            else ->{
                it.first*380000.0
            }
        }
    }.sum()

    println(total)
}


Measured memory_bytes: 36068
#include <stdio.h>

int main(){
  int a,b;
  int i,j;
  int count = 0;

  scanf("%d %d", &a, &b);

  if(a == b) count = a;

  if(a < b) count = a;

  if(a > b) count = a - 1;

  printf("%d", count);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
   cin >> n;
   string ans="";
        while (n) {
            ans = char ((n - 1) % 26 + 'a') + ans;
            n = (n - 1) / 26;
        }
   cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
long long int power(long long int a,long long int b,long long int p)
{
    long long int res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}
bool check(long long int k){
	for(int i=0;i<to_string(k).length();i++){
		if(to_string(k)[i]!='7')
		return false;
	}
	return true;
}
int main(){
	long long int sum=0,k,mod=0;
	cin>>k;
	if(check(k)){
		cout<<(int)(log10(k)+1)<<endl;
		return 0;
	}
	map<long long int,long long int> m;
	while(true){
		mod+=(7%k)*(power(10,sum,k)%k);
		mod%=k;
		if(m[mod])
		break;
		m[mod]=1;
		if(!mod){
			cout<<(sum+1)<<endl;
			return 0;
		}
		sum++;
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 66248
import collections as c
ip = lambda : map(int, input().split())

#################
from fractions import gcd
N = int(input())
A = [int(i) for i in input().split()]
dp = [[0,0,0] for _ in range(N+1)]
dp[1] = [A[0],0,A[0]]
dp[2] = [gcd(dp[1][0],A[1]),dp[1][0],max(A[1] ,gcd(dp[1][2],A[1]))]
for i in range(3,N+1):
    dp[i][0] = gcd(dp[i-1][0],A[i-1])
    dp[i][1] = dp[i-1][0]
    dp[i][2] = max(gcd(dp[i-1][1],A[i-1]),gcd(dp[i-1][2],A[i-1]))

print(max(dp[N]))


Measured memory_bytes: 19608
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int sum , i;
    char x[1000];
    
    while(1){
        scanf("%s",x);
        if (x[0] == '0') break;
        for (sum=0,i=0; x[i]!='\0'; i++) {
            sum += (x[i]-'0');
        }
        printf("%d\n",sum);
    }
    return 0;
}

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

int main() {
    int a, b, k;
    cin >> a >> b >> k;

    int i;
    for (i = a; i <= b; i++) {
        if (i >= a + k) {
            break;
        }
        cout << i << endl;
    }

    for (i = max(i, b - k + 1); i <= b; i++) {
        cout << i << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a="CODEFESTIVAL2016",b;
int s;
int main()
{
    cin>>b;
    for(int i=0;i<16;i++)
    	if(a[i]!=b[i])s++;
    cout<<s;
 	return 0;   
}

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

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}

int main()
{
	int n;
	n=read();cout<<3ll*n*n; 
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1);





int main() 
{
  ll N; cin>>N;
  for(int n=1;n<=N;n++)
  {
    ll ans=0;
    for(int x=1;x<=100;x++)
    {
      for(int y=1;y<=100;y++)
      {
        ll a=sqrt((x+y)*(x+y)-4*(x*x+y*y+x*y-n));
        if(a*a!=(x+y)*(x+y)-4*(x*x+y*y+x*y-n)
           &&(a+1)*(a+1)!=(x+y)*(x+y)-4*(x*x+y*y+x*y-n)) continue;
        if((a+1)*(a+1)==(x+y)*(x+y)-4*(x*x+y*y+x*y-n)) a+=1;
        if(a-x-y>0&&(a-x-y)%2==0) ans++;
      }
    }
    cout<<ans<<endl;
  }  
  return 0;
}


Measured memory_bytes: 3592
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>


#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define swap(p,q) r=(p);(p)=(q);(q)=r
#define INF 1000000000000//10^12
#define INFINT 2000000001//2*10^9+1

using namespace std;

struct edge{
	int to;
	double cost;
};

typedef pair<int, int> P;

int V;//辺の本数
static vector<edge> G[1000010];//辺の情報　手で埋めておく必要あり
double d[1010];
ll int n,xs,ys,xt,yt;

void init(double dd[], int num){
	int i;
	for(i=0;i<num;i++){
		dd[i]=INF;
	}
}

void dijkstra(int s){

	priority_queue<P, vector<P>, greater<P> > que;
	init(d,1010);
//	printf("d[1]=%lf\n",d[1]);
	d[s]=0;
	que.push(P(0,s));

	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v=p.second;
		if(d[v]<p.first) continue;
		for(int i=0; i<G[v].size(); i++){
			edge e=G[v][i];
//			printf("d[0]=%lf,d[1]=%lf,d[2]=%lf",d[0],d[1],d[2]);
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}

}

int main(void)
{
	//変数の宣言
//	int n,xs,ys,xt,yt;
	static ll int x[100010];
	static ll int y[100010];
	static int r[100010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	double temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;



	//データの読み込み


	scanf("%lld %lld %lld %lld\n%lld",&xs,&ys,&xt,&yt,&n);
//	scanf_s("%lld %lld %lld %lld\n%lld",&xs,&ys,&xt,&yt,&n);

	for(i=1;i<=n;i++){
		scanf("%lld %lld %d",&x[i],&y[i],&r[i]);
//		scanf_s("%lld %lld %d",&x[i],&y[i],&r[i]);
	}
	
	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理
	
	x[0]=xs;
	y[0]=ys;
	r[0]=0;
	x[n+1]=xt;
	y[n+1]=yt;
	r[n+1]=0;
	for(i=0;i<=n;i++){
		for(j=i+1;j<=n+1;j++){
			temp=max(0,sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j]);
			edge p;
			p.to=j;
			p.cost=temp;
			G[i].push_back(p);
			p.to=i;
			G[j].push_back(p);
		}
	}

	dijkstra(0);

	
	//	printf("計算部分終了\n");

	//出力

	printf("%1.10lf",d[n+1]);

	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 42136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N,M; cin >> N >> M;
    VI A(N);
    int sum = 0;
    REP(i,N){
        cin >> A[i];
        sum += A[i];
    }
    int acc = 0;
    int norm;
    if(sum % (4*M) == 0){
        norm = sum / (4*M);
    }else{
        norm = sum / (4*M) + 1;
    }
    REP(i,N){
        if(A[i] >= norm){
            acc++;
        }
    }
    if(acc >= M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


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

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define rep(i,a) for(i = 0 ; i < a ; i++)
#define repr(i,a) for(i = a ; i >= 0 ; i--)
#define REP(i,a,b) for(i = a ; i <= b ; i++)
#define REPR(i,a,b) for(i = a ; i >= b ; i--)

#define scan(N) scanf("%lld",&N)
#define print(N) printf("%lld",N)
#define scan2(N1,N2) scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2) printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define mem(a,b)memset(a,b,sizeof(a))
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

#define endl '\n'

const long long INF = 2000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

template<class T> bool is_prime(T n)
{
	if((n%2 == 0 and n > 2) or n < 2 )
		return false;
	for(T i = 3; i*i <= n ; i += 2)
	{
		if( n % i == 0)
			return false;
	}
	return true;
}
lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0)
    {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else
    {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}

lli grid[2][101],ans,n;

void recur(lli x,lli y,lli has)
{
    if(x >= 2 or y >= n)
        return ;
    if(x == 1 and y == n-1)
        ans = max(ans,has + grid[1][n-1]);
    has += grid[x][y];
    recur(x+1,y,has);
    recur(x,y+1,has);
}
int main()
{
	opt;
    lli i,j;
    cin >> n;
    rep(i,2)
    {
        rep(j,n)
            cin >> grid[i][j];
    }
    recur(0,0,0);
    cout << ans << endl;
	return 0;
}










Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,k[10],m[10],r,i,j,temp,zyu[10];
	char t[11],te;
	while(1){
		for(i=0;i<10;i++){
			k[i]=0;
			m[i]=0;
		}
		scanf("%d",&n);
		if(n<2)break;
		for(i=0;i<n;i++){
			zyu[i]=i;
			scanf(" %c",&t[i]);
//			printf("%c\n",t[i]);
			for(j=0;j<n-1;j++){
				scanf("%d",&r);
				if(r==0){
					k[i]++;
				}
				if(r==1){
					m[i]++;
				}
//				printf("%d %d\n",r,k[i]);
			}
		}
		for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				if(k[i]<k[j]||(k[i]==k[j]&&m[i]>m[j] )|| (k[i]==k[j] && m[i]==m[j] && zyu[i]>zyu[j])){
					temp=k[i];
					k[i]=k[j];
					k[j]=temp;
					
					temp=m[i];
					m[i]=m[j];
					m[j]=temp;
					
					temp=zyu[i];
					zyu[i]=zyu[j];
					zyu[j]=temp;				

					te=t[i];
					t[i]=t[j];
					t[j]=te;
				}
			}
		}
		for(i=0;i<n;i++){
			printf("%c\n",t[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 1028
import scala.io.StdIn._

object Main extends App {

  val Array(a,b) = readLine().split(" ").map(_.toInt)

  def solve() = {
    if(a >= b) {
      a + Math.max(a-1, b)
    } else {
      b + Math.max(b-1, a)
    }
  }

  println(solve())

}



Measured memory_bytes: 54648
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    print((a[0]-1)*(a[1]-1))

Measured memory_bytes: 3828
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<pair<int, int>> ab;
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        ab.emplace_back(a, b);
    }
    sort(all(ab));

    int ans = 0;
    rep(i, N) {
        if (K <= ab[i].second) {
            ans = ab[i].first;
            break;
        }
        else K -= ab[i].second;
    }
    write(ans);
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   int n;
           cin>>n;
           vector<string> s(n);
           vin t(n);
           rep(i,0,n)cin>>s[i]>>t[i];
           string x;
           cin>>x;
           int ans=0;
           bool ok=false;
           rep(i,0,n){
             if(ok)ans+=t[i];
             if(s[i]==x)ok=1;
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

#define INF (1<<29)

typedef pair<int, int> P;
typedef pair<P, P> PP;

struct Order{
  string pname, dname;
  string order;
  int price;
  Order(string pname, string dname, string order, int price) :
    pname(pname), dname(dname), order(order), price(price){}
};
  

int main(){
  int n;
  while(cin >> n, n){
    bool used[1010];
    memset(used, false, sizeof(used));
    vector<Order> market;
    map<string, P> person;
    map<string, PP> item;
    
    string pname, dname, order;
    int price;
    for(int i = 0 ; i < n ; i++){
      cin >> pname >> order >> dname >> price;
      market.push_back(Order(pname, dname, order, price));
      if(person.find(pname) == person.end()) person[pname] = P(0, 0);
      if(order == "SELL"){
	int number = -1;
	int p = -1;
	for(int j = 0 ; j < (int)market.size() ; j++){
	  if(market[j].order == "BUY" && market[j].pname != pname &&
	     market[j].dname == dname && market[j].price >= price &&
	     !used[j]){
	    if(p < market[j].price){
	      number = j;
	      p = market[j].price;
	    }
	  }
	}
	if(number == -1) continue;
	int deal = (price + p) / 2;
	person[pname].second += deal;
	person[market[number].pname].first += deal;
	item[dname].first.first += deal;
	item[dname].first.second++;
	item[dname].second.first = max(item[dname].second.first, deal);
	if(item[dname].first.second == 1) item[dname].second.second = deal;
	else item[dname].second.second = min(item[dname].second.second, deal);
	used[i] = used[number] = true;
      }

      if(order == "BUY"){
	int number = -1;
	int p = INF;
	for(int j = 0 ; j < (int)market.size() ; j++){
	  if(market[j].order == "SELL" && market[j].pname != pname &&
	     market[j].dname == dname && market[j].price <= price &&
	     !used[j]){
	    if(p > market[j].price){
	      number = j;
	      p = market[j].price;
	    }
	  }
	}
	if(number == -1) continue;
	int deal = (price + p) / 2;
	person[pname].first += deal;
	person[market[number].pname].second += deal;	       
	used[i] = used[number] = true;
	item[dname].first.first += deal;
	item[dname].first.second++;
	item[dname].second.first = max(item[dname].second.first, deal);
	if(item[dname].first.second == 1) item[dname].second.second = deal;
	else item[dname].second.second = min(item[dname].second.second, deal);      
      }
    }
    
    for(map<string, PP>::iterator it = item.begin() ; it != item.end() ; it++){
      cout << it->first << ' '
	   << it->second.second.second << ' '
	   << it->second.first.first / it->second.first.second << ' '
	   << it->second.second.first << endl;	  

    }
    cout << "--" << endl;
    
    for(map<string, P>::iterator it = person.begin() ; it != person.end() ; it++){
      cout << it->first << ' '
	   << it->second.first << ' '
	   << it->second.second << endl;
    }
    cout << "----------" << endl;
  }
  return 0;
}

Measured memory_bytes: 1416
s,t = gets.chomp.split(' ').map(&:to_s)
a,b = gets.chomp.split(' ').map(&:to_i)
u = gets.chomp.to_s

ans = []

if u == s
	ans = (a - 1),b
else
	ans = a,(b - 1)
end

puts ans.join(' ')

Measured memory_bytes: 1788