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

int main(void) {
  int n, a[1000];
  scanf("%d", &n);
  for (int i = 0; i < 2 * n; ++i) scanf("%d", a + i);
  sort(a, a + 2 * n);
  int sum = 0;
  for (int i = 0; i < n; ++i) sum += a[2 * i];
  printf("%d\n", sum);
}


Measured memory_bytes: 128
#include <stdio.h>
    int  main(void) {
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        if(a,b,c<=100 && a,b,c>=-100){
        if(a<=c && c<=b){
            printf("Yes\n" );
        }else{
            printf("No\n");
        }
        }else{
        printf("No\n");
        }
        return 0;
    }

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

int main(int argc,char* argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG=1;}
  dprint("start");

  int A,B,C,K; cin>>A>>B>>C>>K;
  int count = 0;
  while(A>=B){
    B *= 2;
    ++count;
  }
  while(B>=C){
    C *= 2;
    ++count;
  }
  if(count<=K){
    cout << Liny;
  }else{
    cout << Linn;
  }
}

Measured memory_bytes: 3576
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
def p(a):print(" ".join(list(map(str,a))))
from collections import Counter

s=S()
if s.isupper():print('A')
else:print("a")


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

#define ll long long
#define endl "\n"
#define int ll

void debug(map <int, int> &mp) {
	cout << "New " << endl;
	for (auto &i : mp) {
		cout << i.first << " " << i.second << endl;
	}
}

signed main ()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, p;
	cin >> n >> p;
	int ans = 0;
	string s;
	cin >> s;

	if (p == 2) {
		for (int i = n - 1; i >= 0; i--) {
			int digit = s[i] - '0';
			if (digit % 2 == 0) {
				ans += i + 1;
			}
		}

		cout << ans << endl;
		return 0;
	}

	if (p == 5) {
		for (int i = n - 1; i >= 0; i--) {
			int digit = s[i] - '0';
			if (digit % 5 == 0) {
				ans += i + 1;
			}
		}

		cout << ans << endl;
		return 0;
	}

	map <int, int> mp;
	mp[0] = 1;

	int temp = 1;
	int current = 0;

	for (int i = n - 1; i >= 0; i--) {
		int digit = s[i] - '0';
		current = (current + (temp * digit) % p) % p;
		ans += mp[current];
		mp[current]++;
		temp *= 10;
		temp %= p;
		//debug(mp);
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 4084
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <iostream>
#include <vector>
using namespace std;

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

  for (int i = 1; i <= 10000000; i++) {
    int sum = i * (i + 1) / 2;
    if (sum < N) {
      continue;
    }
    int diff = sum - N;
    for (int j = 1; j <= i; j++) {
      if (j == diff) {
        continue;
      }
      cout << j << endl;
    }
    break;
  }
  return 0;
}


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

    val size = readLine()!!
    val numList = readLine()!!.split(" ").map(String::toInt)

    // スタンダードなInt? -> Intの型変換方法は？
    val min = numList.min()!!
    val max = numList.max()!!
    println(max - min)
}

Measured memory_bytes: 37956
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()

    var ans = 0
    for (i in 1 until b - a) {
        ans += i
    }
    ans -= a
    println(ans)
}


Measured memory_bytes: 31276
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
//-0.4620981203755741
int main(){
    int n,q;
    std::cin >> n>>q;
    std::vector<tuple<int,int,int>> a;
    rep(i,n){
        int ss,tt,xx;
        std::cin >> ss>>tt>>xx;
        a.pb(make_tuple(ss-xx,1,xx));
        a.pb(make_tuple(tt-xx,-1,xx));
    }
    rep(i,q){
        int dd;
        std::cin >> dd;
        a.pb(make_tuple(dd,2,0));
    }
    sort(all(a));
    set<int> s;
    rep(i,a.size()){
        int d,dd,ddd;
        tie(d,dd,ddd)=a[i];
        if(dd==-1){
            s.erase(ddd);
        }
        else if(dd==1){
            s.insert(ddd);
        }
        else if(dd==2){
            if(s.empty())std::cout << -1 << std::endl;
            else std::cout << *s.begin() << std::endl;
        }
    }
}

Measured memory_bytes: 19176
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N) cin>>A[i];

  rep(i,N){
    if(A[i]%2) continue;
    if(A[i]%3!=0&&A[i]%5!=0){
      cout<<"DENIED"<<endl;
      return 0;
    }
  }

  cout<<"APPROVED"<<endl;

  return 0;
}


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

string str;
int countOne = 0;

int main() {
	cin >> str;
	for (int i = 0; i < 3; i++) {
		if (str.at(i) == '1') {
			countOne++;
		}
	}
	cout << countOne << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s,t;
	cin>>s>>t;
	int sl=s.length();
	int tl=t.length();
	int ar[sl][tl];
	int v=0;
	for(int i=0;i<tl;i++)
	{
		if(s.at(0)==t.at(i))v=1;
		ar[0][i]=v;
	}
	v=0;
	for(int i=0;i<sl;i++)
	{
		if(s.at(i)==t.at(0))v=1;
		ar[i][0]=v;
	}
	for(int i=1;i<sl;i++)
	{
		for(int j=1;j<tl;j++)
		{
			if(s.at(i)==t.at(j))
			{
				ar[i][j]=ar[i-1][j-1]+1;
			}
			else
			{
				ar[i][j]=max(ar[i-1][j],ar[i][j-1]);
			}
		}
	}
	string ans=" ";
	int ps=sl-1,pt=tl-1;
	while(ps>=0 &&pt>=0 &&ar[ps][pt]!=0)
	{
		if(ps==0)
		{
			while(s.at(ps)!=t.at(pt))pt--;
			ans=t.at(pt)+ans;break;
		}
		if(pt==0)
		{
		    while(s.at(ps)!=t.at(pt))ps--;
			ans=s.at(ps)+ans;break;
		}
		if(ar[ps][pt]!=max(ar[ps-1][pt],ar[ps][pt-1]))
		{
			ans=s.at(ps)+ans;
			ps--;pt--;
		}
		else if(ar[ps][pt]==ar[ps-1][pt])
		{
			ps--;
		}
		else
		{
			pt--;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void) {
	int n, i, a[200003];
	ll an[200003] = {}, sum = 0;

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		an[a[i]]++;
	}

	for (i = 1; i <= n; i++) {
		sum += an[i] * (an[i] - 1) / 2;
	}

	for (i = 0; i < n; i++) {
		cout << sum - an[a[i]] + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 4864
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        Integer l[] = new Integer[n];
        for (int i = 0; i < l.length; i++) {
            l[i] = s.nextInt();
        }
        Arrays.sort(l, Collections.reverseOrder());
        int sum = 0;
        for (int i = 0; i < l.length; i++) {
            if (i % 2 == 0) {
                sum = sum + l[i];
            } else {
                sum = sum - l[i];
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23892
unittest
{
	assert( [ "15 10",
		"snake snake snake snake snake snake snake snake snake snake",
		"snake snake snake snake snake snake snake snake snake snake",
		"snake snake snake snake snake snake snake snake snake snake",
		"snake snake snake snake snake snake snake snake snake snake",
		"snake snake snake snake snake snake snake snake snake snake",
		"snake snake snake snake snake snake snake snuke snake snake",
		"snake snake snake snake snake snake snake snake snake snake",
		"snake snake snake snake snake snake snake snake snake snake",
		"snake snake snake snake snake snake snake snake snake snake",
		"snake snake snake snake snake snake snake snake snake snake",
		"snake snake snake snake snake snake snake snake snake snake",
		"snake snake snake snake snake snake snake snake snake snake",
		"snake snake snake snake snake snake snake snake snake snake",
		"snake snake snake snake snake snake snake snake snake snake",
		"snake snake snake snake snake snake snake snake snake snake" ].parse.expand.solve == "H6" );
	assert( [ "1 1", "snuke" ].parse.expand.solve == "A1" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hw = input.front.split.to!( long[] );
	auto sss = new dstring[][]( hw[ 0 ], hw[ 1 ] );
	foreach( ref ss; sss )
	{
		input.popFront;
		ss = input.front.split.to!( dstring[] );
	}
	return tuple( sss );
}

auto solve( dstring[][] sss )
{
	foreach( r, ss; sss )
	{
		foreach( c, s; ss )
		{
			if( s == "snuke" ) return cast( dchar )( 'A' + c ) ~ ( r + 1 ).to!dstring;
		}
	}
	assert( false );
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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; }
using namespace std;

class UnionFindS{
private:
    vector<int> par;
public:
    UnionFindS(int n){
        par=vector<int>(n,-1);
    }
    int find(int x){
        if(par.at(x)<0) return x;
        else return par.at(x)=find(par.at(x));
    }
    int size(int x){
        return -par.at(find(x));
    }
    void unite(int x, int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(size(x)<size(y)) swap(x,y);
        par.at(x)+=par.at(y);
        par.at(y)=x;
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
};

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<int> a(n),b(n);
    rep(i,n){
        cin>>a.at(i);
        b.at(a.at(i)-1)=i;
    }
    UnionFindS uni(n);
    int ans=0;
    for(int i=n-1; i>=0; i--){
        int pl=b.at(i);
        int s=0,t=0;
        if(pl>0)if(a.at(pl-1)>i+1){
            s=uni.size(pl-1);
            uni.unite(pl,pl-1);
        }
        if(pl<n-1)if(a.at(pl+1)>i+1){
            t=uni.size(pl+1);
            uni.unite(pl,pl+1);
        }
        ans+=(i+1)*(s+1)*(t+1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())
    BC = [list(map(int, input().split())) for i in range(Q)]

    g = {}
    ans = 0
    for a in A:
        ans += a
        if a not in g:
            g[a] = 1
        else:
            g[a] += 1

    for i in range(Q):
        B, C = tuple(BC[i])
        if B in g:
            t = g.pop(B)
            ans += t * (C - B)
            if C in g:
                g[C] += t
            else:
                g[C] = t
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 37084
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const ll mod = 1e9 + 7;
typedef pair<ll,ll>P;

int main(){

  int a,b;cin>>a>>b;

  out(max(a+b,max(a-b,a*b)));

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	if (n % 10 == 9 || n / 10 == 9)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	cout << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n" 
const int INF = (int) 1e9 + 9;
const int maxn = (int) 1e6 + 6;
const int mod = (int) 1e9 + 7;

using namespace std;

signed main() {

    int n, k; cin >> n;

    vector<int> h(n), dp(n, INF);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }

    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);

    for(int i = 2; i < n; i++){
        int one = dp[i-1] + abs(h[i-1] - h[i]);
        int two = dp[i-2] + abs(h[i-2] - h[i]);
        dp[i] = min(one, two);
    }

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



    return 0;
}

Measured memory_bytes: 1792
# AtCoder
N = int(input())
lst = [input() for _ in range(N)]
ac = 0
wa = 0
tle = 0
re = 0


for s in lst:
    if s == 'AC':
        ac += 1
    elif s == 'WA':
        wa += 1
    elif s == 'TLE':
        tle += 1
    else:
        re += 1

print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))


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

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  
  if (s == t){
    cout << ans << endl;
  }
  
  else{
    for (int i = 0; i < 200001; i++){
      if (s[i] != t[i]){
        s[i] = t[i];
        ans += 1;
        if (i+1 == (int)s.length()){
          break;
        }
      }
    }
  cout << ans << endl;
  }
}

Measured memory_bytes: 3820
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int A = cin.NextInt();
            int B = cin.NextInt();
            Console.WriteLine(A * B);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 27544
using System;
using System.Linq;

namespace CADDi2018C
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            long[] inp = Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
            long N = inp[0];
            long P = inp[1];

            if (N == 1)
            {
                Console.WriteLine(P);
                return;
            }

            long Max = Convert.ToInt64(Math.Pow(P, 1.0 / N));
            long ans = 1;
            for (int i = 2; i <= Max; i++)
            {
                if (P % i == 0)
                {
                    if (P % Convert.ToInt64(Math.Pow(i, N)) == 0)
                    {
                        ans = i;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}

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

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define EPS 1e-8
#define DEB 0

const int dx[] = {0,1,0,-1};
const int dy[] = {-1,0,1,0};
int w,h,sx,sy,home,last;
int field[16][16];
int num[16][16];

class state{
public:
  char x,y;
  int s;
  state(char _x, char _y, int _s){
    x = _x;
    y = _y;
    s = _s;
  }
  
  bool operator<(const state& a)const{
    if( x==a.x ){
      if( y==a.y ) return s<a.s;
      else         return y<a.y;
    }else{
      return x<a.x;
    }
  }
  
};


map<state,int> msi;

bool ischeck(int s){
  return (((last&s)) == last) ;
}
bool inside(char x, char y){
  return (x<0 || y<0 || x>=w || y>=h);
}


int dfs(char x, char y, int s){
  if( (1<<home)-1 == s ){ //âÎÉßêé
    return 1;
  }
  if( msi.count(state(x,y,s)) ){ //ùÉÊÁ½óÔ
    return msi[state(x,y,s)];
  }
  if( ischeck(s) ){
    return 0;
  }
  
  int ret = 0;
  rep(k,4){
    for(int i=1; i<20; i++){
      char tx = x + dx[k]*i;
      char ty = y + dy[k]*i;
      if( inside(tx,ty) ) break;
      if( field[ty][tx]==1 ){
	field[ty][tx] = 0;
	ret += dfs(tx,ty,s|(1<<num[ty][tx]));
	field[ty][tx] = 1;
	break;
      }
    }
  }
  msi[state(x,y,s)] = ret;
  return ret;
}

int main(){

  while(scanf("%d%d",&w,&h),w|h){
    msi.clear();
    memset(num,-1,sizeof(num));
    home = last = 0;
    rep(i,h){
      rep(j,w){
	scanf("%d",&field[i][j]);
	if( field[i][j]==2 ){
	  sx = j;
	  sy = i;
	}
	if( field[i][j]==1 ){
	  num[i][j] = home;
	  home++;
	}
      }
    }

    //last homes
    rep(k,4){
      for(int i=1; i<20; i++){
	char tx = sx + dx[k]*i;
	char ty = sy + dy[k]*i;
	if( inside(tx,ty) )break;
	if( field[ty][tx]==1 ){
	  last |= (1<<num[ty][tx]);
	}
      }
    }

    dfs(sx,sy,0);
    printf("%d\n",msi[state(sx,sy,0)]);
  }
  

  return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll odd(ll a){ return (a+1)/2%2; }

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b; cin>>a>>b; a--;
  ll xa,xb;
  if(a%2==1){
    xa=odd(a);
  }else{
    xa=odd(a+1)^(a+1);
  }
  if(b%2){
    xb=odd(b);
  }else{
    xb=odd(b+1)^(b+1);
  }
  cout<<(xa^xb)<<endl;
}


Measured memory_bytes: 256
/*A*算法*/
#include<iostream>   
#include<cstdio>  
#include<algorithm>
#include<queue>
#include<map>
#include<string>
using namespace std;
const int row = 4;
const int maxx = 16;
const int LIMIT = 100;
struct Puzzle {
    int f[maxx], space, MD;
    int cost;
    bool operator < (const Puzzle &p) const {
        for (int i = 0; i < maxx; i++) {
            if (f[i] != p.f[i])
                return f[i] < p.f[i];
        }
        return false;
    }
};

struct State {
    Puzzle puzzle;
    int estimated;
    bool operator < (const State &s) const {
        return estimated > s.estimated;
    }
};
const int dx[4] = { 0, -1, 0, 1 };
const int dy[4] = { 1, 0, -1 ,0 };
const char dir[4] = { 'r','u','l','d' };
int MDT[maxx][maxx];


int getAllMD(Puzzle pz) {
    int sum = 0;
    for (int i = 0; i < maxx; i++) {
        if (pz.f[i] != maxx)
            sum += MDT[i][pz.f[i] - 1];
    }
    return sum;
}

int astar(Puzzle s) {

    priority_queue<State> PQ;
    s.MD = getAllMD(s);
    s.cost = 0;
    map<Puzzle, bool> V;
    Puzzle u, v;
    State initial;
    initial.puzzle = s;
    initial.estimated = getAllMD(s);
    PQ.push(initial);

    while (!PQ.empty()) {
        State st = PQ.top(); PQ.pop();
        u = st.puzzle;
        if (u.MD == 0)
            return u.cost;
        V[u] = true;
        int sx = u.space / row;
        int sy = u.space % row;
        for (int r = 0; r < 4; r++) {
            int tx = sx + dx[r];
            int ty = sy + dy[r];
            if (tx < 0 || ty < 0 || tx >= row || ty >= row)
                continue;
            v = u;
            // 计算曼哈顿距离的差值，同时交换拼图
            v.MD -= MDT[tx * row + ty][v.f[tx * row + ty] - 1];
            v.MD += MDT[sx * row + sy][v.f[tx * row + ty] - 1];

            swap(v.f[tx * row + ty], v.f[sx * row + sy]);
            v.space = tx * row + ty;
            if (!V[v]) {
                v.cost++;
                State news;
                news.puzzle = v;
                news.estimated = v.cost + v.MD;
                PQ.push(news);
            }
        }
    }

    return -1;
}


int main()
{
    for (int i = 0; i < maxx; i++) {
        for (int j = 0; j < maxx; j++) {
            MDT[i][j] = abs(i / row - j / row) + abs(i % row - j % row);
        }
    }
    Puzzle in;
    for (int i = 0; i < maxx; i++) {
        cin >> in.f[i];
        if (in.f[i] == 0) {
            in.f[i] = maxx;
            in.space = i;
        }
    }

    printf("%d\n", astar(in));
    return 0;
}



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

int main() {
    int n;
    cin >> n;
    int a;
    int count = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        while (a > 0) {
            if (a%2 == 0) {
                a /= 2;
                count++;
            } else break;
        }
    }
    cout << count << endl;
}

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

using namespace std;

int main(){
string S,N;
cin >>S>>N;
int ans=0;
if(S[0]==N[0])ans++;
if(S[1]==N[1])ans++;
if(S[2]==N[2])ans++;
cout <<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int main() {
	scanf("%d",&n);
	for(int i=1,x;i<=n;i++){
		scanf("%d",&x);
		if(x%2==0){
			if(x%3!=0&&x%5!=0){
				printf("DENIED");
				return 0;
			}
		}
	}
	printf("APPROVED");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
	while(1){
		int h,w;
		scanf("%d %d\n", &h,&w);
		if(h==0 && w ==0) break;

		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 3172
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion
void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int N;
    cin >> N;
    ll m = 1;
    REP(i, N){
        int A;
        cin >> A;
        if(A%2==0){
            m *= 2;
        }
    }
    cout << (int)(pow(3, N)-m) << el;
}



Measured memory_bytes: 4060
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-9;

int main() {
	for (;;) {
		int n; cin >> n;
		if (n == 0) break;
		vector<int> a(n);
		vector<bool> b(n);
		for (int i = 0; i < n; i++) {
			string s; cin >> s;
			if (s == "x") b[i] = true;
			else {
				stringstream ss(s);
				ss >> a[i];
			}
		}
		bool flag = true;
		int lb = INT_MIN, ub = INT_MAX;
		for (int i = 0; i + 1 < n; i += 2) {
			if (b[i] && b[i + 1]) flag = false;
			else if (!b[i] && !b[i + 1]) {
				if (a[i] >= a[i + 1]) flag = false;
			}
			else {
				if (b[i]) ub = min(ub, a[i + 1] - 1);
				else lb = max(lb, a[i] + 1);
			}
		}
		for (int i = 1; i + 1 < n; i += 2) {
			if (b[i] && b[i + 1]) flag = false;
			else if (!b[i] && !b[i + 1]) {
				if (a[i] <= a[i + 1]) flag = false;
			}
			else {
				if (b[i]) lb = max(lb, a[i + 1] + 1);
				else ub = min(ub, a[i] - 1);
			}
		}
		if (!flag || lb > ub) cout << "none" << endl;
		else if (lb < ub) cout << "ambiguous" << endl;
		else cout << lb << endl;
	}
}

Measured memory_bytes: 1228
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    string s;
    cin >> s;
    int n=s.size();
    int cnt=0;
    if(s[0]=='A'){
        for(int i=2;i<n-1;i++){
            if(s[i]=='C'){
                cnt+=1;
            }
        }
        if(cnt!=1){
            cout << "WA";
            return 0;
        }
    }
    else{
        cout << "WA";
        return 0;
    }
     
    rep(i,n){
        bool frag = false;
        if(s[i]=='A'||s[i]=='C'){
            continue;
        }
        else {
            for(char q='a';q<='z';q++){
                if(s[i]==q){
                    frag = true;
                    break;
                }
            }
            if(frag){
                continue ;
            }
            else{
                cout << "WA";
                return 0;
            }
        }
    }
    cout << "AC";

    return 0;
}

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

bool a[150000]{};
int sosuu[10000]{};
int main() {
	int s = 0;
	for (int b = 2; b <= 110000; b++) {
		if (!(a[b])) {
			s++;
			for (int c = b * 2; c <= 150000; c += b)a[c] = true;
			sosuu[s + 1] = sosuu[s] + b;
		}
   }
	int e;
	while (cin >> e, e) {
		cout << sosuu[e + 1] << endl;
	}
}

Measured memory_bytes: 3180
#include <stdio.h>
#include<string.h>

#define LENGTH 256

int main(void) {
    char input[LENGTH];
        fgets(input, LENGTH, stdin);
        if(strncmp(&input[2],&input[3],1)==0){
          if(strncmp(&input[4],&input[5],1)==0){
          printf("Yes\n");
          }else{
            printf("No\n");
          }
        }else{
        printf("No\n");
        }
    return 0;
}


Measured memory_bytes: 1532
use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn main() {
    input! {
        n: i32,
    }

    let a = n % 1000;
    if a == 0 {
        println!("0");
    } else {
        println!("{}", 1000 - a);
    }
}

Measured memory_bytes: 2080
#include <bits/stdc++.h>
#define int long long
int v[50*101][51];
using namespace std;

signed main(){
  int N,A;
  cin>>N>>A;
  int x;
  std::vector<int> y(N);
  for(int i=0;i<N;i++){
    cin>>x;
    y[i]=x-A;
  }
  for(int i=0;i<N*101;i++)for(int j=0;j<N;j++)v[i][j]=0;
  v[N*50][0]=1;
  for(int j=1;j<N+1;j++){
    for(int i=50;i<N*101-50;i++){
      v[i][j]=v[i][j-1]+v[i-y[j-1]][j-1];
    }
  }
  cout<<v[N*50][N]-1<<endl;
}


Measured memory_bytes: 2304
n, k = gets.chomp.split(" ").map(&:to_i);
holder = []
1.step(n, 1) do |i|
  holder[i] = false
end
1.step(k, 1) do |i|
  d = gets.chomp.to_i
  a_arr = gets.chomp.split(" ").map(&:to_i);
  a_arr.each do |j|
    holder[j] = true
  end
end

puts holder.select{ |e| e == false}.count


Measured memory_bytes: 14372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;
template<typename T> T factorial(T n){
    if(n==1) return 1;
    else return n*factorial(n-1)%MOD;
}
template<typename T> T Pow(T x, T n, T m){
    if(n == 0) return 1;
    if(n % 2 == 0) return Pow(x * x % m, n / 2, m);
    else return x * Pow(x, n - 1, m) % m;
}
template<typename T> T combination(T n, T k, T m){
    return factorial<T>(n) * Pow<T>(factorial(k), m-2, m) % m * Pow<T>(factorial(n-k), m-2, m) % m;
}
struct edge{
    int to; // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using graph = vector<vector<edge>>;
using Graph = vector<vector<int>>;

int main(){
    double l; cin >> l;
    cout << setprecision(12) << (l/3.0)*(l/3.0)*(l/3.0) << endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;

const int N = 2e5 + 5;
const int mod = 998244353;

vector < pair < int, int > > t (4 * N), vec;

void build (int v, int tl, int tr) {
  if (tl == tr) {
    t[v] = {vec[tl].first + vec[tl].second, tl};
  } else {
    int tm = (tr - tl) / 2 + tl;
    build (2 * v, tl, tm);
    build (2 * v + 1, tm + 1, tr);
    t[v] = max(t[2 * v], t[2 * v + 1]);
  }
}

pair < int, int > query (int v, int tl, int tr, int l, int r) {
  if (l > r) return {INT_MIN, INT_MIN};
  if (tl == l && tr == r) {
    return t[v];
  }
  int tm = (tr - tl) / 2 + tl;
  return max (query (2 * v, tl, tm, l, min (r, tm)), query (2 * v + 1, tm + 1, tr, max (l, tm + 1), r));
}

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

  int n;
  cin >> n;
  vec.resize (n);
  for (auto &i : vec) cin >> i.first >> i.second;

  vec.push_back ({INT_MIN, INT_MIN});
  sort (vec.begin(), vec.end());
  vec.push_back ({INT_MAX, INT_MAX});

  build (1, 1, n);

  vector < ll > dp (n + 2), idx (n + 2);
  dp[n] = 2;
  idx[n] = n + 1;
  for (int i = n - 1; i >= 1; i--) {
    idx[i] = i;
    int j = upper_bound (vec.begin(), vec.end(), make_pair (vec[i].first + vec[i].second, INT_MIN)) - vec.begin();
    if (j == i) idx[i] = i + 1;
    else {
      pair < int, int > p = query (1, 1, n, i, j - 1);
      if (p.second == i) {
        idx[i] = j;
      } else {
        idx[i] = idx[p.second];
      }
    }

    dp[i] = dp[i + 1] + max (dp[idx[i]], (ll)1);
    dp[i] %= mod;
  }

  cout << dp[1] << '\n';
}


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


int main() {
    int n;
    cin >> n;
    vector<int> L(n);
    rep(i,n) cin >> L[i];
    sort(L.begin(),L.end());
    int ans = 0;

    rep(i,n-2) {
        for (int j=i+1; j<(n-1); j++){
            int sum = L[i] + L[j];
            int r = lower_bound(L.begin(), L.end(), sum) - L.begin();
            int l = j+1;
            ans += r - l;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	char alpha; cin >> alpha;
	cout << (isupper(alpha) ? 'A' : 'a');

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int N=310;

int n, m, k, u, v, x, y, t, l, r, ans;
int dp[N][N][N];
vector<pii> vec[N];

inline void fix(int &x){
	if (x>=mod) x-=mod;
	if (x<0) x+=mod;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m;
	while (m--){
		cin>>l>>r>>x;
		vec[r].pb({l, x});
	}
	dp[0][0][0]=1;
	for (int r=0; r<n; r++) for (int g=0; g<n; g++) for (int b=0; b<n; b++) if (dp[r][g][b]){
		int x=max({r, g, b})+1;
		bool R=1, G=1, B=1;
		for (pii p:vec[x]){
			int l=p.first, ted=p.second-1;
			int rr=(l<=r), gg=(l<=g), bb=(l<=b);
			B&=(rr+gg==ted);
			G&=(rr+bb==ted);
			R&=(bb+gg==ted);
		}
		if (B) fix(dp[r][g][x]+=dp[r][g][b]);
		if (G) fix(dp[r][x][b]+=dp[r][g][b]);
		if (R) fix(dp[x][g][b]+=dp[r][g][b]);
	}
	for (int r=0; r<=n; r++) for (int g=0; g<=n; g++) for (int b=0; b<=n; b++)
		if (max({r, g, b})==n) fix(ans+=dp[r][g][b]);
	cout<<ans<<"\n";
	
	return 0;
}


Measured memory_bytes: 114488
#include <stdio.h>

double hantei(double,double,double,double,double,double,double,double);

int main(){
double x1,x2,x3,y1,y2,y3,xp,yp;
double heix,heiy;
int f;

while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
f=0;
heix=(x1+x2+x3)/3;
heiy=(y1+y2+y3)/3;
if(hantei(x1,y1,x2,y2,xp,yp,heix,heiy)<0.0){
f=1;
}
if(hantei(x1,y1,x3,y3,xp,yp,heix,heiy)<0.0){
f=1;
}
if(hantei(x2,y2,x3,y3,xp,yp,heix,heiy)<0.0){
f=1;
}
if(f==1){
printf("NO\n");
}
else if(f==0){
printf("YES\n");
}
}
return 0;
}

double hantei(double p1x,double p1y,double p2x,double p2y,double p3x,double p3y,double p4x,double p4y)
{
double a;
a=((p1x-p2x)*(p3y-p1y)+(p1y-p2y)*(p1x-p3x))*((p1x-p2x)*(p4y-p1y)+(p1y-p2y)*(p1x-p4x));
return a;
}

Measured memory_bytes: 612
from math import *
a, b, x = map(int, input().split())
if a*a*b == x:
    theta = 0
elif a*a*b > 2*x:
    theta = degrees(pi/2 - atan(2*x/(a*pow(b,2))))
else:
    theta = degrees(pi/2 - atan(pow(a,3)/(2*(pow(a,2)*b - x))))
print(theta)

Measured memory_bytes: 3188
#include<stdio.h>

int main(){
  int M[100][100];
  int i,j,n,u,k,v;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j==n-1){
	printf("%d",M[i][j]);
      }
      else{
      printf("%d ",M[i][j]);
      }
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2112
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		int e = Math.min(a, b);
		int f = Math.min(c, d);
		System.out.println(e + f);
	}
}

Measured memory_bytes: 21844
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		boolean go = true;
		for(int i=0;i<n;i++){
			if(go==false) System.out.println();
			go = false;
			
			int[][] map = new int[9][9];
			int[][] check = new int[9][9];
			
			for(int j=0;j<9;j++){
				for(int k=0;k<9;k++){
					map[j][k] = sc.nextInt();
				}
			}
			
			int[] list;
			for(int j=0;j<9;j++){
				list = new int[10];
				for(int k=0;k<9;k++){
					list[map[j][k]]++;
				}
				for(int k=1;k<=9;k++){
					if(list[k]>1){
						for(int p=0;p<9;p++){
							if(map[j][p]==k) check[j][p]++;
						}
					}
				}
			}
			
			for(int j=0;j<9;j++){
				list = new int[10];
				for(int k=0;k<9;k++){
					list[map[k][j]]++;
				}
				for(int k=1;k<=9;k++){
					if(list[k]>1){
						for(int p=0;p<9;p++){
							if(map[p][j]==k) check[p][j]++;
						}
					}
				}
			}

			for(int j=0;j<9;j+=3){
				for(int k=0;k<9;k+=3){
					list = new int[10];
					for(int p=0;p<3;p++){
						for(int q=0;q<3;q++){
							list[map[j+p][k+q]]++;
						}
					}
					for(int r=1;r<=9;r++){
						if(list[r]>1){
							for(int p=0;p<3;p++){
								for(int q=0;q<3;q++){
									if(map[j+p][k+q]==r) check[j+p][k+q]++;
								}
							}
						}
					}
				}
			}
				
			for(int j=0;j<9;j++){
				for(int k=0;k<9;k++){
					if(check[j][k]==0) System.out.print(" ");
					else System.out.print("*");
					System.out.print(map[j][k]);
				}
				System.out.println();
			}		
		}
	}	
}

Measured memory_bytes: 23332
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    x = N%K
    while True:
        tmp = x
        x = min(abs(x - K), x)
        if tmp == x:
            break
    print(x)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int ans=0,now=1e9,N,aa;

int main(){
    cin>>N;
    rep(i,N-1){
        cin>>aa;
        ans+=min(now,aa);
        now=aa;
    }
    out(ans+aa);

    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1061109567
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s,"r",stdin);
#define out(s) freopen(s,"w",stdout);
#define fi first
#define se second
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
#define fa(i,x) for (auto i:x)
using namespace std;
typedef pair<int, int> edge;
string s;
int cur = 0;
vector<edge> e;
void bad() {
	cout << "-1";
	exit(0);
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s;
	int n = s.length();
	s = " " + s;
	fw (i, 1, n) if (s[i] != s[n - i]) bad();
	if (s[1] == '0') bad();
	if (s[n] == '1') bad();
	int lstsz = 1;
	cur = 1;
	fw (i, 2, n + 1) if (s[i] == '1') {
		int k = i - lstsz;
		e.pb({cur + k, cur});
		fw (j, cur + 1, cur + k) e.pb({cur + k, j});
		cur = cur + k;
		lstsz = i;
	}
	e.pb({n, cur});
	fa (i, e) cout << i.fi << " " << i.se << "\n";
	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

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

int main()
{
    string S;
    cin >> S;
    if (S[0] == S[1] and S[1] == S[2])
    {
        OUT("No");
    }
    else
    {
        OUT("Yes");
    }
}

Measured memory_bytes: 256
n = int(input())
if n == 100000:
  print(90909)
elif 1 <= n <= 9:
  print(n)
elif 10 <= n <= 99:
  print(9)
elif 100 <= n <= 999:
  c = n - 99
  print(9 + c)
elif 1000 <= n <= 9999:
  print(909)
elif 10000 <= n <= 99999:
  c = n - 9999
  print(c + 909)

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

using namespace std;
int ans = -1;
int n,m,q;
vector<int> temp;
void dfs(int i, int pos, vector<vector<int>>& val){
	if(i == n){
		int score = 0;
		for(int k = 0; k < q; k++){
			if(temp[val[k][1]-1] == temp[val[k][0]-1]+val[k][2]){
				score += val[k][3];
			}
		}
		ans = max(ans,score);
		return;
	}
	for(int k = pos; k <= m; k++){
		temp.push_back(k);
		dfs(i+1,k,val);
		temp.pop_back();
	}
	return;
}

int main()
{
	cin >> n >> m >> q;
	vector<vector<int>> arr(q,vector<int>(4));
	for(int i=0; i < q; i++){
		for(int j = 0; j < 4; j++){
			cin >> arr[i][j];
		}
	}
	dfs(0,1,arr);
	cout << ans;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <numeric>

using namespace std;

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

    int result = n / (d * 2 + 1);
    if(n % (d * 2 + 1) != 0){
        result++;
    }
    cout << result << endl;

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> data(N);
    bool answer = false;
    for(int i=0; i<N; i++){
        cin >> data.at(i);
    if(data.at(i) % 2 ==0 && data.at(i) % 3 != 0 && data.at(i) % 5 != 0){
          answer = true;
        }
    }
if(answer) cout << "DENIED" << endl;
else cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if(x >= r && y >= r && (H - r) >= y && (W - r) >= x) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2104