akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int>v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  vector<int>dp(n,0);
  dp[1]=abs(v[1]-v[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(abs(v[i]-v[i-1])+dp[i-1],abs(v[i]-v[i-2])+dp[i-2]);
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 1024
from operator import itemgetter
from math import gcd
from collections import Counter

N = int(input())
mod = int(1e9+7)

zero = 0
P = {}
for i in range(N):
  a,b = list(map(int, input().split()))
  if a == 0 and b == 0:
    zero += 1
    continue
  g = gcd(a,b)
  a,b = a//g, b//g
  if b < 0:
    a,b = -a,-b
  if b == 0 and a < 0:
    a,b = -a,b  
  #rot90
  rot90 = a<=0
  if rot90:
    a,b = b,-a
  #add
  if not (abs(a),b) in P:
    P[(a,b)] = [0,0]
  if not rot90 :
    P[(a,b)][0] += 1
  else:
    P[(a,b)][1] += 1
    
ans = 1
for k,v in P.items():
  #print(k,v)
  s,t = v
  wk = 1 + pow(2,s,mod) - 1 + pow(2,t,mod) - 1
  ans *= wk
  ans %= mod
  
ans += zero

print((ans - 1) % mod)

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<62);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;


int T, N, A, B, C, D;
map<int, int> dp;

int dfs(int cur) {
    if(cur == 0) { return 0; }
    if(cur == 1) { return D; }
    if(dp.count(cur) > 0) { return dp[cur]; }

    int ret = LLINF;
    if(cur < ret / D) { ret = cur * D; }

    // + か - どっちか近い方で割り切れるやつに行く
    auto SubDiv = [&](int div, int add) { 
        int cand1 = cur % div;
        int cand2 = div - (cur % div);
        if(cand1 == 0) {
            chmin(ret, dfs((cur - cand1) / div) + D * cand1 + add);
        }
        else if(cand2 == 0) {
            chmin(ret, dfs((cur + cand2) / div) + D * cand2 + add);
        }
        else {
            chmin(ret, dfs((cur - cand1) / div) + D * cand1 + add);
            chmin(ret, dfs((cur + cand2) / div) + D * cand2 + add);
        }
    };
    SubDiv(2, A);
    SubDiv(3, B);
    SubDiv(5, C);

    dp[cur] = ret;
    return ret;
}

int solve() {
    cin >> N >> A >> B >> C >> D;
    dp.clear();
    int ret = dfs(N);
    return ret;
}

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

    cin >> T;
    REP(i, T) {
        int ans = solve();
        printf("%lld\n", ans);
    }

    return 0;
}


Measured memory_bytes: 4588
N,K =map(int,input().split())
List = list(map(int,input().split()))
DP = [False]*(2*K+1)
for i in range(K):
  for item in List:
    if DP[i]==False:
      DP[i+item] = True
if DP[K]==True:
  print('First')
else:
  print('Second')

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

int res = 1e8, chk[26], maxx[26];
string str;

int main() {
	memset(maxx, -1, sizeof(maxx));
	cin >> str;
	int len = str.length();

	for (char c = 'a'; c <= 'z'; ++c) {
		for (int i = 0; i < len; ++i) {
			if (str[i] == c) {
				maxx[str[i] - 'a'] = max(maxx[str[i] - 'a'], (i - chk[str[i] - 'a']));
				chk[str[i] - 'a'] = i + 1;
			}
		}
		maxx[c - 'a'] = max(maxx[c - 'a'], (len - chk[c - 'a']));

		res = min(res, maxx[c-'a']);
	}

	cout << res;

}

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


class Program
{
    static void Main(string[] args)
    {
        string[] NXY = Console.ReadLine().Split(' ');
        int N = int.Parse(NXY[0]);
        int X = int.Parse(NXY[1]);
        int Y = int.Parse(NXY[2]);

        int[] output = new int[N-1];
        int distance = 0;

        for(int i=1; i<=N-1; i++){
            for(int j=i+1; j<=N; j++){
                if(i<=X && j<=X){
                    distance = j - i;
                }else if(i<=X && X<j && j<Y){
                    distance = Math.Min(j-i, X+Y-i-j+1);
                }else if(i<=X && Y<=j){
                    distance = X-Y-i+j+1;
                }else if(X<i && i<Y && X<j && j<Y){
                    distance = Math.Min(j-i, -X+Y+i-j+1);
                }else if(X<i && i<Y && Y<=j){
                    distance = Math.Min(j-i, -X-Y+i+j+1);
                }else{
                    distance = j - i;
                }

                output[distance-1] += 1;
            }
        }

        for(int i=0; i<N-1; i++){
            Console.WriteLine(output[i]);
        }
    }
}

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

int main()
{
    int n , close=0 , to=0 , to1=0;

    cin >> n;

    string s;

    cin >> s;

    for(int i = 0 ; i<s.size() ; i++)
    {
        if(s[i]=='(')
            close++;
        else
            close--;
        to = min(to , close);
    }
    for(int i = to ; i<0 ; i++)
    {
        cout << "(";
    }
    cout << s;
    for(int i = to ; i<close ; i++)
    {
        cout << ")";
    }

}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::BTreeMap;


fn main() {
  let mut n = read::<i64>();
  let mut map: BTreeMap<i64, i64> = BTreeMap::new();


  for i in 0..n {
    let a = read::<i64>();
    let b = read::<i64>();
    let current = map.entry(b).or_insert(0);
    *current += a;
  }

  let mut work = 0;
  let mut ans = "Yes";

  for (k, v) in map.iter() {
    work += *v;
    if k < &work {
      ans = "No"
    }
  }

  println!("{}", ans);
}


Measured memory_bytes: 8444
#include<stdio.h>
int main()
{
    int a,b,t;
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        for(t=1;t!=0;)
        {
            t=a%b;
            a=b;
            b=t;
        }
        printf("%d\n",a);
        t=1;
    }
    return 0;
}



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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    double n;
    cin >> n;

    cout << 2.0 * n * 3.141592 << endl;
}


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

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) ((lli)(x).size())
#define endl '\n'

#ifdef SANJU
    #define localsys 1
#else
    #define localsys 0
#endif

using   lli     =   long long;
using   lld     =   long double;
using   ulli    =   unsigned long long int;
using   pll     =   pair<lli, lli>;
using   ttt     =   pair<lli, pll>;
using   vttt    =   vector<ttt>;
using   vll     =   vector<pll>;
using   vl      =   vector<lli>;
using   vi      =   vector<int>;
using   vvi     =   vector<vector<int>>;
using   cd      =   complex<lld>;

void sanjeev(int kkkk)
{
    int n;
    cin>>n;
    vector<int>A;
    A.push_back(0);
    for(int i=0;i<n;i++)
    {
        int t;
        cin>>t;
        A.push_back(t);
    }

    long long int dp[n+1][n+1]={0};

    for(int i=n;i>0;i--)
    {
        for(int j=i;j<=n;j++)
        {
            if(i==j)dp[i][j]=A[i];
            else
            {
                dp[i][j]=max(A[i]-dp[i+1][j],A[j]-dp[i][j-1]);
            }
        }
    }
    cout<<dp[1][n];

}

int main()
{
    if(!localsys) ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    fol(i,0,t) { sanjeev(i+1); }
    if(localsys) system("pause");
}


Measured memory_bytes: 70656
q=int(input())
for _ in range(q):
  a,b=map(int,input().split())
  if a>b:
    a,b=b,a
  if a==b:
    print(2*a-2)
  elif b==a+1:
    print(2*a-2)
  else:
    c=int((a*b)**0.5)-1
    while (c+1)*(c+1)<a*b:
      c+=1
    if c*(c+1)>=a*b:
      print(2*c-2)
    else:
      print(2*c-1)

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

using namespace std;

int main(){
    string S;
    cin >> S;
    bool app[26];
  	string board = "abcdefghijklmnopqrstuvwxyz";
    for (int i = 0; i< 26; i++){
        app[i] = false;
    }

    for (int i = 0; S[i] != '\0'; i++){
        app[S[i] - 'a'] = true;
      //	cout << S[i] - 'a' << endl;
    }
    for (int i = 0; i < 26; i++){
        if (app[i] == 0){
            cout << board[i] << endl;
            return 0;
     // cout << S[i]-'a' << " " << app[S[i]-'a'] << endl;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;
const ll use =1e6;

int main()
{ 
  

ll x;
cin>>x;

bool prime[use];
memset(prime,1,sizeof(prime));

for(ll i=2;i*i<=use-1;i++)
{
	if(prime[i])
		for(ll j=i*i;j<=use-1;j+=i)
			prime[j]=0;
  }

  for( ll i=x;i<use;i++)
  {
  	if(prime[i])
  	{
  		cout<<i<<endl;
  		break;
  	}
  }
}


Measured memory_bytes: 1280
//TDPC E-数 https://tdpc.contest.atcoder.jp/tasks/tdpc_number
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int const MOD = 1e9 + 7;
ll N;
vector<ll> v;
int a[100010];
int main(void)
{
    int A, B, K; cin >> A >> B >> K;
    
    for(int i=0; i<K; ++i){
        if(i%2==0){
            if(A%2==1) A--;
            B += A/2;
            A/=2;
        }else{
            if(B%2==1) B--;
            A+=B/2;
            B/=2;
        }
    }
    cout << A << " " << B << endl;
    return 0;
}

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

int main(){
	int H,W;
	while(1){
	cin >> H >>W;

	if(H==0 && W==0) break;

	for(int i=0;i<H;i++){
		for (int j=0;j<W;j++){
			cout << "#";
		}
		cout << endl;
	}
	cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
 
const int oo = 1e9 + 7;
const int mod = 1e9 + 7;
const double PI = acos(-1);

ll lcm(ll a, ll b){
    ll ans = a*b;
    return (ans)/(__gcd(a, b));
}
 
 
int main (){
    ll n, m, resto = 0, mul=1, x;

    cin >> n >> m;

    set<ll> v;

    for (int i=0; i<n; i++) {
        cin >> x;
        x/=2;
        v.insert(x);
        mul = x;
    }
    for (auto x: v){
        mul = lcm(mul, x);
    }
    for (auto x: v) resto+= (mul/x)%2;
    if (resto != (int)v.size()){
        cout << 0 << endl;
        return 0;
    }

    ll ans = (m/mul)/2 + (m/mul)%2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
people, foods = map(int, input().split(' '))
buckets = [0] * (foods + 1)
for i in range(people):
  a = list(map(lambda x: int(x), input().split(' ')))
  favorite_foods = a.pop(0)
  for food_num in a:
    buckets[food_num] += 1

count = 0
for food in buckets:
  if food == people:
    count += 1

print (count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() 
{
    int N; cin >> N;
    vector<int> V(N); for (auto &v : V) cin >> v;
    vector<int> C(N); for (auto &c : C) cin >> c;
    vector<pair<double, int>> P(N);
    for (int i = 0; i < N; i++) {
        P[i] = make_pair((double)V[i] / C[i], i);
    }
    sort(rbegin(P), rend(P));
    int ans = 0, x = 0, y = 0;
    for (int i = 0; i < N; i++) {
        x += V[P[i].second];
        y += C[P[i].second];
        ans = max(ans, x - y);
    }
    cout << ans << endl;
    return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int fac[100010];

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

	fac[0] = 1, fac[1] = 1;
	rep(i, 2, 100005)
	{
		fac[i] = i * fac[i - 1];
		fac[i] %= MOD;
	}

	int N, M;
	cin >> N >> M;

	if (abs(N - M) == 1)
	{
		cout << (fac[N] * fac[M]) % MOD << endl;
	}
	else if (N == M)
	{
		cout << (2 * ((fac[N] * fac[M]) % MOD)) % MOD << endl;
	}
	else
	{
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                1000000007
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr(a,n)           for(ll i=0;i<n;i++){ cin>>a[i]; }
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= mod;} b >>= 1; x *= x; x %= mod;} return p % mod;}
using namespace std;
# define INF 1e15
struct lex_compare {
    bool operator() (const pair<db,ll>  p1, const pair<db,ll> p2){
        return (p1.first ==  p2.first) ? p1.ss < p2.ss : p1.first > p2.first;
    }
};
#define MAXN 1005


int main(){
    FIO;
    ll n; cin >> n;
    ll ans = 0;
    forn(i,1,n+1){
        ll a; cin >> a;
        if(i%2 == 1 && a%2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
  int x, y;
  cin >> x >> y;
  int ans = 0;
  
  if(x == 1)
    ans += 300000;
  else if(x == 2)
    ans += 200000;
  else if(x == 3)
    ans += 100000;

  if(y == 1)
    ans += 300000;
  else if(y == 2)
    ans += 200000;
  else if(y == 3)
    ans += 100000;
  
  if(ans == 600000)
    cout << 1000000 << endl;
  else 
    cout << ans;
  
  return 0;
}


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

int compare(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}

int main(void) {
	int n;
	int score[1024];

	while (true) {
		std::cin >> n;
		if (!n) break;

		for (int i = 0; i < n; i++) std::cin >> score[i];

		qsort(score, n, sizeof(int), compare);
		double sum = 0;
		for (int i = 1; i < n - 1; i++) sum += score[i];
		int ave = int(sum / (n-2));
		std::cout << ave << '\n';
	}
	return 0;
}

Measured memory_bytes: 3048
#include <iostream>
#define MAX(a,b) (((a)>(b))?(a):(b))
using namespace std;

int m,n;
int a[90][90];
int now=0;
int ma=0;

int walk(int i,int j){
	if(a[i][j]==0)return 0;
	if(!(0<=i&&i<m&&0<=j&&j<n))return 0;
	now++;
	// cout<<i<<" "<<j<<" "<<now<<endl;
	ma=MAX(ma,now);
	a[i][j]=0;
	walk(i+1,j);
	walk(i-1,j);
	walk(i,j+1);
	walk(i,j-1);
	a[i][j]=1;
	now--;
	return 0;
}

int main(void){
	while(cin>>m>>n,n||m){
		ma=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				cin>>a[i][j];
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				walk(i,j);
			}
		}
		cout<<ma<<endl;
	}
}

Measured memory_bytes: 2968
import java.util.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) {
    Main main = new Main();
    main.solve();
    main.show();
  }

  int n;
  int a[];
  boolean rev;
  Deque<Integer> deq = new ArrayDeque<Integer>();
  int ans;

  public Main() {
    Scanner sc = new Scanner(System.in);
    try {
      n = sc.nextInt();
      a = IntStream.range(0, n).map(i -> sc.nextInt()).toArray();
    } finally {
      sc.close();
    }
  }
  
  void solve() {
    for (int i = 0; i < n; i++) {
      if (i % 2 == 0) deq.addLast(a[i]);
      else deq.addFirst(a[i]);
    }
  }

  void show() {
    if (n % 2 == 0) showForward();
    else showReverse();
  }

  void showForward() {
    for (int i = 0; i < n; i++) {
      ans = deq.pollFirst();
      System.out.print(ans);
      if (i != n - 1) System.out.print(" ");
    }
    System.out.println("");
  }

  void showReverse() {
    for (int i = 0; i < n; i++) {
      ans = deq.removeLast();
      System.out.print(ans);
      if (i != n - 1) System.out.print(" ");
    }
    System.out.println("");
  }
}


Measured memory_bytes: 64480
from math import sqrt, log10
ans = 100000000000000000
N = int(input())
for i in range(1, int(sqrt(N))+1) :
    A = i
    B = int(N / A)
    if N % A == 0:
        if A >= B :
            m = int(log10(A)) + 1
        else :
            m = int(log10(B)) + 1
        if m < ans :
            ans = m
            #print(ans)
            #print('{0},{1}'.format(A,B))
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string s,t;
    cin >> s >> t;
    
    vector<vector<int>> dp(s.size()+1, vector<int>(t.size()+1,0));

    REP(i, s.size()){
        REP(j, t.size()){
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
            if(s[i]==t[j]){
                chmax(dp[i+1][j+1], dp[i][j]+1);
            }
        }
    }

    size_t slen = s.size();
    size_t tlen = t.size();
    string ans(dp[slen][tlen], '0');
    int len=dp[slen][tlen];
    int i=slen;
    int j=tlen;
    while(len>0){
        if(s[i-1]==t[j-1]){
            ans[len-1]=s[i-1];
            i--;
            j--;
            len--;
        }else if(dp[i][j]==dp[i-1][j]){
            i--;
        }else{
            j--;
        }
    }
    pr(ans);
}

Measured memory_bytes: 35584
#include<stdio.h>
int main(void){
  char b[2];
  
  scanf("%s", b);
  
  if(b[0] == 'A'){
    printf("T\n");
  }
  else if(b[0] == 'T'){
    printf("A\n");
  }
  else if(b[0] == 'C'){
    printf("G\n");
  }
  else{
    printf("C\n");
  }
  return 0;
}

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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
//RNG based on mersenne_twister 
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }


int _runtimeTerror_()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll x=(c/b)+(c%b!=0);
	ll y=(a/d)+(a%d!=0);
	if(x>y)
		cout<<"No";
	else cout<<"Yes";
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifdef runSieve
		sieve();
	#endif
	#ifdef NCR
		initialize();
	#endif
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
		_runtimeTerror_();
	cerr<<"\n"<<_time_;
	return 0;
}


Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi 3.141592653589
 
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power(ll b,ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
ll fact[100005],fact_inv[100005],inv[100005],M=1e9+7;
void initialvalues()
{
    fact[0]=fact[1]=1;
    for(ll i=2;i<100005;i++)
        fact[i]=(i*fact[i-1])%M;
    inv[1]=1;
    for(ll i=2;i<100005;i++)
        inv[i]=power(i,M-2,M);
    fact_inv[0]=fact_inv[1]=1;
    for(ll i=2;i<100005;i++)
        fact_inv[i]=(inv[i]*fact_inv[i-1])%M;
}
ll ncr(ll n,ll r)
{
    if(n<r) return 0;
    return ((fact[n]*fact_inv[r]%M)*(fact_inv[n-r]%M))%M;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    initialvalues();
    ll n;
    cin>>n;
    if(n>=6)
    {
        ll ans=1;
        for(ll i=2;i<=n/3;i++)
        {
            ll sum=n;
            sum-=3*i;
            ans+=ncr(sum+i-1,i-1);
            ans%=M;
        }
        cout<<ans;
    }else
    if(n>=3)
        cout<<"1";
    else
        cout<<"0";
    return 0;
}

Measured memory_bytes: 5948
let solve = (input) => {
  const [head, a] = input.split("\n")
  const [N, K] = head.split(" ").map((i) => Number(i))
  const balls = a.split(" ")
  const countMap = {}
  balls.map((i) => {
    countMap[i] = (countMap[i] || 0) + 1
  })

  const keys = Object.keys(countMap)
  const targetNum = keys.length - K
  if (targetNum < 1) {
    return 0
  }

  const sorted = keys
    .map((b) => {
      return [b, countMap[b]]
    })
    .sort((a, b) => a[1] - b[1])
  const r = sorted.slice(0, targetNum).reduce((cnt, c) => cnt + c[1], 0)

  return r
}
const input = require("fs").readFileSync("/dev/stdin", "utf8")
console.log(solve(input.trim()))


Measured memory_bytes: 77008
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long
#define rep(i,n) for (int i = 0; i < (n) ; ++i)

const int MOD = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD;
}

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

    int N;
    string S;
    cin >> N >> S;
    
    vector<int> a(N);

    rep(i, N){
        if(S[i] == 'R') a[i] = 0;
        if(S[i] == 'G') a[i] = 1;
        if(S[i] == 'B') a[i] = 2;
    }

    vector<int> cnt(3);
    rep(i, N) cnt[a[i]]++;

    int ans = 1;
    rep(i, 3) ans *= cnt[i];

    rep(j,N) rep(i,j){
        int k = j + (j-i);
        if(k<N){
            if(a[i]==a[j]) continue;
            if(a[j]==a[k]) continue;
            if(a[k]==a[i]) continue;
            ans--;
        }
    }

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


Measured memory_bytes: 3684
/*       Rohan Balot
    NSIT, New Delhi, India  */
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <utility>

#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
 
#define ALL(t) (t).begin(), (t).end()
#define ALLR(t) (t).rbegin(), (t).rend()
#define MP make_pair
 
const int N = int( 1e6 ) + 1;
const int M = int( 1e6 ) + 1;
const int MOD = int( 1e9 ) + 7;
const double PI = acos(-1);
const double eps = 1e-6;

void __answer()
{
	int n;
	cin >> n;
	vector< vector<int> > f(n, vector<int>(26, 0));
	for (int i = 0; i < n; i++) {
		string a;
		cin >> a;
		for (int j = 0; j < a.size(); j++) {
			f[i][a[j] - 'a']++;
		}
	}
	string s;
	bool foo = true;
	for (int i = 0; i < 26; i++) {
		int t = 1e9;
		for(int x = 0; x < n; x++)
			t = min(t, f[x][i]);
		for(int j = 0; j < t; j++) {
			foo = false;
			cout << char('a' + i);
		}
	}
	if(foo) cout << "";
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifdef LOCAL
        freopen("sample_input.txt", "r", stdin);
    #endif
    __answer();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,h,m,s;
    cin >> x;
    h=x/3600;
    m=(x-h*3600)/60;
    s=x-h*3600-m*60;
    cout << h << ":"<< m << ":" << s <<endl;
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <cfenv>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>

#define rep(i,n) for(int (i)=0;(i)<(n); ++(i))
using namespace std;

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

    vector<int> tasty(n,0);

    rep(i,n){
        cin >> tasty[i];
    }

    int recover = 0;

    for (int i=0; i<n-1; i++){
        for (int j=i+1; j<n; j++){
            recover += tasty[i] * tasty[j];
        }
    }

    cout << recover << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (int argc, char const *argv[])
{
    char S[5];

    gets(S);

    if (S[0] == S[1]) {
        puts("Bad");
        return 0;
    }
    if (S[1] == S[2]) {
        puts("Bad");
        return 0;
    }
    if (S[2] == S[3]) {
        puts("Bad");
        return 0;
    }

    puts("Good");

    return 0;
}


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

int main(void)
{
	string a,b,c;
	cin >> a >> b >> c;
	int n=a.size()-1;
	int m=b.size()-1;
	
	if(a[n]==b[0] && b[m]==c[0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>

using namespace std;

int main() {
	double pai = 3.141592653589793;

	int64_t r;
	cin >> r;

	cout << r * 2 * pai << endl;
	return 0;
}

Measured memory_bytes: 3804
n = gets.to_i
a = gets.chomp.split("")
b = gets.chomp.split("")
c = gets.chomp.split("")
ans = 0
for i in 0..n-1 do
    s = [a[i],b[i],c[i]]
    if s.uniq.length == 2
        ans += 1
    elsif s.uniq.length == 3
        ans += 2
    end
end

puts ans

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H,W;
            H=sc.nextInt();
            W=sc.nextInt();
            if (H==0&&W==0) {
                break;
            }
            for(int i=0;i<H;i++){
                if (i%2==0) {
                    for(int j=0;j<W;j++){
                        if (j%2==0) {
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
    
                    }
                }else{
                    for(int j=0;j<W;j++){
                        if (j%2==0) {
                            System.out.print(".");
                        }else{
                            System.out.print("#");
                        }
    
                }

               
            }
            System.out.println("");
        }
       
        System.out.println("");
    }
    sc.close();
}
}


Measured memory_bytes: 34900
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#define INF 999999999

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int n, m, x, y, l;
char d;

int main()
{
	while (cin >> n) {
		if (n == 0)return 0;
		int field[25][25];
		for (int i = 0; i < 25; i++) {
			for (int j = 0; j < 25; j++) {
				field[i][j] = 0;
			}
		}
		for (int i = 0; i < n; i++) {
			cin >> x >> y;
			field[x][y]--;
		}
		cin >> m;
		int rx = 10, ry = 10;
		for (int i = 0; i < m; i++) {
			cin >> d >> l;
			if (d == 'N') {
				for (int j = 0; j < l; j++) {
					ry++;
					field[rx][ry]++;
				}
			}
			if (d == 'E') {
				for (int j = 0; j < l; j++) {
					rx++;
					field[rx][ry]++;
				}
			}
			if (d == 'S') {
				for (int j = 0; j < l; j++) {
					ry--;
					field[rx][ry]++;
				}
			}
			if (d == 'W') {
				for (int j = 0; j < l; j++) {
					rx--;
					field[rx][ry]++;
				}
			}
		}
		int k = 0;
		for (int i = 0; i <= 20; i++) {
			for (int j = 0; j <= 20; j++) {
				if (field[i][j] < 0) {
					k++;
					break;
				}
			}
		}
		if (k > 0)cout << "No" << endl;
		else cout << "Yes" << endl;
	}

	return 0;
}

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

int a,b;

int main()
{
   // freopen("main.inp","r",stdin);
   // freopen("main.out","w",stdout);
  cin>>a>>b;
  double t1=a/0.08;
  double t2=b/0.1;
  int z=0;
  for(int i=round(t2);i<t2+10;++i)
    if(floor(i*0.08)==a)
  {
      z=1;
      cout<<i;
      break;
  }
  if(z==0) cout<<-1;
    return 0;
}


Measured memory_bytes: 384
def main():
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    M = list(map(int, input().split()))

    totals = set()
    for i in range(2**n):
        total = 0
        for j in range(n):
            if (i >> j) & 1:
                total += A[j]
        totals.add(total)

    for m in M:
        if m in totals:
            print('yes')
        else:
            print('no')


if __name__ == "__main__":
    main()



Measured memory_bytes: 5628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt(), w = sc.nextInt();
        int mod = 1000000007;
        boolean[][] a = new boolean[h + 1][w + 1];
        for (int i = 1; i <= h; i++) {
            String s = sc.next();
            for (int j = 1; j <= w; j++) {
                if ('.' == s.charAt(j - 1)) {
                    a[i][j] = true;
                }
            }
        }
        long[][] dp = new long[h + 1][w + 1];

        dp[1][1] = 1;
        for (int i = 2; i <= w; i++) {
            if (a[1][i]) {
                dp[1][i] = dp[1][i - 1];
            }
        }

        for (int i = 2; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                if (a[i][j]) {
                    dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
                    if (dp[i][j] >= mod) {
                        dp[i][j] = dp[i][j] - mod;
                    }
                }
            }
        }

        System.out.println(dp[h][w]);
    }
}


Measured memory_bytes: 40492
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    c = collections.Counter(S())
    if len(c) == 2 and list(c.values())[0] == 2:
        return 'Yes'

    return 'No'


print(main())



Measured memory_bytes: 5456
#include <stdio.h>

int bubbleSort(int *a, int n){
    int flag = 1, j, v, cnt = 0;
    while(flag){
        flag = 0;
        for(j = n - 1;j > 0;j--){
            if(a[j] < a[j-1]){
                v = a[j];
                a[j] = a[j-1];
                a[j-1] = v;
                flag = 1;
                cnt++;
            }
        }
    }
    return cnt;
}


int main(int argc, const char * argv[]) {
    int N = 100;
    int a[N];
    int n, i, cnt;
    scanf("%d", &n);
    for(i = 0;i < n;i++){
        scanf("%d", &a[i]);
    }
    cnt = bubbleSort(a, n);
    for(i = 0;i < n;i++){
        printf("%d", a[i]);
        if(i < n-1){
            printf(" ");
        }
    }
    printf("\n");
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 604
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
  
using namespace std;

#define pi 3.141592653589793

int main()
{
	int r[16][16][16][257];
	for(int s = 0; s < 16; s++){
		for(int a = 0; a < 16; a++){
			for(int c = 0; c < 16; c++){
				for(int i = 0; i < 257; i++){
					if(i == 0) r[s][a][c][i] = s;
					else r[s][a][c][i] = (a * r[s][a][c][i - 1] + c) % 256;
				}
			}
		}
	}
	int n;
	int i[257];
	while(1){
		cin >> n;
		if(n == 0) break;
		for(int j = 1; j < n + 1; j++){
			cin >> i[j];
		}
		double minh = 1000000, ans_s = 0, ans_a = 0, ans_c = 0;
		for(int s = 0; s < 16; s++){
			for(int a = 0; a < 16; a++){
				for(int c = 0; c < 16; c++){
					int cnt[257] = {};
					int maxo = 0;
					for(int j = 1; j < n + 1; j++){
						int o = (i[j] + r[s][a][c][j]) % 256;
						cnt[o]++;
						maxo = max(maxo, o);
					}
					double h = 0;
					for(int i = 0; i < maxo + 1; i++){
						if(cnt[i] != 0){
							h -= cnt[i] * log(cnt[i]);
						}
					}
					h = h / n;
					h += log(n);
					// cout << s << " " << a << " " << c << " " << h << endl;
					if(h < minh){
						ans_s = s;
						ans_a = a;
						ans_c = c;
						minh = h;
					}
				}
			}
		}
		cout << ans_s << " " << ans_a << " " << ans_c << endl;
	}
	return 0;
}

Measured memory_bytes: 5392
s[2],a[20];main(i,j,n,N,m){for(;scanf("%d",&n),n;printf("%d\n",m)){for(i=0;i<n;i++)scanf("%d",a+i);for(i=0,m=9999999,N=1<<n;i<N;j=abs(*s-s[1]),m=m<j?m:j,i++)for(*s=s[1]=j=0;j<n;j++)s[(i>>j)&1]+=a[j];}exit(0);}

Measured memory_bytes: 600
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int a,b;
    int count;
    int count8 = 0;
    for(int i = 1; i <= n; i = i + 2){
        count = 0;
        for(int j = 1; j <= n; j++){
            if(i % j == 0){
                a = j;
                b = i / j;
                if(a < b){
                    count += 2;
                }else if(a == b){
                    count++;
                }else{
                    if(count == 8){
                        count8++;
                    }
                    break;
                }
            }
        }
    }
    printf("%d\n",count8);

    return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
#include<string.h>
main(){
  char c[102];
  int i,j,len,s,s2;
  while(scanf("%s",c)!=EOF){
    len=strlen(c);
    for(i=0;i<len;i++){
      if(c[i]=='@'){
	s=c[i+1]-'0';
	for(j=0;j<s;j++){
	  printf("%c",c[i+2]);
	}
	i+=2;
      }
      else{
	printf("%c",c[i]);
      }
    }
    printf("\n");
  }
  return 0;
}

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

using namespace std;

int main()
{
	int n, m, e; cin >> n >> m;
	priority_queue<int> data;
	long long amount = 0;

	for (int i = 0; i < n; i++)
	{
		cin >> e;
		data.push(e);
	}
		

	for (int i = 0; i < m; i++)
	{
		e = data.top() / 2;
		data.pop();
		data.push(e);
	}
		

	for (int i = 0; i < n; i++)
	{
		amount += data.top();
		data.pop();
	}

	cout << amount << endl;
	//cin.ignore();
	//cin.get();
    return 0;
}

Measured memory_bytes: 892
# -*- coding;utf-8 -*-
O, E = (list(input()),list(input()))
O.reverse()
E.reverse()
factor = len(O)+len(E)
num = 1
ans = []
while factor > 0:
    if num%2 != 0:
        tmp = O.pop()
    else:
        tmp = E.pop()
    ans.append(tmp)
    num += 1
    factor -= 1
ans = ''.join(ans)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

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

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

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

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

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

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

int main() {
    vector<int> z(3);
        cin >> z.at(0) >> z.at(1) >> z.at(2);
        sort(z.begin(), z.end());
        cout << z.at(0) + z.at(1) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define debug(a) cout<<a<<endl
#define pii pair<int,int>
#define maxn 100009
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    int vet[maxn];
    memset(vet,0,sizeof vet);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        vet[a]++;
        vet[b+1]--;
    }
    for(int i=1;i<=100009;i++){
        vet[i]=vet[i]+vet[i-1];
    }
    ll ans=0;
    for(int i=0;i<100009;i++){
        if(vet[i]==m)ans++;
    }
    cout<<ans<<endl;
    return 0;
}
///usar double sempre ou long double
///pensar em casos que coisas dao negativas
///N esquecer de limpar as coisas em quest de varios testes
///OLHAR A COMPLEXIDADE PRA VER SE N PASSA POR BRUTE FORCE OU BRUTE FORCE COM ALGUMAS OTIMIZACOES

Measured memory_bytes: 640
import numpy as np
import sys
input = sys.stdin.readline

H,W = map(int,input().split())
S=np.array([list(input().rstrip("\n")) for _ in range(H)]) == '.'

D = np.zeros((H,W),dtype=int)
U = np.zeros((H,W),dtype=int)
L = np.zeros((H,W),dtype=int)
R = np.zeros((H,W),dtype=int)

# 上下
for i in range(H):
  U[i] = (U[i-1] + 1) * S[i]
  D[-i-1] = (D[-i] + 1) * S[-i-1]

# 左右
for i in range(W):
  L[:,i] = (L[:,i-1] + 1) * S[:,i]
  R[:,-i-1] = (R[:,-i] + 1) * S[:,-i-1]

print(np.max(U+D+L+R)-3)


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

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

    int ans = 0;
    if(N < 10) {
        ans = R + 100 * (10 - N);
        cout << ans << endl;
    }
    else cout << R << endl;
}

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

def EA(X,Y):
    if X%Y==0:
        return Y
    
    return EA(Y,X%Y)

if C>D:
    CD=int(C/EA(C,D))*D
else:
    CD=int(C/EA(D,C))*D

A-=1

print(int(B-A-(B//C+B//D-B//CD-(A//C+A//D-A//CD))))


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

int main(){
    int n;
    ll a = 1;
    bool can =true;
    cin  >> n;
    vector<ll> vec(n);
    rep(i,n){
        cin>>vec.at(i);
    }
    rep(i,n){
        if(vec.at(i) == 0){
            cout << 0 << endl;
            can = false;
            break;
        }
    }

    
   if(can){
       rep(i,n){
         
           if(vec.at(i) > 1000000000000000000/a){
               cout << -1 << endl;
               can = false;
               break;
           }
           a *= vec.at(i);
       }
   }
    
if(can){
    cout << a <<endl;
}
   
}

Measured memory_bytes: 4040
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int main()
{
  double ans;
  int n,m,d;
  scanf("%d%d%d",&n,&m,&d);
  ans=2.0*(n-d)*(m-1)/n/n;
  if (d==0) ans/=2;
  printf("%.9lf\n",ans);
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    s1, s2, s3 = input().split()
    print(s1[0].upper() + s2[0].upper() + s3[0].upper())


if __name__ == '__main__':
    main()


Measured memory_bytes: 4196
#include<cstdio>
#include<queue>
int n;
std::priority_queue<double> pq;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		double x;
		scanf("%lf",&x);
		pq.push(-x);
	}
	while (pq.size()>1)
	{
		double x=-pq.top();pq.pop();
	    double y=-pq.top();pq.pop();
	    pq.push(-(x+y)/2);
	}
	printf("%lf\n",-pq.top());
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int main(){
    int N;
    cin >> N;
    
    int ans = 0;
    while(N!=0){
        if(N%10 == 2){
            ans++;
        }
        N /= 10;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n; bool f[100][10]; ll p[100][11];
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> f[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 11; j++) {
			cin >> p[i][j];
		}
	}
	ll ans = -1145141919810;
	for (int i = 0; i < pow(4, 5); i++) {
		if(i == 0) continue;
		ll rieki = 0;
		for (int j = 0; j < n; j++) {
			int bit = i, open = 0;
			for (int k = 0; k < 5; k++) {
				if(f[j][2*k] and bit%4 != 2 and bit%4 != 0) open++;
				if(f[j][2*k+1] and bit%4 != 1 and bit%4 != 0) open++;
				bit /= 4;
			}
			rieki += p[j][open];
		}
		if(rieki > ans) ans = rieki;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256