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

using namespace std;

int main() {

	int a,b;
	cin >> a >> b;
	string s;
	cin >> s;
	if(s.length()==a+b+1 and s[a]=='-'){
		for(int i=0;i<s.length();i++){
			if(s[i]=='-' and i!=a){
				cout << "No";
				return 0;
			}
		}
		cout << "Yes";
	}
	else
		cout << "No";
}

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

typedef pair<int, int> P;
int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 };
int dy[8] = { 0, 1, 0, -1, 1, -1, 1, -1 };

vector<int> G[100000];
int dir[100000];
int vis[100000];

void dfs(int v, int p, int d) {
	dir[v] |= 1 << d;
	vis[v] = 1;
	for(auto c : G[v]) {
		if(c == p || vis[c]) continue;
		dfs(c, v, d);
	}
}

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

	int H, W, K;
	cin >> H >> W >> K;

	map<P, int> m;
	vector<P> p(K);
	for(int i = 0; i < K; i++) {
		int x, y;
		cin >> x >> y;
		m[{ x, y }] = i;
		p[i] = { x, y };
	}

	for(int i = 0; i < K; i++) {
		for(int k = 0; k < 8; k++) {
			int ny = p[i].first + dy[k], nx = p[i].second + dx[k];
			if(m.count({ ny, nx })) {
				G[i].push_back(m[{ny, nx}]);
			}
		}
	}

	const int U = 0, D = 1, L = 2, R = 3;
	for(int i = 0; i < K; i++) {
		if(p[i].first == 0 && !vis[i]) dfs(i, -1, U);
	}
	memset(vis, 0, sizeof vis);
	for(int i = 0; i < K; i++) {
		if(p[i].first == H - 1 && !vis[i]) dfs(i, -1, D);
	}
	memset(vis, 0, sizeof vis);
	for(int i = 0; i < K; i++) {
		if(p[i].second == 0 && !vis[i]) dfs(i, -1, L);
	}
	memset(vis, 0, sizeof vis);
	for(int i = 0; i < K; i++) {
		if(p[i].second == W - 1 && !vis[i]) dfs(i, -1, R);
	}

	int ok[4] = { 1 << U | 1 << D, 1 << U | 1 << L, 1 << L | 1 << R, 1 << D | 1 << R };
	for(int i = 0; i < K; i++) {
		for(int j = 0; j < 4; j++) {
			if((dir[i] & ok[j]) == ok[j]) {
				cout << 0 << endl;
				return 0;
			}
		}
	}

	for(int i = 0; i < K; i++) {
		int flag = 0;
		if(dir[i] >> U & 1 && p[i].first == H - 2) flag = 1;
		if(dir[i] >> U & 1 && p[i].second == 1) flag = 1;
		if(dir[i] >> D & 1 && p[i].first == 1) flag = 1;
		if(dir[i] >> D & 1 && p[i].second == W - 2) flag = 1;
		if(dir[i] >> L & 1 && p[i].first == 1) flag = 1;
		if(dir[i] >> L & 1 && p[i].second == W - 2) flag = 1;
		if(dir[i] >> R & 1 && p[i].first == H - 2) flag = 1;
		if(dir[i] >> R & 1 && p[i].second == 1) flag = 1;

		if(flag) {
			cout << 1 << endl;
			return 0;
		}

		for(int dx = -2; dx <= 2; dx++) {
			for(int dy = -2; dy <= 2; dy++) {
				if(abs(dx) != 2 && abs(dy) != 2) continue;
				int nx = p[i].second + dx, ny = p[i].first + dy;
				if(m.count({ ny,nx })) {
					int t = m[{ny, nx}];
					int d = dir[i] | dir[t];
					for(int j = 0; j < 4; j++) {
						if((d & ok[j]) == ok[j]) {
							cout << 1 << endl;
							return 0;
						}
					}
				}
			}
		}
	}
	cout << 2 << endl;
}

Measured memory_bytes: 20788
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
 
    long long X;cin >> X;
    cout << (X/500)*1000+((X%500)/5)*5 << endl;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,q,k;
    vector<int>v;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    cin>>q;
    for(int i=0;i<q;i++)
    {
        cin>>k;
        pair<vector<int>::iterator,
         vector<int>::iterator> s;
        s=equal_range(v.begin(),v.end(),k);
        cout<<s.first-v.begin()<<" "<<s.second-v.begin()<<endl;
    }
    return 0;
}



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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }

    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int n = ri();
	int a[n];
	int b[n];
	FOR(i,n) a[i] = ri(), b[i] = ri();

	vector<pair<int,int> > x,y;
	FOR(i,n) {
		x.push_back({a[i]+b[i], i});
	}
	sort(all(x));

	{
		bool used[n];
		INIT(used,false);

		s64 taka=0,ao=0;

		DOWN(i,n) {
			if ((n-i) % 2) taka += a[x[i].se];
			else ao += b[x[i].se];
		}

		cout << taka-ao << endl;
	}
    return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
 
 
int main(void){
  int N, K;
  cin >> N >> K;
  vector<double> temp(N, 0);
  vector<double> sum(N + 1, 0);
  vector<double> sum2(N - K + 1, 0);
  double p;
  sum[0] = 0;
  for(int i = 0; i < N; i++){
    cin >> p;
    temp[i] = (p + 1) / 2;
    sum[i + 1] = sum[i] + temp[i];
    if(i >= K - 1){
     sum2[i - K + 1] = sum[i + 1] - sum[i + 1 - K];  
    }

  }
  sort(sum2.begin(), sum2.end());
  /*for(int i = 0; i < N - K + 1; i++){
    cout << sum2[i] << " ";
  } 
  cout<< endl;*/
  cout << fixed;
  cout << setprecision(10) << sum2[N - K];
  return 0;
}

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

using namespace std;

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

    if(s.find('?') == string::npos){
        cout << s << endl;
        return 0;
    }

    bool isRestored = false;
    for(int i=s.size()-t.size(); i>=0; i--){
        if(s.at(i) == '?' || s.at(i) == t.at(0)){
            bool correspond = true;
            for(int j=1; j<t.size(); j++){
                if(!(s.at(i+j) == '?' || s.at(i+j) == t.at(j))){
                    correspond = false;
                    break;
                }
            }
            if(correspond){
                s.replace(i, t.size(), t);
                replace(s.begin(), s.end(), '?', 'a');
                isRestored = true;
                break;
            }
        }
    }

    if(isRestored){
        cout << s << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
i = list(map(int, input().split())) #i_1 i_2 1_3を取得し、iに値を入れる

if ((i[1] - i[0]) > 0) :
    if( (i[0] < i[2]) and (i[1] > i[2]) ):
        print('Yes')
    else:
        print('No')
else:
    if( (i[0] > i[2]) and (i[1] < i[2]) ):
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3060
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> P(n);
    vector<int> Q(n);
    vector<int> N(n);
    for (int i = 0; i < n; ++i) cin >> P[i];
    for (int i = 0; i < n; ++i) cin >> Q[i];
    for (int i = 0; i < n; ++i) N[i] = i + 1;

    int a, b, count;
    a = b = count = 0;

    do {
        count++;
        if (equal(N.begin(), N.end(), P.cbegin())) a = count;
        if (equal(N.begin(), N.end(), Q.cbegin())) b = count;
    } while (next_permutation(N.begin(), N.end()));

    cout << abs(a - b);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> A(n);
  rep(i, n) cin >> A[i];
  ll x = 0LL;
  int keta = 0;
  while((k >> keta) > 0) keta++;
  while(keta > 0) {
    keta--;
    int cnt1 = 0;
    rep(i, n) if((A[i] >> keta) & 1) cnt1++;
    if(cnt1 < (n + 1) / 2 && x + (1LL << keta) <= k)
      x += (1LL << keta);
  }
  ll ans = 0LL;
  rep(i, n) ans += A[i] ^ x;
  cout << ans << endl;
  return 0;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

string smax(string a, string b) {
    if (a.length() > b.length()) return a;
    else if (a.length() < b.length()) return b;
    else return a > b ? a : b;
}

char grid[75][75];
string dp[75][75];

int main() {
    cin >> skipws;
    for (;;) {
        int w, h; cin >> w >> h; if (!w) break;
        rep(i, 0, h) {
            rep(j, 0, w) {
                cin >> grid[i][j];
                dp[i][j] = "";
            }
        }
        rep(i, 0, h) {
            rep(j, 0, w) if (isdigit(grid[i][j])) {
                dp[i][j] = string(1, grid[i][j]);
                if (i && dp[i - 1][j].length()) dp[i][j] = smax(dp[i][j], dp[i - 1][j] + grid[i][j]);
                if (j && dp[i][j - 1].length()) dp[i][j] = smax(dp[i][j], dp[i][j - 1] + grid[i][j]);
                if (dp[i][j] == "0") dp[i][j] = "";
                // cout << i << " " << j << " " << dp[i][j] << endl;
            }
        }
        string m = "0";
        rep(i, 0, h) {
            rep(j, 0, w) if (isdigit(grid[i][j])) {
                m = smax(m, dp[i][j]);
            }
        }
        cout << m << endl;
    }
}


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

using namespace std;

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

    int n;
    cin>>n;

    vector<int> arr(n);

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

    int q;
    cin>>q;

    while(q--)
    {
        int l,r,key;
        cin>>l>>r>>key;

        cout<<count(arr.begin()+l,arr.begin()+r,key)<<endl;
    }


    return 0;
}



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


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

  int eat;
  eat = min(abs(L), abs(L + N - 1));
    if (L < 0 && L + N - 1 > 0) {
      eat = 0;
    }
    if (L + N - 1 < 0) {
      eat *= -1;
    }
  int sum;
  sum = (L - 1)*N + N*(N + 1)/2 - eat;
  cout << sum << endl;;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        // string a = Console.ReadLine();
        long n = Read.Int();
        long[] a = Read.ints();
   
        long x = a.Sum(), y = 0;
        long yabaisa = int.MaxValue;
        for (long i = 0; i < a.Length; i++)
        {
            x -= a[i];
            y += a[i];
            if (i != a.Length - 1)
            {
                yabaisa = Math.Min(yabaisa, Math.Abs(x - y));
            }
        }
        Console.WriteLine(yabaisa);
        Console.ReadLine();

    }

    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a * b / gcd(a, b);
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static long[] ints()
    {
        return Console.ReadLine().Split().Select(long
            .Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 32452
#!/usr/bin/env python3
import sys
import functools
INF = float("inf")


@functools.lru_cache(None)
def hight(n):
    return 2**(n+2)-3


@functools.lru_cache(None)
def paty(n):
    return 2**(n+1)-1


def rec(n, x):
    # print(n, x)
    if n == 0:
        if x == 0:
            return 0
        else:
            return 1

    if x == 0:
        return 0
    elif x == 1:
        return 0
    elif x < hight(n-1)+2:
        return rec(n-1, x-1)
    elif x == hight(n-1)+2:
        return paty(n-1) + 1
    else:
        # print(paty(n-1)+1)
        return paty(n-1)+1 + rec(n-1, x-(hight(n-1)+2))


def solve(N: int, X: int):
    print(rec(N, X))

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(N, X)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
def search(here, lb, ub, field):
	count = 0
	if field[here[1]][here[0]] :
		count += 1
		field[here[1]][here[0]] = 0
		if lb[0] < here[0] :
			count += search((here[0]-1, here[1]), lb, ub, field) 
		if lb[1] < here[1] :
			count += search((here[0], here[1]-1), lb, ub, field)
		if ub[0] > here[0] :
			count += search((here[0]+1, here[1]), lb, ub, field)
		if ub[1] > here[1] :
			count += search((here[0], here[1]+1), lb, ub, field) 
	return count

while 1:
	w, h = map(int, raw_input().split(" "))
	if (w,h) == (0,0): 
		break
	field = [[1 for i in range(w)] for j in range(h)]
	for y in range(h):
		tiles = raw_input()
		for x in range(w):
			if tiles[x] == "#":
				field[y][x] = 0
			elif tiles[x] == "@":
				here = (x,y)
	print search(here, (0,0), (w-1,h-1), field)

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

// Author: Ashish

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  if(n==2) {cout<<"1"; return 0;}
  set<int> answer;
  n=n-1;
  answer.insert(2);
  for(int i=1;i*i<=n;i++)
  {
  	if(n%i==0) answer.insert(i),answer.insert(n/i);
  }
  n=n+1;
  for(int i=2;i*i<=n;i++)
  {
  	if(n%i==0)
  	{
  		int temp=n;
  		while(temp%i==0)
  			temp/=i;
  		if(temp%i==1) answer.insert(i);
  	}
  }
  answer.insert(n);
  cout<<answer.size()-1;
 	return 0;
}

Measured memory_bytes: 256
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""
import copy
N=int(input())
A=[list(reversed(list(map(int,input().split())))) for i in range(N)]
for i in range(N):
    for m in range(N-1):
        A[i][m]-=1

playerlst=set([i for i in range(N)])

count=0
nlst=copy.copy(playerlst)
while playerlst:
    flag=0
    lst=set()
    playedlst=set()
    while nlst:
        p=nlst.pop()
        if not p in lst and p in playerlst:
            p2=A[p][-1]
            if not p2 in lst and p2 in playerlst:
                if A[p2][-1]==p:
                    flag=1
                    A[p].pop()
                    A[p2].pop()
                    lst.add(p)
                    lst.add(p2)
                    if p2 in nlst:
                        nlst.remove(p2)
                    playedlst.add(p)
                    playedlst.add(p2)
                    if not A[p]:
                        playerlst.remove(p)
                    if not A[p2]:
                        playerlst.remove(p2)
    if not flag:
        print(-1)
        exit()
    count+=1
    nlst=copy.copy(playedlst)
print(count)


Measured memory_bytes: 64092
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

pair<int, i_i> tab[100];

bool xsort(pair<int, i_i> qwe, pair<int, i_i> rty){
  return qwe.X > rty.X;
}
bool ysort(pair<int, i_i> qwe, pair<int, i_i> rty){
  return qwe.Y.X < rty.Y.X;
}

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    rep(i, n)tab[i] = mp(0, mp(i, 0));
    rep(i, n * (n - 1) / 2){
      int4(a, b, c, d);
      --a; --b;
      if(c == d){
        ++tab[a].X;
        ++tab[b].X;
      }else if(c > d){
        tab[a].X += 3;
      }else{
        tab[b].X += 3;
      }
    }
    sort(tab, tab + n, xsort);
    tab[0].Y.Y = 1;
    rep1(i, n){
      if(tab[i - 1].X == tab[i].X)tab[i].Y.Y = tab[i - 1].Y.Y;
      else tab[i].Y.Y = i + 1;
    }
    sort(tab, tab + n, ysort);
    rep(i, n)pri(tab[i].Y.Y);



/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>

#define sf scanf
#define pf printf

using namespace std;

int GCD(int a,int b)
{
    if(b == 0) return a;
    return GCD(b,a%b);
}
int main()
{
    int a,b;
    while(~sf("%d%d",&a,&b))
    {
        int gcd = GCD(a,b);
        int lcm = a / gcd * b;
        pf("%d %d\n",gcd,lcm);
    }
    return 0;
}

Measured memory_bytes: 1188
main = do
    n <- getInt
    mapM printThree [1..n]   
    putStrLn ""

getInt :: IO (Int)
getInt = do
    str <- getLine
    return $ read str

printThree :: Int -> IO ()
printThree n 
    | isThree n = putStr $ " " ++ (show n)
    | otherwise = return ()

isThree :: Int -> Bool
isThree n 
    | n `mod` 3  == 0 = True
    | hasThree n      = True
    | otherwise       = False

hasThree :: Int -> Bool
hasThree n = any (\c -> c == '3') (show n)
    


Measured memory_bytes: 4800
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    string s;
    cin >> s;
    vector<int> num(26);
    for (int i = 0; i < s.size(); i++) num.at(s.at(i)-'a')++;
    char answer = '\0';
    for (int i=0; i<26; i++) {
        if (num.at(i) == 0) {
            answer = i + 'a';
            break;
        }
    }
    if (answer == '\0') cout << "None" << endl;
    else cout << answer << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int mintemp = 1000000;
  rep(i, n) {
    chmin(mintemp, abs(accumulate(a.begin(), a.begin() + i, 0) -
                       accumulate(a.begin() + i, a.end(), 0)));
  }
  cout << mintemp << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# check reachability B -> A ?
# 隣接和table
P = [B[(i-1)%N] + B[(i+1)%N] for i in range(N)]
D = deque(i for i in range(N) if B[i] - P[i] >= A[i])
ans = 0
nmatch = [B[i] == A[i] for i in range(N)].count(True)
while D:
    upd = False
    i = D.popleft()
    if B[i] == A[i]:
        nmatch += 1
        continue
    if B[i] <= P[i]:
        continue
    if B[i] - P[i] >= A[i]:
        n = (B[i] - A[i]) // P[i]
        P[(i-1)%N] -= P[i] * n
        P[(i+1)%N] -= P[i] * n
        B[i] -= P[i] * n
        upd = True
        ans += n
        if B[i] == A[i]:
            nmatch += 1
        if B[(i-1)%N] - P[(i-1)%N] >= A[(i-1)%N]:
            D.append((i-1)%N)
        if B[(i+1)%N] - P[(i+1)%N] >= A[(i+1)%N]:
            D.append((i+1)%N)
    if not upd:
        break

print(ans if nmatch == N else -1)


Measured memory_bytes: 129812
N, X = map(int, input().split())
maisuu = [1]
patimaisuu = [1]
for i in range(1,N + 1):
    maisuu.append(2 * maisuu[i - 1] + 3)
    patimaisuu.append(2 * patimaisuu[i - 1] + 1)

def pati(l, n):
    if n == 0:
        return 0
    elif l == 0:
        return 1
    elif n == 1:
        return 0
    elif 2 <= n <= maisuu[l] // 2:
        return pati(l - 1, n - 1)
    else:
        return pati(l - 1, n - maisuu[l - 1] - 2) + 1 + patimaisuu[l - 1]

print(pati(N, X))

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


int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(auto& a : A){
    cin >> a;
  }
  cout << *max_element(A.begin(), A.end()) - *min_element(A.begin(), A.end()) << endl;
  return 0;
}

Measured memory_bytes: 256
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
// clang-format off
/* }}} */

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
// clang-format on
/* }}} */

int n, a[100];
ll dp[101][21];

ll dfs(int idx, int sum) {
  if (idx == n - 1) {
    return sum == a[n - 1];
  }
  //cerr << sum << " " << idx << endl;
  if (!(0 <= sum && sum <= 20)) return 0;

  if (dp[idx][sum] != -1) return dp[idx][sum];
  ll& res = dp[idx][sum];
  res = dfs(idx + 1, sum + a[idx]) + dfs(idx + 1, sum - a[idx]);

  return res;
}

signed main() {
  fill(dp[0], dp[100], -1);
  n = in();
  REP(i, n) a[i] = in();
  print(dfs(1, a[0]));

  return 0;
}

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

int main() {
  int N=0;
  int K;
  cin>>K;
  if(K/100==1)
    N++;
  if((K-(K/100)*100)/10==1)
    N++;
  if(K%10==1)
    N++;
  
  cout <<N<<endl;
  
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

// 素因数分解
vector<pair<int, int> > prime_factorize(int n) {
    vector<pair<int, int> > res;
    for (int p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

signed main() {

    int A, B;
    cin >> A >> B;
    int g = gcd(A, B);

    vector<P> r = prime_factorize(g);

    cout << r.size() + 1 << endl;

    return 0;
}


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

#define F first
#define S second
#define pb push_back
#define ll long long
#define int long long
#define ld double

using namespace std ;

const int MAXN = 101 * 1001 ; 

int cnt[MAXN] , can[MAXN] ; 

int32_t main()
{
	ios::sync_with_stdio(0) ; cin.tie(0) ; 
	int n , m ;
	cin >> n >> m ; 
	can[1] = 1 ; 
	for(int i = 1 ; i <= n ; i ++ ) cnt[i] = 1 ; 
	while(m--)
	{
		int x , y ; 
		cin >> x >> y ; 
		if(can[x]) can[y] = 1 ; 
		if(cnt[x]==1) can[x] = 0 ; 
		cnt[y] ++ ; 
		cnt[x] -- ; 
	}
	int ans = 0 ; 
	for(int i = 1 ; i <= n ; i ++ ) ans += can[i] ; 
	cout << ans << endl ; 
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <string>
#define INF 1<<27
#define ESP 1e-10

using namespace std;

int main()
{
  int dp[8][1001];
  int n,m,a[1000],t[1000];

  while( cin >> m,m){

    for(int i = 0 ; i < m ; i++ )
      {
	cin >> a[i] >> t[i];
      }
    /*
      fill(dp[0],dp[8],0);
      dp[0][0] = 1;

      for(int i=0 ; i<m ; i++ )
      {
      for(int j = 0 ; j <= 1000 ; j++ )
      {
      if( dp[i][j] ){
      for(int k = 0 ; k <= t[i]  ; k++ ){
      if(j + a[i]*k <= 1000)dp[i+1][j+k*a[i]] += dp[i][j];
      }
      }
      }
      }*/
    fill(dp[0], dp[8], 0);
    dp[0][0] = 1;
    for( int i=0; i<m; i++ ) {
      for( int j=0; j<1001; j++ ) {
	if( dp[i][j] ) {
	  for( int k=0; k<=t[i]; k++ ) {
	    if( j+k*a[i] <= 1000 ) dp[i+1][j+k*a[i]] += dp[i][j];
	  }
	}
      }
    }
    /*for(int i = 0 ; i <= 7 ; i++){
      for(int j = 0 ; j <= 20;j++  ){
      cout << dp[i][j] << " ";
      }
      cout << endl;
      }*/
    int s;
    cin >> s;
    for(int i = 0 ; i < s ; i++ )
      {
	cin >> n;
	cout << dp[m][n] << endl;
      }
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    int n, k; cin >> n >> k;
    int ans = 1;
    for(int i = 0; i < n; i++){
        int bai = ans * 2;
        int sum = ans + k;
        if(bai > sum){
            ans = sum;
        }else{
            ans = bai;
        }
    }   
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
using namespace std;
using ll = long long int;
int MAX_N = 1e5;
vector<int> is_odd(MAX_N, -1);
vector<vector<int>> edge(MAX_N, vector<int>{});
ll odd_num = 0;
ll even_num = 0;
ll n, m;

int dfs(int d, int v){
    if(is_odd[v] != -1){
        if(is_odd[v] == d % 2){return 0;}
        else{
            cout << n * (n-1) / 2 - m << endl;
            exit(0);
        }
    }
    is_odd[v] = d % 2; 
    if(d%2 == 0){even_num++;}
    else{odd_num++;}
    for(int i=0; i<edge[v].size(); i++){
        dfs(d+1, edge[v][i]);
    }
    return 0;
}

int main() {
    cin >> n >> m;
    int a, b;
    for(int i=0; i<m; i++){
        cin >> a >> b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    dfs(0, 0);
    cout << odd_num * even_num - m << endl;
    return 0;
}

Measured memory_bytes: 6400
#pragma region Template
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX;
const int INF = INT_MAX;

inline int sqr(int x) { return (x * x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }
inline int absdiff(int a, int b) {
	if (b > a) return absdiff(b, a);
	return (a - b);
}
int gcd(int a, int b) { // 最大公約数
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
inline int lcm(int a, int b) { return a * b / gcd(a, b); } // 最小公倍数
#pragma endregion



signed main()
{	
	int N, M;
	cin >> N >> M;
	VP AB(M);
	rbf(ab, AB) cin >> ab.first >> ab.second;

	VI perm(N-1);
	int i = 2;
	rbf(p, perm) p = i++;

	i = 2;
	int pattern = 1;
	while (i < N) pattern *= i++;

	VVI allperm(pattern, VI(N - 1));

	i = 0;
	do {
		allperm[i++] = perm;
	} while (next_permutation(All(perm)));

	int a, b, cnt = 0;
	bool flg = false, flg2 = false;
	rbf(pp, allperm) {
		a = 1; b = 1;
		flg2 = true;
		rep(j, N - 1) {		
			a = b;
			b = pp[j];
			flg = false;
			rbf(ab, AB) {
				if ((a == ab.first && b == ab.second) || (b == ab.first && a == ab.second)) {
					flg = true;
					break;
				}
			}
			if (!flg) {
				flg2 = false;
				break;
			}
		}
		if (flg2) {
			cnt++;
		}
	}

	COL(cnt);

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <stdio.h>
#include <utility>
#include <iomanip>
#include <map>
#include <set>
using namespace std;
#define LL long long;


double w, h, x, y;


int main() {

	cin >> w >> h >> x >> y;

	printf("%lf %d\n", double(w) * double(h) / 2, x + x == w && y + y == h);

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

def ins(): return input().split()
def ii(): return int(input())
def iil(): return list(map(int, ins()))
def lin(): return list(input())
def iin(): return map(int, ins())

n, m = iin()
a = sum(iin())
print(-1 if n-a<0 else n-a)


Measured memory_bytes: 9532
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int n, m, c;
	cin >> n >> m >> c;
	int A[30][30];
	int B[30];

	rep(i, m) cin >> B[i];
	rep(i, n) {
		rep(j, m) {
			cin >> A[i][j];
		}
	}

	int res = 0;
	rep(i, n) {
		int sum = 0;
		rep(j, m) {
			sum += A[i][j]*B[j];
		}
		if (sum +c > 0) res++;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define M 4000010
ll ex(ll a,ll b){ll ans=1;while(b){if(b&1)ans=(ans*a)%md;a=(a*a)%md,b/=2;}return ans;} 
inline ll add(ll a,ll b){return (a+b)%md;}
inline ll mul(ll a,ll b){return (a*b)%md;}
ll f[M],iv[M];
ll C(ll n,ll r){return mul(f[n],mul(iv[r],iv[n-r]));}
void prep_fac(){
    f[0]=1;
    rep(i,1,M)f[i]=mul(i,f[i-1]);
    iv[M-1]=ex(f[M-1],md-2);
    for(ll i=M-2;i>=0;--i)iv[i]=mul(i+1,iv[i+1]);
}
int main(){
    IOS;
 
     prep_fac();
     ll k;cin>>k;
     string s;cin>>s;
     ll n;n=sz(s);
     ll ans=0,x=1;
     ll a[k+1];
     rep(i,0,k+1){
         a[i]=mul(C(n+i-1,i),x);
        x=mul(x,25);
     }x=1;
     for(ll i=k;i>=0;--i)a[i]=mul(a[i],x),x=mul(x,26),ans=add(ans,a[i]);
     cout<<ans<<"\n";
     
     
     
     return 0;
}


Measured memory_bytes: 74648
#include<iostream>
 #include<algorithm>
 #include<cmath>
 #include<iomanip>
 #include<string.h>
 #include<cmath>
 #include<map>
 #include<vector>
using namespace std;
typedef long long ll;
char s[4005];
bool vis[105];
const int maxn=2e5+5;
ll a[maxn],b[maxn],c[maxn];

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        b[i]=i-a[i];
        c[i]=i+a[i];
    }
    map<ll,ll>mp;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=mp[b[i]];
        mp[c[i]]++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 31008
#include <iostream>

using namespace std;

int main() {
    int n,in;
    int maximum=-2147483648, minimum=2147483647;
    long sum = 0;
    cin>>n;
    while(n--)
    {
        cin >>in;
        maximum = max(maximum, in);
        minimum = min(minimum, in);
        sum += in;
    }
    cout<<minimum<<" "<<maximum<<" "<<sum<<"\n";
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;

void solve(){
    string s, t;
    cin>>s>>t;
    if(t.length() - s.length() != 1){
        cout<<"No";
        return ;
    }
    f(i,s.length())if(s[i] != t[i]){cout<<"No";return ;}
    cout<<"Yes";
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


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

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

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

    vector<ll> v;
    for(int i = 0; i < n; i++){
        auto itr = lower_bound(v.begin(), v.end(), a[i]);
        if(i == 0){
            v.push_back(a[i]);
        }else{
            int p = distance(v.begin(), itr);
            if(p == 0){
                v.insert(v.begin(), a[i]);
            }else{
                p--;
                v[p] = a[i];
            }
        }
    }


    cout << v.size() << endl;
}

Measured memory_bytes: 5024
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>

using namespace std;

#define rep(i,n) for(int i=0;i<int(n);i++)
#define reps(i,n) for(int i=1;i<=int(n);i++)
#define sint(i) scanf("%d",&i);
#define sintt(i,j) scanf("%d%d",&i,&j);
#define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k);
#define sintttt(i,j,k,m) scanf("%d%d%d%d",&i,&j,&k,&m);

#define INF 1010000000
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

class S{
	public:
	int p,n,t;
	S(int p,int n,int t):p(p),n(n),t(t){}
	
	bool operator<(const S& a)const{
		return n>a.n;
	}
};


int main(){
	while(1){
		int c,n,m,s,g;
		cin>>c>>n>>m>>s>>g;
		if(n==0)break;
		vector<pair<int,int> > load[101];
		rep(i,m){
			int a,b,c;
			cin>>a>>b>>c;
			load[a].push_back(make_pair(b,c));
			load[b].push_back(make_pair(a,c));
		}
		
		priority_queue<S> que;
		que.push(S(s,0,0));
		int visit[11][101];
		int ans=-1;
		
		rep(j,11)rep(i,101)visit[j][i]=0;
		
		while(1){
			if(que.empty()==1){
				break;
			}
			
			S u=que.top();
			que.pop();
			
			if(visit[u.t][u.p]==1){
				continue;
			}
			visit[u.t][u.p]=1;
			
			if(u.p==g){
				ans=u.n;
				break;
			}
			
			rep(i,load[u.p].size()){
				if(u.t<c){
					que.push( S( load[u.p][i].first,  u.n+load[u.p][i].second/2 ,u.t+1));
				}
				que.push( S( load[u.p][i].first,  u.n+load[u.p][i].second,u.t));
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

int main(void)
{
  int h,w;
  cin>>h>>w;
  char a[110][110];
  bool check[110][110];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      check[i][j]=true;
    }
  }
  bool check2[110];
  for(int i=0;i<h;i++){
    check2[i]=true;
  }


  bool flag;
  for(int i=0;i<h;i++){
    flag=true; 
    for(int j=0;j<w;j++){
      if(a[i][j]=='#')
	flag=false;
      if(flag==false) break;
    }
    if(flag){
      for(int k=0;k<w;k++){
	check[i][k]=false;
	check2[i]=false;
      } 
    }
  }
  for(int i=0;i<w;i++){
    flag=true; 
    for(int j=0;j<h;j++){
      if(a[j][i]=='#')
	flag=false;
      if(flag==false) break;
    }
    if(flag){
      for(int k=0;k<h;k++){
	check[k][i]=false;
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(check[i][j]){
	cout<<a[i][j];
      }
    }
    if(check2[i]){
      cout<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007LL, INF= mod * 6000;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n+1), b(n+1);
    b[0] = 1LL;
    ll ans = 0LL;
    bool cnt = true;
    for(ll i=0LL;i<=n;i++){
    	cin >> a[i];
    	if(cnt){
    	    if(i == 0LL) b[i] -= a[i];
    	    else b[i] = b[i-1] * 2LL - a[i];
    	    if(b[i] < 0LL){
    		    cout << -1 << endl;
    		    return 0;
    	    }
    	    if(b[i] > INF) cnt = false;
        }else b[i] = INF;
    }
    ll now = a[n];
    ans += now;
    for(ll i=n-1;i>=0;i--){
    	now = min(now, b[i]) + a[i];
    	ans += now;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4760
def returnsecond(numbers, N):
    first = 0
    firc = 0;
    second = 0
    for j in range(N):
        if first < numbers[j]:
            first = numbers[j]
            firc = j
    for j in range(N):
        if(j != firc and second <= numbers[j]):
            second = numbers[j]

    return first, second;


numbers = []
N = int(input())

for i in range(N):
    numbers.append(int(input()))
first, second = returnsecond(numbers, N)

for i in range(N):
    if numbers[i] != first:
        print(first)
    else:
        print(second)


Measured memory_bytes: 12532
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define int long long

signed main(){
    int n, m;
    cin >> n >> m;
    int a, b;
    map<int, int> mp;

    for(int i = 1; i <= n; i++){
        mp[i] = 0;
    }
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        mp[a]++;
        mp[b]++;
    }
    for(int i = 1; i <= n; i++){
        cout << mp[i] << endl;
    }
}

Measured memory_bytes: 256
N, A, B = [int(i) for i in input().split()]

if (B - A)%2 == 0:
    print((B - A)//2)
else:
    edge = min([N-A, B-1])
    a_change = A  + (B- A-1)//2
    b_change = N-B+1 +(N-(A + (N-B+1)))//2
    print(min([edge, a_change, b_change]))

    


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main() {
	int argN, argM;
	cin >> argN >> argM;

	vector<int> argA(argM), argB(argM);
	for (int i = 0; i < argM; ++i) {
		cin >> argA.at(i) >> argB.at(i);
		argA.at(i)--;
		argB.at(i)--;
	}

	map<int, int> mapN;
	for (int i = 0; i < argM; ++i) {
		if (mapN.find(argA.at(i)) == mapN.end()) {
			mapN.emplace(argA.at(i), 1);
		}
		else  {
			mapN.at(argA.at(i))++;
		}

		if (mapN.find(argB.at(i)) == mapN.end()) {
			mapN.emplace(argB.at(i), 1);
		}
		else  {
			mapN.at(argB.at(i))++;
		}
	}

	for (int i = 0; i < argN; ++i) {
		if (mapN.find(i) != mapN.end()) {
			cout << mapN.at(i) << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
}

Measured memory_bytes: 504