akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
typedef long long ll;

int f(ll a, ll b)
{
  int i = 0, j = 0;
  while(a > 0){
    a /= 10;
    i++;
  }
  while(b > 0){
    b /= 10;
    j++;
  }
  return (i > j ? i : j);
}

int
main(int argc, char *argv[])
{
  ll n;
  scanf("%lld", &n);

  ll k = 1; int ans = 100; int temp;
  while(k * k <= n){
    if(n % k == 0){
      temp = f(k, n / k);
      ans = (ans > temp ? temp : ans);
    }
    k++;
  }
  printf("%d\n", ans);

  return 0;
}

  


Measured memory_bytes: 128
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    A, B = MAP()
    if (A + B) % 2:
        print('IMPOSSIBLE')
    else:
        print(int((A + B) / 2))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll L[101];
ll ans;

int main(){
	ll n;
	cin >> n;
	cinf(L,n);
	rep(i,n){
		arep(i+1,j,n){
			arep(j+1,k,n){
				if(L[i]+L[j]>L[k] && L[j]+L[k]>L[i] && L[k]+L[i]>L[j] && L[i]!=L[j] && L[j]!=L[k] && L[k]!=L[i])
					ans++;
				//cout << i << "," << j << "," << k<< endl;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N,Q;cin>>N>>Q;
  string s;cin>>s;s='?'+s;s=s+'?';
  vector<pair<char,char>>A(Q);
  for(int i=0;i<Q;i++){
  char t,d;cin>>t>>d;
    pair<char,char>p(t,d);
    A.at(i)=p;
  }int64_t left=0;int64_t right=N+1;
  while(1<right-left){
  int64_t mid=left+(right-left)/2;
    int64_t a=mid;bool x=true;
    for(int i=0;i<Q;i++){
    char t=A.at(i).first;
      char d=A.at(i).second;
      if(s.at(a)==t){
      if(d=='R')a++;
        else a--;
      }if(a==N+1){x=false;break;}
     }if(x)left=mid;
    else right=mid;
   }int64_t left1=0;int64_t right1=N+1;
  while(1<right1-left1){
  int64_t mid=left1+(right1-left1)/2;
    int64_t a=mid;bool x=true;
    for(int i=0;i<Q;i++){
    char t=A.at(i).first;
      char d=A.at(i).second;
      if(s.at(a)==t){
      if(d=='R')a++;
        else a--;
      }if(a==0){x=false;break;}
     }if(x)right1=mid;
    else left1=mid;
   }if(1<=left-right1+1)
    cout<<left-right1+1<<endl;
  else
    cout<<0<<endl;
  return 0;
}

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

signed main(){
	string s;
	cin>>s;
	int a=s.size();
	if(s[a-1]=='s') cout<<s<<"es";
	else cout<<s<<"s";
	return 0;
}


Measured memory_bytes: 3624
// C - Vacation
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

// void vprn(vi &v){ for(int i=0;i<v.size();i++) printf("%4d%c",v[i],(i<v.size()-1?',':'\n')); }
// void vvprn(vvi &vv){ for(auto v:vv){ vprn(v); } }
// void dpprn(vvi &dp){
// 	cout<<"dp a,   b,   c\n----------------\n";
// 	vvprn(dp);cout<<"-----------------\n";
// }

int main(){
	int N; cin>>N;
	vvi dp(N, vi (3));
	cin>>dp[0][0]>>dp[0][1]>>dp[0][2];
	for(int n=1; n<N; n++){
		cin>>dp[n][0]>>dp[n][1]>>dp[n][2];
		dp[n] = {
			//                     a           b           c
			dp[n][0] + max(            dp[n-1][1], dp[n-1][2]),
			dp[n][1] + max(dp[n-1][0],             dp[n-1][2]),
			dp[n][2] + max(dp[n-1][0], dp[n-1][1])
			};
	}
	// dpprn(dp);
	cout<< *max_element(dp[N-1].begin(), dp[N-1].end()) <<endl;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;

ll ncr(ll m, ll n) {
  rep(i,0,30) if ( (n&(1<<i)) and not (m&(1<<i)) ) return 0;
  return 1;
}

int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);

  ll n;
  cin >> n;
  string s;
  cin >> s;

  vi a(n);
  bool b=1;
  rep(i,0,n) {
    a[i] = s[i]-'0';
    --a[i];
    if (a[i] == 1) b=0;
  }

  if (b) rep(i,0,n) if (a[i] == 2) a[i] = 1;

  ll ans = 0;
  rep(i,0,n) {
    ans += a[i]*ncr(n-1, i);
    ans %= 2;
  }

  if (b and ans) ans=2;
  cout << ans << endl;
}

Measured memory_bytes: 9244
from collections import defaultdict


def cand_count(v, d):
    return len(tuple(filter(lambda x: x >= v, d.values())))


n = int(input())
d = defaultdict(int)

for i in range(2, n + 1):
    b = i
    j = 2
    while j * j <= i:
        while b % j == 0:
            b //= j
            d[j] += 1
        j += 1
    if b > 1:
        d[b] += 1
    # print(i, j, d)
# print(d)

ans = 0
ans += cand_count(74, d)
ans += cand_count(24, d) * (cand_count(2, d) - 1)
ans += cand_count(14, d) * (cand_count(4, d) - 1)
ans += cand_count(4, d) * (cand_count(4, d) - 1) // 2 * (cand_count(2, d) - 2)
print(ans)


Measured memory_bytes: 3436
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int N;
    cin >> N;

    vector<pair<int, int>> BA(N);

    int a, b;
    for(int i = 0; i < N; i++){
        cin >> a >> b;
        BA[i] = make_pair(b, a);
    }

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

    int time = 0;
    for(int i = 0; i < N; i++){
        auto temp = BA[i];
        time += temp.second;
        if(time > temp.first){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<vector>
#include<cstdio>
#include<climits>
#include<cfloat>
#include<cstring>
#define foreach(t,p,tit) for(t::iterator tit=p.begin();tit!=p.end();++tit)
#define rforeach(t,p) for(t::reverse_iterator it=p.rbegin();it!=p.rend();++it)
#define all(p) p.begin(),p.end()
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
char uru[3100]={};

#define MAX 3000
int main()
{
    memset(uru,0,sizeof(uru));
    rep(i,MAX+1)if(i%4==0)uru[i]=1;
    rep(i,MAX+1)if(i%100==0)uru[i]=0;
    rep(i,MAX+1)if(i%400==0)uru[i]=1;

    int a,b,f=0,na=1;
    while(cin>>a>>b)
    {
        na = 1;
        if(a==0&&b==0)break;
        if(f){cout<<endl;f=0;}
        for(int i=a;i<=b;i++)if(uru[i]){cout << i << endl; na = 0;}
        
        if(na)cout << "NA"<<endl;

        f=1;
    }
    //cout<<endl;
    
    return 0;
}

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

using namespace std;

#define inputInt(a) scanf("%d", &a)
#define inputStr(a) getline(cin, a)
#define inputLong(a) scanf("%I64d", &a)
#define clr(a) memset(a, 0, sizeof(a))
#define printn(a) cout<<a<<"\n"
#define print(a) cout<<a

int main()
{
	long long Lucas[90];
	int n;

	Lucas[0] = 2;
	Lucas[1] = 1;

	for(int i = 2; i<= 86; i++)
		Lucas[i] = Lucas[i-1] + Lucas[i-2];

	cin>>n;
	cout<<Lucas[n]<<endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

B = [0]*N

num = 0
for i in reversed(range(N)):
    B[i] = A[i] + num
    num = B[i]
    
ans = 0
for i in range(N-1):
    ans += A[i]*B[i+1] %1000000007

print(ans%1000000007)

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

int main() {
  int N;//N日間夏休み
  int M;//M個の宿題
  vector<int> hom(M);//宿題
  int t = 0;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    cin >> hom.at(i);
  }
  for(int i = 0; i < M; i++){
    t += hom.at(i); 
  }
  if(N-t < 0){
    cout << "-1" << endl;
  }
  else{
    cout << N - t << endl;
  }
}

Measured memory_bytes: 3704
/* Coached by rainboy */
#include <math.h>
#include <stdio.h>

#define N 8

int main() {
	static int xx[N], yy[N];
	int n, i, j;
	double x;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d%d", &xx[i], &yy[i]);
	x = 0;
	for (i = 0; i < n; i++)
		for (j = i + 1; j < n; j++)
			x += hypot(xx[i] - xx[j], yy[i] - yy[j]);
	printf("%.10f\n", x / (n * (n - 1) / 2) * (n - 1));
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
string s,t;

int main(){
	cin>>s>>t;
	int ns=s.size();
	int nt=t.size();
	int cnt=ns-1;
	char q;
	if(s==t){
		cout<<"Yes"<<endl;
		return 0;
	}
	else{
		while(cnt--){
			char tmp=s[ns-1];
		    for(int i=ns-1;i>=1;i--){
		        s[i]=s[i-1];
	        }
	        s[0]=tmp;
	        /*
	        for(int i=0;i<ns;i++){
	    	    cout<<s[i];
		    }
		    cout<<endl;
		    */
		    if(s==t){
		    	cout<<"Yes"<<endl;
		    	return 0;
			}
			
		}
	}
	cout<<"No"<<endl;
	return 0;
} 

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

using namespace std;

int n, k;
vector <int> g[100001];
int ans, mx, cur;

void dfs (int v, int pr, int lvl, int start) {
	ans ++;
	if (k % 2 == 0 && lvl == k / 2) return;
	for (auto to : g[v]) {
		if (to == pr) continue;
		if (lvl == k / 2) {
			int sz = g[v].size () - 1;      
			cur += sz;
			break;
		}
		if (v == start) {
			mx = max (mx, cur);
			cur = 0;
		}
		dfs (to, v, lvl + 1, start);
	}
}

int main () {
	cin >> n >> k;
	for (int i = 1;i < n;i ++) {
		int x, y;
		cin >> x >> y;
		g[x].push_back (y);
		g[y].push_back (x);
	}
	if (k == 1) {
		cout << n - 2;
		return 0;
	}
	int almas = 1e9 + 7;
	for (int i = 1;i <= n;i ++) {
		ans = 0, mx = 0, cur = 0;
		dfs (i, 0, 0, i);
	//	ans = n - ans - mx;
	//	cout << "HEY ";
	//	cout << i << ' ' << ans << ' ' << mx << endl;
		almas = min (almas, n - ans - mx);
	}
	cout << almas;
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  string A;
  cin >> A;
  int X = A.size();
  if(A.at(X - 1) == 's') {
    cout << A << "es" << endl;
  }
  else {
    cout << A << "s" << endl;
  }
}

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

int main(){

  string S;
  int sum=0;

  cin >> S;
  
  if(S[0] == 'S'){
    if(S[1] == 'R')
      sum++;
    if(S[2] == 'R')
      sum++;
  }else{
    sum++;
    if(S[1]=='R'){
      sum++;
      if(S[2] == 'R')
        sum ++;
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  cin >> A;
  string B;
  cin >> B;
  for(int i=0;i<B.size();i++){
    if(B[i]+A>'Z'){
      B[i]=B[i]-(26-A);
    }
    else{
    	B[i]=B[i]+A;
    }
    cout << B[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <deque>
#include <functional>
using namespace std;
int main(){
	int num;
	deque<int> h;
	for(int i = 0; i < 10; i++){
		cin >> num;
		h.push_back(num);
	}
	sort(h.begin(), h.end(), greater<int>());
	deque<int>::iterator it = h.begin();
	while(it != h.begin()+3){
		cout << *it << endl;
		++it;
	}
	return(0);
}

Measured memory_bytes: 1204
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>
#include <cassert>
#include <stack>
using namespace std;
typedef long long LL;
const int N = 1e6+7 , INF = 0x3f3f3f3f , MOD = 1e9+7;
const double PI = acos(0.0) * 2;
template<typename T1>
T1 gcd(T1 a , T1 b){ return b ? gcd(b,a%b) : a;}

int main(){
#ifdef LOCAL
    freopen("F:\\c++\\in.txt", "r", stdin);
//  freopen("F:\\c++\\out.txt","w",stdout);
#endif
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    puts((a*100+b*10+c)%4==0?"YES":"NO");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <functional>
#include <cassert>

using namespace std;

using i64 = long long;
using P = pair<i64, i64>;

const i64 mod = 1e9 + 7;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

int main(){
    int x, y;
    cin >> x >> y;
    if(x == y && x == 1){
        cout << 1000000 << endl;
    }else{
        int sum = 0;
        if(x == 1) sum += 300000;
        if(y == 1) sum += 300000;
        if(x == 2) sum += 200000;
        if(y == 2) sum += 200000;
        if(x == 3) sum += 100000;
        if(y == 3) sum += 100000;
        cout << sum << endl;
    }
}

Measured memory_bytes: 256
ary = list(map(int, input()))

# それぞれ数ごと
for i in range(1 << 3):
    tmp = ary[0]
    ans = str(ary[0])
    for j in range(3):
        if i & (1 << j):
            tmp += ary[j + 1]
            ans += "+" + str(ary[j + 1])
        else:
            tmp -= ary[j + 1]
            ans += "-" + str(ary[j + 1])

    if tmp == 7:
        print(ans + '=7')
        break


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		//かんらんしゃ
		int A=sc.nextInt();
		int B=sc.nextInt();
		if(A<6) {
			pl(0);
		}
		else if(A<13) {
			pl(B/2);
		}
		else{
			pl(B);
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

int N;
int solve(vector<int> A){
  int ret = 0;
  int sum = 0;
  REP(i, N-1) A[i+1] += A[i];
  FOR(i, 1, N){
    A[i] += sum;
    if(A[i]*A[i-1] >= 0){
      if(A[i] == 0){
        if(A[i-1] < 0){
          sum++;
          ret++;
          A[i] += 1;
        }else{
          sum--;
          ret++;
          A[i] -= 1;
        }
      }else if(A[i] > 0){
        sum -= A[i]+1;
        ret += A[i]+1;
        A[i] = -1;
      }else{
        sum += -A[i]+1;
        ret += -A[i]+1;
        A[i] = 1;
      }
    }
  }
  return ret;
}

signed main() {
  cin >> N;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int ans = 0;
  if(A[0] != 0){
    ans = solve(A);
    int ret = abs(A[0])+1;
    if(A[0] > 0){
      A[0] = -1;
    }else{
      A[0] = 1;
    }
    chmin(ans, solve(A)+ret);
  }
  else{
    A[0] = 1;
    ans = solve(A)+1;
    A[0] = -1;
    chmin(ans, solve(A)+1);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1804
/*------------------------Original Copyright belongs to-------------------------/
!      																			!
!      ##  ##                                                		##  ##	    !
!      #   #             											#   #		!		                
!      				 ###  ####  ###   ###     ##         #                      !
!					#     #  #  #  #  #  #   #  #       ##                      !
!					#	  #  #  ###   ###    ####        #                      !
!					#     #  #  #  #  #  #   #  #        #                      !
!					 ###  ####  ###   #   #  #  #  ###  ### 			        !
!                                                                               !
/------------------------------------------------------------------------------*/
#include<bits/stdc++.h>
using namespace std;
//------------Template begins--------------------//
#define ss string
#define last(s) s.length()-1
#define lli long long int
#define v(type) vector<type>
#define pr(type1,type2) pair<type1,type2>
#define ma(type1,type2) map<type1,type2>
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define L(i,start,end) for(lli i=start;i<=end;i++)
#define R(i,start,end) for(lli i=start;i>=end;i--)
#define inp(var,start,end,array) for(var=start;var<=end;var++) cin>>array[var];
#define whatIs(x) cout<<#x<<" is "<<x<<endl
#define dbg1D(i,start,end,arr) for(lli i=start;i<=end;i++) cout<<i<<"th : "<<arr[i]<<endl;
#define dbg2D(i,j,s1,e1,s2,e2,arr) for (lli i=s1;i<=e1;i++) {cout<<i<<"th :"; for(lli j=s2;j<e2;j++)cout<<arr[i][j]<<" ";cout<<endl;}

lli dx[4]={-1, 0, 0, +1};
lli dy[4]={0, -1, +1, 0};
const lli LINF = 1e18;
const lli INF = 1e9;
const lli mod = 1e9+7;
lli power(lli a,lli b,lli m){ if(b==0) return 1; if(b==1) return a%m;
 		lli t=power(a,b/2,m); t=(t*t)%m; if(b&1) t=(t*a)%m; return t;}
lli modInverse(lli a, lli m) { return power(a, m-2, m); }
//---------------Template ends------------------//
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	#ifndef ONLINE_JUDGE
	//freopen("ip.txt","r",stdin);
	//freopen("op.txt","w",stdout);
	#endif
//#################### CATCH HERE ##########################
   	/* Uncomment if t test cases
	lli t;
	cin>>t;
	while(t--)
	{
		lli n,ans,i,j;

		cout<<ans<<endl;
	}
	*/
	lli a,b,ans=0;
	cin>>a>>b;
	if(a>=13)
		ans=b;
	else if(a>=6)
		ans=b/2;
	else
		ans=0;
	cout<<ans<<endl;
//##########################################################
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  char A,B;;
  cin>>A>>B;
  if((A=='H'&&B=='H')||(A=='D'&&B=='D')){
    cout<<'H'<<endl;
  }else{
    cout<<'D'<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e6 + 1;
	
	void doIt() {
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		int sum = 0;
		if(K >= A) {
			K -= A;
			sum += A;
		}
		else {
			sum += K;
			K = 0;
		}
		K -= B;
		if(K >= 0) {
			sum -= Math.min(K, C);
		}
		System.out.println(sum);
		
		
		
		
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}

}


Measured memory_bytes: 35712
#include <iostream>
#include <vector>
#include <algorithm>
#include<string>

using namespace std;

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        if(i % 2 != 1 ){
            cout << s[i] ;
        }
    }
    cout << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;
    
int main() {
  int h, w, ch, cw, dh, dw;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  //ch--; cw--; dh--; dw--;
  ch++; cw++; dh++; dw++;
  vector<vector<char>> v(h+4, vector<char>(w+4, '#'));
  rep(i, 0, h) {
    rep(j, 0, w) {
      cin >> v[i+2][j+2];
    }
  }
  vector<vector<ill>> vv(h+4, vector<ill>(w+4, -2));
  rep(i, 0, h) {
    rep(j, 0, w) {
      if(v[i+2][j+2] == '.') vv[i+2][j+2] = -1;
    }
  }
  vv[ch][cw] = 0;
  queue<pair<ill, ill>> q, qq;
  q.push(make_pair(ch, cw));
  ill cost = 0;
  vv[ch][cw] = cost;
  while(!q.empty() || !qq.empty()) {
    while(!q.empty()) {
      pair<ill, ill> f = q.front();
      q.pop();
      qq.push(f);
      if(vv[f.first+1][f.second] == -1) {
        q.push(make_pair(f.first+1, f.second));
        vv[f.first+1][f.second] = cost;
      } if(vv[f.first-1][f.second] == -1) {
        q.push(make_pair(f.first-1, f.second));
        vv[f.first-1][f.second] = cost;
      } if(vv[f.first][f.second+1] == -1) {
        q.push(make_pair(f.first, f.second+1));
        vv[f.first][f.second+1] = cost;
      } if(vv[f.first][f.second-1] == -1) {
        q.push(make_pair(f.first, f.second-1));
        vv[f.first][f.second-1] = cost;
      }
    }
    cost++;
    while(!qq.empty()) {
      pair<ill, ill> f = qq.front();
      qq.pop();
      rep(i, -2, 3) {
        rep(j, -2, 3) {
          if(vv[f.first+i][f.second+j] == -1) {
            q.push(make_pair(f.first+i, f.second+j));
            vv[f.first+i][f.second+j] = cost;
          }
        }
      }
    }
  }
  /*rep(i, 0, h) {
    rep(j, 0, w) {
      cout << vv[i+2][j+2] << " ";
    }
    cout << "\n";
  }*/
  cout << vv[dh][dw] << "\n";
}

Measured memory_bytes: 12580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
inline int popcount(const int x) { return __builtin_popcount(x);}
template<class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b;}
template<class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b;}
template<class T> void drop(const T &x) { std::cout<<x<<endl; exit(0);}
void debug_out() { std::cout << "\n";}
template<class T, class... Args> void debug_out(const T &x, const Args &... args) { std::cout<<x<< " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct InitIO{
  InitIO() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
  }
}init_io;

int main() {
  int n;
  double d;
  cin >> n >> d;
  int ans = 0;
  rep(i,n) {
    double x, y;
    cin >> x >> y;
    double r = sqrt(x*x + y*y);
    if (r <= d) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3864
#include<stdio.h>

char times[26];

int main(void) {
	char inptem;
	int i, flag = 0;
	inptem = getchar();
	while (inptem >= 'a' && inptem <= 'z') {
		times[inptem - 'a']++;
		inptem = getchar();
	}
	for (i = 0; i < 26; i++) {
		if (times[i] & 1) {
			flag = 1;
			break;
		}
	}
	if (flag) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;
const long long MINF = LLONG_MIN;

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

ll N, W;
map<ll, vector<ll>> vs;
ll csum[4][200];
ll items[4];
ll minw;

int main() {
  cin >> N >> W;
  rep(i, 0, N) {
    ll w, v;
    cin >> w >> v;
    vs[w].push_back(v);
  }

  ll cnt = 0;
  for (auto e : vs) {
    if (cnt == 0) minw = e.first;

    sort(e.second.begin(), e.second.end(), greater<ll>());
    rep(i, 0, e.second.size()) {
      csum[cnt][i + 1] = csum[cnt][i] + e.second[i];
    }
    items[cnt] = e.second.size();
    ++cnt;
    vs[e.first] = e.second;
  }

  ll ans = 0;
  for (ll i = 0; i <= items[0]; ++i) {
    for (ll j = 0; j <= items[1]; ++j) {
      for (ll k = 0; k <= items[2]; ++k) {
        ll total = minw * i + (minw + 1) * j + (minw + 2) * k;
        if (total > W) {
          continue;
        }

        ll rest = W - total;
        ll l = rest / (minw + 3);

        chmax(ans, csum[0][i] + csum[1][j] + csum[2][k] + csum[3][l]);
      }
    }
  }

  cout << ans;
}


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

const int MAXN = 105;

int a[MAXN], n, m;

int ax[MAXN];
int bx[100005], btop = 0;

int main()
{
	scanf("%d%d", &n, &m);
	int odd = 0; 
	for (int i = 1; i <= m; i++) {
		scanf("%d", &a[i]);
		odd += (a[i]&1);
	}
	if (n&1) {
		if (odd > 1) { cout << "Impossible" << endl; return 0; }
		else {
			int top = 0;
			for (int i = 1; i <= m; i++)
				if (a[i]&1)
					ax[++top] = a[i];
			for (int i = 1; i <= m; i++)
				if (!(a[i]&1))
					ax[++top] = a[i];
			int tmp = ax[1];
			while (tmp != 1) bx[++btop] = 2, tmp -= 2;
			for (int i = 2; i <= m; i++)
				bx[++btop] = ax[i];
			bx[++btop] = 1;
		}
	} else {
		if (odd > 2) { cout << "Impossible" << endl;  return 0; }
		else {
			assert(odd == 0 || odd == 2);
			if (odd == 0) {
				memcpy(ax, a, sizeof a);
				if (a[1] > 2) 
					bx[++btop] = a[1]-2;
				bx[++btop] = 1;
				for (int i = 2; i <= m; i++)
					bx[++btop] = a[i];
				bx[++btop] = 1;
			} else if (odd == 2) {
				int flag = 0, top = 1;
				for (int i = 1; i <= m; i++) {
					if (a[i]&1) {
						if (!flag) ax[1] = a[i], flag = 1;
						else ax[m] = a[i];
					} else ax[++top] = a[i];
				}
				int tmp = ax[1];
				while (tmp != 1) bx[++btop] = 2, tmp -= 2;
				for (int i = 2; i < m; i++) bx[++btop] = ax[i];
				tmp = ax[m]+1;
				while (tmp) bx[++btop] = 2, tmp -= 2;
			}
		}
	}
	for (int i = 1; i <= m; i++) cout << ax[i] << " ";
	cout << endl;		
	cout << btop << endl;
	for (int i = 1; i <= btop; i++)
		cout << bx[i] << " ";
	cout << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    cout << ((s.size() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') ? "Yes" : "No") << endl;

    return 0;
}

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

int main(){
    int a,b;
    string s;
    cin >> a >> b;
    if (a == 1){
        a += 13;
    }
    if (b == 1){
        b += 13;
    }
    if (a == b){
        s = "Draw";
    }else if (a < b){
        s = "Bob";
    }else{
        s = "Alice";
    }
    cout << s << endl;
}

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

int main() {
  int i,N;
  cin>>N;
  long long x[N],y[N],z[i];
  for(i=0;i<N;i++) cin>>x[i];
  for(i=0;i<N;i++) cin>>y[i];
  long long sum=0;
  long long plus=0;
  long long minus=0;
  for(i=0;i<N;i++) {
	z[i]=y[i]-x[i];
	sum+=z[i];
	if(z[i]>0) {
		plus+=(z[i]+1)/2;
		minus+=z[i]%2;
	}
        if(z[i]<0) minus-=z[i];
  }
  if(plus<=sum&&minus<=sum) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}    

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

using namespace std;

int main(){

  int t;

  cin>>t;
  
  for(int i=0;i<t;i++){

	int n,k;
	int sum=0;

	cin>>n>>k;

	vector<int> x(n);
	vector<int> dis;
	int n_k;

	n_k = n-k;

	for(int i=0;i<n;++i)
	  cin>>x[i];

	for(int i=0;i<n-1;++i)
	  dis.push_back(x[i+1]-x[i]);

	sort(dis.begin(),dis.end());
	
	for(int i=0;i<n_k;i++){

	  sum+=dis[i];
	  
	}

	cout<<sum<<endl;
	
  }
  
}



Measured memory_bytes: 4172
#include <iostream>
using namespace std;
 
int main() {
  int X, A, B;
  cin >> X >> A >> B;
  
  if (A >= B) {
   cout << "delicious" << endl; 
   return 0;
  }
  
  A -= B;
  A += X;
  if (A >= 0) {
   cout << "safe" << endl; 
  }
  else
    cout << "dangerous" << endl;
  
  return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    N = Number(tmp0[0])

    var ans = 0

    for(var i=1; i <= N; i++)
    {
      if(String(i).length % 2 === 1){
        ans++
      }
    }
    console.log(ans)
}
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("136\n");

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,b,a) for(int i=(b);i>=(a);i--)
#define len(a) int((a).size())
using namespace std;
using LL = long long;
using PII = pair<int, int>;

const int N = 1e5 + 5;
int n, A[N], B[N], C[N];
int S[N];

int main() {
    scanf("%d", &n);
    FI(i,1,n) scanf("%d", &A[i]);
    FI(i,1,n) scanf("%d", &B[i]);
    FI(i,1,n) scanf("%d", &C[i]);
    sort(A+1, A+1+n);
    sort(B+1, B+1+n);
    sort(C+1, C+1+n);
    for (int p=n, q=n+1;p>=1;p--) {
        while (C[q-1] > B[p]) q--;
        S[p] = n-q+1; 
    }
    LL ans = 0;
    LL sum = 0;
    for (int p=n, q=n+1;p>=1;p--) {
        while (B[q-1] > A[p]) {
            q--;
            sum += S[q];
        }
        ans += sum;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1792
#include <stdio.h>

#define INF (2<<28)
#define STANUM 110
#define COST 0
#define TIME 1

int min(int a, int b){
	if(a > b) return b;
	return a;
}

int main(){
	int n, m;
	int road[2][STANUM][STANUM];
	int i, j, k;
	int a, b, cost, time;
	int type;

	while(1){
		scanf("%d %d", &n, &m);
		if(!n && !m) break;
		for(i = 0; i <= m; i++){
			for(j = 0; j <= m; j++){
				for(k = 0; k < 2; k++){
					road[k][i][j] = INF;
				}
			}
		}
		while(n--){
			scanf("%d %d %d %d", &a, &b, &cost,	&time);
			road[COST][a][b] = road[COST][b][a] = cost;
			road[TIME][a][b] = road[TIME][b][a] = time;
		}

		for(type = 0; type < 2; type++){
			for(i = 0; i <= m; i++){
				for(j = 0; j <= m; j++){
					for(k = 0; k <= m; k++){
						road[type][j][k] = min(road[type][j][k], road[type][j][i] + road[type][i][k]);
					}
				}
			}
		}
		
		//for(type = 0; type < 2; type++){
		//	for(i = 0; i <= m; i++){
		//		for(j = 0; j <= m; j++){
		//			printf("%d ", road[type][i][j]);
		//		}
		//		printf("\n");
		//	}
		//	printf("\n");
		//	printf("\n");
		//}

		scanf("%d", &n);
		while(n--){
			scanf("%d %d %d", &a, &b, &type);
			printf("%d\n", (a==b)?0:road[type][a][b]);
		}
	}

	return 0;
}

Measured memory_bytes: 696
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define mod 1000000007
#define pb push_back  
#define endl "\n"
#define fi first
#define se second 
#define ll long long
#define inf 9000000000000000000
#define PI 3.14159265359

int power(int a,int b,int m=mod)
{
     if(b==0)	return 1;
     if(b==1)	return a;
	 int res=power(a,b/2,m);
	 res=(res*res)%m;
     if(b&1)	res=(res*a)%m;
     return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a%m+b%m);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a%m-b%m);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}

int32_t main()
{
   IOS
   
   int n;
   cin>>n;
   
   
   int p = add(power(10,n),power(8,n));
   
   p = sub(p,power(9,n));
   p = sub(p,power(9,n));
   
   cout<<p<<endl;
	
	
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll M = N%K;
    cout << min(M,abs(M-K)) << "\n";   
}

Measured memory_bytes: 256
//32:51
#include<bits/stdc++.h>
using namespace std;
int f(int a)
{
	int p=a,sum=0;
	while(p>0)sum+=p%10,p/=10;
	return sum;
}
int main()
{
	//freopen("/home/zz7/CFInput","r",stdin);
	int n;scanf("%d",&n);
	int ans=0x3f3f3f3f;
	for(int i=1;i<n;i++){
		ans=min(f(i)+f(n-i),ans);
	}cout<<ans<<'\n';
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n, k = li()

if k > (n-1) * (n-2) // 2:
    print(-1)

else:
    edges = []
    for i in range(1,n):
        edges.append((1, i+1))

    surp = (n-1)*(n-2) // 2 - k
    for frm in range(1, n):
        for to in range(frm+1, n):
            if surp == 0:
                break

            edges.append((frm+1, to+1))
            surp -= 1


    print(len(edges))
    for ei, ej in edges:
        print(ei, ej)

Measured memory_bytes: 3992
def encode(a):
    hour = 0
    minu = 0
    sec = 0
    if a >= 3600:
        hour = int(a/3600)
        a = a%3600
    if a >= 60:
        minu = int(a/60)
        a = a%60
    sec = a
    return hour,minu,sec
    
def decode(hour,minu,sec):
    return 3600*hour + 60*minu + sec

while(1):
    t,h,s = [int(i) for i in input().split()]
    if t == -1 and h == -1 and s == -1:
        break
    secs = decode(t,h,s)
    left_secs = 120*60 - secs
    hour,minu,sec = encode(left_secs)
    hour_,minu_,sec_ = encode(3*left_secs)
    print("{:0>2}:{:0>2}:{:0>2}".format(hour,minu,sec))
    print("{:0>2}:{:0>2}:{:0>2}".format(hour_,minu_,sec_))


Measured memory_bytes: 5612
n = int(input())
s = []
for _ in range(n):
    s.append(input())
import collections
s1 = collections.Counter(s)
x = max(s1.values())
key = [k for k,v in s1.items() if v == x]
s2 = sorted(key)
ans = '\n'.join(s2)
print(ans)

Measured memory_bytes: 37516
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll x;cin>>x;
    cout<<x/500*1000+x%500-x%5<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, a, x[55];
ll dp[55][55][2505];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> a;
	FOR(i, 55) dp[i][0][0] = 1;
	ll cnt = 0;
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
		for (int j = 1; j <= i; j++) {
			FOR(k, 2505) {
				if (k >= x[i]) dp[i][j][k] = dp[i-1][j-1][k-x[i]] + dp[i-1][j][k];
				else dp[i][j][k] = dp[i-1][j][k];
				if (i == n && k % j == 0 && k / j == a) cnt += dp[i][j][k];
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,0,n)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int, int>;

const int mod = 1e9 + 7, INF = 1 << 30;
const double EPS = 1e-12, PI = 3.1415926535897932384626;
const ll LINF = 1LL << 60, lmod = 1e9 + 7;

const int MAX_N = 2003;

int N, K, c[MAX_N][MAX_N], s[MAX_N][MAX_N];

void prepare() {
	REP(x, 1, 2 * K + 2) REP(y, 1, 2 * K + 2) s[x][y] = c[x][y] + s[x - 1][y] + s[x][y - 1] - s[x - 1][y - 1];
}

int query(int x1, int y1, int x2, int y2) {
	// return sum(x1<=x<=x2,y1<=y<=y2)
	if (x1 > x2 || y1 > y2) return 0;
	else return s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1];
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> K;
	fill(c[0], c[MAX_N - 1], 0);
	rep(i, N) {
		int x, y;
		char cc;
		cin >> x >> y >> cc;
		if (cc == 'B') x += K;
		x %= (2 * K);
		y %= (2 * K);
		c[x + 1][y + 1]++;
	}
	prepare();
	int ans = -INF;
	REP(x, 1, K + 1) REP(y, 1, K + 1) {
			int temp =
					query(x, y, x + K - 1, y + K - 1) + query(x + K, y + K, 2 * K, 2 * K) + query(1, 1, x - 1, y - 1) +
					query(x + K, 1, 2 * K, y - 1) + query(1, y + K, x - 1, 2 * K);
			ans = max(ans, max(temp, N - temp));
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 31616
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, M;
    cin >> N >> M;
    vv<int> A(N);
    rep(i, M) {
        int s, c;
        cin >> s >> c;
        A[s - 1].push_back(c);
    }

    if (N == 1 && all_of(all(A[0]), [](int c) { return c == 0; })) {
        write(0);
        return 0;
    }

    string ans(N, '_');
    rep(i, N) {
        if (A[i].size()) {
            sort(all(A[i]));
            if (A[i].front() != A[i].back() || (i == 0 && A[i].front() == 0)) {
                write(-1);
                return 0;
            }
            ans[i] = '0' + A[i].front();
        }
        else ans[i] = i == 0 ? '1' : '0';
    }
    write(ans);
}

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

int main(){
  int W,H,N;
  cin >>W>>H>>N;
  
  int w=0;
  int h=0;  
  repeat(i,0,N){
    int x,y,a;
    cin >>x>>y>>a;
    
    if(a==1) w = max(x,w);
    else if(a==2) W = min(x,W);
    else if(a==3) h = max(y,h);
    else if(a==4) H = min(y,H);
  }
  
  int ans = max(0,H-h)*max(0,W-w);
  
  cout <<ans<< endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  085_C_Otoshidama
//
//  Created by tolemy on 2019/07/15.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int n, y = 0;
    cin >> n >> y;
    
    for(int i = 0;i<=n; i++)
    {
        for(int j = 0;j<=n-i; j++)
        {
            int k = n - i - j;
            if(10000 * i + 5000*j + 1000*k == y)
            {
                cout << i << " " << j << " " << k;
                return 0;
            }
        }
    }
    
    std::cout << "-1 -1 -1";
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,K;;
  cin >> N >> K;
  vector<int> p(N);
  for(int i=0;i<N;i++) cin >> p.at(i);

  sort(p.begin(),p.end());
  
  long long ans = 0;
  for(int i=0;i<K;i++){
    ans += p.at(i);
  }

  cout << ans << endl;
}

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

long long n, m, rs;

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

  cin >> n >> m;

  if(2LL * n > m) return cout << m / 2 << '\n', 0;

  rs = n;
  m -= 2LL * n;
  rs += m / 4;
  cout << rs << '\n';

  return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int K; scanf("%d", &K);
  vector<int> dist(K, INF);
  dist[1] = 1;
  deque<int> deq;
  deq.push_back(1);
  while (not deq.empty()) {
    int u = deq.front(); deq.pop_front();
    int x = (u + 1) % K, y = (u * 10) % K;
    if (dist[u] + 1 < dist[x]) {
      dist[x] = dist[u] + 1;
      deq.push_back(x);
    }
    if (dist[u] < dist[y]) {
      dist[y] = dist[u];
      deq.push_front(y);
    }
  }
  int ans = dist[0];
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  std::string N; std::cin >> N;
  if ( N.find('9') != std::string::npos ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int n, x, y, a, b, c;
int k[2000];
int main() {
	scanf("%d%d%d", &n, &x, &y);
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			a = j - i;
			b = i - x;
			if (b < 0)b = -b;
			c = j - y;
			if (c < 0)c = -c;
			b = b + c + 1;
			if (a > b)a = b;
			k[a]++;
		}
	}
	for (int i = 1; i < n; i++) {
		printf("%d\n", k[i]);
	}
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	k := iScan()
	x := 0
	ans := -1
	d := make(map[int]struct{})
	for i := 1; ; i++ {
		x = (x*10 + 7) % k
		if x == 0 {
			ans = i
			break
		}
		if _, ok := d[x]; ok {
			break
		} else {
			d[x] = struct{}{}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 47000
import sys

N, M, C = map(int, sys.stdin.readline().split())
B = list(map(int, sys.stdin.readline().split()))

ans = 0
for _ in range(N):
    A = list(map(int, sys.stdin.readline().split()))
    tmp = 0
    for a, b in zip(A, B):
        tmp += a*b
    if tmp + C > 0:
        ans += 1

print(ans)

Measured memory_bytes: 9132
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{	
public static void main(String[] args) throws FileNotFoundException, IOException{
        Scanner s = new Scanner(System.in);
         StringBuilder sb=new StringBuilder();
         BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
         int n=s.nextInt(),w=s.nextInt();
        int[][] arr=new int[n+1][2];
        long[][] dp=new long[100001][101];
        
        for(int i=1;i<100001;i++){
            Arrays.fill(dp[i],(long)1e13); 
        }
        dp[0][0]=0;
        //dp[i] hold- minimum wt needed to get i values given j points
        for(int i=1;i<=n;i++){
            arr[i][0]=s.nextInt(); arr[i][1]=s.nextInt();
        }

        for(int i=1;i<100001;i++){
            for(int j=1;j<=n;j++){
                if(arr[j][1]<=i){
                    dp[i][j]=Math.min(dp[i][j-1],arr[j][0]+dp[i-arr[j][1]][j-1]);
                }
                else{
                    dp[i][j]=dp[i][j-1];
                }
            }
        }
        int res=0;
        for(int i=1;i<100001;i++){
            if(dp[i][n]<=w){res=i;}
        }       
        System.out.println(res);
    }
}

Measured memory_bytes: 128724
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int x, y, z;
    cin >> x >> y >> z;

    Int w = z, ans = 0;
    while (w <= x) {
        ans++;
        w += z + y;
    }
    ans--;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
abc = []
for i in range(N):
  abc.append([int(i) for i in input().split()])
abc.append([0,0,0])
dp = np.zeros([N+1,3])
#print(dp)

for i in range(1,N+1):
  dp[i][0],dp[i][1],dp[i][2] = max(dp[i-1][1]+abc[i-1][0], dp[i-1][2]+abc[i-1][0]), max(dp[i-1][0]+abc[i-1][1], dp[i-1][2]+abc[i-1][1]), max(dp[i-1][1]+abc[i-1][2], dp[i-1][0]+abc[i-1][2])
  #print(dp)
print(int(max(dp[N])))


Measured memory_bytes: 48892
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector <long long int, long long int> 
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int MAX = 1e5 + 5;
ll arr[MAX], pre[MAX];
int main()
{
	boost;
	ll n, m, i;
	cin >> n >> m;
	fo(i, 0, n)
	cin >> arr[i];
	sort(arr, arr + n);
	pre[0] = arr[0];
	fo(i, 1, n)
	pre[i] = pre[i - 1] + arr[i];
	ll f = 0, l = 2e5, mid;
	tuple <ll, ll, ll> ans;
	ll curr = 0, cnt = 0;
	while(f <= l){
		mid = (f + l) / 2;
		curr = 0;
		cnt = 0;
		fo(i, 0, n){
			ll x = lower_bound(arr, arr + n, mid - arr[i]) - arr;
			cnt += n - x;
			curr += pre[n - 1] - (x > 0 ? pre[x - 1] : 0) + (n - x) * arr[i];
		}
		if(cnt >= m){
			ans = mt(mid, cnt, curr);
			f = mid + 1;
		}
		else
		l = mid - 1;
	}
	cout << get<2>(ans) - (get<1>(ans) - m) * get<0>(ans);
}

Measured memory_bytes: 1792