akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define P pair<int,int>
#define enld endl

vector<lint> prime_factorization(lint N) {
	//素因数分解して配列で返す
	vector<lint> R;
	if (N < 2)return R;
	for (lint i = 2; i * i <= N; i++) {
		while (N % i == 0) {
			R.push_back(i);
			N /= i;
		}
	}
	if (N != 1) {
		R.push_back(N);
	}
	return R;
}

lint eulerphi(lint N) {
	double ans = 1;
	vector<lint>V = prime_factorization(N);
	set<lint>S;
	rep(i, V.size()) {
		S.insert(V[i]);
	}
	ans *= N;
	set<lint>::iterator it;
	for (it = S.begin(); it != S.end(); it++) {
		ans *= 1 - 1 / double(*it);
	}
	return ans;
}

int main() {
	lint N;
	cin >> N;
	cout << eulerphi(N) << endl;
}


Measured memory_bytes: 3144
#include<stdio.h>

int main(void){
    int A, B;
    int ans, a, b;
    scanf("%d %d", &A, &B);
    if(A > B){
        a = A-1;
        if(a > B){
            ans = a + A;
        }else{
            ans = A + B;
        }
    }else{
        b = B-1;
        if(b > A){
            ans = B + b;
        }else{
            ans = B + A;
        }
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=3e5+5;
char s[N],a[N],b[N],c;
int main() {
	int n,q,t=0,ta=0,tb=0;
	scanf("%s%d",s,&q);
	n=strlen(s);
	for(int i=0,op;i<q;i++) {
		scanf("%d",&op);
		if(op==1) t++;
		else {
			scanf("%d",&op);
			getchar();
			scanf("%c",&c);
			if(t%2){
                if(op==2) op=1;
                else op=2;
			}
			if(op==1) b[tb++]=c;
			else a[ta++]=c;
		}
	}
	if(t%2==0) {
		for(int i=tb-1;i>=0;i--)
            printf("%c",b[i]);
		for(int i=0;i<n;i++)
            printf("%c",s[i]);
		for(int i=0;i<ta;i++)
            printf("%c",a[i]);
	}
	else {
		for(int i=ta-1;i>=0;i--)
            printf("%c",a[i]);
		for(int i=n-1;i>=0;i--)
            printf("%c",s[i]);
		for(int i=0;i<tb;i++)
            printf("%c",b[i]);
	}
	return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define double long double
#define INF LLONG_MAX
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, m, k, kaijo[200010];
int mypow(int a, int b) {
	if (!b)return 1;
	if (b % 2)return mypow(a, b - 1) * a % moder;
	int c = mypow(a, b / 2);
	return c * c % moder;
}
int comb(int a, int b) {
	return kaijo[a] * mypow(kaijo[a - b], moder - 2) % moder * mypow(kaijo[b], moder - 2) % moder;
}
signed main() {
	cin >> n >> m >> k;
	kaijo[0] = 1;
	REP(i, 200000) {
		kaijo[i] = kaijo[i - 1] * i;
		kaijo[i] %= moder;
	}
	int ans = 0;
	REP(i, n - 1) {
		ans += i * (n - i) % moder * m % moder * m % moder;
		ans %= moder;
	}
	REP(i, m - 1) {
		ans += i * (m - i) % moder * n % moder * n % moder;
		ans %= moder;
	}
	cout << ans * comb(n * m - 2, k - 2) % moder << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll  long long int
#define N 100000
#define M 1000000007
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
  * @author :: Sawlani
  *
  */
int main()
{
  string s;
    cin >> s;
   string k="";
    f(i,0,1)
        k+=s[i];
    string m="";
    f(i,2,3)
        m+=s[i];
   
      if(!(k>"00" && k<="12")&& !(m>"00" && m<="12"))
   {
       cout <<  "NA" << endl;
   }
   else if((k>"00" && k<="12")&& !(m>"00" && m<="12"))
   {
       cout  << "MMYY" << endl;
   }
    else if(!(k>"00" && k<="12")&& (m>"00" && m<="12"))
   {
       cout  << "YYMM" << endl;
   }
    else if((k>"00" && k<="12")&& (m>"00" && m<="12"))
   {
       cout  << "AMBIGUOUS" << endl;
   }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b;
	char op;
	while(1){
	scanf("%d %c %d",&a,&op,&b);
	if(op=='+'){
		printf("%d\n",a+b);
	}
	else if(op=='-'){
		printf("%d\n",a-b);
	}
	else if(op=='*'){
		printf("%d\n",a*b);
	}
	else if(op=='/'){
		printf("%d\n",a/b);
	}
	else if(op=='?'){
		break;
	}
	}
	return 0;
}

Measured memory_bytes: 600
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N = ri()
ans = 0
for i in range(1, N + 1):
    ans += i * (N // i) * (N // i + 1) // 2
print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int n;

	cin >> n;

	if (n == 1) {
		Out("Hello World");
	} else {
		int a, b;

		cin >> a;
		cin >> b;

		Out(a + b);
	}
	
	return 0;
}


Measured memory_bytes: 256
def gcd(a,b):
    if b==0: 
        return a 
    return gcd(b,a%b)
n=int(input())
l=[int(input()) for i in range(n)]
ans=l[0]
for i in range(1,n):
    ans=(ans*l[i])//gcd(ans,l[i])
print(ans)

Measured memory_bytes: 38256
#include<iostream>

using namespace std;

int path[6][2];

void init(){
  //a0,b1,w2,x3,y4,z5
  path[0][0] = 3;
  path[0][1] = 4;
  path[1][0] = 4;
  path[1][1] = 3;
  path[2][0] = 1;
  path[2][1] = 4;
  path[3][0] = -1;
  path[3][1] = 5;
  path[4][0] = 3;
  path[4][1] = -1;
  path[5][0] = 2;
  path[5][1] = 1;

}
int main(){

  init();
  string s;
  while(cin >> s && s != "#"){
    int now = 0;

    for(int i = 0; i < s.length(); i++){
      now = path[now][s[i]-'0'];
      if(now == -1) break;
    }
    if(now == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
map<char,ll> mp;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
 string s; 
 cin>>s;
 ll n=s.size();
 for(int i=0;i<n;i++){
     mp[s[i]]++;
 }
 ll ma=n*(n-1)/2;
 ll same=0;
 for(char c='a';c<='z';c++){
     same+=mp[c]*(mp[c]-1)/2;
 }
 cout<<ma-same+1<<endl;
}

Measured memory_bytes: 720
def inpl(): return list(map(int, input().split()))

N = int(input())
ns = inpl()
nss = sorted(ns)
c1 = nss[int(N/2)-1]
c2 = nss[int(N/2)]
for i in range(N):
	if ns[i] <= c1:
		print(c2)
	else:
		print(c1)

Measured memory_bytes: 26772
#include <bits/stdc++.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	int r = 0;
	for (char c = 'a'; c <= 'z'; ++ c) {
		string s = S;
		for (;;) {
			if (s == string(s.length(), c)) {
				r = max(r, (int)s.length());
				break;
			}
			if (s.length() == 1) break;
			string t(s.length()-1, ' ');
			for (int i = 0; i < (int)s.length()-1; ++ i) {
				t[i] = s[i];
				if (s[i+1] == c) t[i] = c;
			}
			s = t;
		}
	}
	cout << S.length() - r << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
cd = [list(map(int, input().split())) for i in range(M)]
for i in range(N):
  ma = 10000000000
  ans = 0
  for j in range(M):
    a = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])
    if ma > a:
      ans = j+1
      ma = a
  print(ans)
      

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

using namespace std;
using i64 = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())

template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int K = 1000;
const int NMAX = 1000;
#define FILENAME ""   

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
//	freopen("symposium.in", "r", stdin);
//	freopen("symposium.out", "w", stdout);
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int t1 = -10000, t2 = 1e6;
    for (int i = 0; i < n; i++)
    {
    	int x;
    	cin >> x;
    	t1 = max(t1, x); 	
    }
    for (int i = 0; i < m; i++)
    {
     	int x;
     	cin >> x;
     	t2 = min(t2, x);
    }
    if (x >= y)
    {
     	cout << "War";
     	re 0;
    }
    if (t1 >= t2)
    {
     	cout << "War";
     	re 0;
    }
    else 
    {
     	for (int i = t1 + 1; i <= t2; i++)
     	{
     	 	if (i > x && i <= y)
     	 	{
     	 	 	 cout << "No War";
     	 	 	 re 0;
     	 	}
     	}
     	cout << "War";
     	re 0;

    }
    re 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	
	public static void main(String[] args) {
		String alpha = "abcdefghijklmnopqrstuvwxyz";
		int [] counter = new int[27];
		boolean [] result = new boolean[27];
		for (int i = 0; i < counter.length;i++) {
			result[i] = true;
			counter[i] = 0;
		}
		Scanner sc = new Scanner(System.in);
		String in = sc.nextLine();
		char [] array = in.toCharArray();
		for ( int i = 0; i < array.length; i++) {
			String a = Character.toString(array[i]);
			int pos = alpha.indexOf(a);
			counter[pos]++;
		}

		for (int j = 0; j < counter.length; j++) {
			if (counter[j] != 0) {
				if (counter[j] % 2 != 0) {
					result[j] = false;					
				}
			}
			
		}
		boolean isBeatiful = true;
		for (int i = 0; i <result.length;i++){
			if (result[i] == false){
				isBeatiful = false;
			}
		}
		if (isBeatiful) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		
	}
}

Measured memory_bytes: 8788
#include <stdio.h>

int main(void)
{
	int n, b[200];
	int i, j, k, key;
	
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
	}
	
	for(j=2;j<=n;j++)
	{
		for(k=1;k<n;k++)
		{
			printf("%d ", b[k]);
		}
		printf("%d\n", b[k]);
		
		key = b[j];
		i=j-1;
		while(i>0 && b[i]>key)
		{
			b[i+1] = b[i];
			i--;
		}
		b[i+1]=key;
}

for(k=1;k<n;k++)
{
	printf("%d ", b[k]);
}
printf("%d\n", b[k]);
	
	
	
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define ll long long int
#define N 3000
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
        * @author :: Sawlani
        *
        */

ll n;
ll a[N + 1];
ll dp[3001][3001][2];

ll rec(ll i, ll j, ll p)
{
    if (i == j)
        return p == 1 ? a[i] : -a[i];

    if (dp[i][j][p] != -1)
        return dp[i][j][p];

    ll c = rec(i + 1, j, p % 2 + 1);
    ll d = rec(i, j - 1, p % 2 + 1);
    ll ans;
    if (p == 1)
    {
        c = a[i] + c;
        d = a[j] + d;
        ans = (c > d ? c : d);
    }
    else
    {
        c = -a[i] + c;
        d = -a[j] + d;
        ans = (c < d ? c : d);
    }

    return dp[i][j][p] = ans;
}
int main()
{
   // freopen("input.txt", "r", stdin);

    memset(dp, -1, sizeof(dp));
    cin >> n;

    f(i, 1, n) cin >> a[i];

    cout << rec(1, n, 1) << endl;
}

Measured memory_bytes: 141184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define ld long double
#define mod 1000000007ll
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)#define case_g "Case #"<<ti<<": "
#define Debug(x) cout << x << "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const string check = "abacaba";
int main() {
    ll n;
    cin >> n;
    vl a(n);
    for(auto &it: a) cin >> it;
    sort(rall(a));
    ll ans = a[0];
    ll cover = 1;
    for(int i = 1; i < n && cover < n; ++i) {
        if(cover + 2 < n) {
            ans += (2 * a[i]);
            cover += 2;
        }
        else if(cover + 1 < n) {
            ans += a[i];
            ++cover;
        }
        else {
            break;
        }
    }
    cout << ans;
}


Measured memory_bytes: 4824
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w;
	cin >> h >> w;
	vector<vector<char>> mp(h + 2, vector<char>(w + 2));
	fill(all(mp[0]), '.');
	fill(all(mp[h + 1]), '.');
	rep(i, h + 2) mp[i][0] = '.';
	rep(i, h + 2) mp[i][w + 1] = '.';
	rrep(i, h + 1)rrep(j, w + 1) {
		cin >> mp[i][j];
	}
	vector<vector<int>> ans(h + 2, vector<int>(w + 2));
	vector<int> dx = { -1,-1,-1,0,0,1,1,1 };
	vector<int> dy = { -1,0,1,-1,1,-1,0,1 };
	rrep(i, h + 1)rrep(j, w + 1) {
		rep(k, 8) {
			if (mp[i + dx[k]][j + dy[k]] == '#') ans[i][j]++;
		}
	}
	rrep(i, h + 1) {
		rrep(j, w + 1) {
			if (mp[i][j] == '#') cout << mp[i][j];
			else cout << ans[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
 
using namespace std;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;

	string S, T;

	cin >> N >> S >> T;

	for(int i = 0; i < N; i++) {
		cout << S[i] << T[i];
	}


}


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

void solve(){
    int N, K; cin >> N >> K;
    int X, Y; cin >> X >> Y;
    long long sum = 0;
    for(int i = 0; i < K && i < N; ++i) sum += X;
    for(int i = K; i < N; ++i) sum += Y;
    cout << sum << endl;

}

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

Measured memory_bytes: 3552
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a*c <= b) {
		print(c);
	}
	else {
		print(b / a);
	}







	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>
#include <utility>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

int lcm(int a, int b) { return a * b / gcd(a, b); }
void solve(){
    string s;
    cin >> s;
    s += 'O';
    int tmp =0;
    int ans = 0;
    for(int i=0;i<s.length();i++){
        if(s[i] == 'A' || s[i] ==  'G' || s[i] ==  'T' || s[i] ==  'C'){
            tmp++;
        }else{
            if(ans < tmp){
                ans = tmp;
            }
            tmp = 0;
        }
    }
    cout << ans;
}
signed main() {
    solve();
}



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

using vi = vector<int>;
using vvi = vector<vi>;

int main()
{
    ios_base::sync_with_stdio(0);

    int n, m; cin >> n >> m;

    vvi a(n, vi(2));
    vvi b(m, vi(2));

    for(int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1];
    for(int i = 0; i < m; i++) cin >> b[i][0] >> b[i][1];

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

        for(int j = 0; j < m; j++)
            k = min(k, abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1]));

        for(int j = 0; j < m; j++)
        if(abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1]) == k)
        {
            cout << (j + 1) << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
 
const int MAXN = 2e5 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


mt19937 rnd(time(0));


ll pw(ll a, ll x) {
	ll res = 1;
	while (x > 0) {
		if (x & 1) {
			res = (res * a) % MOD;
		}
		a = (a * a) % MOD;
		x >>= 1;
	}
	return res;
}


signed main() {
	int n, k;
	cin >> n >> k;
	vector<bool> has(n);
	forn(i, k) {
		int sz;
		cin >> sz;
		forn(j, sz) {
			int b;
			cin >> b;
			b--;
			has[b] = 1;
		}
	}
	int cnt = 0;
	forn(i, n) {
		if (!has[i]) {
			cnt++;
		}
	}
	cout << cnt << "\n";
 	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
	string a, b;
	while(cin >> a >> b) {
		bool ans = true;
		int sz = a.size();
		for(int i = 0; i < sz && ans; i++) {
			if(a[i] != b[i]) 
				ans = false;
		}
		cout << (ans && (sz == b.size() - 1) ? "Yes" : "No") << endl; 
	}
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
 
int main() {
  int r,g,b,n;
  cin>>r>>g>>b>>n;
  int ans=0;
  for(int i=0;i<=n/r;i++){
    for(int j=0;j<=n/g;j++){
      if((n-(r*i+g*j))%b==0&&n-(r*i+g*j)>=0) ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
#!/usr/bin/env python3

s=input()

ans=tmp=0
t=len(s)

for i in range(1<<(t-1)):
#    print(i)
    tmp=int(s[0])
    for j in range(t-1):
        if (i & (1<<j)):
            tmp*=10
            tmp+=int(s[j+1])
        else:
            ans+=tmp
            tmp=int(s[j+1])
    ans+=tmp
print(ans)

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

const ll INF = 1001001001;


int main(){
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  bool f =true;
  rep(i,n-1){
    if(a[i]==a[i+1]){
      f=false;
      break;
    }
  }
  if(f) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskE {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			long[] a = new long[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextLong();
			}
			long ans = 0;
			while (true) {
				boolean changed = false;
				for (int i = 0; i < n; i++) {
					if (a[i] < n) {
						continue;
					}
					changed = true;
					long x = a[i] / n;
					a[i] -= n * x;
					ans += x;
					for (int j = 0; j < n; j++) {
						if (j != i) {
							a[j] += x;
						}
					}
				}
				if (!changed) {
					break;
				}
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}



Measured memory_bytes: 23508
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    long N = scan.nextInt();
    List<Integer> list = new ArrayList<>();
    for (long i = 0; i < N; i++) {
      list.add(scan.nextInt());
    }

    List<Integer> result = new LinkedList<>();
    for (int j = 1; j <= N; j++) {
      Integer max = list.stream()
          .max((a, b) -> a.compareTo(b)).get();
      for (int i = 0; i < max; i--) {

        if (max > list.size()) {
          System.out.println(-1);
          return;
        }
        if (max.equals(list.get(max - 1))) {
          result.add(max);
          list.remove(max);
          break;
        }
        max--;
      }
    }

    Collections.reverse(result);
    result.stream().forEach(System.out::println);
  }
}


Measured memory_bytes: 29908
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
int ans=99999999;
		String s = sc.nextLine();
for(int i=0;i<=s.length()-3;i++){
	int x=Integer.parseInt(s.substring(i,i+3));

if(Math.abs(753-x)<ans){
	ans=Math.abs(753-x);
}
}
System.out.println(ans);
	}
}

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

using ll = long long;

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

    int n,p;cin>>n>>p;

    vector<int> odd,even;
    for(int i=0;i<n;i++)
    {
        int a;cin>>a;

        if(a%2)odd.push_back(a);
        else even.push_back(a);
    }

    int osz=odd.size();
    int esz=even.size();

    ll ans=0;

    if(osz==0)
    {
        if(p)
        {
            cout<<ans<<"\n";
        }
        else
        {
            ans=pow(2,n);
            cout<<ans<<"\n";
        }
        return 0;
    }

    ans=pow(2,n-1);
    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 4016
void main() {
    long n = readln.chomp.to!int;
    long mod = 10 ^^ 9 + 7;
    long power = 1;
    foreach (i; 1 .. n+1) {
        power = power * i % mod;
    }
    power.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, k; cin >> n >> k;
    map<int,int> mp;
    rep(i,n) {
        int x; cin >> x;
        mp[x]++;
    }
    vint ct;
    for (P p : mp) ct.push_back(p.second);
    sort(all(ct));
    int ans = 0;
    rep(i,ct.size()-k) {
        ans += ct[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 10748
import sys
n = int(input())
input_lines = [input() for i in range(n)]
char_set = set()
for i in range(n):
    line = input_lines[i].split()
    if line[0] == 'insert':
        char_set.add(line[1])
    elif line[0] == 'find' and line[1] in char_set:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 104800
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n;
  cin >> n;
  set<int> a;
  rep(i, n){
    int t;
    cin >> t;
    a.insert(t);
  }
  if (n == a.size()) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 9600
N = int(input())
list_n = list(map(int, input().split()))
M = int(input())
list_m = [[int(i) for i in input().split()] for j in range(M)]

for i in range(M):
    x, y = list_m[i][0], list_m[i][1]
    a = list_n[x-1]
    sum_a = sum(list_n)
    print(sum_a - (a-y))
    

Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
	long A,B,K,i;
	
	scanf("%ld %ld %ld",&A,&B,&K);
	
	if(A+K-1 >= B-K+1)
	{
		for(i=A;i<=B;i++)
		{
			printf("%ld\n",i);
		}
	}
	else
	{
		for(i=A;i<=A+K-1;i++)
		{
			printf("%ld\n",i);
		}
		for(i=B-K+1;i<=B;i++)
		{
			printf("%ld\n",i);
		}
	}
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s: String = sc.next()
    println(answer071bAlt(s))
}

fun answer071bAlt(s: String): String {
    val alphabets: Array<String> = arrayOf(
        "a",
        "b",
        "c",
        "d",
        "e",
        "f",
        "g",
        "h",
        "i",
        "j",
        "k",
        "l",
        "m",
        "n",
        "o",
        "p",
        "q",
        "r",
        "s",
        "t",
        "u",
        "v",
        "w",
        "x",
        "y",
        "z"
    )
    val set: MutableSet<String> = mutableSetOf<String>()
    for (c: Char in s) {
        set.add(c.toString())
    }
    for (i: Int in alphabets.indices) {
        if (!set.contains(alphabets[i])) {
            return alphabets[i]
        }
    }
    return "None"
}

Measured memory_bytes: 41376
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
	long long n, x;
	scanf("%lld %lld", &n, &x);
	long long ans = n;
	n -= x;
	while (true) {
		if (n % x == 0) {
			ans += 2 * x * (n / x) - x;
			break;
		} else {
			ans += 2 * x * (n / x);
		}
		long long res = n % x;
		n = x;
		x = res;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int, int>P;

const int MAX_N = 1400;

int a[MAX_N][MAX_N];
int dp[MAX_N][MAX_N];

int main()
{
	int h, w;
	cin >> h >> w;
	int ans = 0;
	rep(i, h) {
		rep(j, w) {
			scanf("%d", &a[i][j]);
			if (a[i][j] == 0) {
				dp[i][j] = 1;
				ans = 1;
			}
		}
	}
	for (int i = 1; i<h; i++) {
		for (int j = 1; j<w; j++) {
			if (a[i][j] == 0) {
		 dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
				ans = max(ans, dp[i][j]);
			}
			else {
				dp[i][j] = 0;
			}
		}
	}
	cout << ans*ans << "\n";
}

Measured memory_bytes: 18532
#include <bits/stdc++.h>
using namespace std;
#define maxn 300010
#define ll long long
#define db double
#define vi vector<int>
#define pb push_back
#define mod 998244353
#define fi first
#define pi pair<int, int>
#define se second
#define mp make_pair
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
// head
int n;
ll a, b, k;
ll jc[maxn], bjc[maxn];
ll c(int a, int b) {
	return jc[a] * bjc[b] % mod * bjc[a - b] % mod;
}
int main() {
	cin >> n >> a >> b >> k;
	jc[0] = bjc[0] = 1;
	for (int i = 1; i < maxn; i++)
		jc[i] = jc[i - 1] * i % mod, 
		bjc[i] = ksm(jc[i], mod - 2);
	ll ans = 0;
	for (int i = 0; i <= n; i++) {
		ll ns = k - a * i;
		if (ns % b) continue;
		ns /= b;
		if (ns < 0 || ns > n) continue;
		ll nans = c(n, ns) * c(n, i);
		ans = (ans + nans) % mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define oo 0x3fffffff
#define N 505
using namespace std;


long long n,k,a,b,m,d[N];

int main(void){
    long long i,j,x,y;
    //freopen("in.txt","r",stdin);
    scanf("%lld %lld %lld",&k,&a,&b);

    if(b-a<=2 || k<a+1){
        printf("%lld",k+1);
        return 0;
    }

    x=1;
    k -=(a+1);
    x=a;
    x +=(b-a);
    x +=(b-a)*(k/2);
    if(k%2==1) x++;

    printf("%lld",x);
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	int count = 0;
	if (s.at(0) == 0) {
		for (int i = 0; i < s.size(); i++) {
			if (i % 2 == 0 && s.at(i) == '1')count++; 
			if (i % 2 == 1 && s.at(i) == '0')count++; 
		}
	}
	else {
		for (int i = 0; i < s.size(); i++) {
			if (i % 2 == 0 && s.at(i) == '0')count++;
			if (i % 2 == 1 && s.at(i) == '1')count++;
		}
	}
	int rest = s.size() - count;
	cout << min(count, rest) << endl;
}

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

#define x first
#define y second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define REP(i, a) FOR(i, 0, a)
#define TRACE(x) cout << #x << " " << x << endl
#define _ << " _ " <<

using namespace std;

//#define task "a"
#define oo 1e9

const int MAXM = 100010;

class inter {
 public:
  int h, l;
  vector<int> V;
  void reset() {
    h = l = 0;
    V.clear();
  }
} a[MAXM*2];

int n, m, q;
int par[MAXM*2];
vector<int> graf[MAXM*2];

int nadji(int x) {
  if (par[x] == x) return x;
  return par[x] = nadji(par[x]);
}

void spoji(int i1, int i2) {
  i1 = nadji(i1);
  i2 = nadji(i2);
  par[i1] = i2;
  //  printf("Spajam %d %d\n", i1, i2);
}

int cnt;
int sol[MAXM*2];
int bio[MAXM*2];

int mini[MAXM*2];

void DFS(int curr) {
  //  TRACE(curr);
  mini[curr] = oo;
  if (curr <= n) {
    mini[curr] = curr;
    //    sol[cnt++] = curr;
    //    bio[curr] = 1;
  }
  for (auto it: graf[curr]) {
    DFS(it);
    mini[curr] = min(mini[curr], mini[it]);
  }
sort(graf[curr].begin(), graf[curr].end(), [](const int &i1, const int &i2) { return mini[i1] < mini[i2]; });
}

void DFS2(int curr) {
if (curr <= n) {
sol[cnt++] = curr;
bio[curr] = 1;
}

for (auto it: graf[curr]) DFS2(it);

}

int main(){
  while(1==1) {
    cnt = 1;
    memset(sol, 0, sizeof sol);
    memset(bio, 0, sizeof bio);
    memset(mini, 0, sizeof mini);
    REP(i, MAXM*2) par[i] = i;
    //  freopen(task ".in", "r", stdin);
    //  freopen(task ".out", "w", stdout);

    scanf("%d%d%d", &n, &m, &q);
    if (n == 0 && m == 0 && q == 0) break;
    REP(i, m) {
      scanf("%d%d", &a[i].h, &a[i].l);
      REP(j, a[i].l) {
	int pom;
	scanf("%d", &pom);
	a[i].V.pb(pom);
      }
    }
    sort(a, a + m, [](const inter &i1, const inter &i2){ return i1.h > i2.h; });

    int tr = n + 1;
    REP(i, m) {
      REP(j, a[i].V.size()) {
	int pom = nadji(a[i].V[j]);
	graf[tr].pb(pom);
	//	printf("Edge %d %d\n", tr, pom);
	spoji(pom, tr);
      }
      tr++;
    }
    for (int i = tr - 1; i > 0; i--) {
      if (par[i] == i) {
	par[i] = tr;
	graf[tr].pb(i);
	//	printf("Edge %d %d\n", tr, i);     
      }
    }
    
    DFS(tr);
    DFS2(tr);
    //    FOR(i, 1, n+1) {
    //      if (bio[i] == 0) sol[cnt++] = i;
    //    }

    REP(i, q) {
      int pom;
      scanf("%d", &pom);
      printf("%d\n", sol[pom]);
    }

    REP(i, tr+1) {
      graf[i].clear();
      a[i].reset();
    }
    printf("\n");
  }
  
  
  return 0;
}

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

namespace Pair0
{
    class Program
    {
        static void Main(string[] args)
        {
            int x1,y1,x2,y2;

            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            x1 = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
            y1 = int.Parse(str[1]);
            x2 = int.Parse(str[2]);
            y2 = int.Parse(str[3]);

            int x = x2 - x1;
            int y = y2 - y1;

            int x3 = x2 - y;
            int y3 = y2 + x;
            int x4 = x3 - x;
            int y4 = y3 - y;

            Console.Write(x3 + " ");
            Console.Write(y3 + " ");
            Console.Write(x4 + " ");
            Console.WriteLine(y4);
        }
    }
}


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

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

    switch(N%7){
        case 2 : cout<<"sat\n"; break;
        case 3 : cout<<"sun\n"; break;
        case 4 : cout<<"mon\n"; break;
        case 5 : cout<<"tue\n"; break;
        case 6 : cout<<"wed\n"; break;
        case 0 : cout<<"thu\n"; break;
        case 1 : cout<<"fri\n"; break;
        default : break;
    }
}


Measured memory_bytes: 3092
#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()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    bool zero = false;
    ll a[n];
    rep(i, n) {
        cin >> a[i];
        if (a[i] == 0) zero = true;
    }
    if(zero){
        cout << 0 << endl;
        return 0;
    }
    __int128_t ans = 1;
    for (int i = 0; i < n; i++) {
        ans *= a[i];
        if (ans > (__int128_t)LINF) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << (ll)ans << endl;
    return 0;
}

Measured memory_bytes: 4424
from collections import deque
import sys
sys.setrecursionlimit(int(1e7))

def inpl(): return list(map(int, input().split()))

N = int(input())
G = [[] for _ in range(N+1)]

X = [-1 for _ in range(N+1)] # is odd
U = [1e7 for _ in range(N+1)]
L = [-1e7 for _ in range(N+1)]

for _ in range(N-1):
    a, b = inpl()
    G[a].append(b)
    G[b].append(a)

K = int(input())
for _ in range(K):
    v, p = inpl()
    U[v], L[v], X[v] = p, p, p%2

searched = [0]*(N+1)

def dfs(u, l, x, i):
    searched[i] = True
    if X[i] >= 0 and X[i] != x:
        X[i] = 2
        return -1e7, 1e7
    U[i] = min(U[i], u)
    L[i] = max(L[i], l)
    X[i] = x

    for j in G[i]:
        if searched[j]:
            continue
        nu, nl = dfs(U[i]+1, L[i]-1, (X[i]+1)%2, j)
        U[i] = min(U[i], nu+1)
        L[i] = max(L[i], nl-1)
    return U[i], L[i]

dfs(U[v], L[v], X[v], v)

Q = [v]
searched = [0]*(N+1)
answer = [0]*(N+1)
answer[v] = U[v] 
OK = True

if max(X) == 2:
    OK = False
    Q = []

while Q:
    p = Q.pop()
    for q in G[p]:
        if searched[q]:
            continue
        searched[q] = True
        Q.append(q)
        if L[q] <= answer[p] + 1 <= U[q]:
            answer[q] = answer[p] + 1
        elif L[q] <= answer[p] - 1 <= U[q]:
            answer[q] = answer[p] - 1
        else:
            OK = False
            Q = []
            break
if OK:
    print("Yes")
    print(*answer[1:], sep="\n")
else:
    print("No")

Measured memory_bytes: 137108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000

int main(){
    ll H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<(H*W-(h*W+w*H-h*w));
}

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

int main(){
	int maxP=-1, maxD=-1;
	int p, d1, d2;
	int num;
	while(cin >> num, num){
		maxD = 0;
		for(int i=0; i< num; i++){
			cin >> p >> d1 >> d2;
			maxD = max(maxD, d1 + d2);
			if(maxD == d1+d2) maxP = p;
		}
		cout << maxP << " " << maxD << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    for(;;){
        int y[2], m[2], d[2];
        for(int i=0; i<2; ++i){
            cin >> y[i] >> m[i] >> d[i];
            if(y[i] < 0 || m[i] < 0 || d[i] < 0)
                return 0;
        }

        long long sum[2] = {0};
        for(int i=0; i<2; ++i){
            for(int j=1; j<y[i]; ++j){
                sum[i] += 365;
                if(j % 400 == 0 || (j % 100 != 0 && j % 4 == 0))
                    ++ sum[i];
            }
            for(int j=1; j<m[i]; ++j){
                sum[i] += month[j];
                if(j == 2 && (y[i] % 400 == 0 || (y[i] % 100 != 0 && y[i] % 4 == 0)))
                    ++ sum[i];
            }
            sum[i] += d[i];
        }

        cout << (sum[1] - sum[0]) << endl;
    }
}

Measured memory_bytes: 0
n = int(input())

ac = wa = tle = re = 0
for i in range(n):
    s = input()
    if s == 'AC':
        ac += 1
    elif s == 'WA':
        wa += 1
    elif s == 'TLE':
        tle += 1
    elif s == 'RE':
        re += 1
print('AC x', ac)
print('WA x', wa)
print('TLE x', tle)
print('RE x', re)

Measured memory_bytes: 9216
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;

int N,K;
vector<int> pt(3);
string T;
const string hand = "rsp";

int main()
{
	cin>>N>>K;
	rep(i,3)cin>>pt[i];
	cin>>T;

	vector<vector<int>> dp(N,vector<int>(3,0));
	rep(i,K)rep(j,3){
		if(T[i]==hand[(j+1)%3])dp[i][j]=pt[j];
	}
	REP(i,K,N)rep(j,3){
		const int befScore= max(dp[i-K][(j+1)%3], dp[i-K][(j+2)%3]);
		if(T[i]==hand[(j+1)%3]){
			dp[i][j] = befScore + pt[j];
		}else{
			dp[i][j] = befScore;
		}
	}
	int res = 0;
	REP(i, max(0, N-K), N){
		res += *max_element(dp[i].begin(),dp[i].end());
	}
	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 5760
#include<iostream>
// #include<string>
using namespace std;

int findSumOfDigits(int n){
    int sum=0;
    while(n>0){
        sum +=n %10;
        n /=10;
    }
    return sum;
}

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    int total=0;
    for (int i=1;i<=N; ++i){
        int sum=findSumOfDigits(i);
        if (sum >=A && sum <=B){
            total +=i;
        }
    }

    cout <<total <<endl;
}

Measured memory_bytes: 256
// Problem : A - Frog 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;

#define ff first
#define fs second
#define lb lower_bound
#define ub upper_bound

#define int long long
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector< vi >
#define vpii vector< pii >
#define vb vector<bool>
#define si set<int>
#define mii map<int, int>
#define mci map<char, int>
#define md 1000000007
#define pb push_back
#define eb emplace_back
#define fio ios_base::sync_with_stdio (false); cin.tie (NULL);  cout.tie (NULL);
#define qw1(x) cerr<<#x<<": "<<x<<" "<<endl
#define qw2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define qw3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define qw4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl


#define f(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define rl(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define all(x) x.begin(),x.end()
#define endl '\n'
void printv(vector<int>  v){ for(int i=0;i<v.size();i++) cout<<v[i]<<' '; cout<<endl;   }
int bem(int m , int n, int mod) { int res=1; while(n){
	     			        if(n%2!=0) { res*=m; res%=mod; }
	    			        m*=m;   m%=mod;   n/=2;
			                          }
				return res;	}
int be(int a, int b) { int res=1; 	while(b){
				if(b%2!=0) res*=a;
				a*=a; b/=2;
				}
			return res;	}
void sieve(int n, vb &prime){
    prime[0]=false;     prime[1]=false;
    for(int i=2;i*i<=n;i++){
         if(prime[i]==true){
              for(int j=i*i;j<=n;j+=i)    prime[j]=false;
             	  }
    	 }
	}

void solve()
  {
int n; cin>>n;
vi v(n); f(i, 0, n-1) cin>>v[i];
vi dp(n, 0);
dp[1]=abs(v[1]-v[0]);
dp[2]=abs(v[2]-v[0]);
f(i, 3, n-1) dp[i]=min(dp[i-1]+ abs(v[i]-v[i-1]), dp[i-2]+abs(v[i]-v[i-2]));

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

int32_t main ()
{
//fio
int t=1; 
//cin>>t; 
while(t--){
	solve();
}
 
}








Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> PP;
static const int MAX_N = 100;
struct Point{int x, y; bool is_red;};

int N;
Point p[2 * MAX_N];

bool comp(const Point &a, const Point &b){
	return (a.x == b.x) ? (a.y < b.y) : (a.x < b.x);
}
int main() {
	vector<int> va;
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> p[i].x >> p[i].y;
		p[i].is_red = true;
	}
	for(int i = N; i < 2 * N; i++){
		cin >> p[i].x >> p[i].y;
		p[i].is_red = false;
	}
	sort(p, p + 2 * N, comp);
	int ans = 0;
	for(int i = 0; i < 2 * N; i++){
		if(p[i].is_red){
			va.push_back(p[i].y);
			sort(va.begin(), va.end());
		}
		else if(!p[i].is_red && !va.empty()){
			if(va[0] >= p[i].y) continue;
			else{
				for(int j = va.size() - 1; j >= 0; j--){
					if(va[j] < p[i].y){
						ans++;
						va.erase(va.begin() + j);
						break;
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
cards = int(input())
i = 0
cardlist = []
while(i < cards):
    cardlist.append(list(map(str,input().split())))
    i += 1
SP = [False] * 13
HR = [False] * 13
CL = [False] * 13
DY = [False] * 13

for i in cardlist:
    num = int(i[1])-1
    if  (i[0] == "S"):
        SP[num] = True
    elif(i[0] == "H"):
        HR[num] = True
    elif(i[0] == "C"):
        CL[num] = True
    elif(i[0] == "D"):
        DY[num] = True

c = 0
for i in SP:
    c += 1
    if i == False:
        print("S %d" %c)
c = 0
for i in HR:
    c += 1
    if i == False:
        print("H %d" %c)
c = 0
for i in CL:
    c += 1
    if i == False:
        print("C %d" %c)
c = 0
for i in DY:
    c += 1
    if i == False:
        print("D %d" %c)


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

int main(){
	int n;
	cin >> n;
	int p[n];
	for(int i = 0; i < n; i++) cin >> p[i];
	int a[n];
	int b[n];
	int s[n];
	for(int i = 0; i < n; i++) s[p[i]-1] = i;
	a[0] = 1;
	b[0] = 999999999;
	for(int i = 1; i < n; i++){
		a[i] = a[i-1] + 20000 - s[i-1] + s[i];
		b[i] = b[i-1] - 20000;
	}
	for(int i = 0; i < n; i++){
		cout << a[i] << " ";
	}
	cout << endl;
	for(int i = 0; i < n; i++){
		cout << b[i] << " ";
	}
	cout << endl;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using longlong=long long;

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    std::string s;std::cin>>s;
    int ans=700;
    for(char c:s){
        if(c=='o')ans+=100;
    }
    std::cout<<ans<<std::endl;
}

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

typedef long long ll;
typedef long double ld;

#define fi first;
#define se second;
int x[400][400];

int main() {
    //ios_base::sync_with_stdio(0);
    //cout<<setprecision(20);
    int n;
    cin>>n;
    char s[400][400];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)
            cin>>s[i][j];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int  y=1;
            for(int k=0;k<n;k++){
                int t1=k+i;
                int t2=k+j;
                if(t1>=n) t1-=n;
                if(t2>=n) t2-=n;
                if(s[t1][j]!=s[i][t2]){
                    y=0;
                }
            }
         //   cout<<y;
            x[i][j]=y;
        }
       // cout<<endl;
    }   
    int ans=0;
    for(int k=0;k<n;k++){
        bool y=1;
        for(int i=0;i<n;i++){
            int t=(k+i)%n;
            if(x[t][i]==0){
                y=0;
            }
        }
        if(y==1){
            ans++;
        }
    }
    cout<<ans*n;
}

Measured memory_bytes: 896