akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main()
{
	ll t1,t2;
	ll a1,a2,b1,b2;
	ll ans=0;
	cin>>t1>>t2;
	cin>>a1>>a2;
	cin>>b1>>b2;
	ll ldif=a2*t2-b2*t2;
	ll fdif=a1*t1-b1*t1;
	if(fdif+ldif==0)
	{
		cout<<"infinity"<<endl;
		return 0;
	}else if((ldif+fdif>0 && fdif>0)||(ldif+fdif<0 && fdif<0)){
		cout<<0<<endl;
		return 0;
	}
	if(fdif+ldif<0)
	{
		ldif*=-1;
		fdif*=-1;
	}
	cerr<<fdif<<" "<<ldif<<" "<<-1*fdif/(fdif+ldif)<<endl;
	//前を求める
	ans+=-1*fdif/(fdif+ldif);
	//後ろ
	ans+=-1*fdif/(fdif+ldif)+1;
	//重複を除く
	if((-1*fdif)%(fdif+ldif)==0)
		ans--;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[100001];
int main(){
	ios::sync_with_stdio(false);
	gets(a);
	int len=strlen(a);
	for(int i=0;i<len;i+=2){
		cout<<a[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

//#define PI 3.141592653589

using namespace std;



int main()
{
	int w_score[10];
	int k_score[10];
	int w_sum, k_sum;
	
	for (int i=0; i<10; i++)
	{
		cin >> w_score[i];
	}
	for (int i=0; i<10; i++)
	{
		cin >> k_score[i];
	}
	
	sort(w_score, w_score+10);
	sort(k_score, k_score+10);
	w_sum = w_score[9] + w_score[8] + w_score[7];
	k_sum = k_score[9] + k_score[8] + k_score[7];
	
	cout << w_sum << " " << k_sum << endl;
	
	/*
	for (int i=0; i<10; i++)
	{
		cout << w_score[i] << endl;
	}
	*/
	
	
	return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <string>
#include <vector>

int main(){
  std::vector<std::string> w{"SAT","FRI","THU","WED","TUE","MON","SUN"};
  std::string s;
  std::cin >> s;
  for(int i=0; i<7; ++i)
    if(w[i] == s)
      std::cout << i+1 << std::endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main()  {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if (a == b && b == c) {
		fmt.Println("No")
		return
	} else if (a == b || a == c || b == c) {
		fmt.Println("Yes")
		return
	} 
	fmt.Println("No")
}

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

int main()
{
        string src, dst;
        int flag = 0, index;

        getline(cin, src);
        getline(cin, dst);

        for(int i = 0; i < src.length(); i++) {
                for(int j = 0; j < dst.length(); j++) {
                        index = i + j;
                        if(index >= src.length()) {
                                index -= src.length();
//                              cout << i << ',' << j << ',' << index << ':' << src[index] << '=' << dst[j] << endl;
                        } else {
//                              cout << i << ',' << j << ',' << index << ':' << src[index] << '=' << dst[j] << endl;
                        }
                        if(src[index] != dst[j]) {
                                break;
                        } else {
                                if(j == dst.length()-1) {
                                        flag = 1;
                                }
                        }
                }

        }

        if(flag) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }

        return 0;
}


Measured memory_bytes: 3200
# https://onlinejudge.u-aizu.ac.jp/problems/DPL_1_D
import bisect

INF = float('inf')

n = int(input())
A = []
for _ in range(n):
    a = int(input())
    A.append(a)

dp = [INF for _ in range(n)]

for a in A:
    update_index = bisect.bisect_left(dp, a)
    dp[update_index] = a

print(bisect.bisect_left(dp, INF))



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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    ll n, a[5];
    cin >> n;
    rep(i, 5) cin >> a[i];
    ll min = INF;
    rep(i, 5) {
        if(min > a[i]) min = a[i];
    }
    cout << (n+min-1)/min + 4 << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}



Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        s: String,
        w: usize,
    }

    let ans: String = s
        .chars()
        .enumerate()
        .filter(|(i, _)| i % w == 0)
        .map(|k| k.1)
        .collect();

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


Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;

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

    for (int x = 1; x <= 1009; x++){
        int p1 = x * 8;
        int p2 = x * 10;
        if (a == p1/100 && b == p2/100){
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
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
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CLiningUp solver = new CLiningUp();
        solver.solve(1, in, out);
        out.close();
    }

    static class CLiningUp {
        private static final int MOD = (int) 1e9 + 7;

        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            int[] a = in.ints(n);
            int[] b = new int[n];
            for (int d : a) {
                if ((n - d) % 2 == 0 || ++b[d] > 2) {
                    out.println(0);
                    return;
                }
            }
            if (n % 2 == 1 && b[0] > 1) {
                out.println(0);
                return;
            }
            out.println(pow(2, n / 2));
        }

        private static long pow(long x, long y) {
            if (y == 0) {
                return 1;
            } else if (y % 2 == 0) {
                long z = pow(x, y / 2);
                return (z * z) % MOD;
            } else {
                return (x % MOD) * pow(x, y - 1) % MOD;
            }
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

        public int[] ints(int length) {
            return IntStream.range(0, length).map(x -> ints()).toArray();
        }

    }
}



Measured memory_bytes: 36816
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int a[200000];
int b[200000];

signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	
	vector<int> S;
	rep(i, n) S.push_back(b[i] ^ b[(i + 1) % n]);
	S.push_back(-1);
	rep(i, n) S.push_back(a[i] ^ a[(i + 1) % n]);
	rep(i, n - 1) S.push_back(a[i] ^ a[i + 1]);
	
	//SにZ-algoを適用する.
	vector<int> A;
	A.resize(S.size());
	A[0] = S.size();
	i = 1;
	j = 0;
	while (i < S.size()) {
	  while (i + j < S.size() && S[j] == S[i + j]) ++j;
	  A[i] = j;
	  if (j == 0) { ++i; continue; }
	  int k = 1;
	  while (i + k < S.size() && k + A[k] < j) A[i + k] = A[k], ++k;
	  i += k; j -= k;
	}
	
	for (i = n + 1; i < S.size(); i++) {
		if (A[i] >= n) {
			int x = a[i - (n + 1)] ^ b[0];
			cout << i - (n + 1) << " " << x << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 16232
#include<bits/stdc++.h>
using namespace std;
int A[100005];

int main() {
    int a,n,k,mn=1e9;
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;++i) {
        scanf("%d",&A[i]);
        //if(A[i]<mn) mn = A[i];
    }
    int op=0;
    for(int i=1;i<n;i+=(k-1)) {

        op++;
        //cout<<i<<" "<<j<<endl;
    }
    cout<<op;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
 
  if ((a * b) % 2 == 0) {
    cout << "Even" << endl;
  }
  
  else {
    cout << "Odd" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;

int main() {
  int H,W;
  cin>>H>>W;
  vector<string> s(H);
  vector<vector<int>> dp(H,vector<int>(W,100000));
  int dx[]={1,0};
  int dy[]={0,1};
  
  for(int i=0;i<H;i++){
    cin>>s[i];
  }

  if(s[0][0]=='.'){dp[0][0]=0;}
  else{dp[0][0]=1;}
  
  for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
         for(int d=0;d<2;d++){
            int ni=i+dy[d],nj=j+dx[d];
            if(ni>=H||nj>=W){continue;}
            int add=0;
            if(s[i][j]=='.'&&s[ni][nj]=='#'){add=1;}
            chmin(dp[ni][nj],dp[i][j]+add);
         } 
      }
  }

  cout<<dp[H-1][W-1]<<endl;
  return 0;
}

Measured memory_bytes: 3668
# coding: utf-8
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]

s = sum(a) / (4*m)
if len([x for x in a if x >= s]) >= m:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int a[maxn*2];
int ans[maxn*2];
struct Node
{
    int x,y;
}s[maxn*2];
int maxpr[maxn*2];
int maxed[maxn*2];
int main()
{

   int n;
   cin>>n;
   for(int i=1;i<=n;i++)
    cin>>a[i];
    for(int i=1;i<=n;i++)
        maxpr[i]=max(maxpr[i-1],a[i]);
    for(int i=n;i>=1;i--)
        maxed[i]=max(maxed[i+1],a[i]);
    for(int i=1;i<=n;i++)
    {
        cout<<max(maxpr[i-1],maxed[i+1])<<endl;
    }

    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <map>
#include <cmath>
using namespace std;

int H[10000];

int main()
{
    int N, T, A;
    map<float, int> ans;

    cin >> N >> T >> A;
    for(int i = 0; i < N; i++) {
        cin >> H[i];
        ans[abs((float)A - ((float)T - (float)H[i] * 0.006))] = i + 1;
    }

    cout << ans.begin()->second << endl;

    return 0;
}


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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define mp(a, b) make_pair(a, b) 

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;

const long double PI  = 3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


void solve()
{
	ll n, k;
	cin>>n>>k;
	vector<ll> v(n);
	rep(i, 0, n) cin>>v[i];
	sort(all(v), greater<ll>());
	ll ans = 0;
	rep(i, 0, n)
	{
		if(i < k) ans+=0;
		else ans += v[i];
	}
	cout<<ans<<endl;
}


int main()
{
	ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
    	solve();
    }
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'

int main()
{
    fastio;
    int n;
    cin>>n;
    vinput(a,n+1);
    vinput(b,n); 

    lli ans=0;
    rep(i,n,0){
        lli t=min(a[i],b[i]);
        ans+=t;
        a[i]-=t;
        b[i]-=t;
        t=min(a[i+1],b[i]);
        ans+=t;
        a[i+1]-=t;
        b[i]-=t;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  string s;
  cin >> s;

  const int N = s.size();
  int ans = 0;
  for (int i = 0; i < (int)N; ++i) {
    if (i % 2) {
      ans += (s[i] == 'g' ? 1 : 0);
    } else {
      ans += (s[i] == 'g' ? 0 : -1);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#coding:utf-8
S = str(input())
T = str(input())
S = "".join(sorted(S))
T = "".join(sorted(T))
T = T[::-1]
ST = sorted([S,T])
#print (ST)
if (ST[0]==S and S!=T):
    print ("Yes")
else:
    print ("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr(be, en) for(int i = be; i <= en; i++) 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, val;
	bool flag = 1;
	cin >> n;
	while(n--)
	{
		cin >> val;
		if(val%2 == 0)
		{
			if(val%3 && val%5) flag = 0;
		}
	}
	if(flag) cout << "APPROVED";
	else cout << "DENIED";
}

Measured memory_bytes: 256
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""
dp, 取引所Bで一度全てacornにする
取引所Aでの通貨の値段を重さとする
"""

N = ir()
A = lr()
B = lr()
dp = [x for x in range(N+1)]
for a, b in zip(A, B):
    for x in range(N):
        if x + a <= N:
            dp[x+a] = max(dp[x+a], dp[x] + b)

half_way = max(dp)
dp = [x for x in range(half_way+1)]
A, B = B, A
for a, b in zip(A, B):
    for x in range(half_way):
        if x + a <= half_way:
            dp[x+a] = max(dp[x+a], dp[x] + b)

answer = max(dp)
print(answer)

# 56


Measured memory_bytes: 449876
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<ctype.h>
int main()
{
    int n, x, t;
    scanf("%d%d%d", &n, &x, &t);
    if(n%x==0)
    {
        printf("%d\n", (n/x)*t);
    }
    else
    {
        printf("%d\n", ((n/x)*t)+t);
    }
    return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>

int main() {
	int n;
    scanf("%d", &n);
    int temp = 0;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if(i * j == n){
                temp = 1;
                break;
            }
        }
    }
    if(temp == 1){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< long long > vll;
typedef pair< int,int > ii;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define mp  make_pair
#define mod 1000000007
#define mod2 998244353
#define all(c) c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())
#define cpresent(c,x) (find(all(c),x) != c.end())
#define rep(i, a, b) for (int i = (a); i <= int(b); i++)
#define fo(i,n) for(ll i=0;i<n;i++)
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define nl "\n"
ll gcd (ll a, ll b) {
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

unsigned long long factorial[1000004]; 
    /*factorial[0] = 1; 
    for (int i = 1; i <= n; i++) {
        factorial[i] = (factorial[i - 1] * i) % mod3; 
    }*/




unsigned long long power(unsigned long long x, 
                         int y, int p) 
{ 
    unsigned long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 



  
// Returns n^(-1) mod p 
unsigned long long modInverse(unsigned long long n, int p) 
{ 
    return power(n, p - 2, p); 
} 
unsigned long long nc(unsigned long long n, 
                                 int r, int p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
 
  
    return (factorial[n]* modInverse(factorial[r], p) % p * modInverse(factorial[n - r], p) % p) % p; 
} 



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w;
    int m;
    cin>>h>>w>>m;
    int a[h+1]={0};
    int b[w+1]={0};
    set<int> g[h+1];
    
    int x,y;
    fo(i,m){
        cin>>x>>y;
        g[x].insert(y);
        a[x]++;
        b[y]++;
    }
    vi r,c;
    int m0=a[1];
    fo(i,h){
        if(a[i+1]>m0){
            m0=a[i+1];
        }
    }
    int m1=b[1];
    fo(i,w){
        if(b[i+1]>m1){
            m1=b[i+1];
        }
    }
    int f=0;
    fo(i,h){
        if(a[i+1]==m0){
            r.pb(i+1);
        }
    }
    fo(i,w){
        if(b[i+1]==m1){
            c.pb(i+1);
        }
    }
    
    for(auto i= r.begin();i!=r.end();i++){
        for(auto j=c.begin();j!=c.end();j++){
            if(g[*i].find(*j)==g[*i].end()){
                f=1;
                break;
            }
        }
        if(f){
            break;
        }
    }
    //cout<<m1<<" "<<m0<<nl;
    if(f){
        cout<<m1+m0;
    }
    else{
        cout<<m1+m0-1;
    }
        
    

    


	return 0;
}


Measured memory_bytes: 37828
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    N, K = map(int, input().split())

    if K > (N-1)*(N-2)//2:
        print(-1)
    else:
        edges = []
        m = N-1+(N-1)*(N-2)//2-K
        for i in range(2, N+1):
            edges.append("{} {}".format(1, i))

        add_edge = (N-1)*(N-2)//2-K

        fr = 2
        to = 3
        while add_edge:
            edges.append("{} {}".format(fr, to))
            to += 1
            if to > N:
                fr += 1
                to = fr+1
            add_edge -= 1
        print(m)
        print("\n".join(edges))


solve()


Measured memory_bytes: 3444
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<x86intrin.h>
#include<math.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

int64_t MtDist(int64_t a,int64_t b,int64_t c,int64_t d){
    return abs(a-c)+abs(b-d);
}

uint64_t sqrt_64(uint64_t a){
    uint64_t ret=0;

    for(uint64_t i=(1llu)<<31;i>0;i>>=1){
        if((ret+i)*(ret+i) <= a)
            ret+=i;
    }
    return ret;
}
int GetDigit(uint64_t a){
    return (a>0)?(GetDigit(a/10)+1):0;
}

int main(){
    uint64_t N;

    scanf("%lld",&N);
    for(uint64_t i=sqrt_64(N); i>0; i--){
        if(N%i==0){
            printf("%d\n",GetDigit(N/i));
            break;
        }
    }
    return 0;
}

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

int main(){
  ll N, i;
  string S, ans = "No";
  cin >> S;
  if(S[2] == S[3] && S[4] == S[5]){
    ans = "Yes";
  }

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


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<int> a(n);
    for(int in=0;in<n;in++) {
        cin >> a.at(in);
    }
    
    llint ans=0;
    int r = 0, sum = 0;
    for(int l=0;l<n;l++) {
        while(r<n && (sum^a.at(r))==(sum+a.at(r))) {
            sum += a.at(r);
            r++;
        }
        ans += r-l;
        if(l==r) r++;
        else {
            sum -= a.at(l);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [i64; n],
    }

    let mut ans = std::i64::MAX;
    for bit_row in 0..2u32.pow(n as u32) {
        // selected の建物で条件を満たす
        let mut selected = vec![];
        for i in 0..n {
            if bit_row & (1 << i) > 0 {
                selected.push(i);
            }
        }
        if selected.len() != k {
            continue;
        }
        // println!("{:?}", selected);

        let mut current = 0;
        let mut required = 0;
        let mut selected_idx = 0;
        for i in 0..n {
            if i == selected[selected_idx] {
                // println!("required: {}", required);
                if required > a[i] {
                    current += required - a[i];
                    required = required + 1;
                } else {
                    required = a[i] + 1;
                }
                selected_idx += 1;
                if selected_idx == k {
                    break;
                }
            } else {
                required = required.max(a[i] + 1);
            }
        }
        // println!("{}", current);
        ans = ans.min(current);
    }
    println!("{}", ans);
}


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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define fcout cout << fixed << setprecision(15)

signed main() {
  IOS;
  int W,H,x,y, ans;
  cin >> W >> H >> x >> y;
  if (x*2 == W and y*2 == H) {
    ans = 1;
  } else {
    ans = 0;
  }

  fcout << (W*H/2.0);
  cout << " " << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define MAX_V 100
#define INF 1e9
using namespace std;
int cost[MAX_V][MAX_V];
int d[MAX_V];
bool used[MAX_V];
int V;
void dijkstra(int s) {
	for (int i = 0; i < V; i++) {
		d[i] = INF;
		used[i] = false;
	}
	d[s] = 0;
	while (true) {
		int v = -1;
		for (int u = 0; u < V; u++) {
			if (!used[u] && ((v == -1) || d[u] < d[v])) {
				v = u;
			}
		}
		//全ての頂点が到達済み
		if (v == -1) {
			break;
		}
		//集合に新たに頂点を追加
		used[v] = true;
		for (int u = 0; u < V; u++) {
			d[u] = min(d[u], d[v] + cost[v][u]);
		}
	}
}

int main() {
	for (int i = 0; i < V+100; i++) {
		for (int j = 0; j < V+100; j++) {
			cost[i][j] = INF;//iからjへの辺の重さ
		}
	}
	cin >> V;
	for (int i = 0; i < V; i++) {
		int u;
		cin >> u;
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int v;
			cin >> v;
			int c;
			cin >> c;
			cost[u][v] = c;
		}
	}
	dijkstra(0);

	for (int i = 0; i < V; i++) {
		cout << i << " " << d[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

int main(){
  int N;
  cin >> N;
  int a[N];
  ll ans=0;
  int t=0;
  for(int i=0;i<N;i++){
    cin >> a[i];
    t=a[i];
    while(a[i]%2!=1){
      a[i]=a[i]/2;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

const int N = 1e5 + 10;

int n, m, a;
vector<int> V[N];

int get_same(int x){
	sort(V[x].begin(), V[x].end());
    int cnt = 1;
    int ret = 0;
    for(int i=1; i<V[x].size(); i++){
        if(V[x][i] == V[x][i-1]){
			cnt++;
        } else {
			ret = ret + cnt / 2;
			cnt = 1;
        }
    }
    ret = ret + cnt / 2;
    return ret;
}

int cal(int x, int y){
	int n = V[x].size();
	int m = V[y].size();
    int ret = min(n, m);
    int a = get_same(x);
    int b = get_same(y);
    int c = 0;
    while(a && b){
        if(n > m){
            n-=2;
            a--;
            c++;
        } else {
			m -= 2;
			b--;
			c++;
        }
        ret = max(ret, min(n, m) + c);
    }
    while(a){
		n-=2;
		a--;
		c++;
        ret = max(ret, min(n, m) + c);
    }
    while(b){
		m-=2;
		b--;
		c++;
        ret = max(ret, min(n, m) + c);
    }
    return ret;
}

int solve(){
    int ans = V[0].size() / 2;
    for(int i=1; i<m; i++){
		int j = m - i;
		if(j < i)	break;
        if(i == j){
			ans += V[i].size() / 2;
        } else {
            ans += cal(i, j);
        }
    }
    return ans;
}

int main(){
	while(~scanf("%d %d", &n, &m)){
		for(int i=0; i<m; i++){
			V[i].clear();
		}
		for(int i=0; i<n; i++){
			scanf("%d", &a);
			V[a%m].push_back(a);
		}
		printf("%d\n", solve());
	}
	return 0;
}


Measured memory_bytes: 5760
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines;
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines = Number(line);
});
reader.on('close', () => {
    console.log(lines * lines *lines);
});


Measured memory_bytes: 20584
#import<bits/stdc++.h>
#define sorted(vector) sort(vector.begin(),vector.end())
#define append(a) push_back(a)
#define int(a) stoi(a)
#define str(a) to_string(a)
using namespace std;

int main(void){
    string s;
    int n;
    cin>>s;
    n=s.size();
    cout<<s[0]<<n-2<<s[n-1]<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	string s;
	bool flag = 0;
	while(cin >> s) {
		if(s[s.length()-1] != ',' && s[s.length()-1] != '.') {
			if(s.length() > 2 && s.length() < 7) {
				if(flag) cout << " " << s;
				else {
					flag = 1;
					cout << s;
				}
			}
		} else {
			if(s.length() > 3 && s.length() < 8) {
				s.erase(--s.end());
				if(flag) cout << " " << s;
				else {
					flag = 1;
					cout << s;
				}
			}
		}
	}
        cout << endl;
	return 0;
}

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

int main() {
  int N, x;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  x = 0;
  for (int i = 0; i < N; i++) {
    cin >> V.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> C.at(i);
  }
  for (int i = 0; i < N; i++) {
    if (V.at(i) > C.at(i)) {
      x += V.at(i) - C.at(i);
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
// Date: 2020-03-13

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int dp[N], h[N], n;

int main() {
    FIO;
    cin >> n;
    rep(i, 1, n) cin >> h[i];
    mem(dp, 0x3f);
    dp[1] = 0;
    rep(i, 2, n) {
        chkmin(dp[i], dp[i-1] + abs(h[i]-h[i-1]));
        if(i > 2) chkmin(dp[i], dp[i-2] + abs(h[i]-h[i-2]));
    }
    cout << dp[n];

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N, X;
    cin >> N >> X;
    vector<int> A(N);
    int mi = 1001;
    for(int i=0; i<N; i++){
        cin >> A[i];
        X = X - A[i];
        if(A[i] < mi){
            mi = A[i];
        }
    }
    cout << A.size() + (X/mi) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int h[3];
	int n;
	
	scanf("%d", &n);
	
	while(n){
		scanf("%d %d %d", &h[0], &h[1], &h[2]);
		
		if (h[0] < h[1]){
			h[0] += h[1];
			h[1] = h[0] - h[1];
			h[0] -= h[1];
		}
		if (h[0] < h[2]){
			h[0] += h[2];
			h[2] = h[0] - h[2];
			h[0] -= h[2];
		}
		
		if (h[1] * h[1] + h[2] * h[2] == h[0] * h[0]){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
		n--;
	}
	
	return (0);
}

Measured memory_bytes: 580
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstring>
#define R register
#define EN std::puts("")
#define LL long long
inline int read(){
	int x=0,y=1;
	char c=std::getchar();
	while(c<'0'||c>'9'){if(c=='-') y=0;c=std::getchar();}
	while(c>='0'&&c<='9'){x=x*10+(c^48);c=std::getchar();}
	return y?x:-x;
}
int n;
int main(){
	n=read();
	for(R int i=1;i<=n;i++){
		int x=read();
		if(x&1) continue;
		if((x%3)&&(x%5)) return std::puts("DENIED"),0;
	}
	std::puts("APPROVED");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
/*bool subseq(string s,string t){
    ll y=0;
    for(ll i=0;y<s.size()&& i<t.size();i++){
        if(s[y]==t[i]){
            y++;
        }
    }
        if(y==s.size())
            return true;
        else  return false;
}*/
/*ll x=1000000001;
vector<bool>p(x,false);
void prime(){
    p[2]=true;
    for(ll i=3;i<x;i=i+2)
        p[i]=true;
    for(ll i=0;i<x;i=i+2){
        if(p[i]){
            for(ll j=i*i;j<x;j=j+i)
                p[j]=false;
        }
    }
}*/
/*vector<ll> divisor(ll n){
    vector<ll> d;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0){
        d.push_back(i);
        d.push_back(n/i);
        }
    }
    sort(d.begin(),d.end(),greater<ll>());
    return d;
}*/
/*bool bs(ll n,string s){
    ll a[4]={0};
    for(ll i=0;i<n-1;i++){
        a[s[i]-'0']++;
    }
    for(ll i=n-1;i<s.size();i++){
        a[s[i]-'0']++;
        if(a[1]>0 && a[2]>0 && a[3]>0)
        return true;
        a[s[i-n+1]-'0']--;
    }
    return false;
}*/


/*ll binarySearch(ll n,ll a[],ll x){
    ll low=0,high=n-1,mid,ans=-1;
    while(low<=high){
        mid=low+(high-low)/2;
        if(a[mid]>=x){

            high=mid-1;
        }
        else{
                ans=mid;
            low=mid+1;
        }
    }
    return a[ans];
}*/
/*ll lcs(string a,string b,ll n,ll m){
    ll dp[n+1][m+1];
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=m;j++){
            if(i==0|| j==0)
                dp[i][j]=0;
            else if(a[i]==b[j])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    return dp[n][m];

}*/
/*ll editDist(string a,string b,ll n,ll m){
    vector<vector<ll> >dp(n+1,vector<ll>(m+1,-1));
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=m;j++){
            if(i==0)
                dp[i][j]=j;
            else if(j==0)
                dp[i][j]=i;
            else if(a[i]==b[j])
                dp[i][j]=dp[i-1][j-1];
            else{
                dp[i][j]=1+min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]));
            }
        }
    }
    return dp[n][m];
}*/

/*ll d1(vector<string>a,ll n,ll m,vector<vector<ll> >dp){
    if(n<0 || m<0 ) return 0;
    if(n==0 && m==0) return 0;
    if(a[n][m]=='#') dp[n][m]=0;
    if((n==0 &&m==1) || (m==0&&n==1)) return 1 ;
    if(dp[n][m]!=-1)
        return dp[n][m];

    dp[n][m]=d(a,n-1,m,dp)+d(a,n,m-1,dp);
    return dp[n][m];
}*/
ll solve(ll a[],ll n){
    ll l=0,r=n-1;
        while(a[l+1]>a[l] && l<n-1){
            l++;
        }
        while(a[r-1]<a[r] && r-1>=0){
            r--;
        }
        if(r==n-1 && l==0){
            cout<<"yes"<<endl;
            cout<<1<<" "<<n;
        }


}
int main() {
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++) cin>>a[i];
    ll dp[n+1];
    dp[0]=0;dp[1]=0;

        dp[2]=abs(a[0]-a[1]);
    for(ll i=3;i<=n;i++){
        dp[i]=min(abs(a[i-1]-a[i-2])+dp[i-1],abs(a[i-1]-a[i-3])+dp[i-2]);
    }
    cout<<dp[n];
}


Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i< (n); ++i)
const long long INF = 1LL<<58;

// aを常に小さい値にする　大きい値にする
template<class T> void chmin(T &a, T b){ if(a>b) a = b; }
template<class T> void chmax(T &a, T b){ if(a<b) a = b; }

// 二分探索 前方のindexを返すもの（自分自身を含む） 前方: -INF側のこと
template<class T> int former(const vector<T> &v, T x){
    return upper_bound(v.begin(), v.end(), x) - v.begin() -1; // upper_bound : keyより大きい要素の内の一番左側のイテレータを返す
}
// 二分探索 後方のindexを返すもの（自分自身を含む）後方: INF側のこと
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(), v.end(), x) - v.begin(); // lower_bound : key以上の要素の内の一番左側のイテレータを返す
}

/*
 *  問題の条件は

    "AGC"
    "GAC"
    "ACG"
    "A＊GC" ( ＊は任意)
    "AG＊C" ( ＊は任意)
    のいずれも含まないことと言い換えられる。こういう禁止文字列系の問題は最悪 trie 木で直近文字列の遷移状態を管理するような DP でできる
    (蟻本に載ってる) が、ここでは

    「直近 3 文字がわかっていれば、それより前の文字列の情報は要らない」

    ということによって、簡単な DP でできる。

    dp[ n ][最後の前の前の文字][最後の前の文字][最後の文字] := 長さ n の文字列が何通り作れるか
    とした。文字として

    0: dammy (DP を初期化するのにこれがあると便利)
    1: A
    2: G
    3: C
    4 : T
    の 5 種類を割り当てた。dammy を用意すれば初期条件を
    dp[0][0][0][0] = 1
    と表せる
 * */

// mod add
const int MOD = 1000000007;
void add(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

// 多次元 vector 生成
// https://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}


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

    auto dp = make_vec<long long>(N+1, 5, 5, 5); // dp[i文字][3文字前][2文字前][1文字前]


    dp[0][0][0][0] = 1; // 初期化

    // 0: dammy, 1: 'A', 2: 'G', 3: 'C', 4: 'T'
    // "AGC, GAC, ACG", "A*GC", "AG*C" を含まない (012, 102, 021 を禁止)
    for (int n = 0; n < N; ++n) {
        for (int i = 0; i < 5; ++i) {
            for (int j = 0; j < 5; ++j) {
                for (int k = 0; k < 5; ++k) {
                    for (int l = 1; l < 5; ++l) {
                        if (i == 1 && j == 2 && l == 3) continue;
                        if (i == 1 && k == 2 && l == 3) continue;
                        if (j == 1 && k == 2 && l == 3) continue;
                        if (j == 2 && k == 1 && l == 3) continue;
                        if (j == 1 && k == 3 && l == 2) continue;
                        add(dp[n+1][j][k][l], dp[n][i][j][k]);
                    }
                }
            }
        }
    }

    long long res = 0;
    for (int i = 1; i < 5; ++i)
        for (int j = 1; j < 5; ++j)
            for (int k = 1; k < 5; ++k)
                add(res, dp[N][i][j][k]);

    cout << res << endl;
}

Measured memory_bytes: 384
//f
#include<cstdio>
int main()
{
	int a,c;
	char b,n,m;
	int sum;
	while(scanf("%d",&a)!=EOF)
	{
		scanf("%c",&m);
		scanf("%c",&b);
		scanf("%c",&n);
		scanf("%d",&c);
		if(b==43)
		{
			sum=a+c;
			printf("%d\n",sum);
		}
		else
		{
			sum=a-c;
			printf("%d\n",sum);
		}

	}
	return  0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	int r1, r2, r3, r4, r5;
	cin >> r1 >> r2 >> r3 >> r4 >> r5;
	if (r1 == 0) cout << "1" << endl;
	if (r2 == 0) cout << "2" << endl;
	if (r3 == 0) cout << "3" << endl;
	if (r4 == 0) cout << "4" << endl;
	if (r5 == 0) cout << "5" << endl;
	return 0;
}

Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

signed main()
{
	int a, b;
	cin >> a >> b;
	cout << ((a <= 8 && b <= 8) ? "Yay!" : ":(") << endl;
}



Measured memory_bytes: 3028
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
	int n, d, x;
	cin >> n >> d >> x;
	vector<vector<int>> p(d, vector<int>(n));
	for (int i = 0; i < d; i++) {
		for (int j = 0; j < n; j++) {
			cin >> p[i][j];
		}
	}
	for (int i = 1; i < d; i++) {
		vector<int> dp(100001, -1);
		dp[x] = x;
		for (int j = 0; j < n; j++) {
			for (int k = 0; k <= 100000 - p[i][j]; k++) {
				if (dp[k] >= p[i - 1][j]) {
					dp[k + p[i][j] - p[i - 1][j]] = max(dp[k + p[i][j] - p[i - 1][j]], dp[k] - p[i - 1][j]);
				}
			}
		}
		int Max = 0;
		for (int k = 0; k <= 100000; k++) {
			if (dp[k] >= 0) {
				Max = k;
			}
		}
		x = Max;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 3964
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000007
//S.size()

using namespace std;


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;



int main(void){
  int A,B,C,X;cin>>A>>B>>C>>X;
  int cnt = 0;
  for(int i = 0;i <= A;i++){
    for(int t = 0;t <= B;t++){
      for(int j = 0;j <= C;j++){
        if(i * 500 + t * 100 + j * 50 == X)cnt++;
      }
    }
  }
  cout<<cnt;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<ctype.h>
#include<string>
using namespace std;

string deck;
int m,h;

int main(){
    while(1){
        cin>>deck;
        if(deck=="-")break;
        cin>>m;
        for(int i=0;i<m;++i){
            cin>>h;
            deck=deck.substr(h,deck.size()) + deck.substr(0,h);
        }
        cout<<deck<<endl;
    }
    return 0;
}


Measured memory_bytes: 3140
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int A, B, C;
	cin >> A >> B >> C;
	if(B > A * C){
		cout << C << endl;
	}
	else{
		cout << B / A << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import numpy as np

N,D = map(int,input().split())

X_list = [np.array(list((map(int, input().split())))) for _ in range(N)]

ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        euc = np.linalg.norm(X_list[i] - X_list[j])
        if euc.is_integer():
            ans += 1

print(ans)


Measured memory_bytes: 12500
def dfs(L):
    if len(L) == 0:
        return 0

    ret = min(L)
    L = [e - ret for e in L]
    L2 = []
    for i, e in enumerate(L):
        if e == 0:
            ret += dfs(L2)
            L2 = []
        else:
            L2.append(e)

    ret += dfs(L2)
    return ret

def main():
    n = int(input())
    H = [int(e) for e in input().split()]

    print(dfs(H))

if __name__ == "__main__":
    main()


Measured memory_bytes: 38768
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	cout << max(0, min(B, D) - max(A, C)) << endl;

	return 0;
}

Measured memory_bytes: 384
N, M = gets.chomp.split.map(&:to_i)
l_max = 1
r_min = N
M.times do
  p, q = gets.chomp.split.map(&:to_i)
  l_max = p if (l_max < p)
  r_min = q if (q < r_min)
end
puts [r_min - l_max + 1, 0].max

Measured memory_bytes: 1788
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
if M == 0:
    print([0, 10, 100][N - 1])
    exit()
m = map(int, read().split())
S, C = zip(*zip(m, m))

def test(n):
    st = str(n)
    if len(st) != N:
        return False
    for i, c in zip(S, C):
        i -= 1
        if st[i] != str(c):
            return False
    return True

def main():
    for n in range(1000):
        if test(n):
            return n
    return -1

print(main())

Measured memory_bytes: 9292