akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2200000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b) {a = b; return true;}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b) {a = b; return true;}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

vector<ll> fac(MAX), finv(MAX), inv(MAX);

void comInit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(ll i=2; i<MAX; i++){
        fac[i] = fac[i-1]*i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}


ll com(ll n, ll k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
    ll r1,c1,r2,c2; cin >> r1 >> c1 >> r2 >> c2;
    ll ans = 0;
    comInit();
    REP(c,c1,c2+1){
        ll ad = (r2+1)*com(c+r2+1,c)%mod-r1*com(r1+c,c)%mod;
        ad = (ad + mod) % mod;
        ad = (ad * inv[c+1]) % mod;
        ans = (ans + ad) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 51840
#include<stdio.h>
#define MAX 2000000
#define INFTY 10000000

int H, A[MAX+1];

void maxHeapify(int i){
  int l, r, largest, temp;
  l=2*i;
  r=2*i+1;

  if(l<=H && A[l]>A[i]) largest = l;
  else largest = i;
  if( r<= H && A[r]>A[largest]) largest = r;
  if( largest!=i ){
    temp = A[i];
    A[i]=A[largest];
    A[largest]=temp;
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if(H<1) return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key){
  int temp;
  if(key<A[i]) return;
  A[i] = key;
  while(i>1 && A[i/2] < A[i]){
    temp = A[i];
    A[i] = A[i/2];
    A[i/2] = temp;
    i=i/2;
  }
}

void insert(int key){
  H++;
  A[H]=-INFTY;
  increaseKey(H,key);
}

int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[0]=='e' && com[1]=='n') break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }else{
      printf("%d\n",extract());
    }
  }

  return 0;
}


Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int p[100005];
int main()
{
  int k;
  cin >> k;
  int a, b;
  cin >> a >> b;
  int br = 0;
  for(int i = a; i <= b; i++)
    if(i%k==0)
      br++;
  if(br>0)
    cout << "OK";
  else 
    cout << "NG";
}


Measured memory_bytes: 3540
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

bool comp(pair<int, long> l, pair<int, long> r){
    return l.second < r.second;
}

string padding(int a){
    string str = to_string(a);
    if(str.size() != 6){
        while(true){
            str = "0" + str;
            if(str.size() == 6){
                break;
            }
        }
    }
    return str;
}

int main(){
    int n, m;
    cin >> n >> m;
    vector< pair<int, long> > v[n+1];
    int p;
    long y;
    string ans[m+1];
    for(int i = 1; i <= m; i++){
        cin >> p >> y;
        v[p].push_back(make_pair(i,y));
        ans[i] = "";
    }
    for(int i = 1; i <= n; i++){
        sort(v[i].begin(), v[i].end(), comp);
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= v[i].size(); j++){
            int city = v[i][j-1].first;
            ans[city] = padding(i) + padding(j);
        }
    }
    for(int i = 1; i <= m; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 12416
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <set>
#include <map>
#define mp make_pair
using namespace std;
int main(void)
{
	int i, j, k;
	while (1) {
		int n, h, a, b;
		char p[4];
		scanf("%d%d", &n, &h);
		if (n == 0 && h == 0) break;

		set<pair<int, pair<int, int> > > s;
		for (i = 0; i < h; ++i) {
			scanf("%s %d%d", p, &a, &b);
			if (strcmp(p, "xy") == 0)
				for (j = 1; j <= n; ++j) s.insert(mp(a, mp(b, j)));
			else if (strcmp(p, "yz") == 0)
				for (j = 1; j <= n; ++j) s.insert(mp(j, mp(a, b)));
			else if (strcmp(p, "xz") == 0)
				for (j = 1; j <= n; ++j) s.insert(mp(a, mp(j, b)));
		}
		int res = n * n * n - s.size();
		printf("%d\n", res);
	}
	return 0;
}

Measured memory_bytes: 2224
n, m = map(int, input().split())

smi = [ None ] * m

for i in range(m):
    k, *si = map(lambda x: int(x) - 1, input().split())

    smi[i] = si

pi = list(map(int, input().split()))

def emitable(bit_pattern, i):
    si = smi[i]
    px = pi[i]
    py = 0

    for s in si:
        py += (bit_pattern & (2 ** s)) >> s

    return px == (py % 2)

count = 0

for bi in range(2 ** n):
    if all(emitable(bi, i) for i in range(m)):
        count += 1

print(count)

Measured memory_bytes: 73588
def main():
    N = int(input())
    d = {}
    for _ in range(N-1):
        u, v, w = map(int, input().split())
        w %= 2
        if u in d:
            d[u].append((v, w))
        else:
            d[u] = [(v,w)]
        if v in d:
            d[v].append((u, w))
        else:
            d[v] = [(u,w)]
    cur = [1]
    nextp = []
    l = [0] * N
    v = set(range(1, N+1))
    while v:
        for i in cur:
            v.remove(i)
            for j, k in d[i]:
                if j in v:
                    l[j-1] = 1 - l[i-1] if k else l[i-1]
                    nextp.append(j)
        cur = nextp
        nextp = []
    return l
l = main()
for i in l:
    print(i)



Measured memory_bytes: 49336
#include<algorithm>
#include<vector>
#include<stack>
#include<deque>
#include<iostream>
#include<cstdio>
#define F first
#define S second
#define LIM 1000000010
#define pb push_back
#define all(n) n.begin(),n.end()
using namespace std;
typedef pair<int,int> P;
int dp[5002][5002];
int main(){
  int n,m;
 
  vector<int> X,Y;
  
  while(cin >> n >> m){
    for(int i=0;i<5000;i++)for(int j=0;j<5000;j++)dp[j][i] = 0;
    for(int i=0;i<n;i++){
      int x,y;
      cin >> x >> y;
      X.pb(x); Y.pb(y);
    }
    vector<int> x,y;
    x = X;
    y = Y;
    X.pb(-LIM); X.pb(LIM); Y.pb(-LIM); Y.pb(LIM);
    sort(all(X)); sort(all(Y));
    X.erase(unique(all(X)),X.end());
    Y.erase(unique(all(Y)),Y.end());
    for(int i=0;i<n;i++){
      x[i] = find(all(X),x[i])-X.begin();
      y[i] = find(all(Y),y[i])-Y.begin();
      dp[y[i]][x[i]]++;
    }
    for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++){
	dp[i+1][j+1] += dp[i+1][j]+dp[i][j+1]-dp[i][j];

      }

    }
    for(int i=0;i<m;i++){
      int sx,sy,gx,gy;
      cin >> sx >> sy >> gx >> gy;
      sx = lower_bound(all(X),sx)-X.begin();
      sy = lower_bound(all(Y),sy)-Y.begin();
      gx = upper_bound(all(X),gx)-X.begin()-1;
      gy = upper_bound(all(Y),gy)-Y.begin()-1;
      cout << dp[gy][gx]-dp[gy][sx-1]-dp[sy-1][gx]+dp[sy-1][sx-1] << endl;

    }



  }
  return 0;
}

Measured memory_bytes: 99048
#-*- coding: utf-8
#  -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(n):
    # 3 -> 3 * 60 = 180
    # 4 -> 4 * 90 = 360
    # 5 -> 5 *
    # 360 / 5 = 180 - 72 = 108 = 54 * 2 * 5
    # (180 - (360 / 5)) * 5

    return int((180 - (360 / n)) * n)


do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    n = int(parsed_lines[0][0])
    # k = int(parsed_lines[0][1])
    # S = parsed_lines[1][0]
    # return n, k, S
    return n


if not do_submit:
    n = input_parse("""
    3
    """)
    print(sol(n))

    n = input_parse("""
    100
    """)
    print(sol(n))

else:
    # n, k = list(map(int, input().split()))
    # S = input().split()
    # print(sol(n, k, S))
    n = int(input().strip())
    # S = input().strip()
    print(sol(n))



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

    U = []; V = []
    for x in range(1, int(N**.5)+1):
        U.append(x)
        if x < N//x:
            V.append(N//x)
    V.reverse(); U.extend(V)

    L = len(U)
    prv = 0
    R = []
    for x in U:
        R.append(x-prv)
        prv = x
    def gen(it):
        MOD = 10**9 + 7
        r = 0
        for p, s in it:
            r = (p * s + r) % MOD
            yield r

    S = [1]*(L+1)
    S[-1] = 0
    for k in range(K):
        S[L-1::-1] = gen(zip(R, S))
    print(S[0])
solve()

Measured memory_bytes: 11824
#include <stdio.h>
int main(){
    int a,b,c,d,e,k;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&e);
    scanf("%d",&k);
    int way[5];
    way[0]=a;
    way[1]=b;
    way[2]=c;
    way[3]=d;
    way[4]=e;
    for(int i = 0;i < 5;i++){
        for(int j = i;j < 5;j++){
            if(way[j] - way[i] > k){
                printf(":(\n");
                return 0;
            }
        }
    }
    printf("Yay!\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int d; cin >> d;
    string ans;
    switch(d){
        case 25 :
            ans="Christmas";
            break;
        case 24 :
            ans="Christmas Eve";
            break;
        case 23 :
            ans="Christmas Eve Eve";
            break;
        case 22 :
            ans="Christmas Eve Eve Eve";
            break;
    }
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 3536
import sys
input = sys.stdin.readline

N = int(input())
X =list(map(int,input().split()))
sX = sorted(X)
med_s = sX[((N-1)+1)//2-1]
med_b = sX[((N-1)+1)//2]
ave_med = (med_s+med_b)/2

for i in range(N):
    if X[i] <= ave_med:
        print(med_b)
    else:
        print(med_s)


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


using namespace std;



int main(){

	int n ,m , x , y; 
	
	
	cin >> n >> m >> x >> y; 
	
	int val;
	
	vector<int> v1 , v2;
	
	
	for(int i=0;i<n;i++){
		cin >> val; 
		
		v1.push_back(val);
	}
	
	for(int i=0;i<m;i++){
		cin >> val; 
		
		v2.push_back(val);
	}
	
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	
	for(int i=-200;i<=200;i++){
		bool ok = true;
		for(int j = 0;j<n;j++){
			if(i<=v1[j] || i <=x){
				ok = false;
				break;
			}
		}
		
		if(!ok) continue;
		
		for(int j = 0;j<m;j++){
			if(i>v2[j]  || i > y){
				ok = false;
				break;
			}
		}
		
		if(ok){
			cout << "No War" << endl;
			return 0;
		}
	
	}
	
	cout << "War" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <cstdlib>
using namespace std;
using ll = long long int;
const int INF = 100000000;
using P = pair<int,int>;
ll a[11];
string S;
ll sum;
ll DFS(ll psum, ll i,ll power) {
    if (i == S.size()-1) {
        sum += psum+a[0]*power;
    }
    else {
        DFS(psum+a[S.size()-1-i]*power,i+1,1);
        DFS(psum+a[S.size()-1-i]*power,i+1,power*10);
    }
}

int main()
{
    cin >> S;
    for (int i = 0; i < S.size(); i++) {
        a[i] = S[i] - '0';
    }
    DFS(0,0,1);
    cout << sum<< endl;
}


Measured memory_bytes: 256
package main

import "fmt"

var n, m int

func main() {
	fmt.Scan(&n, &m)
	a := make([]int, m)
	b := make([]int, m)
	for i := range a {
		fmt.Scan(&a[i], &b[i])
	}
	m := make(map[int]bool)
	for i := range a {
		m[a[i]] = !m[a[i]]
		m[b[i]] = !m[b[i]]
	} // if odd, true
	for _, v := range m {
		if v {

			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 7040
<?php

$n = trim(fgets(STDIN));

$a = array_map('intval',explode(' ', trim(fgets(STDIN))));
sort($a);

$sum = ($a[0] + $a[1]) / 2;
for($i = 2;$i < $n;$i++) {
	$sum = ($sum + $a[$i]) / 2;
}
echo $sum."\n";


Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll MOD=1e9+7;
const ll N=2e5+5;
const ld pi=3.14159265359;
const ll INF=(1LL<<63);
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()

ll m1,d1,m2,d2;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>m1>>d1>>m2>>d2;
	cout<<(m1==m2?0:1)<<"\n";
	return 0;
}




Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();
		
		pr.println(Math.min(p + q, Math.min(q + r, r + p)));
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#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 all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int n;
	cin >> n;
	cout << (n < 1000 ? "ABC" : "ABD") << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
using namespace std;
map<string,bool> dic;
int main(){
    int n;string opt,c;
    cin>>n;
    while(n--){
        cin>>opt>>c;
        if(opt=="insert"){
            dic[c]=true;
        }else if(opt=="find"){
            if(dic.find(c)==dic.end()){
                cout<<"no"<<endl;
            }else cout<<"yes"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 36876
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(long long i=j;i<(n);++i)
#define bk(i,j,n)   for(long long i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define srt(x) sort(x.begin(),x.end());
#define ret     return 0;
#define mem(x,y)    memset((x),(y),sizeof (x));
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;

//std::cout << std::setprecision(12) << s << '\n';
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

ll n,k;
ll a[102];

int main()
{
    run;
    cin>>n>>k;
    fr(i,0,n)
    {
        cin>>a[i];
    }
    ll dp[k+1];
    memset(dp,0ll,sizeof dp);
    fr(j,1,k+1)
    {
        fr(i,0,n)
        {
            if(j-a[i]>=0 && dp[j]==0)
            {
                dp[j]=1-dp[j-a[i]];
            }
        }
    }
    if(dp[k]==1)
    {
        cout<<"First";
        ret;
    }
    cout<<"Second";









}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ctype.h>
using namespace std;
 
 
int main(){
    int N,ans=0;
    cin >>N;

    for(int i=1;i<=N;i+=2){
        int a=0;
        for(int j=1;j<=N;j++){
            if(i%j==0)a++;
        }
        if(a==8)ans++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
w,h,n=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

xy=[['.' for i in range(w)] for i in range(h)]

for x,y,a in l:
  x-=1
  y-=1

  if a==1:
    for i in range(h):
      for j in range(w):
        if j<=x:
          xy[i][j]='#'
  if a==2:
    for i in range(h):
      for j in range(w):
        if x<j:
          xy[i][j]='#'
  if a==3:
    for i in range(h):
      for j in range(w):
        if i<=y:
          xy[i][j]='#'
  if a==4:
    for i in range(h):
      for j in range(w):
        if y<i:
          xy[i][j]='#'

cnt=0
for i in xy:
  cnt+=i.count('.')
print(cnt)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=20,inf=(ll)4e17;
ll val[N];
ll solve(ll l,ll r,ll vl,ll vr){
  //  cout << l << " " << r << endl;
    if (l+2==r){
        return vl*val[l]+vr*val[r-1];
    }
    ll vv=vl+vr;
    ll ans=inf;
    for (int i=l+1;i<r-1;i++){
        ans=min(ans,solve(l,i+1,vl,vv)+solve(i,r,vv,vr)-val[i]*vv);
    }
    return ans;
}
int32_t main(){
    sync;
    ll n;
    cin >> n;
    for (int i=1;i<=n;i++) cin >> val[i];
    cout << solve(1,n+1,1,1);
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	std::cin >> n;
	std::vector<uint32> a(n);
	rep(i, 0, n)
		std::cin >> a[i];
	std::map<uint32, uint32> m;
	uint32 ans = 0;
	rep(i, 0, n) {
		auto itr = m.find(a[i]);
		if (itr == m.end()) {
			m[a[i]] = 1;
		}
		else {
			m[a[i]] += 1;
		}
	}
	for (auto itr = m.begin();itr != m.end();++itr){
		if (itr->first > itr->second) {
			ans += itr->second;
		}
		else {
			ans += itr->second - itr->first;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 7040
n, m = map(int, input().split())

A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
C = []
D = []
for i in range(m):
    a, b = map(int, input().split())
    C.append(a)
    D.append(b)

for i in range(n):
    t = 0
    T = []
    for j in range(m):
        t = abs(A[i] - C[j]) + abs(B[i] - D[j])
        T.append(t)
    print(T.index(min(T)) + 1)

Measured memory_bytes: 39408
#include <bits/stdc++.h>
using namespace std;
int N;
int F[100][14];
int P[100][15];
int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 10; j++) scanf("%d", &F[i][j]);
    }
    for (int i = 0; i < N; i++)
        for (int j = 0; j < 11; j++) scanf("%d", &P[i][j]);
    int res = -(1 << 30);
    for (int b = 1; b < (1 << 10); b++) {
        int cc = 0;
        for (int i = 0; i < N; i++) {
            int c = 0;
            for (int j = 0; j < 10; j++)
                if ((b >> j & 1) && F[i][j]) c++;
            cc += P[i][c];
        }
        if (res < cc) res = cc;
    }
    printf("%d\n ", res);
}

Measured memory_bytes: 3768
/*
author: shah_entrance
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll k,a,b,curr=1,task;
    cin>>k>>a>>b;
    task=k;
    while(task!=0){
        if(curr<a){
            if(task>=(a-curr)){
                task-=(a-curr);
                curr=a;
            }
            else{
                task=0;
                curr+=(task);
            }
        }
        else{
            if((b-a)>=2){
                if(task>=2){
                    curr+=(b-a);
                    task-=2;
                }
                else{
                    curr+=task;
                    task=0;
                }
            }
            else{
                curr+=task;
                task=0;
            }
        }
    }
    cout<<curr<<endl;
    return 0;
}


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

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

typedef long long ll;

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

template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
 //入力
int N;          //足場の総数
ll h[110000];   //足場
ll dp[110000];  //DPテーブル

const ll INF = 1LL << 60;   //2^60で初期化

int main() {
    int K;
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    for (int i = 0; i < 110000; ++i) dp[i] = INF;

    dp[0] = 0;  //初期条件

    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j])); //2つ前のコスト総和を比較
        }
    }

    cout << dp[N - 1] << '\n';

    return 0;
}


Measured memory_bytes: 5224
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;++x)
#define Red(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
const int MAXN=2e5+5;
char buf[1<<12],*p1=buf,*p2=buf,nc;int ny;
inline char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;if(nc<0)return nc;
	x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48);return x*ny;
}int n,a[MAXN],cnt,top;pint stk[MAXN];
inline void Ins(int x,int k){
	for(;top&&stk[top].fir>x;top--);
	if(stk[top].fir==x)stk[top].sec++;else stk[++top]=mk(x,1);
	if(top>1&&stk[top].sec==k)top--,Ins(x-1,k);
}
inline bool chk(int k){
	stk[top=1]=mk(0,0);
	Rep(i,2,n)if(a[i]<=a[i-1])Ins(a[i],k);
	return stk[1].sec==0;
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();Rep(i,1,n)a[i]=read();Rep(i,2,n)cnt+=a[i]>a[i-1];
	if(cnt==n-1){puts("1");return 0;}
	int l=2,r=n,ans=n;
	for(int mid;l<=r;)(chk(mid=l+r>>1)?r=mid-1,ans=mid:l=mid+1);
	cout<<ans<<'\n';
	return 0;
}




Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

int main()
{
  int n, q, l, r;
  string s;
  cin >> n >> q >> s;
  vector<int> t(n, 0);

  for (int i =0;i<n-1;i++){
    if(s[i]=='A' && s[i+1]=='C'){
      t[i+1]=t[i]+1;
    } else {
      t[i+1]=t[i];
    }
  }

  for (int i = 0; i < q; i++)
  {
    cin >> l >> r;
    cout << t[r-1]-t[l-1] << endl;
  }

  return 0;
}

Measured memory_bytes: 1408
N=int(input())
S=input()
SS=[a for a in S]
SS.insert(0,0)
nr=S.count("R")
ng=S.count("G")
nb=S.count("B")
n=0
for i in range(1,N-1):
    for j in range(i+1,N):
        k=j*2-i
        if k<=N :
            if SS[i]!=SS[j] and SS[j]!=SS[k] and SS[k]!=SS[i]:
                n+=1
answer=nr*ng*nb-n
print(answer)


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


void solve(long long K, long long S){
    int res = 0;
    for (int i = 0; i <= K; i++) {
      for (int j = 0; j <= K; j++) {
	  if (S-i-j <= K and S-i-j >= 0) res++;
        }
    }
    cout << res << endl;
}


int main(){
    long long K;
    scanf("%lld",&K);
    long long S;
    scanf("%lld",&S);
    solve(K, S);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define MAX 25
#define NIL -1

struct Node 
{
    int parent, left, right;
};

Node T[MAX];

int depth(int i)
{
    int count = 0;
    int c = i;

    while(T[c].parent != NIL)
    {
        c = T[c].parent;
        count++;
    }

    return count;
}

int height(int i)
{
    if (T[i].left == NIL && T[i].right == NIL)
    {
        return 0;
    }

    int dl, dr;
    dl = dr = 0;

    if (T[i].left != NIL)
    {
        dl = height(T[i].left) + 1;
    }

   if (T[i].right != NIL)
    {
        dr = height(T[i].right) + 1;
    }

    return max(dl,dr);
}

int sibling(int i)
{
    if (T[i].parent == NIL)
    {
        return NIL;
    }
    else
    {
        int p = T[i].parent;

        if(T[p].left != NIL && T[p].right != NIL)
        {
            if (T[p].left == i)
            {
                return T[p].right;
            }
            else
            {
                return T[p].left;
            }
        }
    }

    return NIL;
}

int degree(int i)
{
    int count = 0;

    if (T[i].left != NIL)
    {
        count++;
    }

    if (T[i].right != NIL)
    {
        count++;
    }

    return count;
}

string nodeType(int i)
{
    if (T[i].parent == NIL)
    {
        return "root";
    }
    else if (T[i].left == NIL && T[i].right == NIL)
    {
        return "leaf";
    }
    else
    {
        return "internal node";
    }
}

void printNode(int i)
{
    cout << "node " << i << ": ";
    cout << "parent = " << T[i].parent << ", ";
    cout << "sibling = " << sibling(i) << ", ";
    cout << "degree = " << degree(i) << ", ";
    cout << "depth = " << depth(i) << ", ";
    cout << "height = " << height(i) << ", ";
    cout << nodeType(i);

    cout << endl;
}

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

    for (int i = 0; i < N; i++)
    {
        T[i].parent = T[i].left = T[i].right = NIL;
    }

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

        cin >> T[id].left;
        cin >> T[id].right;

        if (T[id].left != NIL)
        {
            T[T[id].left].parent = id;
        }

        if (T[id].right != NIL)
        {
            T[T[id].right].parent = id;
        }
    }

    for (int i = 0; i < N; i++)
    {
        printNode(i);
    }

    return 0;
}


Measured memory_bytes: 3212
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

const int N = 500500;

int EA[N], EB[N], EC[N];
vector<int> E[N];

vector<pair<int, int>> F[N];

void add_edge(int a, int b, int c) {
    F[a].emplace_back(b, c);
    F[b].emplace_back(a, c);
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        scanf("%d %d %d", &EA[i], &EB[i], &EC[i]);
        --EA[i], --EB[i];
        E[EA[i]].push_back(i);
        E[EB[i]].push_back(i);
    }
    for (int i = 0; i < n; i++) {
        sort(E[i].begin(), E[i].end(), [](int a, int b) { return EC[a] < EC[b]; });
        for (int l = 0, r = 0; l < (int)E[i].size(); l = r) {
            while (r < (int)E[i].size() && EC[E[i][l]] == EC[E[i][r]])
                r++;
            for (int j = l; j + 1 < r; j++) {
                add_edge(E[i][j], E[i][j + 1], 0);
            }
        }
        for (int j = 0; j < (int)E[i].size(); j++) {
            F[E[i][j]].emplace_back(m + i, 1);
            F[m + i].emplace_back(E[i][j], 0);
        }
    }
    vector<int> D(n + m, N);
    vector<char> used(n + m, false);
    vector<int> Q(2 * (n + m) + 100);
    int lpt = n + m + 50, rpt = lpt;
    Q[rpt++] = m + 0;
    used[m + 0] = true;
    D[m + 0] = 0;
    while (lpt < rpt) {
        int x = Q[lpt++];
        for (auto pr : F[x]) {
            int y = pr.first, c = pr.second;
            if (!used[y]) {
                used[y] = true;
                D[y] = D[x] + c;
                if (c == 0)
                    Q[--lpt] = y;
                else
                    Q[rpt++] = y;
            }
        }
    }
    if (!used[m + n - 1])
        puts("-1");
    else
        printf("%d\n", D[m + n - 1]);

}


Measured memory_bytes: 55676
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}

template<typename T>
void dijkstra(const V<V<int>>& G, vector<T>& d, int s)
{
   priority_queue<P<T,int>, vector<P<T,int>>, greater<P<T,int>> > que;
   fill(d.begin(), d.end(), INF);
   d[s] = 0;
   que.push(make_pair(0, s));
   while(!que.empty()) {
      T temp_cost = que.top().first;
      int from = que.top().second;
      que.pop();
      if (d[from] < temp_cost) continue;
      for (int i = 0; i < G[from].size(); i++) {
         int to = G[from][i];
         if (d[to] > d[from] + 1) {
            d[to] = d[from] + 1;
            que.push(make_pair(d[to], to));
         }
      }
   }
}

signed main()
{
   int N; cin >> N;
   V<int> a(N-1), b(N-1);
   REP(i, N-1) {
      cin >> a[i] >> b[i];
      --a[i]; --b[i];
   }

   V<V<int>> G(N);
   REP(i, N-1) {
      G[a[i]].PB(b[i]);
      G[b[i]].PB(a[i]);
   }

   V<int> distA(N), distB(N);
   dijkstra(G, distA, 0);
   dijkstra(G, distB, N-1);
   int scoreA = 0, scoreB = 0;
   REP(i, N) {
      if (distA[i] <= distB[i]) {
         ++scoreA;
      } else {
         ++scoreB;
      }
   }

   cout << (scoreA > scoreB ? "Fennec" : "Snuke") << endl;

   return 0;
}


Measured memory_bytes: 9996
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define LOG(FMT...) fprintf(stderr, FMT)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int mod = 1e9+7;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260811, P_2=999998639;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
int a[1000];
int main()
{
    int n , k , x;
    cin >> n >> k;
    for(int i = 1; i <= k; i++){
        int p;
        cin >> p;
        for(int j = 1; j <= p ; j++){
            cin >> x;
            a[x]++;
        }
    }
    int ress = 0;
    for(int i = 1; i <= n; i++){
        if(!a[i])ress++;
    }
    cout << ress << endl;

    
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int d; cin >> d;
	if (d==25) cout << "Christmas\n";
	else if (d==24) cout << "Christmas Eve\n";
	else if (d==23) cout << "Christmas Eve Eve\n";
	else if (d==22) cout << "Christmas Eve Eve Eve\n";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
/* 入力

5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3

 */

#include<stdio.h>

#define N 100

#define WHITE 0
#define GRAY 1
#define BLACK 2

static const int INFTY = (1<<21);

int n;
int M[N][N];

void dijkstra(void){
  int i;
  int u,v;
  int mincost;
  int d[N],color[N];

  for(i = 0;i < n;i++){
    color[i] = WHITE;
    d[i] = INFTY;
  }

  color[0] = GRAY;
  d[0] = 0;
  
  while(1){
    mincost = INFTY;
    u = -1;
    
    for(i = 0;i < n;i++){
      if(color[i] != BLACK && mincost > d[i]){
	u = i;
	mincost = d[i];
      }
    }
    
    if(u == -1){
      break;
    }
    
    color[u] = BLACK;
    for(v = 0;v < n;v++){
      
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > d[u]+M[u][v]){
	  color[v] = GRAY;
	  d[v] = d[u]+M[u][v];
	}
      }
      
    }
    
  }

  for(i = 0;i < n;i++){
    if(d[i] == INFTY){
      d[i] = -1;
    }
    printf("%d %d\n",i,d[i]);
  }
  
}

int main(void){
  int i,j,k;
  int u,v;
  int s;
  
  scanf("%d",&n);

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      M[i][j] = INFTY;
    }
  }

  for(i = 0;i < n;i++){
    scanf("%d %d",&u,&k);
    
    for(j = 0;j < k;j++){
      scanf("%d %d",&v,&s);
      M[u][v] = s;
    }
    
  }

  dijkstra();

  return 0;
}
       
  



Measured memory_bytes: 2108
#include <stdio.h>
#include <string.h>
int main(){
  char s[202];
  char p[102];
  char tmp[202];
  int i, j;
  int count=0;
  //文字列の取得
  fgets(s, sizeof(s), stdin);
  fgets(p, sizeof(p), stdin);
  //改行文字の削除
  s[strlen(s)-1]='\0';
  int slength=strlen(s);
  strcat(s, s);
  p[strlen(p)-1]='\0';
  //
  for(i=0; i<(slength); ++i){
	strcpy(tmp, &s[i]);	
	tmp[strlen(p)]='\0';
  if(strcmp(tmp, p)==0)
	++count;
  }
  if(count!=0)
	printf("Yes\n");
  else
	printf("No\n");

  return 0;
}



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

namespace ConsoleApp15
{
    class Class63
    {
        static void Main()
        {
            var HN = Console.ReadLine().Split();
            int H = int.Parse(HN[0]), N = int.Parse(HN[1]);

            int[] dp = new int[H + 1];
            for (int i = 1; i <= H; i++) dp[i] = int.MaxValue;
            for(int i = 0; i < N; i++)
            {
                var r = Console.ReadLine().Split();
                int A = int.Parse(r[0]), B = int.Parse(r[1]);
                for(int j = 0; j < H; j++)
                {
                    if (dp[j] != int.MaxValue)
                    {
                        int k = Math.Min(H, A + j);
                        dp[k] = Math.Min(dp[k], dp[j] + B);
                    }
                }
            }
            Console.WriteLine(dp[H]);
        }
    }
}


Measured memory_bytes: 13220
#include<stdio.h>
int main(){
  long long int i,a,b,c;
  double ans=0,n,m,d;
  scanf("%lld %lld %lld\n",&a,&b,&c);
  n=a,m=b,d=c;
  if(d==0){
    ans=n/n/n;
  }
  else{
    ans=2*(n-d)/(n*n);
  }
  ans=ans*(m-1);
  printf("%.10lf\n",ans);
  return 0;
}

Measured memory_bytes: 128
N,W=map(int,input().split())

def solve_knapsack(capacity):
    # basic checks
 
    
    # populate the capacity = 0 columns, with '0' capacity we have '0' profit
    dp = [0]*(W + 1)
    weights, profits = [0]*(N+1), [0]*(N+1)
    

    for i in range(0, N):
        weights[i],profits[i] = map(int,input().split())
        for c in range(capacity, weights[i]-1, -1):
            tmp = profits[i] + dp[c - weights[i]]
            if tmp > dp[c]: dp[c] = tmp
 
    # maximum profit will be at the bottom-right corner.
    return dp[capacity]
  
def main():
    
 
    res = solve_knapsack(W)
 
    print(res)
if __name__ == "__main__":
	main()

Measured memory_bytes: 7796
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll N = 2000009;
const ll p = 31;
const ll m = 1e9 + 7;
const ll inf= 1e14;
ll mod = 1e9+7;
ll powm(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
// ll fact[N];


// ll ncr(ll n,ll r){
//      return (((fact[n]*powm(fact[r],mod-2))%mod)*powm(fact[n-r],mod-2))%mod;
// }
 int main() {   
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
     // #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
     // #endif
     ll t = 1;
     // cin>>t;
     while(t--){
          ll n;cin>>n;
          ll ans = n-1;
          for(ll i = 2;(i*i)<=n;i++){
               if(n%i == 0){
                    // cout<<i<<'\n';
                    ans = min(ans,i + (n/i) -2);
               }
          } 
          cout<<ans;
     }
}            


Measured memory_bytes: 256
import java.util.Scanner;

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

        int max = 0, min = 0;
        long sum = 0;
        int x;
        int limit = scanner.nextInt();
        for(int i = 0; i < limit; i++){
            x = scanner.nextInt();
            if(i == 0){
                max = min = x;
            }

            sum += x;
            if(x > max){
                max = x;
            }
            if(min > x){
                min = x;
            }
        }
        System.out.printf("%d %d %d\n", min, max, sum);
        scanner.close();
    }
}



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

int main(){
  int a, b;
  char op;
  int c = 0;
  cin >> a >> op >> b;
  if(op == '+') c = (a + b);
  else if(op == '-') c = (a - b);
  cout << c << endl;
}


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

typedef long long ll;

int main() {
    int N, a;
    cin >> N;
    string ans = "second\n";
    rep(i, N) {
        cin >> a;
        if (a % 2) ans = "first\n";
    }
    cout << ans;
}

Measured memory_bytes: 256
import sys

mod = 10**9 + 7
N = int(sys.stdin.readline())

stones = []
for _ in range(N):
    stones.append(int(sys.stdin.readline()))

left = {}
dp = [0 for _ in range(N+5)]
dp[0] = 1
for i in range(N):
    dp[i+1] = dp[i]
    # 同じ色が前回出現した位置
    c = stones[i]
    if c in left and 0 <= left[c] < i - 1:
        dp[i+1] += dp[left[c] + 1]
    
    dp[i+1] %= mod
    left[c] = i

print(dp[N])

Measured memory_bytes: 123160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a;
	cin >> n >> a;
	n %= 500;
	if (n <= a) puts("Yes");
	else puts("No");
	return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll count = 0;
    cin >> N;
    ll m = 1;
    while(N/m > 0){
        if((N/m)>(N%m)){
            m++;
            continue;
        }
        if((N%m-(N/m))%(N/m)!=0){
            m+=(N%m)/(N/m)+1;
            continue;
        }
        m += (N%m-(N/m))/(N/m);
        count += m;
        m += 2;
    }
    cout << count << "\n";
}

Measured memory_bytes: 256
N, K1 = map(int, input().split())
S = list(input())
K = K1 - 1
if S[K] == "A":
  S[K] = "a"
elif S[K] == "B":
  S[K] = "b"
else:
  S[K] = "c"
Str = "".join(S)
print(Str)

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long

#define sc(n) scanf("%lld",&n)
#define scc(n1,n2) scanf("%lld %lld",&n1,&n2)
#define sccc(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define debug(x) cerr<<#x<<": "<<x<<endl;



signed main() {

    char c;
    cin>>c;
    cout<<( isupper(c)? 'A' : 'a');
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	string str;
	cin>>str;
	if(str[0]==str[1]&&str[0]==str[2])
	{
	    cout<<"No"<<endl;
	}
	else
	{
	    cout<<"Yes"<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#define MP make_pair
using namespace std;

set<pair<int,int> > se;
pair<int,int> mo[2][2];
int X[5010],Y[5010];
int main(){
	int N,res,hog,x,y;
	while(1){
		cin>>N;
		if(N==0) break;
		se.clear();
		for(int i=0;i<N;i++){
			cin>>X[i]>>Y[i];
			se.insert(MP(X[i],Y[i]));
		}
		res=0;
		for(int i=0;i<N-1;i++){
			for(int j=i+1;j<N;j++){
				x=X[i]-X[j];
				y=Y[i]-Y[j];
				hog=x*x+y*y;
				if(hog<=res) continue;
				mo[0][0]=MP(X[i]+y,Y[i]-x);
				mo[0][1]=MP(X[j]+y,Y[j]-x);
				mo[1][0]=MP(X[i]-y,Y[i]+x);
				mo[1][1]=MP(X[j]-y,Y[j]+x);
				if((se.count(mo[0][0])&&se.count(mo[0][1]))||(se.count(mo[1][0])&&se.count(mo[1][1]))){
					res=hog;
				}
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 1368
#include<stdio.h>

int f[50];

int  fb(int n){
  if(n == 0 || n == 1){
    f[n] = 1;
    return f[n];
  }
  if(f[n] != 0)return f[n];
  f[n] = fb(n-1) + fb(n-2);
  return f[n];
}

int main(){
  int i,n;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    f[i]=0;
  }

  printf("%d\n",fb(n));

  return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(){
	int n;
	while(~scanf("%d",&n))
	{
		int t,x,y;
		int flag=0;
		int x1=0,t1=0;
		int y1=0;
		for(int i=0;i<n;i++){
			scanf("%d%d%d",&t,&x,&y);
			if(i==0){
				if(t-x-y-t1>=0){
				
					if((t-x-y-t1)%2)
					{
					flag=1;
					}
				}
				else {
					flag=1;
				}
				x1=x;
				y1=y;
				t1=t;
			}
			else{
					int w=(x-x1),z=(y-y1);
					if(w<0)w=-w;
					if(z<0)z=-z;
					if(t-t1-w-z>=0)
					{
						if((t-t1-w-z)%2)
						{
							flag=1;
						}
					}
				else {
					flag=1;
				}
				x1=x;
				y1=y;
				t1=t;
			}
			
		}
		if(flag==0)printf("Yes\n");
		else 	printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S; cin >> S;
    
    if(S.at(0) == S.at(1) && S.at(1) == S.at(2) && S.at(2) == S.at(0)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n;
	int card[210];
	int card1[210];
	int card2[210];
	int m;
	int k;
	cin >> n;
	for (int i = 0;i < 2 * n;i++) {
		card[i] = i + 1;
	}
	cin >> m;
	for (int i = 0;i < m;i++) {
		cin >> k;
		if (k == 0) {
			for (int i = 0;i < 2 * n;i++) {
				card1[i] = 0;
				card2[i] = 0;
			}
			for (int i = 0;i < n;i++) {
				card1[i] = card[i];
			}
			for (int i = n;i < 2 * n;i++) {
				card2[i - n] = card[i];
			}
			for (int i = 0;i < n + 1;i++) {
				card[2 * i] = card1[i];
			}
			for (int i = 0;i < n;i++) {
				card[2 * i + 1] = card2[i];
			}
		}
		else {
			for (int i = 0;i < 2 * n;i++) {
				card1[i] = 0;
			}
			for (int i = 0;i < k;i++) {
				card1[i] = card[i];
			}
			for (int i = k;i < 2 * n;i++) {
				card[i - k] = card[i];
			}
			for (int i = 0;i < k;i++) {
				card[2 * n - k + i] = card1[i];
			}
		}
	}
	for (int i = 0;i < 2 * n;i++) {
		cout << card[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int P;

int main() {

    int N;
    Scd2(N,P);
    char s[222222];
    Scs(s);

    vl t(N+1);

    auto ten = [&]( int t ){
        ll ret = 1;
        ll te = 10;
        while( t ){
            if( t&1 ){
                ret *= te; ret %= P;
            }
            te *= te; te %= P;
            t >>= 1;
        }
        return ret;
    };
    Rep(i,N){
        t[i+1] = (s[i]-'0') + t[i]*10;
        t[i+1] %= P;
    }
    Rep(i,N+1){
        t[i] *= ten(N-i);
        t[i] %= P;
    }

    ll ans = 0;
    if( P == 2 || P == 5 ){
        Rep(i,N){
            if( (s[i]-'0') % P == 0 ){
                ans += (i+1);
            }
        }
        printf ("%lld\n", ans );
        return 0;
    }
    vi a(P);
    Rep(i,N+1){
        ans += a[t[i]];
        a[t[i]]++;
    }

    printf ("%lld\n", ans );

    return 0;
}



Measured memory_bytes: 2176