akhauriyash/Code-Regression huggingface dataset:
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let s: String = read();
    println!("{}", &s[0..3]);
}

Measured memory_bytes: 2064
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
X = []
for i in range(N):
  tmp = AB[i][1] - AB[i][0] % AB[i][1]
  X.append(tmp)
  #print(tmp)
c = 0
for i in range(N):
  j = N-1-i
  X[j] -= c
  c += X[j] % AB[j][1]
print(c)

Measured memory_bytes: 31472
#include <stdio.h>

int N;
int a[5001];
 
int main(void){
    int i , j;
    while(scanf("%d", &N) != EOF) {
        if(N == 0) break;
        
        for(i = 0; i < N; ++i){
            scanf("%d", &a[i]);
        }
        
        int ans = a[0];
        for(i = 0; i < N; ++i){
            int sum = 0;
            for(j = i; j < N; ++j){
                sum += a[j];
                ans = (sum >= ans ? sum : ans);
            }
        }
        printf("%d\n" , ans);
    }
    return 0;
}


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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}

int solve(){
 int n;cin>>n;
 vector<int> dp(1<<n,0);
 int a[n][n];
 rep(i,0,n){
 	rep(j,0,n)cin>>a[i][j];
 }
 for(int i=0;i<(1<<n);i++){
 	dp[i]=0;
 	for(int j=0;j<n;j++){
 		for(int k=j+1;k<n;k++){
 			if((i>>j&1) && (i>>k&1))dp[i]+=a[j][k];
 		}
 	}
 	for(int s=i;s;s=(s-1)&i){
 		maxs(dp[i],dp[s]+dp[s^i]);
 	}
 }
 cout<<dp.back()<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef sieve
    sieve();
    #endif
    #ifdef ncr
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

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

int main() {
  int n;
  cin >> n;
  vector<int> mon(n+1);
  vector<int> b(n);
  rep(i, n+1) cin >> mon[i];
  rep(i, n) cin >> b[i];
  ll cnt = 0;
  rep(i, n) {
    if (b[i] > mon[i]) {
      cnt += mon[i];
      b[i] -= mon[i];
      int x = min(b[i], mon[i+1]);
      cnt += x;
      mon[i+1] -= x;
    } else {
      cnt += b[i];
      b[i] = 0;
    }
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 4016
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<long long> s(A + 2);
    vector<long long> t(B + 2);
    long long INF = 1e18;
    s[0] = -INF;
    t[0] = -INF;
    for(int i = 0; i < A; i++) cin >> s[1 + i];
    s[A + 1] = INF;
    for(int i = 0; i < B; i++) cin >> t[1 + i];
    t[B + 1] = INF;
    for(int i = 0; i <Q; i++){
        long long x;
        cin >> x;
        int ind1 = lower_bound(s.begin(), s.end(), x) - s.begin();
        int ind2 = lower_bound(t.begin(), t.end(), x) - t.begin();
        long long ans = 1e18;
        for(int j = 0; j < 2; j++){
            long long y = s[ind1 - j];
            for(int k = 0; k < 2; k++){
                long long res = abs(x - y);
                res += abs(t[ind2 - k] - y);
                ans = min(ans, res);
            }
        }
        for(int j = 0; j < 2; j++){
            long long y = t[ind2 - j];
            for(int k = 0; k < 2; k++){
                long long res = abs(x - y);
                res += abs(s[ind1 - k] - y);
                ans = min(ans, res);
            }
        }
        cout << ans << endl;
    }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll H,W;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	ll mi=1LL<<60;
	
	x = H/3;
	y = (H+2)/3;
	mi = min(mi,(y-x)*W);
	x = W/3;
	y = (W+2)/3;
	mi = min(mi,(y-x)*H);
	
	for(x=1;x<W;x++) {
		ll a=x*H;
		ll b=(H/2)*(W-x);
		ll c=((H+1)/2)*(W-x);
		mi = min(mi, max({a,b,c})-min({a,b,c}));
	}
	for(y=1;y<H;y++) {
		ll a=y*W;
		ll b=(W/2)*(H-y);
		ll c=((W+1)/2)*(H-y);
		mi = min(mi, max({a,b,c})-min({a,b,c}));
	}
	
	cout<<mi<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

namespace ConsoleApp3 {
    class Program {
        static void Main(string[] args) {
            int r = int.Parse(Console.ReadLine());

            Console.WriteLine(r * r * 3);

        }
    }
}


Measured memory_bytes: 13140
alphabet  = 'abcdefghijklmnopqrstuvwxyz'
number = [0 for i in range(26)]
import sys
lines = sys.stdin.readlines()
for i, line in enumerate(lines):
    line = line.rstrip('\n')
    line =  line.lower()
    for i in range(len(line)):
      if line[i] in alphabet:
        number[alphabet.index(line[i])] += 1
    
for i in range(len(alphabet)):
  print(f'{alphabet[i]} : {number[i]}')


Measured memory_bytes: 5584
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define deb(x) cout<<#x<<" "<<x<<endl;
#define print(arr,n) for(int i=0;i<n;++i) { cout<<arr[i]<<" "; } cout<<endl;
#define ub(x,el) upper_bound(x.begin(),x.end(),el) - x.begin()
#define lb(x,el) lower_bound(x.begin(),x.end(),el) - x.begin();
#define bs(x,el) binary_search(x.begin(),x.end(),el)
#define MOD 1000000007
#define finish return 0
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds; 
typedef int ll;
typedef tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<int D, typename T> struct Vec : public vector<Vec<D - 1, T>> { static_assert(D >= 1, "Vector dimension must be greater than zero!"); template<typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) { }}; template<typename T> struct Vec<1, T> : public vector<T> { Vec(int n = 0, T val = T()) : vector<T>(n, val) { } };
inline ll mod(ll x) { return (x%MOD + MOD)%MOD; }
ll gcd(ll a, ll b, ll &x, ll &y){if(a == 0){x = 0, y = 1; return b;} ll x1, y1;  ll d = gcd(b%a, a, x1, y1); x = y1 - (b/a) * x1; y = x1; return d;}
ll power(ll x,ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p;   } return res; } 
ll power(ll x,ll y) { ll res = 1; while (y > 0) { if (y & 1) res = (res*x); y = y>>1; x = (x*x);   } return res; } 
ll mod(ll num, ll den){ return mod(mod(num) * power(den,MOD-2,MOD)); }
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll a,b,h,m;
    scanf("%d %d %d %d",&a,&b,&h,&m);
   // deb(a);
    //deb(b);
    //deb(h);
    //deb(m);
    //cin>>a>>b>>h>>m;
    long double pi = acos(-1);
    ll total = h*60 + m;
    long double ang1 = ((2*pi)/(720.0))*total;
    long double ang2 = ((2*pi)/(60.0))*m;
   // deb(ang1);
    //deb(ang2);
    long double c = ang1-ang2;
    if(c<0) c = -1*c;

    if(c>pi) c = (2*pi)-c;
    //deb(cos(c));
    long double ans = (a*a) + (b*b)-(2*a*b*cos(c));
    ans = sqrt(ans);
    printf("%.12Lf\n",ans);
  //  cout<<ans<<endl;
}

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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 110; //点数
const i64 INF = 0x3f3f3f3f3f3f3f3fLL;
struct node {
    int id, w, money;  // w == distance
    node(){}
    node(int a, int b, int c) : id(a), w(b), money(c) {}
    friend bool operator < (node a, node b) {return a.w > b.w;}
};
vector<node> G[maxn];
i64 dp[55][3050], a[maxn], b[maxn], c[maxn], d[maxn];
i64 n, m, s;

void dij(int start, int n) {
    for (int i = 0; i <= 50; ++i) {
        for (int j = 0; j <= 3000; ++j) {
            dp[i][j] = INF;
        }
    }
    priority_queue<node> q;
    node cur;
    q.push(node(start, 0, s));
    dp[start][s] = 0;
    while (!q.empty()) {
        cur = q.top();
        q.pop();
        int u = cur.id;
        int temp = cur.money+c[u];
        temp = min(temp, 3000);
        if (dp[u][temp] > dp[u][cur.money]+d[u]) {
            dp[u][temp] = dp[u][cur.money]+d[u];
            q.push(node(u, dp[u][temp], temp));
        }
        for (node to : G[cur.id]) {
            if (cur.money >= to.money
                && dp[to.id][cur.money-to.money] > dp[cur.id][cur.money]+to.w) {
                dp[to.id][cur.money-to.money] = dp[cur.id][cur.money]+to.w;
                q.push(node(to.id, dp[to.id][cur.money-to.money], cur.money-to.money));
            }
        }
    }
}
void init(int n) {
    for (int i = 0; i <= n; ++i) G[i].clear();
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> n >> m >> s;
    s = min(s, 3000LL);
    init(n);
    forn(i, m) {
        int u, v;
        cin >> u >> v >> a[i] >> b[i];
        G[u].eb(node(v, b[i], a[i]));
        G[v].eb(node(u, b[i], a[i]));
    }
    for1(i, n) cin >> c[i] >> d[i];
    dij(1, n);
    for (int i = 2; i <= n; ++i) {
        i64 ans = LLONG_MAX;
        for (int j = 0; j <= 3000; ++j) {
            ans = min(ans, dp[i][j]);
        }
        cout << ans << '\n';
    }

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 10736
// D - Flipping Signs
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

int main(){
	int N; cin>>N;
	ll sum = 0;
	ll mini = 1e9;
	bool exist_zero = false;
	int minus_count = 0;
	rp(i,N){
		ll a; cin>>a;
		if(a==0) exist_zero = true;
		if(a<0){
			a = -a;
			++minus_count;
		}
		mini = min(mini, a);
		sum += a;
	}

	if(exist_zero){
		cout<< sum <<endl;
		return 0;
	}

	if(minus_count%2){
		sum -= mini*2;
	}
	cout<< sum <<endl;
}

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

int main() {
  int a, b, c;
  cin >> a >> b;
  
  c = a * b;
  if(c % 2 == 0) {
    cout << "Even"; 
  }
  else {
    cout << "Odd"; 
  }
  
  
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int W,H,x,y,r;
scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);
if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
    printf("Yes\n");
}else{
    printf("No\n");
}
return 0;
}


Measured memory_bytes: 2112
/*
ID: leihaow1
TASK: 
LANG: C++              
*/ 
#include <iostream>
#include <cstdio>
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	for (int i=n;i<=999;i++){
		if ((i/100==i%10)&&(i/100==i/10%10)){
			cout<<i<<endl;
			return 0;
		}
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>
#include <cmath>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

const ll INF = 1e9+7;

// 各桁の和
template<typename T>T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;}
template<typename T>T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}

#define test(a) cout<<#a<<':'<<a<<endl;

class tree{
public:
  tree* par;
  vector<tree*> chi;
  int cnt;
};


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> b(n-1);rep(i,n-1)cin>>b[i];
  ll ans = 0;

  ans += b[0];
  ans += b[n-2];
  rep(i,n-1){
    if(i == 0)continue;
    ans += min(b[i],b[i-1]);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
package main
import . "fmt"
import "sort"
func main() {
  var n,x,d int
  var y,z []int
  Scan(&n,&x)
  y = make([]int,n+1)
  z = make([]int,n)
  for i:=0;i<n;i++ { Scan(&y[i]) }
  y[n] = x
  sort.Ints(y)
  for i:=0;i<n;i++ { z[i] = y[i+1] - y[i] }
  sort.Ints(z)
  d = z[0]
  for i:=1;i<n;i++ { d = gcd(z[i],d) }
  Println(d)
}
func gcd(x int,y int) int {
  if x < y { return gcd(y,x) }
  if x%y == 0 { return y }
  return gcd(y,x%y)
}

Measured memory_bytes: 5504
//
//  main.cpp
//  grandcontest24-A
//
//  Created by takumi on 2018/05/20.
//  Copyright © 2018年 starone. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <functional>
#include <cassert>


int main(int argc, const char * argv[]) {
   // printf(" ");
    using namespace std;
    long long int a,b,c,d,a1,b1,c1,p=0;

    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    if(d%2==0){
        cout << a-b;
    }else{
        cout << b-a;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {	
	int a[10000],b[10000],i;
	char op[10000];

	for(i=0;i<9999;i++) {
	scanf("%d %s %d",&a[i],&op[i],&b[i]);
		if(op[i]=='?') {
			break;
		}
	}

	for(i=0;i<9999;i++){
		if(op[i]=='+'){
			printf("%d\n",a[i]+b[i]);
	}
		else if(op[i]=='-'){
			printf("%d\n",a[i]-b[i]);
	}
		else if(op[i]=='*'){
			printf("%d\n",a[i]*b[i]);
	}
		else if(op[i]=='/'){
			printf("%d\n",a[i]/b[i]);
	} else {
		break;
	}
}

	return 0;
}

Measured memory_bytes: 616
<?php
  
$nm = explode(' ',trim(fgets(STDIN)));
$n = $nm[0];
$m = $nm[1];
$t = explode(' ',trim(fgets(STDIN)));

$s = 0;
for($i=0; $i<$n-1; $i++){
  
  if($t[$i+1]-$t[$i] >= $m) {
    $s += $m;
  } else if ($t[$i+1]-$t[$i] < $m){
    $s +=$t[$i+1]-$t[$i];
  }
}
$s += $m;

echo $s;

?>

Measured memory_bytes: 23028
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int64_t solve(vector<int64_t> & as, int i, int n, int k, int64_t v, int64_t a)
{
	if (i == n) {
		return a;
	}

	if (i != -1) {
		a = a + max((int64_t)0, as[i] - v);
	}

	int64_t pv = v;
	v = 0;
	if (i != -1) {
		v = as[i];
	}

	static map<pair<int, int>, int64_t> memo;
	auto it = memo.find({ i, k });
	if (it != memo.end()) {
		return it->second + a;
	}

	int64_t ans = INT64_MAX;
	FOR_LE(j, i + 1, n) {
		if (k < j - i - 1) {
			break;
		}

		ans = min(ans, solve(as, j, n, k - (j - i - 1), v, a));
	}

	memo.insert({ { i, k}, ans - a });

	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, k; cin >> n >> k;
	vector<int64_t> as(n); for (auto& a : as) { cin >> a; }

	int64_t ans = solve(as, -1, n, k, 0, 0);
	cout << ans << endl;

	return 0;
}

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

using namespace std;

const int N = 1e5 + 5;

int n, a[N];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);

    if (a[1] >= 0) {
        int cur = a[1];
        vector <pair <int, int> > res;
        for (int i = 1; i <= n - 2; i++) {
            res.push_back({cur, a[i + 1]});
            cur -= a[i + 1];
        }

        res.push_back({a[n], cur});
        a[n] -= cur;
        cout << a[n] << "\n";
        for (auto i: res) cout << i.first << " " << i.second << '\n';
        return 0;
    }

    vector <pair <int, int> > res;
    for (int i = 1; i <= n; i++) {
        if (a[i] >= 0) {
            int cur = a[i - 1];
            for (int j = i; j <= n - 1; j++) res.push_back({cur, a[j]}), cur -= a[j];
            res.push_back({a[n], cur}); cur = a[n] - cur;
            for (int j = i - 2; j >= 1; j--) res.push_back({cur, a[j]}), cur -= a[j];
            cout << cur << '\n';
            for (auto i: res) cout << i.first << " " << i.second << '\n';
            return 0;
        }
    }

    int cur = a[n];
    for (int i = n - 1; i >= 1; i--) {
        res.push_back({cur, a[i]});
        cur -= a[i];
    }

    cout << cur << '\n';
    for (auto i: res) cout << i.first << " " << i.second << "\n";
    return 0;
}


Measured memory_bytes: 3188
N,M = map(int,input().split(" "))
light = []
for i in range(M):
    tmp = list(map(int,input().split(" ")))
    light.append(tmp)

p = list(map(int,input().split(" ")))


switch = [0 for i in range(N)] 


def search(N,M,light,p,l,switch):#全探索
    if l<N:
        l += 1
        a=search(N,M,light,p,l,switch)
        switch[l-1]+=1 
        b = search(N,M,light,p,l,switch)
        return a+b
    else:#それぞれの場合について判定
        flag = 0
        for i in range(M):
            a = 0
            for j in range(light[i][0]):
                a +=switch[light[i][j+1]-1]
            if a%2 == p[i]:
                continue
            else:
                flag = 1
                break
        if flag == 0:
            return 1
        else:
            return 0
  

ans = search(N,M,light,p,0,switch)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
  char txt;

  while(1){
    scanf("%c",&txt);

    if(txt>96 && txt<123)txt-=32;
    else  if(txt>64 && txt<91)txt+=32;

    printf("%c",txt);
   if(txt=='\n')break;
  }
  return 0;
}

Measured memory_bytes: 524
import math


def Primes(n):
    if n > 2:
        Prime = []
        Table = list(range(2, n))
        for k in range(2, int(math.sqrt(n-1))+1):
            if k == Table[0]:
                Prime.append(Table[0])
                Table = [i for i in Table if i % k]
        return Prime + Table
    else:
        return []


n = int(input())
mod = 10**9+7
ans = 1

for p in Primes(n+1):
    m = 0
    for k in range(2, n+1):
        for _ in range(10):
            if k % p == 0:
                m += 1
                k = k // p
            else:
                break
    ans = (ans*((1+m) % mod)) % mod

print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
	ll i,j,n,equal;
  	cin>>n;
  for(i=-119;i<=119;i++)
  {
    for(j=-119;j<=119;j++)
    {
      equal=pow(i,5)-pow(j,5);
      if(equal==n)
      {
        cout<<i<<" "<<j<<endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4056
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//}

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
int cnt[2][105];

int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
using namespace atcoder;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,q,type,u,v;
    cin>>n>>q;
    dsu d(n);
    while(q--&&cin>>type>>u>>v){
        if(type==0)
            d.merge(u,v);
        else
            cout<<d.same(u,v)<<"\n";
    }
    return 0;
}


Measured memory_bytes: 4012
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << " = " << x << "\n"
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie()
using namespace std;
using ll = long long;

int main() {
    fast_io;

    int n;
    cin >> n;

    cout << ((n + 999) / 1000) * 1000 - n << "\n";
}


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

A1 = [int(a) for a in input().split()]
A2 = [int(a) for a in input().split()]

ans = 0
for i in range(N):
    ansA = sum(A1[0:i+1])+sum(A2[i:])
    if ans<=ansA:
        ans = ansA
        


print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;

signed main() {
    int N;
    cin >> N;
    int B = N;
    int A = 0;
    while(B != 0) {
        B = B / 10;
        A++;
    }
    B = 0;
    for(int i = 0;i < A;i++) {
        int C = 1;
        for(int j = 0;j < i;j++) {
            C *= 10;
        }
        B += 9 * C;
    }
    for(int i = 0;i < 10;i++) {
        if(B <= N) {
            cout << 9 * A - i << endl;
            break;
        }
        B -= pow(10,A - 1);
    }
}

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

int main() {
    string s, ans="No";
    cin >> s;
    if (s[0]!=s[1] || s[1]!=s[2]) ans = "Yes";
    cout <<ans<< endl;
    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() {
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(); 
		int b = sc.nextInt(); 
		int c = sc.nextInt(); 
		int x = sc.nextInt(); 
		int cnt=0;
		for(int i = 0; i <= a; i++) {
			for(int j = 0; j <= b; j++) {
				for(int k = 0; k <= c; k++) {
					if(500*i + 100*j + 50*k == x) {
						cnt++;
					}
				}
			}
		}
		
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21844
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    rep(_,n){
        char a,b,g,c,d; cin>>a>>b>>g>>c>>d;
        double h=(a-'0')*10+(b-'0');
        double m=(c-'0')*10+(d-'0');
        double hoge=h*30;
        h=m/2.0+hoge;
        m*=6;
        double cal=min((ld)abs((ld)h-(ld)m),(ld)360-(ld)abs((ld)h-(ld)m));
        
        //cout<<h<<" "<<m<<" "<<cal<<endl;
        if(cal<30)cout<<"alert"<<endl;
        else if(90<=cal&&cal<=180)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }
}

Measured memory_bytes: 2988
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
const int N=100000;
int n,m;
struct edge{
	int u,v,w;
	friend bool operator<(edge a,edge b){return a.w<b.w;}
}e[N];
int f[N/10],ans=0;
int find(int x){return x==f[x]?x:find(f[x]);}
main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);
	sort(e,e+m);
	for(int i=0;i<n;i++) f[i]=i;
	for(int i=0;i<m;i++){
		int x=find(e[i].u),y=find(e[i].v);
		if(x!=y){
			ans+=e[i].w;
			f[x]=y;
		}
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
struct xy{
int x;int y;}node,top;
const int dx[2] = {-1,1};
int main(){
int n,m;
cin >> n >> m;
vector<string>s(n);
queue<xy>q;
int cur = 0;
for(int i = 0;i<n;i++) cin >> s[i];
for(int i = 0;i<n;i++)
for(int j = 0;j<m;j++){
    if(s[i][j]=='#'){node.x = i;node.y = j;q.push(node);cur++;}
}
int t = 0,tt = 0,curr = 0;
bool ok = 0;
while(!q.empty()){
    top = q.front();
    q.pop();
    for(int i = 0;i<=1;i++)
    {
      if(top.x+dx[i]>=0&&top.x+dx[i]<n&&s[top.x+dx[i]][top.y]=='.'){
        s[top.x+dx[i]][top.y] = '#';
        node.x = top.x+dx[i];node.y = top.y;
        q.push(node);curr++;
        ok = 1;
      }
      if(top.y+dx[i]>=0&&top.y+dx[i]<m&&s[top.x][top.y+dx[i]]=='.'){
        s[top.x][top.y+dx[i]] = '#';
        node.x = top.x;node.y = top.y+dx[i];
        q.push(node);curr++;
        ok = 1;
      }
    }
    //cout << t << ' '<< cur << ' '<<curr <<' '<<ok <<endl;
    t++;
        if(t==cur&&ok){tt++;cur += curr;curr = 0;ok = 0;}
}
//cout << t <<endl;
   cout << tt;
   return 0;
}

Measured memory_bytes: 9488
from collections import Counter

N = int(input())
s = [input() for _ in range(N)]
 
# N=10^5より、O(N)で解く
# ソート（さらに扱いやすくするため、文字列に直す）することで、文字分布を得る
for i in range(N):
  s[i] = ''.join(sorted(s[i]))

# 文字分布が同じになる組み合わせの個数を求めればよい
# 各文字分布の出現個数nに対して、nC2の和を取る
s = Counter(s).most_common()
ans = 0
for p in s:
  ans += p[1] * (p[1]-1) // 2
  
print(ans)

Measured memory_bytes: 29048
#include <stdio.h>
#include <stdlib.h>
int main(){
	int W,H,N;
	int a[100],x[100],y[100];
	scanf("%d %d %d",&W,&H,&N);
	int i;
	for(i=0;i<N;i++){
		scanf("%d %d %d",&x[i],&y[i],&a[i]);
	}
	int x1=0,x2=W,y1=0,y2=H;
	for(i=0;i<N;i++){
		switch(a[i]){
		case 1:
			if(x1<x[i])
				x1=x[i];
			break;
		case 2:
			if(x2>x[i])
				x2=x[i];
			break;
		case 3:
			if(y1<y[i])
				y1=y[i];
			break;
		case 4:
			if(y2>y[i])
				y2=y[i];
			break;
		default:break;
		}
	}
	int w,h;
	w = x2>=x1 ? x2-x1 :0;
	h = y2>=y1 ? y2-y1 : 0; 
	printf("%d\n",w*h);
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            // write your code here
            char[] s = in.next().toCharArray();
            int sum = 0;
            for (char c : s) {
                sum += c == '+' ? 1 : -1;
            }
            out.println(sum);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

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

int main(){
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans;
  if (b > n){
    ans = a * n / b - a * (n / b);
    cout << ans << endl;
    return 0;
  }
  else {
    n = b - 1;
    ans = a * n / b - a * (n / b);
    cout << ans << endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 3632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn run() -> bool {
    input![
        a: [[u32; 3]; 3],
        n: u8,
        b: [u32; n],
    ];

    let mut ans: Vec<Vec<bool>> = vec![
        vec![false, false, false],
        vec![false, false, false],
        vec![false, false, false],
    ];

    for b in b {
        for i in 0..3{
            for j in 0..3 {
                if a[i][j] == b {
                    ans[i][j] = true;
                }
            }
        }
    }

    // col
    for i in 0..3 {
       if ans[i][0] && ans[i][1] && ans[i][2] {
            return true;
       }
    }

    //row
    for j in 0..3 {
        if ans[0][j] && ans[1][j] && ans[2][j] {
            return true;
        }
    }

    //naname
    if (ans[0][0] && ans[1][1] && ans[2][2])
    || (ans[2][0] && ans[1][1] && ans[0][2])
    {
        return true;
    }

    return false;

}

fn main() {
    println!("{}", if run() {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
<?php
    $line = trim(fgets(STDIN));
    $arr = explode(' ', $line);
    if($arr[0]+$arr[1]+$arr[2] >= 22){
        echo "bust\n";
    } elseif ($arr[0]+$arr[1]+$arr[2] <= 21){
        echo "win\n";
    }

Measured memory_bytes: 4728
#include<iostream>
using namespace std;
int main(){
  
  long long int n,a,b,c,d;
  cin>>n>>a>>b;
  
  if(a==0 && b==0)
  cout<<0<<"\n";
  
  else{
      if(n >= (a+b)){
        c=n/(a+b);
        d=n%(a+b);
        
        if(a==0)
        cout<<0<<"\n";
        
        else{
            if(d<=a)
            cout<<(c*a + d)<<"\n";
            
            else
            cout<<(c*a + a)<<"\n";
        }
      }
      
      else{
          if(n>=a)
          cout<<a<<"\n";
          
          else cout<<n<<"\n";
      }
  }
return 0;
}

Measured memory_bytes: 384
/*
2020/7/21
7/23
*/

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

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef long long ll;

int main(){
    long long N;
    cin >> N;
    vector<pair<ll,ll> > prime;
    long long i=2;
    while(i*i<=N){
        if(N%i==0){
            int count=0;
            while(N%i==0){
                N/=i;
                count++;
            }
            prime.push_back({i,count});
        }
        i++;
    }
    if(N!=1) prime.push_back({N,1});
    int ans=0;
    for(auto kani : prime){
        int i=1;
        while(kani.second-i>=0){
            ans++;
            kani.second-=i;
            i++;
        }
    }

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int w, h, n;
    cin >> w >> h >> n;

    int b = 0, u = h, l = 0, r = w;
    rep(i, n) {
        int x, y, a;
        cin >> x >> y >> a;
        switch (a) {
            case 1:
                chmax(l, x);
                break;
            
            case 2:
                chmin(r, x);
                break;

            case 3:
                chmax(b, y);
                break;
            
            case 4:
                chmin(u, y);
                break;
        }
    }
    cout << max(0, r-l) * max(0, u-b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

int main(){

    for(int i = 0;i < 3;i++){
        char n;
        cin >> n;

        if(n == '1')cout << 9;
        else cout << 1;
    }

    cout << endl;

    return 0;
}

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

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

    vector<vector<int>> l(M);
    int k;
    int s;
    for (int i = 0; i < M; i++)
    {
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            cin >> s;
            l[i].push_back(s);
        }
    }

    vector<int> p(M);
    for (int i = 0; i < M; i++)
    {
        cin >> p[i];
    }

    int ans = 0;
    for (int i = 0; i < (1 << N); i++)
    {
        bitset<12> b(i);
        bool is_valid = true;
        for (int j = 0; j < M; j++)
        {
            int sum = 0;
            for (int k = 0; k < l[j].size(); k++)
            {
                sum += b[l[j][k] - 1];
            }
            if ((sum % 2) != p[j])
            {
                is_valid = false;
                break;
            }
        }
        if (is_valid)
        {
            ans++;
        }
    }
    cout << ans << endl;
}


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

int N;
string S;
int main(){
    cin >> N >> S;
    int r = 0,b = 0;
    for(int i=0;i<N;i++){
        if(S[i]=='B') b++;
        else r++;
    }
    cout << (r>b? "Yes":"No") << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	int N, L;
	cin >> N >> L;
	vector<string> S(N);
	FOR(i, 0, N) cin >> S[i];
	
	sort(S.begin(), S.end());
	string ans;
	FOR(i, 0, N) {
		ans += S[i];
	}

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


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $allMoney);
$cards = trim(fgets(STDIN));
$card = explode(" ", $cards);

$alicePoint = 0;
$bobPoint = 0;
$who = 'alice';

rsort($card);

while(count($card)!=0){
    $cardPoint = array_splice($card, 0, 1);
    if($who === 'alice'){
        $alicePoint += $cardPoint[0];
        $who = 'bob';
    }
    else{
        $bobPoint += $cardPoint[0];
        $who = 'alice';
    }
}

echo $alicePoint - $bobPoint;

Measured memory_bytes: 4856
#include<stdio.h>
#define inf 1145141919

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

int main(void){
    int a,b,c,n;
    scanf("%d%d%d",&a,&b,&c);
    n = 100*a+10*b+c;
    if(n%4 == 0){printf("YES\n");}else{printf("NO\n");}
    return 0;
}

Measured memory_bytes: 128
import re
a,b=map(int,input().split())
s=input()
if re.search(r"^([0-9])*$",s[:a]) and s[a]=="-" and re.search(r"^([0-9])*$",s[a+1:]) and len(s)==a+b+1:
    print("Yes")
else:
    print("No")

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

namespace abc164_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var lotteryNum = int.Parse(Console.ReadLine());
            var prizes = new string[lotteryNum];

            for (int i = 0; i < lotteryNum; i++)
            {
                var prize = Console.ReadLine();

                prizes[i] = prize;
            }

            var duplicationDeletePrizes =  prizes.Distinct().ToArray();

            Console.WriteLine(duplicationDeletePrizes.Length);
            Console.Read();
        }
    }
}

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

int main() {
	int n;
	cin>>n;
	int d[n],map[101]={0},count=0;
	for(int i=0; i<n;i++){
		cin>>d[i];
		map[d[i]]++;
	}
	for(int i=0;i<101;i++){
		if(map[i]){
			count++;
		}
	}
	cout<<count;
		
	}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 long double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  101LL
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll Powb(ll b,ll n,ll m);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
ll P[N+1];
void Sieve(int n=N);

int main()
{
fast;
ll q=1,t;
//cin >> q; t = q;
while(q--)
{
    ll i,j,n,m,k,l=0,r=0,a=1,b=0,c=0,d=0,e,g=1,p,u,v,w,x,y,flag=1;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
 cin >> n >> m;
 vector<int> A(n+1);
 for(i=0;i<m;i++)
 {
     cin >> u >> v;
     A[u]++;
     A[v]++;
 }
 for(i=1;i<=n;i++) cout << A[i] << endl;
}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    //memset(P,true,sizeof(P));
    //P[0] = false;
    //P[1]= false;
    for(int i=1;i<=n;i++) P[i] = i;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i]==i)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                if(P[j]==j)
                    P[j]=i;
            }
        }
    }

}



Measured memory_bytes: 3600
n = int(input())
a_input = list(map(int,input().split()))

dic={}
for i in range(n):
    dic[a_input[i]]=dic.get(a_input[i],0)+1
    dic[a_input[i]-1]=dic.get(a_input[i]-1,0)+1
    dic[a_input[i]+1]=dic.get(a_input[i]+1,0)+1
print(max(dic.values()))

Measured memory_bytes: 18760
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
const ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

//最大公約数
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll R, C, N;
bool edge(ll x, ll y){
  if(x == 0 || x == R || y == 0 || y == C) return 1;
  return 0;
}

int main(void){
  cin >> R >> C >> N;
  vector<pair<ll, ll>> A;
  rep(i, N){
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if(edge(x1, y1) && edge(x2, y2)){
      if(y1 == 0) A.pb({x1, i});
      else if(x1 == R) A.pb({R + y1, i});
      else if(y1 == C) A.pb({2 * R + C - x1, i});
      else A.pb({2 * R + 2 * C - y1, i});

      if(y2 == 0) A.pb({x2, i});
      else if(x2 == R) A.pb({R + y2, i});
      else if(y2 == C) A.pb({2 * R + C - x2, i});
      else A.pb({2 * R + 2 * C - y2, i});
    }
  }
  sort(A.begin(), A.end());
  stack<ll> st;
  rep(now, A.size()){
    if(st.size() == 0){
      st.push(A[now].second);
    }else{
      if(st.top() == A[now].second){
        st.pop();
      }else{
        st.push(A[now].second);
      }
    }
  }
  if(st.size()) cout << "NO" << endl;
  else cout << "YES" << endl;
}


Measured memory_bytes: 6384
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
    
K = int(input())
cnt = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            cnt += gcd(i,j,k)
            
print(cnt)


Measured memory_bytes: 69820
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

def main():
    n = II()
    print(n//3)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define LL long long 
const int N=105;
using namespace std;
LL f[N][2],a[N],n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	if(a[1]&1) f[1][1]=1,f[1][0]=2;
	else f[1][1]=2,f[1][0]=1;
	for(int i=2;i<=n;++i)
	{
		if(a[i]&1)
		{
			f[i][0]=f[i-1][1]*2+f[i-1][0]*3;
			f[i][1]=f[i-1][1];
		    continue;
		}
		f[i][0]=f[i-1][0]*3+f[i-1][1];
		f[i][1]=f[i-1][1]*2;
	}
//for(int i=1;i<=n;++i)
// printf("f[%d][0]:%d\nf[%d][1]:%d\n",i,f[i][0],i,f[i][1]);
	cout<<f[n][0]<<endl;
	return 0;
}


Measured memory_bytes: 256
for(map$q[$_]+=$q[$N]/@$N,@{/ /,push@
$`,$' for<>;++$N}for++$q[1]..<>;--$N;$a<($~=$q[$N]*($b-1-$_)/($#$N||1))or$a=$~for grep$e[$N]=$b+=$_/@$N,@e[@$N]){$b=1}print$a+$b

Measured memory_bytes: 108308