akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n,a,b,c;cin >> n >> a >> b >> c;
    vi l(n);
    rep(i,n) cin >> l[i];
    int ans = INF;
    for(int i=0;i<(1<<n);++i){
        bitset<8> one(i);
        for(int j=0;j<(1<<n);++j){
            bitset<8> two(j);
            int A = 0, B = 0, C = 0;
            int Acount = 0, Bcount = 0, Ccount = 0;
            for(int k=0;k<n;++k){
                if(one.test(k) && two.test(k)){
                    A += l[k];
                    ++Acount;
                }else if(one.test(k) && !two.test(k)){
                    B += l[k];
                    ++Bcount;
                }else if(!one.test(k) && two.test(k)){
                    C += l[k];
                    ++Ccount;
                }
            }
            if(Acount==0 || Bcount==0 || Ccount==0) continue;
            --Acount;--Bcount;--Ccount;
            int tmp = (Acount + Bcount + Ccount) * 10 + abs(A - a) + abs(B - b) + abs(C - c);
            chmin(ans, tmp);
        }
    }
    cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> w(n);
    rep(i, n){
        cin >> w[i];
    }
    int s2 = accumulate(all(w), 0);
    int s1 = 0;
    int smin = s2;
    rep(i, n){
        s1 += w[i];
        s2 -= w[i];
        if(abs(s2-s1) < smin){
            smin = abs(s2-s1);
        }
    }

    cout << smin;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;


public class Program
{
    int N;
    long[] X;
    long[] L;

    public void Input()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        X = new long[N];
        L = new long[N];

        for (int i = 0; i < N; i++)
        {
            X[i] = sc.NextLong();
            L[i] = sc.NextLong();
        }
    }


    public void Solve()
    {
        Input();
        var robots = new List<Robot>();
        var robots_arr = new Robot[N]; 

        for (int i = 0; i < N; i++)
        {
            var robot = new Robot(X[i] - L[i], X[i] + L[i]);
            robots.Add(robot);
            robots_arr[i] = robot;
        }

        robots.Sort((a, b) => (int)a.r - (int)b.r);
        robots_arr = robots_arr.OrderBy(a => a.r).ToArray();

        int ans = 0;
        long cur = -1001000100;
        for (int i = 0; i < N; i++)
        {
            if (cur <= robots[i].l)
            {
                ans++;
                cur = robots[i].r;
            }
        }
        Console.WriteLine(ans);

    }

    public static void Main(string[] args) => new Program().Solve();
}

public class Robot
{
    public long l { get; set; }
    public long r { get; set; }


    public Robot(long _l, long _r)
    {
        l = _l;
        r = _r;
    }

}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

ULL ds(ULL a){
  ULL ans = 0;
  while(a){
    ans += a%10;
    a/=10;
  }
  return ans;
}

int main(){
  ULL A,N,M; cin >>A>>N>>M;
  UL ans = 0;
  for(ULL y=1; y<=M; y++){
    ULL tmp = y+A;
    ULL x = 1;
    bool over = false;
    rep(i,N){
      x*=tmp;
      if(x>=M) over=true;
    }
    if(over)break;
    if(ds(x) == y){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3132
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int a[5],k;
	a[0] = 0;
	for(int i = 0; i < 5; i++)
	{
		scanf("%d", &a[i]);
		if(a[i] > 123 || a[i] < 0)
			{
				return 0;
				break;
			}
		if(i >= 1 && a[i] <= a[i-1])
			{
				return 0;
				break;
			}
	}
	scanf("%d", &k);
	
	int flag = 1;
	
	for(int i = 0; i < 4; i++)
	{
		for(int j = 1; j < 5; j++)
			{
				if(abs(a[i] - a[j]) > k)
					{
						flag = 0;
						break;
					}
				else
					continue;
			}
	}
	
	if(flag)
		printf("Yay!");
	else
		printf(":(");
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>

int main(){
    int a, b, angle;
    double s, l, h;

    scanf("%d %d %d", &a, &b, &angle);
    h=b*sin(angle*M_PI/180.0);
    s=a*h/2;
    l=a+b+sqrt((a*a+b*b-2*a*b*cos(angle*M_PI/180.0)));
    printf("%f\n", s);
    printf("%f\n", l);
    printf("%f\n", h);

    return 0;
}

Measured memory_bytes: 632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifdef LOCAL
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define debug(x) ;
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

/* FastZetaTransform */

// a[1001] = a[1001] + a[1011] + a[1101] + a[1111];

void FZT(int n, ll *a){
  for(int i=0; i<n; i++)
    for(int j=0; j<(1<<n); j++)
      if(!(j & (1<<i))) a[j] += a[j | (1<<i)]; //総和
}

// a[1001] = a[1001] + a[1000] + a[0001] + a[0000];

void FZT2(int n, ll *a){
  for(int i=0; i<n; i++)
    for(int j=0; j<(1<<n); j++)
      if(j & (1<<i)) a[j] += a[j ^ (1<<i)]; //総和
}

ll sum[1<<16];
ll dp[1<<16];

int main(){
  int n, a[20][20];

  scanf("%d", &n);

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      scanf("%d", a[i]+j);
      if(i > j) sum[(1<<i)+(1<<j)] += a[i][j];
    }
  }

  FZT2(n, sum);

  for(int i=0;i<(1<<n);i++){
    for(int j=n-1;j>=0;j--){
      if(i>>j&1) continue;

      for(int k=0;k<(1<<(j+1));k++){
        while(i & k) k += i & k;
        if(k >= (1<<(j+1))) break;
        dp[i|k] = max(dp[i|k], dp[i] + sum[k]);
      }
      break;
    }
  }

  cout << dp[(1<<n)-1] << endl;

  return 0;
}


Measured memory_bytes: 1280
N,X=map(int,input().split())
w=[0]
for i in map(int,input().split()):w+=[w[-1]+i]
print(min(5*w[N]+k*X+sum(2*w[j]for j in range(N-k*2,0,-k))for k in range(1,N+1))+N*X)

Measured memory_bytes: 28372
n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
c=[list(map(int,input().split())) for _ in range(m)]
INF=10**9+7
for i in a:
    ans=INF
    for j in range(m):
        tmp=abs(i[0]-c[j][0])+abs(i[1]-c[j][1])
        if tmp<ans:
            ans=tmp
            num=j+1
    print(num)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

void counting_sort(vector<size_t> const seq, vector<size_t>* res, size_t k)
{
    vector<size_t> c(k, 0);

    for (auto key : seq)
        c[key]++;
    
    size_t total = 0;
    for (size_t i = 0; i < k; i++) {
        auto old = c[i];
        c[i] = total;
        total += old;
    }

    for (auto key : seq) {
        (*res)[c[key]] = key;
        c[key]++;
    }
}

int main(void)
{
    size_t n, k = 0;
    vector<size_t> seq;

    cin >> n;
    for (size_t i = 0; i < n; i++) {
        size_t x; cin >> x;
        seq.push_back(x);
        if (x > k) k = x;
    }

    vector<size_t> res(n);
    counting_sort(seq, &res, k+1);

    for (size_t i = 0; i < res.size() - 1; i++)
        cout << res[i] << " ";
    cout << res.back() << endl;

    return 0;
}

Measured memory_bytes: 48160
package main

import (
	"fmt"
	"sort"
)

func calcScore(n, m []int) (int, int) {
	sort.Ints(n)
	sort.Ints(m)
	
	return n[9] + n[8] + n[7], m[9] + m[8] + m[7]
}

func main(){
	var team_W, team_K []int
	var inp int
	
		for i := 0; i < 10; i++ {		
			fmt.Scan(&inp)
			team_W = append(team_W, inp)
		}

		for j := 0;  j< 10; j++ {		
			fmt.Scan(&inp)
			team_K = append(team_K, inp)
		}

	fmt.Println(calcScore(team_W, team_K))
}


Measured memory_bytes: 1180
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
// #ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
       *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
// #else
// sim dor(const c&) { ris; }
// #endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int MOD=998244353;

void solve(){
    int n,k;
    cin>>n>>k;
    int range[k][2];
    for(int i=0;i<k;i++){
        cin>>range[i][0]>>range[i][1];
    }
    long long dp[n];
    memset(dp,0ll,sizeof(dp));
    dp[0]=1ll;
    long long win[k];
    memset(win,0ll,sizeof(win));
    for(int i=1;i<n;i++){
        for(int j=0;j<k;j++){
            if(i-range[j][0]>=0){
                win[j]+=dp[i-range[j][0]];
            }
            win[j]%=MOD;
            if(i-range[j][1]>0){
                win[j]-=dp[i-range[j][1]-1];
            }
            win[j]=((win[j]%MOD)+MOD)%MOD;
            dp[i]+=win[j];
            dp[i]%=MOD;
            // cout<<i<<" "<<j<<" "<<win[j]<<'\n';
        }
    }
    // for(int i=0;i<n;i++){
    //     cout<<i<<" "<<dp[i]<<'\n';
    // }
    cout<<dp[n-1]<<'\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 5212
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
vector<pair<ll,ll>> B;
ll dp[2222][2222];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  for(auto &a:A)cin>>a;
  ll ans = 0;
  B.resize(n);
  for(int i=0;i<n;i++){
    B[i] = mp(A[i],i);
  }
  sort(ALL(B),greater<pair<ll,ll>>());
  for(int i=0;i<2222;i++){
    for(int j=0;j<2222;j++){
      dp[i][j] = -1;
    }
  }
  dp[0][0] = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<=n;j++){
      if(dp[i][j] >= 0){
	dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+abs(B[i].S-j)*B[i].F);
	if(i-j < 0)continue;
	ll num = n-(i-j)-1;
	dp[i+1][j] = max(dp[i+1][j],dp[i][j]+abs(num-B[i].S)*B[i].F);
      }
    }
  }
  for(int i=0;i<=n;i++){
    ans = max(ans,dp[n][i]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 42280
{-# OPTIONS_GHC -O2 #-}
import Control.Applicative
import qualified Data.HashMap.Strict as Map

main = do
    [_,capa] <- map (read :: String -> Int) . words <$> getLine
    goods <- map (map (read :: String -> Int) . words) . lines <$> getContents
    print $ maximum $ map snd $ Map.toList (resolve capa (Map.fromList (zip [0..capa] [0,0..])) goods)

resolve capa capaMap ([v,w]:xs)
  | xs == []  = koushin'
  | otherwise = resolve capa koushin' xs
  where
    koushin' =  koushin capaMap [v,w] 0
    koushin capaMap [v,w] n
      | n == 0 && capaMap Map.! w <= v          = next'
      | n > (capa - w)                       = capaMap
      | capaMap Map.! (n+w) >= v + oldValue   = next
      | otherwise                            = next'
      where
        oldValue = capaMap Map.! n
        next     = koushin capaMap [v,w] (n+1)
        next'    = koushin (Map.insert (n+w) (v + oldValue) capaMap) [v,w] (n+1)

Measured memory_bytes: 7812
N = int(input())
flag = 0
for i in range(N) :
    t,x,y = map(int,input().split())
    if t % 2 == 0 :
        if (x+y) <= t and (x+y) % 2 == 0 :
            continue
        else :
            flag += 1
    else :
        if (x+y) <= t and (x+y) % 2 == 1 :
            continue
        else :
            flag += 1
if flag == 0 :
    print("Yes")
else :
    print("No")


Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			string a = Console.ReadLine();
			int n = a.Length;
			long ans = (long)n * (n - 1) / 2 + 1;
			long[] counts = new long[26];
			for (int i = 0; i < n; i++) {
				counts[(int)(a[i] - 'a')]++;
			}

			foreach (long count in counts) {
				if (count > 0) {
					ans -= count * (count - 1) / 2;
				}
			}

			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int problemCount = sc.nextInt();
		int teisyutuCount = sc.nextInt();

		int seitoCount = 0;
		int penaltyCountTotal = 0;

		boolean[] seitoList = new boolean[problemCount];
		int[] penaltyCount = new int[problemCount];

		for(int i =0;i < problemCount; i++) {
			seitoList[i] = false;
			penaltyCount[i] = 0;
		}

		for(int i = 0;i < teisyutuCount; i++) {
			int problemNo = sc.nextInt();
			String result = sc.next();

			if(seitoList[problemNo -1]) {
				// すでに正解している場合は何もしない
				continue;
			}else if(result.equals("AC")) {
				// 初めて正解した場合
				seitoCount++;
				seitoList[problemNo-1] = true;
				// これまでの不正解数を加える
				penaltyCountTotal += penaltyCount[problemNo-1];
			}else {
				// 不正解の場合
				penaltyCount[problemNo-1]++;
			}
		}

		System.out.println(seitoCount + " " + penaltyCountTotal);
	}
}


Measured memory_bytes: 63628
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int N = 110;
char s[N];

int main(){
    int n;
    bool flag = false;
    char str[2];
    scanf("%d", &n);
    scanf("%c", &str);
    scanf("%s", s);
    if(n % 2 != 0)
        printf("No");
    else{
        int len = n / 2;
        for(int i = 0, j = len; i < len && j < n; i ++, j ++){
            if(s[i] != s[j]){
                flag = true;
                break;
            }
        }
        if(flag)
            printf("No");
        else
            printf("Yes");
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int a,b,x;
  cin>>a>>b>>x;
  if (x<=a+b && x >=a){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  long a,b,m;
  scanf("%ld %ld %ld", &a, &b, &m);
  long a_price[a], b_price[b], x[m], y[m], c[m];
  for (long i = 0; i < a; i++) {
    scanf("%ld", &a_price[i]);
  }
  for (long i = 0; i < b; i++) {
    scanf("%ld", &b_price[i]);
  }
  for (long i = 0; i < m; i++) {
    scanf("%ld %ld %ld", &x[i], &y[i], &c[i]);
  }

  long without_m;
  long min = a_price[0];
  for (long i = 1; i < a; i++) {
    if (a_price[i] < min) {
      min = a_price[i];
    }
  }
  without_m = min;
  min = b_price[0];
  for (long i = 1; i < b; i++) {
    if (b_price[i] < min) {
      min = b_price[i];
    }
  }
  without_m += min;

  long price;
  min = without_m;
  for (long i = 0; i < m; i++) {
    price = a_price[x[i]-1]+b_price[y[i]-1]-c[i];
    if (price < min) {
      min = price;
    }
  }
  printf("%ld\n", min);

  return 0;
}

Measured memory_bytes: 4096
N = int(input())
T,A = map(int,input().split())
for i in range(N-1):
    t,a = map(int,input().split())
    T1 = (T+t-1)//t*t
    A1 = (T+t-1)//t*a
    T2 = (A+a-1)//a*t
    A2 = (A+a-1)//a*a
    if A1 < A:
        T,A = T2,A2
    else:
        T,A = T1,A1
print(T+A)


Measured memory_bytes: 3064
import sys,math
import numpy as np

n=int(sys.stdin.readline())
#n,k=map(int,sys.stdin.readline().split())
#a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')
ans=0
for i in range(1,n+1):
    ans+=i
    if i!=n:
        for j in range(i+1,n+1):
            f=math.gcd(i,j)
            ans+=f*6
            if j!=n:
                for k in range(j+1,n+1):
                    ans+=math.gcd(f,k)*6

print(ans)


Measured memory_bytes: 27124
#include<stdio.h>
 int main(void)
 {
     int X;

     scanf("%d",&X);

     if(X==7) printf("YES\n");
     else if(X==5) printf("YES\n");
     else if(X==3) printf("YES\n");
     else printf("NO\n");

     return 0;
 }


Measured memory_bytes: 1616
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;

int main()
{
	int N,A,B;
	cin >> N >> A >> B;
	if (N*A < B) { cout << N * A << endl; }
	else { cout << B << endl; }

}

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

int main()
{
  int a[114514];
  int b[114514];
  
  int n,m;
  while(1){
    cin>>n>>m;
    if(n==0&&m==0){
      return 0;
    }
    int a_total=0;
    int b_total=0;
    rep(i,n){
      cin>>a[i];
      a_total+=a[i];
    }
    rep(i,m){
      cin>>b[i];
      b_total+=b[i];
    }

    int ans1=114514;
    int ans2=114514;
    rep(i,n){
      rep(j,m){
	if(a_total+b[j]-a[i]==b_total+a[i]-b[j]){
	  if(a[i]+b[j]<ans1+ans2){
	    ans1=a[i];
	    ans2=b[j];
	  }
	}
      }
    }
    if(ans1==114514){
      cout<<-1<<endl;
    }else{
      cout<<ans1<<" "<<ans2<<endl;
    }
  }
}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const ld PI=abs(acos(-1));
ll h,w,mi=(ll)10e10;

int main(){
	cin >> h >> w;
	
	REP(x,0,2){
		REP(i,1,w){
			ll a=i*h,b=(w-i)*(h/2);
			mi=min(mi,max(a,max(b,h*w-(a+b)))-min(a,min(b,h*w-(a+b))));
		}
		
		REP(i,1,w){
			ll a=i*h,b=((w-i)/2)*h;
			mi=min(mi,max(a,max(b,h*w-(a+b)))-min(a,min(b,h*w-(a+b))));
		}
		swap(h,w);
	}

	cout << mi << endl;
	
	
	return 0;
}


Measured memory_bytes: 256
state = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(0, n):
    x = list(map(int, input().split()))
    state[x[0] - 1][x[1] - 1][x[2] - 1] += x[3]
for k in range(0, 4):
    for j in range(0, 3):
        for i in range(0, 10):
            print("", state[k][j][i], end="")
        print()
    if k != 3: print("####################")


Measured memory_bytes: 5636
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		String a = sc.next();
		String b = sc.next();

		int ab = Integer.parseInt(a + b);

		int sqrt = (int)Math.sqrt(ab);

		if (ab == sqrt * sqrt) {
			pr.println("Yes");
		} else {
			pr.println("No");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


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

int main() {
  string S;
  cin >> S;
  bool OK = true;
  if (S.at(0) != 'A') {
    OK = false;
  }
  int capital, counter = 0;
  for (int i=2; i<S.size()-1; i++) {
    if (S.at(i) == 'C') {
      counter++;
      capital = i;
    }
  }
  if (counter != 1) {
    OK = false;
  }
  for (int i=1; i<S.size(); i++) {
    if ('A'<=S.at(i) && S.at(i)<='Z' && i != capital) {
      OK = false;
      break;
    }
  }
  string answer;
  if (OK) {
    answer = "AC";
  }
  else {
    answer = "WA";
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;

struct uf{
  static const int MAXN=100005;
  int par[MAXN];
  int size[MAXN];
  void init(){
    memset(par,-1,sizeof(par));
    REP(i,MAXN) size[i]=1;
  }
  int root(int a){
    if(par[a]==-1) return a;
    return par[a]=root(par[a]);
  }
  void unite(int a,int b){
    a=root(a);b=root(b);
    if(a==b) return;
    if(size[a]<size[b]) swap(a,b);

    par[b]=a;
    size[a]+=size[b];
  }
  bool same(int a,int b){
    return root(a)==root(b);
  }
};

uf u;
int n,m;
vector<pi> g[100005];
int col[100005];

bool fail;
lint mark[3];
int E;
void dfs(int v){
  mark[col[v]]++;
  for(auto e:g[v]){
    ++E;
    if(~col[e.fr] && col[e.fr]!=(col[v]+e.sc)%3) fail=true;
    if(col[e.fr]==-1){
      col[e.fr]=(col[v]+e.sc)%3;
      dfs(e.fr);
    }
  }
}

int main(){
  u.init();
  cin>>n>>m;
  REP(i,m){
    int a,b;scanf("%d%d",&a,&b);--a;--b;
    g[a].pb(mp(b,1));
    g[b].pb(mp(a,2));
    u.unite(a,b);
  }
  memset(col,-1,sizeof(col));
  lint res=0;
  REP(i,n) if(u.root(i)==i){
    col[i]=0;
    CLR(mark);
    E=0;
    fail=false;
    dfs(i);
    if(fail){
      lint s=u.size[i];
      res+=s*s;
    }else if(mark[0] && mark[1] && mark[2]){
      res+=mark[0]*mark[1]+mark[1]*mark[2]+mark[2]*mark[0];
    }else{
      res+=E/2;
    }
  }
  cout<<res<<endl;
  return 0;
}





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

int main() {
  int n;
  cin >>n;
  vector<int>t(n),x(n),y(n);
  for(int i=0;i<n;i++){
    cin>>t.at(i)>>x.at(i)>>y.at(i);
  }
  for(int i=0;i<n;i++){
    if(t.at(i)<x.at(i)+y.at(i)){
      cout<<"No"<<endl;
      return 0;
    }
    if((t.at(i)-x.at(i)-y.at(i))%2==1){
      cout<<"No"<<endl;
      return 0;
    } 
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <fstream>
#include <cmath>
#include <limits>
#include <chrono>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
#include <cassert>
#pragma warning (disable: 4996)
using namespace std;

using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

struct UnionFind {
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

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

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

long long modpow(long long a, long long n, long long mod) {
    if (n < 0)return 0;
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

ll merge_cnt(vector<ll>& a) {
    int n = a.size();
    if (n <= 1) { return 0; }

    ll cnt = 0;
    vector<ll> b(a.begin(), a.begin() + n / 2);
    vector<ll> c(a.begin() + n / 2, a.end());

    cnt += merge_cnt(b);
    cnt += merge_cnt(c);

    int ai = 0, bi = 0, ci = 0;
    while (ai < n) {
        if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) {
            a[ai++] = b[bi++];
        }
        else {
            cnt += n / 2 - bi;
            a[ai++] = c[ci++];
        }
    }
    return cnt;
}

int main() {
    ll n;
    cin >> n;
    ll k;
    cin >> k;
    vector<ll> z(n);
    for (int i = 0; i < n; i++) {
        cin >> z[i];
        z[i] -= k;
    }
    vector<ll> x(n + 1);
    for (int i = 0; i < n; i++) {
        x[i + 1] = z[i] + x[i];
    }
    cout << n*(n+1)/2-merge_cnt(x) << endl;
}

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

int main()
{
	//freopen("/home/zz7/CFInput","r",stdin);
	int A,B,C,X,Y;
	scanf("%d%d%d%d%d",&A,&B,&C,&X,&Y);
	int Out=1e9+7;
	for(int i=0;i<=100000;i++)
	{
		int u=2*i,ans=u*C;
		if(X-i>0)ans+=(X-i)*A;
		if(Y-i>0)ans+=(Y-i)*B;
		Out=min(Out,ans);
	}cout<<Out<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << 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; }

int main(){
  vector<ll> a(6);
  rep(i,6){
    cin >> a[i];
  }
  rep(i,5){
    chmin(a[0], a[i]);
  }
  ll b = a[0];
  rep(i, 5){
    chmax(a[0], a[i]);
  }
  ll c = a[0];
  ll d = c - b;
  if(d>a[5]){
    print(":(");
  }
  else{
    print("Yay!");
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

double MinksDistance(double *x, double *y, int p, int n);

int main(void){
  int i, n;
  double d1, d2, d3, dm = 0, x[100], y[100];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%lf", &x[i]);
  }
  for(i = 0; i < n; i++){
    scanf("%lf", &y[i]);
    if(fabs(x[i]-y[i]) > dm){
      dm = fabs(x[i]-y[i]);
    }
  }
  d1 = MinksDistance(x, y, 1, n);
  d2 = MinksDistance(x, y, 2, n);
  d3 = MinksDistance(x, y, 3, n);
  printf("%f\n%f\n%f\n%f\n", d1, d2, d3, dm);
  return 0;
}


double MinksDistance(double *x, double *y, int p, int n){
  double dis = 0;
  int i;

  for(i = 0; i < n; i++){
    dis += fabs(pow(x[i]-y[i], p));
  }
  dis = pow(dis, 1.0/p);
  return dis;
}

Measured memory_bytes: 720
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		for(int i=0;i<Math.max(n, m);i++) {
			System.out.print(Math.min(n, m));
		}
		System.out.println();



	}

}


Measured memory_bytes: 21844
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <utility>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define MOD 1000000007

int main(int argc, char const *argv[]) {
  int i,o,t,j,l,s,z;
  cin >> i >> o >> t >> j >> l >> s >> z;
  long k = 0;
  k += o;
  k += (i - i%2);
  k += (j - j%2);
  k += (l - l%2);
  int amari = 0;
  amari += i%2;
  amari += j%2;
  amari += l%2;
  if(amari == 3) k += 3;
  if(amari == 2){
    if(i%2 == 1 && j%2 == 1 && l > 0) k += 1;
    if(j%2 == 1 && l%2 == 1 && i > 0) k += 1;
    if(l%2 == 1 && i%2 == 1 && j > 0) k += 1;
  }
  cout << k << endl;
}


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

using namespace std;


class LazySegT{
private:
  int NN;
  struct Node{
	int f, g, l, r;
	int lazy;
  };
  Node segT[2*(1<<17)-1]; // =131072
public:
  LazySegT(int n){
	NN = 1;
	while(NN < n) NN <<= 1;

	for(int i=0;i<2*NN-1;++i){
	  segT[i].f = segT[i].g = segT[i].l = segT[i].r = 0;
	  segT[i].lazy = -1;
	}
  }

  void eval(int k, int l, int r){
	if(segT[k].lazy < 0) return;
	
	segT[k].f = (r-l) * segT[k].lazy;
	segT[k].g = (r-l-1) * segT[k].lazy;
	segT[k].l = segT[k].r = segT[k].lazy;

	if(k < NN-1){
	  segT[2*k+1].lazy = segT[2*k+2].lazy = segT[k].lazy;
	}
	segT[k].lazy = -1;
  }

  void update(int a, int b, int bit, int k, int l, int r){
	eval(k,l,r);
	if(r <= a || b <= l) return;

	if(a <= l && r <= b){
	  segT[k].lazy = bit;
	  eval(k,l,r);
	}
	else{
	  int m = (l+r) / 2;
	  update(a, b, bit, k*2+1, l, m);
	  update(a, b, bit, k*2+2, m, r);

	  segT[k].f = segT[k*2+1].f + segT[k*2+2].f;
	  segT[k].g = segT[k*2+1].g + segT[k*2+2].g + segT[k*2+1].r * segT[k*2+2].l;
	  segT[k].l = segT[k*2+1].l;
	  segT[k].r = segT[k*2+2].r;
	}
  }
  void update(int a, int b, int c){
	update(a, b, c, 0, 0, NN);
  }

  int query(){
	eval(0, 0, NN);
	return segT[0].f - segT[0].g;
  }
};

int main(){
  int N; cin >> N;
  string X; cin >> X;
  int Q; cin >> Q;

  LazySegT seg(N);
  for(int i=0;i<X.size();++i){
	seg.update(i, i+1, X[i]-'0');
  }

  for(int q=0;q<Q;++q){
	int l, r, b;
	cin >> l >> r >> b;
	--l;
	seg.update(l, r, b);
	cout << seg.query() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 8408
import sys
readline=sys.stdin.readline

H,W=map(int,readline().split())

sy,sx = map(int,readline().split())
gy,gx = map(int,readline().split())

sy -= 1
sx -= 1
gy -= 1
gx -= 1

G = [None] * H
for i in range(H):
  G[i] = readline().rstrip()

# 幅優先探索
INF = 10 ** 10
costs = [[INF] * W for i in range(H)]

from collections import deque
q = deque([])
# y,x,魔法の回数,親y,親x
q.append((sy,sx,0))

cases = {(0,1),(0,-1),(1,0),(-1,0)}
while q:
  y,x,co = q.popleft()
  if costs[y][x] <= co:
    continue
  if G[y][x] == "#":
    continue
  costs[y][x] = co
  for c in cases:
    if 0 <= y + c[0] < H and 0 <= x + c[1] < W:
      if G[y + c[0]][x + c[1]] == "#":
        continue
      if costs[y + c[0]][x + c[1]] <= co:
        continue
      q.appendleft((y + c[0], x + c[1], co))
  for i in range(-2,3):
    for j in range(-2,3):
      if (i,j) in cases or (i,j) == (0,0):
        continue
      if 0 <= y + i < H and 0 <= x + j < W:
        if G[y + i][x + j] == "#":
          continue
        if costs[y + i][x + j] <= co + 1:
          continue
        q.append((y + i, x + j, co + 1))

if costs[gy][gx] == INF:
  print(-1)
else:
  print(costs[gy][gx])


Measured memory_bytes: 236688
#include<stdio.h>
int main()
{
	int N,A,b;
	scanf("%d",&N);
	if(N>=1 && N<=100)
	{
		scanf("%d",&A);
		if(A>=0 && A<=N*N)
		{
			b = N*N-A; 
			printf("%d\n",b);
		}
	}
	return 0;
}

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

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) cout << "Yes" << endl; else cout << "No" << endl;
}

int main() {
    solve();
}

Measured memory_bytes: 256
object Main extends App {
  import scala.math.sqrt
  
  val x = readInt
  
  var p = x-1
  var check = false
  while(!check) {
    p += 1
    check = (2 to sqrt(x).toInt).map{p % _ == 0}.forall{_ == false}
  }
  
  println(p)
}

Measured memory_bytes: 27456
#include<stdio.h>
#define N 100000
int isIncluded(int);//binary search
int arr[N];//first line
int n;//the number of first line
int main(void)
{
  int i;//counter
  int q;//the number of second line
  int x;//the element of second array
  int ans=0;//output
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&arr[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&x);
      ans+=isIncluded(x);
    }
  printf("%d\n",ans);
  return 0;
}
int isIncluded(int x)
{
  int head=0;
  int tail=n-1;
  int middle=(head+tail)/2;
  for(;;)
    {
      if(x==arr[middle]) return 1;
      if(head>tail) break;
      else if(x>arr[middle]) head=middle+1;
      else tail=middle-1;
      middle=(head+tail)/2;
    }
  return 0;
}



Measured memory_bytes: 2144
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int A[25][25];

int main() {
  int N, M, C; cin >> N >> M >> C;
  for (int i = 0; i < M; i++) {
    cin >> Input[i];
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int sum = 0;
    for (int j = 0; j < M; j++) {
      cin >> A[i][j];
      A[i][j] *= Input[j];
      sum += A[i][j];
    }
    if (sum  + C > 0) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin >> n;
  	set<string> s;
  	for(int i =0;i<n;i++){
      	string j;
	    cin >> j;
      	s.insert(j);
    }
  	cout << s.size()<<endl;
	}

Measured memory_bytes: 19144
n = int(input())
a = list(map(int,input().split()))
sum1 = sum2 = cost1 = cost2 = 0
for i in range(n):
    cur = a[i]
    sum1 += cur
    if (sum1<=0, sum1>=0)[i%2]:
        cost1 += 1+sum1*[-1,1][i%2]
        sum1 = [1,-1][i%2]
    sum2 += cur
    if (sum2>=0, sum2<=0)[i%2]:
        cost2 += 1+sum2*[1,-1][i%2]
        sum2 = [-1,1][i%2]
print(min(cost1, cost2))

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

int main(){
  long int n,s=0,c=0,v=0,k; cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    s += a[i];
  }
  
  for(int j=0;j<n;j++){
    s = s - a[j];
    c += a[j];
    if(c>=s){
      k=abs(min(c-s,s-c+2*a[j]));
      break;
    }
  }
  cout<<k<<endl;
	
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

    int x=0,y=0,w=0;

    scanf("%d",&y);
    
    for (int i = 0 ; i < 3 ;++i){
        x = y%10; 
        if(x != 7){
            y=y/10;
        }
        else{ 
            ++w;
            break;
    }
    }
    if(w == 1)
        puts("Yes");
    else    
        puts("No");
    
    return 0;
}
//todo
// !
// ?
// * 

Measured memory_bytes: 1632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n;
	cin >> n;
	map<int, int> a;
	rep(i, n){
		int tmp;
		cin >> tmp;
		a[tmp]++;
	}
	
	int count = 0;
	for(auto itr : a){
		if(itr.second - itr.first < 0){
			count += itr.second;
		}
		else{
			count += itr.second - itr.first;
		}
	}
	cout << count << endl;
	return 0;
}



Measured memory_bytes: 4736
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

int main(){
    int N,K;
    cin>>N>>K;
    vector<int64_t> A(N),sum(N);
    for(auto &a:A) cin>>a;
    sort(A.begin(), A.end());
    int ans = N;
    sum[0]=A[0];
    for(int i=1;i<N;i++)sum[i]=sum[i-1]+A[i];
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(j<=i){
                int64_t lo,up;
                lo=(j?sum[j-1]:0)+K-A[i];
                up=(j?sum[j-1]:0)+K;
                auto lb=lower_bound(sum.begin()+j, sum.begin()+i,lo);
                if(lb!=sum.begin()+i&&*lb<up){
                    ans--;
                    break;
                }
                lo=(j?sum[j-1]:0)+K;
                up=(j?sum[j-1]:0)+K+A[i];
                lb=lower_bound(sum.begin()+i, sum.end(),lo);
                if(lb!=sum.end()&&*lb<up){
                    ans--;
                    break;
                }
            }else{
                int64_t lo,up;
                lo=(j?sum[j-1]:0)+K-A[i];
                up=(j?sum[j-1]:0)+K;
                auto lb=lower_bound(sum.begin()+j, sum.end(),lo);
                if(lb!=sum.end()&&*lb<up){
                    ans--;
                    break;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int fld[700][700];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,D[2];cin>>N>>D[0]>>D[1];
  int d[2]={0,0};
  repeat(k,2){
    while(!(D[k]&1)){
      d[k]++;
      D[k]/=2;
    }
    D[k]<<=d[k];
  }
  //debugArray(d,2);
  vector<Pii> ans;
  repeat(i,2*N){
    repeat(j,2*N){
      bool isok=true;
      repeat(k,2){
        if(d[k]&1){
          isok &= !((i/(1<<((d[k]-1)/2)))&1);
        }else{
          isok &= !((i/(1<<(d[k]/2))+j/(1<<(d[k]/2)))&1);
        }
      }
      if(isok){
        fld[i][j]=1;
        ans.push_back({i,j});
      }
    }
  }
  /*
  if(ans.size()<N*N){
    cerr<<"!!!!!!!"<<endl;
    return 0;
  }
  */

  repeat(i,2*N){
    repeat(j,2*N){
      cerr<<fld[i][j];
    }
    cerr<<endl;
  }

  repeat(i,N*N){
    cout << ans[i].first<<" "<<ans[i].second<<endl;
  }
  return 0;
}


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

namespace ABC141
{
    class A
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            switch(S)
            {
                case "Sunny":
                    Console.WriteLine("Cloudy");
                    break;
                case "Cloudy":
                    Console.WriteLine("Rainy");
                    break;
                case "Rainy":
                    Console.WriteLine("Sunny");
                    break;
                default:
                    break;
            }

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = K; i < N; i++) {
        if (A[i] > A[i-K]) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vector<vi>
#define vll vector<ll>
#define vb vector<bool>
#define vd vector<double>
#define vvll vector<vll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define PI 2*acos(0.0)
#define yes cout<<"Yes"<<endl
#define no cout<<"-1"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
///................function.....................///
#define siz(s) (int)(s.size())
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
int main()
{
    FIO;
    ///freopen("in.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    int n,i,j;
    cin>>n;
    n++;
    vd v(n);
    read(v,1,n);
    vector<vd> dp(n, vd (n));
    dp[0][0]=1;
    for(i=1; i<n; i++)
    {
        dp[i][0] = dp[i-1][0]*(1-v[i]);
        for(j=1; j<=i; j++)
        {
            dp[i][j] = dp[i-1][j-1]*v[i] + dp[i-1][j]*(1-v[i]);
        }
    }

    double sum=0;
    for(i=n/2; i<n; i++)
        sum+=dp[n-1][i];
    cout<<setprecision(15)<<sum<<endl;
    return 0;
}
/**
1
5
5 4 3 2 1
**/


Measured memory_bytes: 73744
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
	long long n;
	string s = "YES";
	cin >> n;
	vector<long long> a(n);

	for (long long i = 0; i < n; i++)
		cin >> a[i];

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

	for (long long i = 0; i < n-1; i++)
	{
		if (a[i] == a[i + 1])
		{
			s = "NO";
			break;
		}
	}

	cout << s << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<int> t(n);
  rep(i,n) cin >> t.at(i);
  int m;
  cin >> m;
  vector<int> p(m),x(m);
  rep(i,m){
    cin >> p.at(i) >> x.at(i);
    p.at(i)--;
  }
  rep(i,m){
    int ans = 0;
    rep(j,n){
      if(j==p.at(i)){
        ans+=x.at(i);
      }else{
        ans+=t.at(j);
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char a[16]={"CODEFESTIVAL2016"};
    char b[16];
    int i,n=0;
    gets(b);
    for(i=0;i<16;i++)
        if(a[i]!=b[i])
            n++;
    printf("%d",n);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int x, i;
    
    i = 1;
    
    while(1)
    {
        scanf("%d", &x);
        if(x == 0)
        {
            break;
        }
        else
        {
            printf("Case %d: %d\n", i, x);
            i++;
        }
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long L, R;
  cin >> L >> R;
  if (L / 2019 != R / 2019) {
    cout << 0 << endl;
    return;
  }
  L %= 2019;
  R %= 2019;
  long result = 2019;
  for (long i = L; i < R; i++) for (long j = i + 1; j <= R; j++) {
    result = min(result, (i * j) % 2019);
  }
  cout << result << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
from fractions import gcd
A, B, C, D = list(map(int, input().split()))
num_B_C = B // C
num_B_D = B // D
lcm_C_D = int(C * D / gcd(C, D))
num_B = B - (num_B_C + num_B_D) + B // lcm_C_D

num_A_C = (A-1) // C
num_A_D = (A-1) // D
num_A = (A-1) - (num_A_C + num_A_D) + (A-1) // lcm_C_D

ans = num_B - num_A
print(ans)

Measured memory_bytes: 5076
local N = io.read("n", "l")
local counts = setmetatable({}, {__index=function()return 0 end})
local max = 0
for i=1,N do
  local s = io.read("l")
  counts[s] = counts[s] + 1
  if counts[s] > max then
    max = counts[s]
  end
end
local anstbl = {}
for s, c in pairs(counts) do
  if c == max then
    table.insert(anstbl, s)
  end
end
table.sort(anstbl)
for i=1,#anstbl do
  print(anstbl[i])
end


Measured memory_bytes: 25696
#include<bits/stdc++.h>
using namespace std;
#define big long long
int main()
{
	//#ifndef ONLINE_JUDGE
		//freopen("take.in","r",stdin);
		//freopen("give.out","w",stdout);
	//#endif

	big n,a,b;
	cin>>n>>a>>b;
	big ans=((n/(a+b))*a);
	ans+=min(a,(n%(a+b)));
	cout<<ans<<endl;

}

Measured memory_bytes: 256