akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin>>s;
map<char,int>d;
rep(i,s.size()){
    d[s[i]]=1;
}
if(d['N']==d['S']&&d['W']==d['E']){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
return 0;
}

Measured memory_bytes: 256
def main():
  h,w = list(map(int,input().split()))
  a = [input() for i in range(h)]
  
  for i in range(0,w+2):
    print("#",end="")
  print()
  for i in range(0,h):
    print("#"+a[i]+"#")
  for i in range(0,w+2):
    print("#",end="")
    
main()

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ');
            int A = int.Parse(line[0]), B = int.Parse(line[1]);
            int[] AB = new int[3];
            AB[0] = A + B;
            AB[1] = A - B;
            AB[2] = A * B;
            Console.WriteLine(AB.Max());

        }
    }
}


Measured memory_bytes: 13780
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;

typedef long long ll;

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

//--------------------

int main() {

  string s;
  ll k;
  cin >> s >> k;

  rep(i, s.size()) {
    if(s[i]!='1') {
      cout << s[i]-'0' << endl;
      return 0;
    }if(i==k-1) {
      break;
    }
  }

  cout << 1 << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N; cin>>N;
	ll mt=0,mx=0,my=0; 
	bool ans=true;
	rep(v,N){
		ll t,x,y; cin>>t>>x>>y;
		if(abs(mx-x)+abs(my-y)<=abs(mt-t) && (abs(mx-x)+abs(my-y))%2==abs(mt-t)%2) mt=t,mx=x,my=y;
		else ans=false;
	}
	if(ans) cout<<"Yes";
	else cout<<"No";
}

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

struct Pos{ int x, y, i; };

int R, C, n;
vector<Pos> v;
stack<int> st;
const int B = 2e8;

int get(Pos p){
	if(p.x == 0) return p.y;
	if(p.y == C) return B + p.x;
	if(p.x == R) return 3 * B - p.y;
	if(p.y == 0) return 5 * B - p.x;
}

int main(){
	scanf("%d%d%d", &R, &C, &n);
	for(int i = 1, x1, y1, x2, y2; i <= n; i++){
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		if((0 < x1 && x1 < R && 0 < y1 && y1 < C) ||
		   (0 < x2 && x2 < R && 0 < y2 && y2 < C)) continue;
		v.push_back({x1, y1, i});
		v.push_back({x2, y2, i});
	}
	sort(v.begin(), v.end(), [](Pos a, Pos b){
		return get(a) < get(b);
	});
	for(auto &i : v){
		if(!st.empty() && st.top() == i.i) st.pop();	
		else st.push(i.i);
	}
	puts(st.empty() ? "YES" : "NO");
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

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

int a,b,c;


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

	cin>>a>>b>>c;
	if(a==b) cout<<c<<endl;
	else if(b==c) cout<<a<<endl;
	else cout<<b<<endl;

	return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<climits>
using namespace std;
int main(){
  long long n;
  cin>>n;
  
  long long num=100;
  long long ans=0;
  while(num<n){
    long long kinri=num/100;
    ans++;
    num+=kinri;
  }

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

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

using namespace std;
typedef long long int ll;

int main()
{
    vector<char> alp = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    vector<int> v;
    ll N;
    cin >> N;
    N--;
    while(1)
    {
        ll tmp = N % 26;
        v.push_back(tmp);
        N = N / 26;
        if(N == 0)
        {
            break;
        }
        N--;
    }
    ll l = v.size();
    for(ll i = l - 1; i >= 0; i--)
    {
        cout << alp[v[i]];
    }
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
const int MAX = 1e5;
typedef long long ll;
typedef pair<char,int> P;

vector<int> tr[MAX+1];
int par[MAX+1],n,q;
int mark[MAX+1];

void init(){
    for(int i = 0 ; i < MAX ; i++){
        par[i] = i;
    }
}

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

void unite(int x,int y){
    x = find(x); y = find(y);
    if(x == y) return;
    
    par[y] = x;
}

bool same(int x,int y){
    return find(x) == find(y);
}

int tmp[MAX+1];
void rec(int x,int y,int z){
    int t = z;
    tmp[x] = y;
    if(mark[x]){
        t = x;
    }
    unite(t,x);
    
    for(int i = 0 ; i < tr[x].size() ; i++){
        rec(tr[x][i],x,t);
    }
}

int main(){
    int p,num;
    char m;
    while(cin >> n >> q , n + q){
        ll sum = 0;
        stack<P> st;
        init();
        fill(mark,mark+MAX,0);
        fill(tmp,tmp+MAX,0);
        mark[0] = 1;
        for(int i = 0 ; i < MAX ; i++){
            tr[i].clear();
        }
        for(int i = 1 ; i < n ; i++){
            cin >> p; --p;
            tr[p].push_back(i);
        }
        for(int i = 0 ; i < q ; i++){
            cin >> m >> num; --num;
            st.push(P(m,num));
            
            if(m == 'M'){
                ++mark[num];
            }
        }
        rec(0,-1,-1);
        while(q--){
            P p = st.top(); st.pop();
            if(p.first == 'Q'){
                sum += find(p.second)+1;
            }
            else{
                --mark[p.second];
                if(!mark[p.second]) {
                    unite(tmp[p.second],p.second);
                }
            }
        }
        cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 13768
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a >= b) {
    for (int i = 0; i < a; i++) {
      cout << b;
    }
  } else {
    for (int i = 0; i < b; i++) {
      cout << a;
    }
  }
  return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b,c;
	cin >> a >> b >> c;
	swap(a,b);
	swap(a,c);
	cout << a << " " << b << " " << c;
	return 0;
}

Measured memory_bytes: 3644
import collections
from collections import OrderedDict

#入力
N = int(input())
S = [input() for i in range(N)]

#出現回数のカウント
c = OrderedDict(collections.Counter(S))
ln = len(c.values())

#多い順に並べ替えた辞書をつくる
d = OrderedDict(sorted(c.items(), key = lambda x : x[1], reverse=True))
dval = list(d.values())
dkey = list(d.keys())

#回数が多い単語を抜き出したリストの制作
word = list()
word.append(dkey[0])
i=1
if ln>1:
    while dval[i-1]==dval[i]:
        word.append(dkey[i])
        i+=1
        if i==ln:
            break

#辞書順に並べ替える
dic = sorted(word)

#表示
for i in range(len(dic)):
    print(dic[i])

Measured memory_bytes: 206532
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}



int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);


	int n, x;
	cin >> x >> n;
	set<int> S;


	for(int i = 0; i < n; i++){
		int v;
		cin >> v;
		S.insert(v);
	}

	int dif = 1e9, opt = -101;
	for(int i = -100; i <= 105; i++){
		if(S.count(i))
			continue;

		if(abs(i - x) < dif){
			dif = abs(i - x);
			opt = i;
		}
	}

	cout << opt << endl;

	return 0;
}

Measured memory_bytes: 3652
// Vivek Rai
// Blazer_007

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define fastio      ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll          long long
#define int         long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define ppi         pair<ll,pii>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define bit(x, y)   (((x)>>(y))&1)
#define bpt(x)      (__builtin_popcount(x))
#define bptl(x)     (__builtin_popcountll(x))
#define loop(i,a,b)  for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)

using namespace std;
using namespace __gnu_pbds;

typedef priority_queue<int> maxHeap;
typedef priority_queue<int, vector<int>, greater<int> > minHeap;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(index) -> value at given index or Kth smallest element in set
// order_of_key(X) -> number of elements strictly less than X
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> OST;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cout << name << " : " << arg1 << endl;
    //use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif


istream &operator>>(istream &in, vector<int> &arr)
{
    for(int i = 0 ; i < arr.size() ; i++)
        cin >> arr[i];
    return in;
}

ostream &operator<<(ostream &os, vector<int> arr)
{
    for(int i = 0 ; i < arr.size() ; i++)
        cout << arr[i] << " ";
    cout << endl;
    return os;
}

void solution()
{
    string str;
    cin >> str;
    int sum = 0;
    loop(i,0,sz(str))
        sum += (str[i] - '0');
    if (sum % 9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

signed main()
{
    fastio

    ll t = 1;
    // cin >> t;
    loop(i, 1, t + 1)
    {
        //cout<<"Case #"<<i<<": ";
        solution();
    }
}


    

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

const int DIM = 2e5 + 5;

bitset<DIM> oki; long long val[DIM];
vector<pair<int, long long>> edg[DIM];

void dfs( int x, int r, bool &ok, long long &mn1, long long &mn2 ) {
    oki[x] = true;
    
    if( x <= r )
        mn1 = min( mn1, val[x] );
    else
        mn2 = min( mn2, val[x] );
    
    for( pair<int, long long> y : edg[x] ) {
        if( oki[y.first] == true )
            ok &= ( val[x] + val[y.first] == y.second );
        else {
            val[y.first] = y.second - val[x];
            dfs( y.first, r, ok, mn1, mn2 );
        }
    }
    
    return;
}

int main( void ) {
    
    int r, c, n;
    cin >> r >> c >> n;
    
    for( int i = 1; i <= n; i ++ ) {
        int x, y, z;
        cin >> x >> y >> z;
        
        edg[x].push_back( make_pair( r + y, z ) );
        edg[r + y].push_back( make_pair( x, z ) );
    }
    
    bool ok = true;
    for( int i = 1; i <= r + c; i ++ ) {
        if( oki[i] == false ) {
            long long mn1 = numeric_limits<long long> :: max();
            long long mn2 = numeric_limits<long long> :: max();
           
            dfs( i, r, ok, mn1, mn2 );
            ok &= ( mn1 + mn2 >= 0 );
        }
    }
    
    
    cout << ( ( ok == true ) ? "Yes" : "No" ) << endl;
    return 0;
}

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

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

    if (N%2==0) printf("%lf\n", (double)0.5);
    else {
        double n = (double) N;
        printf("%lf\n", (n+1)/(2*n));
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

using Graph=vector<vector<int>>;
Graph G;

int main(){
  //input
  string s, t;
  cin >> s >> t;
  int ns = s.size();
  int nt = t.size();
  
  bool can = false;
  
  if(ns >= nt){
    int move = ns - nt + 1;
    int start = ns - nt;
    rep(i,move){
      bool match = true;
      rep(j,nt){
        if(s[start-i+j]==t[j])continue;
        else if(s[start-i+j]=='?')continue;
        else{
          match = false;
          break;
        }
      }
      if(match){
        rep(j,nt) s[start-i+j]=t[j];
        can = true;
        break;
      }
    }
  }
  rep(i,ns){
    if(s[i]== '?') s[i]='a';
  }
  
  //output
  if(can) cout << s << endl;
  if(!can) cout << "UNRESTORABLE" <<endl;
  
}
    


Measured memory_bytes: 256
// 2019/06/18
// AtCoder Beginner Contest 075 - A

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

int main() {
    int a, b, c, ans;
    cin >> a >> b >> c;
    if(a == b){
        ans = c;
    } else if(a == c) {
        ans = b;
    } else {
        ans = a;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
string s,t;
int n;
int ans=0;
cin>>n>>s>>t;
for(int i=n;i>=0;i--){
	bool ok=true;
	for(int j=0;j<i;j++){
		if(s[n-i+j]!=t[j]){
			ok=false;
			break;
		}
	}
	if(ok){
		ans=i;
		break;
	}
	}
	cout<<2*n-ans<<endl;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n , x;

int main()
{
    _FastIO;
    set<int> s;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x;
        s.insert(x);
    }
    if(s.size() == n){
        cout <<  "YES" << endl;
    }
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 9600
# coding: utf-8
# Your code here!
import sys
N, M, X = map(int, input().split())

mylist = []

for n in range(N):
    costlist = list(map(int, input().split()))
    mylist += [costlist]
#print(mylist)

mymin =  float('INF')
for i in range(2 ** N):             #①
    myflag = [0 for i in range(N)]  #結果を出力するためのlistの初期化
    for j in range(N):
        if ((i >> j) & 1):          #②
            myflag[n - 1 - j] = 1

    mycost = 0
    myab = [0 for m in range(M)]
    #print(myflag, myab)
    for n in range(N):
        if myflag[n] == 1:
            mycost += mylist[n][0]
            for m in range(M):
                myab[m] += mylist[n][m+1]
    if min(myab) >= X:
        if mycost < mymin:
            mymin = mycost
            
if mymin == float('INf'):
    print(-1)
else:
    print(mymin)


Measured memory_bytes: 9240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			if (numA * numB % 2 == 0) {
				System.out.println("Even");
			} else {
				System.out.println("Odd");
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 22484
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,k,d[100];
    bool b[100]={};
    cin>>n>>k;
    rep(i,k){
        cin>>d[i];
        b[d[i]]=1;
    }
    ll now=n;
    while(true){
        string s=to_string(now);
        bool ok=true;
        rep(i,s.size()){
            if(b[s[i]-'0']){
                ok=false;
                break;
            }
        }
        if(!ok){
            now++;
            continue;
        }
        break;
    }
    cout<<now<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	ll n,a,b;
	ll minsum;
	ll maxsum;
	ll ans=0;
	
	cin>>n>>a>>b;
	minsum=b;
	maxsum=a;
	for(int i=0;i<n-1;i++)
	{
		minsum+=a;
		maxsum+=b;
	}
	ans=maxsum-minsum+1;
	if(ans<0)
		ans=0;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<int, int>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

void printv(const vector<int>& vec){
	for (int i = 0; i < vec.size(); ++i) {
		cout << vec[i];
		if (i != vec.size() - 1) cout << ' ';
		else cout << endl;
	}
}

int main(){
	int n; cin >> n;
	if(n==3){
		printv({2,5,63});
		return 0;
	}
	if(n==4){
		printv({ 2,5,20,63 });
		return 0;
	}

	vector<int> two, three, six;
	for(int i = 2; i <= 30000; ++i){
		if(i%6==0)six.push_back(i);
		else if(i%2==0)two.push_back(i);
		else if(i%3==0)three.push_back(i);
	}

	vector<int> ans { two[0], two[1], three[0], three[1]};
	n -= 4;

	for (int i = 2; i + 1 < three.size(); i += 2) {
		if (n <= 1)break;
		ans.push_back(three[i]);
		ans.push_back(three[i + 1]);
		n -= 2;
	}
	for(int i = 2; i+1 < two.size(); i+=2){
		if (n <= 1)break;
		ans.push_back(two[i]);
		ans.push_back(two[i+1]);
   		n-=2;
	}

	for (int i = 0; i < six.size(); ++i) {
		if (n == 0)break;
		ans.push_back(six[i]);
		--n;
	}

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

	printv(ans);
	
	return 0;
}

Measured memory_bytes: 640
s  = input().split(" ")
a  = int(s[0])
b  = int(s[1])
c  = int(s[2])
k  = int(s[3])
 
t = 0
if a >= k:
  print(k)
else:
  t += a
  if b >= (k - a):
    print(a)
  else:
    if c <= (k - a -b): 
    	t -=  c
    else:
      	t -= (k - a -b)
    print(t)

Measured memory_bytes: 9204
// header {{{
// #define NDEBUG
#include <bits/stdc++.h>
using namespace std;

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
// #define EQ(a, b)    (abs((a)-(b)) < EPS)
inline bool EQ(double a, double b) {return abs(a-b) < EPS;}
// ciling(x/y) = (x+y-1)/y

template<class T>
using PIT = pair<int, T>;
template<class T>
using PTI = pair<T, int>;
using PII = pair<int, int>;
using PDI = pair<double, int>;
using LL  = long long;
using ULL = unsigned long long;
// }}}

int main() {
    string s;cin >> s;
    map<char, bool> m;
    m['N'] = false;
    m['W'] = false;
    m['S'] = false;
    m['E'] = false;
    for(auto c : s) m[c] = true;
    cout << ((m['N'] ^ m['S']) | (m['W'] ^ m['E']) ? "No" : "Yes") << endl;
    return 0;
}


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

bool mas[11][10][10];
int sy, sx, n;
int dy[] = { -2, -2, -2, -1, 0, 1, 2, 2, 2, 1, 0, -1};
int dx[] = { -1, 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2};

bool dfs(int y, int x, int idx){
  if(idx == n) return true;
  for(int i = 0; i < 12; i++){
    int ny = y + dy[i], nx = x + dx[i];
    if(ny < 0 || ny >= 10 || nx < 0 || nx >= 10 || !mas[idx][ny][nx]) continue;
    if(dfs( ny, nx, idx + 1)) return true;
  }
  return false;
}

int main(){

  while(cin >> sx >> sy, sx||sy){
    memset( mas, false, sizeof(mas));

    cin >> n;

    int y0, x0;

    for(int i = 0; i < n; i++){
      int y, x;
      cin >> x >> y;

      mas[i][y][x] = true;
      for(int j = -1; j <= 1; j++){
        for(int k = -1; k <= 1; k++){
          int ny = y + j, nx = x + k;
          if(ny < 0 || ny >= 10 || nx < 0 || nx >= 10) continue;
          mas[i][ny][nx] = true;
        }
      }
    }
    puts(dfs( sy, sx, 0) ? "OK" : "NA");
  }
}

  

Measured memory_bytes: 1116
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <cstdlib>
using namespace std;
#define pii pair<int,int>
#define ft first
#define sc second
#define INF 1000000006
#define INFLL 4000000000000000006ll
#define vi vector<int>
#define pb push_back
#define eb emplace_back
#define gc getchar_unlocked
#define getInt(x) while((_c=gc())<'0'); x=_c-'0'; while((_c=gc())>='0') x=x*10+_c-'0';
#define LL long long
#define DB double
#define PARAM int id, int l, int r
#define _L id*2,l,mid
#define _R id*2+1,mid+1,r
#define PREP int mid = (l+r)/2
#define MEMSET(x,y) memset(x,y,sizeof(x));
#define MOD 1000000007

int n;
vector<pii> ax, ay;
vector<pair<int,pii> > dx, dy;
int par[100005];

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

int main(){
	char _c; getInt(n);
	for(int i = 0; i < n; i++ ){
		par[i] = i;
		int x, y; getInt(x) getInt(y)
		ax.eb(x,i);
		ay.eb(y,i);
	}
	sort(ax.begin(),ax.end());
	sort(ay.begin(),ay.end());
	for(int i = 1; i < (int)ax.size(); i++ ){
		dx.pb({ax[i].ft-ax[i-1].ft,{ax[i-1].sc,ax[i].sc}});
	}
	for(int i = 1; i < (int)ay.size(); i++ ){
		dy.pb({ay[i].ft-ay[i-1].ft,{ay[i-1].sc,ay[i].sc}});
	}
	sort(dx.begin(),dx.end());
	sort(dy.begin(),dy.end());
	dx.pb({INF,{0,0}});
	dy.pb({INF,{0,0}});
	int px = 0, py = 0;
	LL res = 0;
	while(px<dx.size()-1 || py<dy.size()-1){
		pii comb; int diff;
		if(dx[px].ft < dy[py].ft){
			comb = dx[px].sc; diff = dx[px].ft; px++;
		}
		else comb = dy[py].sc, diff = dy[py].ft, py++;
		int u = parOf(comb.ft);
		int v = parOf(comb.sc);
		if(u==v) continue;
		par[v] = u;
		res += diff;
	}
	printf("%lld\n",res);
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vi l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(),l.end());
  ll ans = 0;
  for(int a=0; a<n-2; a++){
    for(int b=a+1; b<n-1; b++){
      for(int c=b+1; l[c]<l[a]+l[b]; c++){
        if(l[a] >= l[b] + l[c]) continue;
        if(l[b] >= l[a] + l[c]) continue;
        if(l[c] >= l[a] + l[b]) continue;
        ans ++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define N 500005
using namespace std;
typedef long long LL;
int read()
{
	int ans=0,f=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar())
	if(c=='-') f*=-1;
	for(;'0'<=c&&c<='9';c=getchar())
		ans=ans*10+c-'0';
	return ans*f;	
}
int lst[N],nxt[N],e[N],cnt;
void build(int x,int y)
{
	e[++cnt]=y;
	nxt[cnt]=lst[x];
	lst[x]=cnt;
}
int dfn[N],tot,ed[N];
void dfs(int x,int f)
{
	dfn[x]=++tot;
	for(int u=lst[x];u;u=nxt[u])
	if(e[u]!=f)dfs(e[u],x);
	ed[x]=tot;
}
LL v[N];
int n,q;
int main()
{
	n=read(),q=read();
	for(int i=1;i<n;i++)
	{
		int u=read(),v=read();
		build(u,v),build(v,u);
	}
	dfs(1,0);
	while(q--)
	{
		int x=read();
		LL p=read();
		v[dfn[x]]+=p,v[ed[x]+1]-=p;
	}
	for(int i=1;i<=n;i++)v[i]+=v[i-1];
	for(int i=1;i<=n;i++)printf("%d%c",v[dfn[i]],(i==n)?'\n':' ');
	return 0;
}

Measured memory_bytes: 23808
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var N = consoleReader.Int;
            var a = consoleReader.Split.Int.Select((x, i) => x - i - 1).OrderBy(i => i).ToArray();
            var b = a[(a.Length - 1) / 2];

            long s = 0;
            foreach (var item in a)
                s += Math.Abs(item - b);

            return s;
        }


        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader
    {
        private string[] line = Array.Empty<string>();
        private int linePosition;
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                if (linePosition >= line.Length)
                {
                    linePosition = 0;
                    line = textReader.ReadLine().Split();
                }
                return line[linePosition++];
            }
        }
        public class SplitLine
        {
            private string[] splited;
            public SplitLine(ConsoleReader cr) { splited = cr.textReader.ReadLine().Split(); }
            public int[] Int => String.Select(x => int.Parse(x)).ToArray();
            public long[] Long => String.Select(x => long.Parse(x)).ToArray();
            public double[] Double => String.Select(x => double.Parse(x)).ToArray();
            public string[] String => splited;
        }
        public SplitLine Split => new SplitLine(this);
        public class RepeatReader
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerable<T> Select<T>(Func<ConsoleReader, T> func) { for (int i = 0; i < count; i++) yield return func(cr); }
            public IEnumerable<string> String { get { for (int i = 0; i < count; i++) yield return cr.String; } }
            public IEnumerable<int> Int { get { for (int i = 0; i < count; i++) yield return cr.Int; } }
            public IEnumerable<double> Double { get { for (int i = 0; i < count; i++) yield return cr.Double; } }
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
}

Measured memory_bytes: 36128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<double, double> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

P grabity(vector<P> points){
  double x=0,y=0;
  REP(i,points.size()){
    x += points[i].first;
    y += points[i].second;
  }
  x/=(double)points.size();
  y/=(double)points.size();
  return P(x,y);
}
double diff(P p1, P p2){
  return sqrt( pow(p2.first-p1.first,(double)2) 
      + pow(p2.second-p1.second,(double)2) );
}
double area(P p1, P p2, P p3){
  double a = diff(p1,p2);
  double b = diff(p2,p3);
  double c = diff(p3,p1);
  double z = (a+b+c)/2;
  return (sqrt(z*(z-a)*(z-b)*(z-c)));
}

int main(void){
  vector<P> points;
  double x,y;
  while(scanf("%lf,%lf",&x,&y)!=EOF){
    points.push_back(P(x,y));
  }
  double ans = 0;
  P g = grabity(points); 
  REP(i,points.size()){
    ans += area(points[i],
        points[(i+1)%points.size()],g);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
 
int main() {
  int five = 0;
  int seven = 0;
  
  using namespace std;
  int i;
  cin >> i;
  if (i == 5) ++five; else if (i == 7) ++seven;
  cin >> i;
  if (i == 5) ++five; else if (i == 7) ++seven;
  cin >> i;
  if (i == 5) ++five; else if (i == 7) ++seven;
  cout << (five == 2 && seven == 1 ? "YES" : "NO");
}

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

const int PRIME_MAX = 1e5+100;

int main(){
    using namespace std;
    int Q; cin >> Q;
    vector<int> l(Q), r(Q);
    vector<int> n_like(PRIME_MAX, 0);
    for (int i = 0; i < Q; i++) cin >> l[i] >> r[i];

    vector<bool> is_prime(PRIME_MAX, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 4; i < PRIME_MAX; i+=2) is_prime[i] = false;
    for (int i = 3; i < PRIME_MAX; i+=2)
    {
        if(!is_prime[i]) continue;
        for (int j = i*2; j < PRIME_MAX; j+=i) is_prime[j] = false;  
    }
    
    for (int i = 1; i < PRIME_MAX; i++)
    {
        if(i%2==1 && is_prime[i] && is_prime[(i+1)/2]) n_like[i] = n_like[i-1] + 1;
        else n_like[i] = n_like[i-1];
    }
    
    for (int i = 0; i < Q; i++)
    {
        cout << n_like[r[i]] - n_like[l[i]-1] << endl;
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N;
    cin >> N;
    vector<int> L(N);
    REP (i, N) {
        cin >> L[i];
    }
    REP(i,N) FOR(j,i+1,N) FOR(k,j+1,N) {
        if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) {
            if (L[i]+L[j] > L[k] && L[j]+L[k]>L[i]&&L[k]+L[i]>L[j]) ans++;
        }
    }
    cout << ans << endl;
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc175/abc175_b && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc175/abc175_b && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc175/abc175_b && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int H = scanner.nextInt();
    int W = scanner.nextInt();
    char[][] graph = new char[H][W];
    for (int i = 0; i < H; i++) {
      graph[i] = scanner.next().toCharArray();
    }

    int[][] groups = new int[H][W];
    int gid = 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (groups[i][j] == 0) {
          gid++;
          groups[i][j] = gid;
          dfs(H, W, graph, groups, gid, i, j);
        }
      }
    }

    long[][] numcolor = new long[gid + 1][2];
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (graph[i][j] == '.') numcolor[groups[i][j]][0]++;
        else numcolor[groups[i][j]][1]++;
      }
    }

    long res = 0;
    for (int i = 0; i <= gid; i++) res += numcolor[i][0] * numcolor[i][1];
    System.out.println(res);
  }

  private static void dfs(int H, int W, char[][] graph, int[][] groups, int gid, int i, int j) {
    for(int[] d : new int[][]{ {-1, 0}, {1, 0}, {0, -1}, {0, 1}}) {
      int ni = i + d[0];
      int nj = j + d[1];
      if (ni >= 0 && ni < H && nj >= 0 && nj < W) {
        if (graph[i][j] != graph[ni][nj] && groups[ni][nj] == 0) {
          groups[ni][nj] = gid;
          dfs(H, W, graph, groups, gid, ni, nj);
        }
      }
    }

  }
}


Measured memory_bytes: 79732
#include<iostream>
#include<vector>
#include<math.h>

using namespace std;

int maxnum(int f, int s, int t) {

   if (f >= s && f >= t) {

      return 0;

   }
   else if (s >= f && s >= t) {

      return 1;

   }
   else {

      return 2;

   }

}

bool solve() {

   int n;
   int set[1000][3];
   bool f;

   cin >> n;

   for (long i = 0; i<n; i++) {

      for (long j = 0; j < 3; j++) {

         cin >> set[i][j];

      }

   }

   for (long i = 0; i < n; i++) {

      f = (pow(set[i][0], 2) == (pow(set[i][1], 2) + pow(set[i][2], 2)) || pow(set[i][1], 2) == (pow(set[i][0], 2) + pow(set[i][2], 2)) || pow(set[i][2], 2) == (pow(set[i][0], 2) + pow(set[i][1], 2)));
      f ? cout << "YES\n" : cout << "NO\n";
   }

   return 0;
}

int main() {

   return solve();

}

Measured memory_bytes: 2952
number = list(map(int,input().split()))
K = int(input())
sum = 0
times = 0

while True:
    large_number = max(number)
    number.remove(large_number)
    number.append(large_number*2)
    times += 1
    if times == K:
        break
for i in range(3):
    sum += number[i]
print(sum)


Measured memory_bytes: 3060
# -*- coding: cp932 -*-

import sys
import os
import re
import datetime
import bisect

### main ###

X = input()

restS = []
for c in X:
    #print("c = {}".format(c))
    restS.append(c)
    if c == 'T':
        while(len(restS) >= 2):
            #print("restS = {}, last 2 string = {} ".format(restS, restS[-2:]))
            #if("".join(restS[-2:]) == 'ST'):
            if(restS[-2] == 'S' and restS[-1] == 'T'): # Higher Speed than join ?
                #print("hit restS[-2] = {}, restS[-1] = {}".format(restS[-2], restS[-1]))
                #restS = restS[:-2] # TLE
                del restS[-2:]
                #print("new restS = {}".format(restS))
            else:
                #print("no hit restS = {}".format(restS))
                break # out of while

print(len(restS))

Measured memory_bytes: 5652
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    long double A, B;
    cin >> A >> B;
    long double a = floorl(A * B);
    ll ans = a;
    cout << ans << endl;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
int fac[9];
int count(int A[],int n){
  if(n==2){
    if(A[0]==1) return(1);
    else return(2);
  }
  int arr[n-1],x=A[0];
  for(int i=0;i<n-1;i++){
    if(A[i+1]<x) arr[i]=A[i+1];
    else arr[i]=A[i+1]-1;
  }
  
  return(count(arr,n-1)+(x-1)*fac[n-1]);
}
int main(){
	int n;
  	cin>>n;
  	int A[n],B[n];
  	fac[0]=1;
  	for(int i=1;i<=8;i++) fac[i]=fac[i-1]*i;
  	fac[0]=0;
    for(int i=0;i<n;i++) cin>>A[i];
  	for(int i=0;i<n;i++) cin>>B[i];
  	
  	cout<<abs(count(A,n)-count(B,n));
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    long long A, B; cin >> A >> B;
    if (A == B) {
        cout << A << endl;
        return 0;
    } else if ((A+B)%2 == 0) {
        cout << (A+B)/2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 256
// Problem : B - Go to Jail
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

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

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  lcm(x, y)   ((x) * (y) / __gcd(x, y))
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    int n; cin >> n;
    
    int cnt = 0,n1,n2;
    
    while(n--){
        cin >> n1 >> n2;
        if(n1!=n2) cnt = 0;
        else cnt++;
        
        if(cnt==3) {cout << "Yes"; return;}
    }
    
    cout << "No";
    
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 3616
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin >> s>>t;
  t.pop_back();
  if(s==t){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }

}


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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  int ans = 0;
  for(int i=0;i<N;i++){
    int l,r;
    cin >> l >> r;
    sum = r - l + 1;
    ans += sum;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char c(const string&s){
  return char(s[0] + 'A' - 'a');
}
int main(){
  string s;
  cin >> s;
  cout << c(s);
  cin >> s;
  cout << c(s);
  cin >> s;
  cout << c(s);
  cout << endl;
}

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (ll i = a; i >= b; i--)
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           (a)*(a)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)

int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        ll x=1,y=1,z=1;
        loop(i,0,n-1) x=(x*10)%mod;
        loop(i,0,n-1) y=(y*9)%mod;
        loop(i,0,n-1) z=(z*8)%mod;
        ll ans=(x+z-(2*y)%mod)%mod;
        if(ans<0) ans+=mod;
        cout<<ans%mod;
    }
    return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;

int main(){
    int n,m;
    cin>>n>>m;
    vector<P>job(n);
    rep(i,n){
        cin>>job[i].first>>job[i].second;
    }
    sort(job.begin(),job.end());
    priority_queue<int>q;
    int i=0;
    int ans=0;
    rep(j,m+1){
        while(i<n&&j>=job[i].first){
            q.push(job[i].second);
            i++;
            if(i>n-1)break;
        }
        if(q.size()!=0){
            ans+=q.top();
            q.pop();
        }
        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1660
N = int(input())

def dfs(number):
    if int(number) > N:
        return 0
    if all(number.count(n) > 0 for n in '753'):
        ret = 1
    else:
        ret = 0
    for n in '753':
        ret += dfs(number + n)
    return ret
    
print(dfs('0'))

Measured memory_bytes: 3060
#include <stdio.h>

int isprime(int n)
{
	for(int i = 2; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			return 0;
		}
	}
	return 1;
}

int main()
{
	int p1[10000];
	int q1[10000];
	int n, i, cnt = 0;

	while(1)
	{
		scanf ("%d",&n);
		for(i=n; i!=0; i--)
		{
			if(isprime(i) == 1 && isprime(i-2) == 1)
			{
				p1[cnt] = i;
				q1[cnt] = i-2;
				break;
			}
		}
		if(n==0)
		{
			break;
		}
		cnt++;
	}
	for(i=0; i<cnt; i++)
	{
		printf("%d %d\n",q1[i],p1[i]);
	}
	return 0;
}

Measured memory_bytes: 2788