akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include<stdlib.h>
const int N = 10000;
int main()
{
	int a[N], n, maxn=-1000000, minn=1000000;
	long long sum = 0;
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		if(a[i] > maxn)
		{ 
			maxn = a[i];
		}
		if(a[i] < minn)
		{ 
			minn = a[i];
		}
		sum += a[i];
	}
	printf("%d %d %lld\n", minn, maxn, sum);
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
int a[200050],num[200050];
int n;
int cmp(int a,int b)
{
	return a>b;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		num[i]=a[i];
	}
	sort(num+1,num+1+n,cmp);
	for(int i=1;i<=n;++i)
	{
		if(a[i]<num[1])
		{
			printf("%d\n",num[1]);
		}
		else if(a[i]==num[1])
		{
			printf("%d\n",num[2]);
		}
	}
	return 0;
}
/*
Date:
Name:
*/


Measured memory_bytes: 3200
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	comInit()
	ans := 0
	for i := 0; i <= min(n-1, k); i++ {
		// nCi * n-iHi
		ans += com(n, i) * com(n-i+i-1, i)
		ans %= mod
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

const mod int = 1e9 + 7
const max int = 1e5*2 + 1000

var fac [max]int
var finv [max]int
var inv [max]int

func comInit() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := 2; i < max; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

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


Measured memory_bytes: 6564
#include <iostream>
#include <vector>
#include <string>
using namespace std;

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

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define REP(i,n) for(int i=0;i<n;i++)
#define pb push_back


// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

int main(void) {
	// cin, coutの結びつきを解除し、速くする
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int n; cin >> n;

	bool buyable = false;
	REP(i, n/7+1) {
		if ((n - 7 * i) % 4 == 0) {
			buyable = true;
			break;
		}
	}
	buyable?Yes:No;
}

// 0 % 4 == 0 ではない？
// そこでエラー。7の倍数の時、Noになっていた


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

int main(){
  int N, K, Q;
  cin >> N >> K >> Q;

  vector<int> A(N);
  for(auto& x: A){
    cin >> x;
  }
  //banpei
  A.push_back(0);
  N++;
  

  int ans = 1e9;
  for(int X: A){
    // cout << "X: " << X << endl;
    vector<int> removal;

    int start = 0;
    for(int i = 0; i < N; i++){
      if(A[i] < X){
        vector<int> interval;
        for(int j = start; j < i; j++){
          interval.push_back(A[j]);
        }
        sort(interval.begin(), interval.end());

        /*
        cout << "Interval: ";
        for(auto x: interval){
          cout << x << ' ';
        }cout << endl;
        */

        for(int j = 0; j < static_cast<int>(interval.size()) - K + 1; j++){
          removal.push_back(interval[j]);
        }
        start = i + 1;
      }
    }
    /*
    cout << "Removal: ";
    for(auto r: removal){
      cout << r << ' ';
    }cout << endl;
    */
    
    sort(removal.begin(), removal.end());
    if(removal.size() >= Q){
      ans = min(ans, removal[Q - 1] - X);
    }
    
  }
  cout << ans << endl;

}


Measured memory_bytes: 384
//
// Created on 2020/09/16.
//


#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 <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;



int main() {
    int n;
    cin>>n;
    int m;
    cin>>m;
    int q;
    cin>>q;
    vector<vector<int>>point(n+2,vector<int>(n+2,0));

    for (int i = 0; i < m; ++i) {
        int l,r;
        cin>>l>>r;
        point[l][r]++;
    }

    for (int i = 1; i < n+2; ++i) {
        for (int j = 1; j < n+2; ++j) {
            point[i][j] = point[i][j-1] + point[i][j];
        }
    }

    for (int i = 1; i < n+2; ++i) {
        for (int j = 1; j < n+2; ++j) {
            point[i][j] = point[i-1][j] + point[i][j];
        }
    }

    for (int k = 0; k < q; ++k) {
        int q_l,q_r;
        cin>>q_l>>q_r;

        int ans = point[q_r][q_r] - point[q_l - 1][q_r] - point[q_r][q_l-1] + point[q_l-1][q_l-1];
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 4492
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=2e5+10;
const ll MOD=1e7;
ll _gcd(ll a,ll b){if(b==0)return a;return _gcd(b,a%b);}
ll gcd(ll a,ll b){a=abs(a),b=abs(b);if(a<b)swap(a,b);return _gcd(a,b);}
ll qpow(ll a,ll n){ll rt=1;while(n){if(n&1)rt=(rt*a)%MOD;a=a*a%MOD;n>>=1;}return rt;}
ll factor[MAXN];
void cal_factor(){factor[0]=1;for(int u=1;u<MAXN;u++){factor[u]=(factor[u-1]*u)%MOD;}}
ll C(ll n,ll k){return factor[n]*qpow(factor[n-k],MOD-2)%MOD*qpow(factor[k],MOD-2)%MOD;}
int N;
vector<int>G[MAXN];
vector<int>path,tmp;
void dfs(int rt,int fa)
{
    if(path.size())return;
    tmp.push_back(rt);
    if(rt==N){
        path=tmp;
        return;
    }
    for(int v:G[rt]){
        if(v==fa)continue;
        dfs(v,rt);
    }
    tmp.pop_back();
}
int treesz(int rt,int fa)
{
    if(G[rt].size()==1)return 1;
    int sz=1;
    for(int v:G[rt]){
        if(v==fa)continue;
        sz+=treesz(v,rt);
    }
    return sz;
}
void solve()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    for(int u=0;u<N-1;u++){
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(1,0);
    int b,w;
    if(path.size()%2==0){
        b=path[path.size()/2-1];
        w=path[path.size()/2];
    }
    else {
        b=path[path.size()/2];
        w=path[path.size()/2+1];
    }
    int f=treesz(b,w),
    s=treesz(w,b);
    if(f<=s){
        cout<<"Snuke\n";
    }
    else cout<<"Fennec\n";
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

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

using namespace std;

ll mod = 1e9+7;

ll f(ll x,ll n){//x^n
	ll tmp=1;
	rep(i,n){
		tmp*=x;
		tmp%=mod;
	}
	return tmp;
}

int main(){
	//cout << mod << endl;
	ll n;
	cin >> n;
	cout << (f(10,n)+f(8,n)-2*f(9,n)%mod+mod)%mod << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

int main(){

    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll a;
        cin >> a;
        while(a % 2 == 0){
            ans++;
            a /= 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
/*
    Author: isaf27 (Ivan Safonov)
*/

#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC

//permanent constants
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int dxt[6] = {0, 0, -1, -1, 1, 1};
const int dyt[6] = {-2, 2, 1, -1, -1, 1};
const int alf = 26;
const int dig = 10;
const int two = 2;
const int th = 3;
const ll prost = 239;
const ll bt = 30;
const ld eps = 1e-8;
const ll INF = 1e18 + 239;
const int BIG = 1e9 + 239;
const int MOD = 998244353; //1e9 + 7; //;
const ll MOD2 = (ll)MOD * (ll)MOD;

//random
mt19937 rnd(239); //rnd(chrono::high_resolution_clock::now().time_since_epoch().count())

//constants
const int M = 2e5 + 239;
const int N = 2e3 + 239;
const int L = 20;
const int T = (1 << 20);
const int B = trunc(sqrt(M)) + 1;
const int X = 4010;

int n;
string s;
int dp[X][X], kb[X], kr[X];

int fnd(int x, int y)
{
    if (x < 0 || y < 0) return 0;
    if (x == 0 && y == 0) return 1;
    int t = (x + y);
    t = min(t, n);
    if (x > kr[t] || y > kb[t]) return 0;
    if (dp[x][y] != -1) return dp[x][y];
    dp[x][y] = (fnd(x - 1, y) + fnd(x, y - 1));
    if (dp[x][y] >= MOD) dp[x][y] -= MOD;
    return dp[x][y];
}

int32_t main()
{
    #ifdef ONPC
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    memset(dp, -1, sizeof(dp));
    kb[0] = 0;
    kr[0] = 0;
    cin >> s;
    n = (int)s.size();
    for (int i = 0; i < n; i++)
    {
        kb[i + 1] = kb[i];
        kr[i + 1] = kr[i];
        if (s[i] == '0')
            kr[i + 1] += 2;
        else if (s[i] == '1')
        {
            kb[i + 1]++;
            kr[i + 1]++;
        }
        else
            kb[i + 1] += 2;
    }
    cout << fnd(kr[n], kb[n]);
    return 0;
}


Measured memory_bytes: 63360
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();
        char[] S = next().toCharArray();
        char[] T = next().toCharArray();

        for(int i=0; i<N; i++){
            print(S[i]);
            print(T[i]);
        }
    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 25300
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;
 
int a[7];


int f(int t){
    int res = ((a[0] - t) / 2) * 2 + ((a[3] - t) / 2) * 2 + ((a[4] - t) / 2) * 2;
    return res;
}
 

signed main(){
    rep(i, 0, 7) cin >> a[i];
    int ans = a[1];
    int t = 0;
    if(a[0] && a[3] && a[4]) t = 3; 
    ans += max(t + f(1), f(0));
    o(ans);
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    ll n,m,k,A,B;
    cin>>n>>m>>k;
    vector<ll> a(n+1),b(m+1);
    rep(i,0,n){
        cin>>A;
        a[i+1]=a[i]+A;
    }
    rep(i,0,m){
        cin>>B;
        b[i+1]=b[i]+B;
    }

    ll ans=0,j=m;
    rep(i,0,n+1){
        if(a[i]>k)break;
        while(b[j]>k-a[i])j--;
        ans=max(ans,i+j);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6432
def main():
    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)
            if x == y:
                return
            if self.parents[x] > self.parents[y]:
                x, y = y, x
            self.parents[x] += self.parents[y]
            self.parents[y] = x

        def size(self, x):
            return -self.parents[self.find(x)]

        def same(self, x, y):
            return self.find(x) == self.find(y)

        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def other_members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root and i != x]

        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]

        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    import sys
    def input():
        return sys.stdin.readline().rstrip()
    n, m, k = list(map(int, input().split()))
    uf = UnionFind(n)
    counts = [0] * n
    for _ in range(m):
        a, b = list(map(lambda x: int(x) - 1, input().split()))
        uf.union(a, b)
        counts[a] += 1
        counts[b] += 1
    for _ in range(k):
        c, d = list(map(lambda x: int(x) - 1, input().split()))
        if uf.same(c, d):
            counts[c] += 1
            counts[d] += 1
    print(' '.join([str(uf.size(i) - counts[i] - 1) for i in range(n)]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 21432
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>

int main() {
	int n;
	std::string s, t;

	std::cin >> n >> s >> t;

	for (size_t i = 0; i < s.length(); i++)
	{
		std::cout << s[i] << t[i];
	}

	std::cout << std::endl;

	return 0;
}

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

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

A = [0] * N

#端っこを決める
A[0] = B[0]
A[N-1] = B[N-2]

for i in range(1,N-1):
    A[i] = min(B[i-1],B[i])

print(sum(A))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 2000001
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main(){
    ll n,k,ans=0,cnt=0;
    cin>>n>>k;
    cnt=n/k;
    ans+=pow(cnt,3.0);
    if(k%2==0){
      if(n%k>=k/2){
        cnt++;
      }
      ans+=pow(cnt,3.0);
    }
    cout<<ans<<endl;
  }









Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long ans;
  int n;
  cin >> n ;
  ans = 0;
  for(int i=1; i <= n; i++){
    if(i % 3 != 0 && i % 5 != 0){
      ans = ans + i;
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}




signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
    string s;
    cin>>s;
    int n = s.size();
    ll dp[2][2020]={};
    ll ans = 0;
    for(int i=0;i<n;i++){
      	int now = i%2, nx = (i+1)%2;
        for(int j=0;j<2019;j++){
            dp[nx][j] = 0;
        }
        dp[nx][s[i]-'0']++;
        for(int j=0;j<2019;j++){
            dp[nx][(j*10+(s[i]-'0')) % 2019] += dp[now][j];
        }
        ans += dp[nx][0];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3804
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  ll a,b,k;
  cin>>a>>b>>k;
  ll x=min(a,k);
  a-=x;
  k-=x;
  b-=min(b,k);
  cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
import numpy as np

data = np.array([input().split() for i in range(3)])
data = data.astype(np.int64)

N = int(input())

ans = 0
for i in range(N):
	check = 0
	num = int(input())
	for x in range(3):
		for y in range(3):
			if num == data[x][y]:
				data[x][y] = -1
				break
		if check == 1:
			break

if data[0][0] == -1 and data[0][1] == -1 and data[0][2] == -1:
	ans = 1
elif data[1][0] == -1 and data[1][1] == -1 and data[1][2] == -1:
	ans = 1
elif data[2][0] == -1 and data[2][1] == -1 and data[2][2] == -1:
	ans = 1
if data[0][0] == -1 and data[1][0] == -1 and data[2][0] == -1:
	ans = 1
elif data[0][1] == -1 and data[1][1] == -1 and data[2][1] == -1:
	ans = 1
elif data[0][2] == -1 and data[1][2] == -1 and data[2][2] == -1:
	ans = 1
elif data[0][0] == -1 and data[1][1] == -1 and data[2][2] == -1:
	ans = 1
elif data[0][2] == -1 and data[1][1] == -1 and data[2][0] == -1:
	ans = 1

if ans == 1:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 12448
#include<stdio.h>

int prime(int x){
int i;

if(x==2)
 return 1;
else if((x<2)||(x%2==0))
 return 0;
else{
 i=3;
while(i<=sqrt(x)){
if(x%i==0)
 return 0;
 i=i+2;
}
return 1;
}
}

int main(void){
int a[10000],n,k,q=0;
scanf("%d",&n);

for(k=0;k<n;k++){
scanf("%d",&a[k]);
}

for(k=0;k<n;k++){
q=q+prime(a[k]);
}

printf("%d\n",q);
}




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

using namespace std;

int main()
{
  int a, b, ans = 0, s, s2, l, l2;

  scanf("%d %d", &a, &b);

  for (int i = a; i <= b; i++)
  {
    l = i % 10;
    l2 = i / 10 % 10;
    s2 = i / 1000 % 10;
    s = i / 10000 % 10;

    if (s == l && s2 == l2)
    {
      ans++;
    }
  }

  printf("%d", ans);
}

Measured memory_bytes: 256
a,b,n=list(map(int,input().split()))
if a<n:
	n-=a
	a=0
	if b<n:
		n-=b
		b=0
	else:
		print(0,b-n)
		exit()
else:
	print(a-n,b)
	exit()
print(0,0)

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol sum{0};
    lol n; cin >> n;
    vector<lol> a(n+1, 0), b(200001, 0);
    REP(i, n)
    {
        cin >> a[i+1];
        b[a[i+1]]++;
    }
    FOR(i, 1, 200000)
    {
        if(b[i] != 0)
        {
            lol bn = b[i];
            sum += ((bn-1)*bn)/2;
        }
    }
    FOR(i, 1, n)
    {
        lol result;
        lol bn = b[a[i]];
        result = sum - ((bn-1)*bn)/2 + ((bn-1)*(bn-2))/2;
        cout << result << endl;
    }
    

    return 0;
}

Measured memory_bytes: 6408
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int numBlue = stdin.nextInt();
		Map<String, Integer> strCountMap = new HashMap<>();
		List<String> listBlue = new ArrayList<>();
		for (int i = 0; i < numBlue; i++) {
			String str = stdin.next();
			int count = strCountMap.getOrDefault(str, 0) + 1;
			strCountMap.put(str, count);
		}
		int numRed = stdin.nextInt();
		for (int i = 0; i < numRed; i++) {
			String str = stdin.next();
			int count = strCountMap.getOrDefault(str, 0) - 1;
			strCountMap.put(str, count);
		}

		int max = 0;
		for (int count : strCountMap.values()) {
			max = Math.max(max, count);
		}

		System.out.println(max);
	}

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll n,m,sum=0,ans=0,a;
    cin>>n>>m;
    map<ll,ll>mp;
    mp[0]=1;
    while(n--)
    {
        cin>>a;
        sum+=a;
        sum%=m;
        ans+=mp[sum]++;
    }
    cout<<ans<<endl;
    return 0;
}


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

int num1(int n){ //二進数表記した時の1の数をカウント
    int ans = 0;
    while(n > 0){
        if( n%2 == 1) ans ++;
        n = (n>>1);
    }
    return ans;
}

int main(){
    int N, M;
    cin >> N >> M;
    int A[M] = {0};
    int p[M];
    for(int i =0; i < M; i++){
        int k;
        cin >> k;
        for(int j =0; j < k; j++){
            int s;
            cin >> s;
            A[i] += (1<<(s-1));
        }
    }
    for(int i =0; i < M; i++){
        cin >> p[i];
    }                  //ここまでは準備,入力
    
    int ans =0;
    for(int i =0; i < (1<<N); i++){  //オンオフ全パターン探索
        int on = 0;
        for(int j =0; j < M; j++){  //オンオフがgivenで電球をそれぞれ調べる。
            int a = (A[j]&i); //aは反応するスイッチかつオンのものを表す。
            if(num1(a)%2 == p[j]) on++;
        }
        if(on == M) {
            ans ++;
            // bitset<2> h(i);
            // cout << h << endl;
        }
    }
    cout << ans << endl;
}

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

const int N = 1e5 + 5;
int n,c;

struct program {
    int time,type,c;
    bool operator < (const program& rhs) const{
        return time == rhs.time?type<rhs.type: time<rhs.time;
    }
};


program p[2*N];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>c;
    
    int s,t, c;
    for (int i = 0; i < n; i++){
        cin>>s>>t>>c;
        p[2*i].time = 2*s;
        p[2*i].type = 0;
        p[2*i].c = c;
        
        p[2*i+1].time = 2*t+1;
        p[2*i+1].type = 1;
        p[2*i+1].c = c;
    }
    
    sort(p, p+2*n);
    
    int cnt = 0, cnt_mx = 0;
    
    map<int,int> running;
    for (int i = 0; i < 2*n; i++){
        if(p[i].type == 0) {
            if(running.count(p[i].c) && running[p[i].c] > 0){
                running[p[i].c] ++;
                continue;
            }
            cnt++;
            cnt_mx = max(cnt_mx, cnt);
            running[p[i].c] = 1;
        }
        if(p[i].type == 1){
            running[p[i].c] --;
            if(running[p[i].c] == 0)cnt--;
        }
    }
    cout<<cnt_mx<<endl;
    
    return 0;
}



Measured memory_bytes: 2560
import heapq
N = int(input())
V = [int(_) for _ in input().split()]
heapq.heapify(V)

for n in range(N - 1):
    a = heapq.heappop(V)
    b = heapq.heappop(V)
    heapq.heappush(V, (a + b) / 2)
print(heapq.heappop(V))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    ll n,k;
    cin>>n>>k;

    if(n==0){
        cout<<0<<endl;
        return 0;
    }
    if(n<k){
        cout<<min(n,k-n)<<endl;
        return 0;
    }

    ll a=n%k;
    cout<<min(a,k-a)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    int64_t ans;
    if(M/2<=N) ans=M/2;
    else{
        ans=N;
        ans+=(M-2*N)/4;
    }

    cout<<ans<<endl;
}

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

# print(N)
# print(int(N**0.5))
# print('')
a=0
b=0
c=N+1


for i in range(1,int(N**0.5)+1):
    if N%i==0:
        a=i
        b=N/i
        # print(a)
        # print(b)
        c=min([c, a+b])
        # print(c)
        # print('')

c=int(c-2)
print(c)

Measured memory_bytes: 2940
#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 (void){
    int n;
    cin >> n;
    vector<ll> A(n);
    ll ans = 1;
    rep(i, n) {
        cin >> A.at(i);
        if (A.at(i) == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i, n) {
        if (A.at(i) > (LLONG_MAX) / ans) {
            ans = -1;
            break;
        }
        ans *= (ll)A.at(i);
        if (ans > 1000000000000000000) {
            ans = -1;
            break;
        }
    }

    cout << ans << endl;
    
}


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

int n;
long long dp[2][100005];
// int daddy[2][100005];

long long f(vector<vector<int>>& g, int parent, int node, int color) {
    if(dp[color][node] != -1) return dp[color][node];
    
    if(color) {
        long long ans = 1;
        for(int i = 0; i < g[node].size(); i++) {
            if(parent != g[node][i]) {
                ans *= f(g, node, g[node][i], 0);
                ans %= 1000000007;
            }
        }
        return dp[color][node] = ans%1000000007;
    }
    
    
    if(!color) {
        long long ans1 = 1, ans2 = 1;
        for(int i = 0; i < g[node].size(); i++) {
            if(g[node][i] != parent) {
                ans1 *= f(g, node, g[node][i], 0);
                ans1 %= 1000000007;
            }
            
            if(g[node][i] != parent) {
                ans2 *= f(g, node, g[node][i], 1);
                ans2 %= 1000000007;
            }
            
        }
        return dp[color][node] = (ans1 + ans2)%1000000007;
    }
}


int main() {
	// your code goes here
	cin >> n;
	vector<vector<int>> graph(n);
	
	int x, y;
	for(int i = 0; i < n-1; i++) {
	    cin >> x >> y;
	    graph[x-1].push_back(y-1);
	    graph[y-1].push_back(x-1);
	}
	memset(dp, -1, sizeof dp);
// 	memset(daddy, -1, sizeof daddy); // OwO daddy's size is too big !! OuO
	
	cout << f(graph, -1, 0, 0);
	
	return 0;
}

Measured memory_bytes: 15616
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int MOD = 1e+7;

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

  int zero = 0;
  int one  = 0;
  string s;
  cin >> s;

  rep(i, s.size()) {
    if(s[i] == '0') zero++;
    if(s[i] == '1') one++;
  }

  cout << min(zero, one) * 2 << endl;
  return 0;
}

Measured memory_bytes: 512
import itertools
def main():
    N, M = map(int, input().split())
    s = []
    for _ in range(M):
        t = tuple(map(int, input().split()))
        s.append(t)
    p = tuple(map(int, input().split()))
    a = 0
    for i in range(2**N):
        for j in range(M):
            x = 0
            for k in s[j][1:]:
                if i & (1 << (k-1)):
                    x += 1
            if x % 2 != p[j]:
                break
        else:
            a += 1
    return a
print(main())


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

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n;
    cin>>n;
    vi a(n);
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    map<int,int> c1 , c2;
    for(int i = 0 ; i< n ; i+= 2){
        c1[a[i]]++;
    }
    for(int i = 1 ; i< n; i+= 2){
        c2[a[i]]++;
    }
    int f1[2]; f1[0] = 0 , f1[1] = 0 ;
    int v1[2] = {0};
    for(auto i : c1){
        if(i.second > f1[0]){
            f1[1] = f1[0]; v1[1] = v1[0];
            f1[0] = i.second; v1[0] = i.first;
        }else if(i.second > f1[1]){
            f1[1] = i.second; v1[1] = i.first;
        }
    }
    int f2[2]; f2[0] = 0 , f2[1] = 0 ;
    int v2[2] = {0};
    for(auto i : c2){
        if(i.second > f2[0]){
            f2[1] = f2[0]; v2[1] = v2[0];
            f2[0] = i.second; v2[0] = i.first;
        }else if(i.second > f2[1]){
            f2[1] = i.second; v2[1] = i.first;
        }
    }
    if(v1[0] != v2[0]){
        cout<<(n / 2) - f1[0] + (n / 2) - f2[0] <<endl;
    }else {
        int m1 = (n / 2) - f1[1] + (n / 2) - f2[0];
        int m2 = (n / 2) - f1[0] + (n / 2) - f2[1];
        cout<<min(m1 , m2)<<endl;
    }

}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>    
#define pb push_back
 
#define FOR(x,to) for(int x=0;x<(to);x++)
#define F0R(x,in,to) for(int x=(in);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))
 
typedef long long ll;
using namespace std;
ll MOD = 1e9 + 7;
 
typedef pair<int,int> ii;
typedef struct {int a,b,c;}iii;
typedef vector<int> vi;
 
void mosA(vector<int> a){
	for(int i=0; i<a.size(); i++) printf("%d ",a[i]);
	printf("\n");
}
void mosP(vector<ii> a){
	for(int i=0; i<a.size(); i++) printf("%d %d\n",a[i].first,a[i].second);
	printf("\n");
}
 
ll min_especial(ll a, ll b){
  if(a!=-1 && b!=-1) return min(a,b);
  else return max(a,b);
}
/*
bool ord(ii a, ii b){
	if(a.first == b.first){
		return a.second < b.second;
	}
	return a.first < b.first;
}*/
 
bool ord(ll a, ll b){
	return a>b;
}
 
ll ans = 0;
int a,n,w,t,k,m,z,q,l,r,x,b,c,y;
char S[300005];
vi G[300005];
ii A[300005];
ii B[300005];
 
vector<iii> v;
 
int main(){
	scanf("%s",S);
 	int as = 0, n =strlen(S);
    FOR(i,n){
        
      if(i<n-1 && S[i]=='B' && S[i+1]=='C'){ i++;ans+=as;continue;}
      if(S[i]=='A') as++;
      else as = 0;
    }
  printf("%lld",ans);
}
 
 
 
 
// REVISATE ESTO:
// - memset(A,-1,SIZEOF()*n)
// - (x-y+MOD)%MOD
// - int o ll?

Measured memory_bytes: 8064
import java.util.*;

public class Main {

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			HashMap<Character, Character> map = new HashMap<Character, Character>();
			for(int i = 0; i < n; i++){
				char c = sc.next().charAt(0);
				char d = sc.next().charAt(0);
				map.put(c, d);
			}
			int m = sc.nextInt();
			while(m-- > 0){
				char c = sc.next().charAt(0);
				if(map.containsKey(c)){
					System.out.print(map.get(c));
				}
				else{
					System.out.print(c);
				}
			}
			System.out.println();
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 70384
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int a[100],t;
  string s;
  cin>>s>>t;
  char b[100];
  a[0]=s[0]-'0';
  r(i,s.size()/2)a[i+1]=s[(i+1)*2]-'0';
  r(i,s.size()/2)b[i]=s[i*2+1];
  int p1=a[0],p2=0;
  r(i,s.size()/2)
    if(b[i]=='*')p1*=a[i+1];
    else p1+=a[i+1];
  r(i,s.size()/2)if(b[i]=='*')a[i+1]=a[i]*a[i+1],a[i]=0;
  r(i,s.size()/2+1)p2+=a[i];
  if(t==p1&&t==p2)cout<<'U'<<endl;
  else if(t!=p1&&t!=p2)cout<<'I'<<endl;
  else if(t!=p1&&t==p2)cout<<'M'<<endl;
  else cout<<'L'<<endl;
}

Measured memory_bytes: 3212
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				sc.close();
				break;
			}

			boolean[][] sche = new boolean[n][31];
			for (int i = 0; i < n; i++) {
				int days = sc.nextInt();
				for (int j = 0; j < days; j++) {
					int d = sc.nextInt();
					sche[i][d] = true;
				}
			}

			ArrayList<Integer>[][] dp = new ArrayList[n][31];
			adjust: for (int day = 1; day < dp[0].length; day++) {
				for (int child = 0; child < dp.length; child++) {
					if (sche[child][day]) {
						if (day == 1) {
							// 1日目ならとりあえず新しく作る
							dp[child][day] = new ArrayList<Integer>();
							dp[child][day].add(child);
						} else {
							for (int past = day - 1; past >= 1; past--) {
								// 前に地図をゲットしてたら引き継ぐ
								if (sche[child][past]) {
									dp[child][day] = new ArrayList<Integer>(
											dp[child][past]);
									break;
								}

								// 前にゲットしてなかったら新しく作る
								if (past == 1) {
									dp[child][day] = new ArrayList<Integer>();
									dp[child][day].add(child);
								}
							}
						}
					}
				}

				for (int child = 0; child < dp.length; child++) {
					if (sche[child][day]) {
						for (int person = 0; person < sche.length; person++) {
							// 集まれる人から地図をもらう
							if (sche[person][day]) {
								for (int map : dp[person][day]) {
									if (!dp[child][day].contains(map)) {
										dp[child][day].add(map);
									}
								}
							}
						}
						if (dp[child][day].size() == n) {
							System.out.println(day);
							break adjust;
						}
					}
				}
				if (day == dp[0].length - 1) {
					System.out.println(-1);
				}
			}

		}
	}
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000003;
    auto modpow = [&MOD](auto a, auto b, auto n) -> decltype(b){
        a %= MOD;
        while(n){
            if(n & 1)(a *= b) %= MOD;
            (b *= b) %= MOD;
            n >>= 1;
        }
        return a;
    };
    vector<unsigned long> fr(MOD, 1), inv(MOD, 1), ifr(MOD, 1);
    iota(fr.begin() + 1, fr.end(), 1UL);
    partial_sum(fr.begin(), fr.end(), fr.begin(), [&MOD](auto a, auto b){return a * b % MOD;});
    ifr.back() = modpow(1, fr.back(), MOD - 2);
    for(unsigned long i = MOD - 1; i > 0; --i)ifr[i - 1] = ifr[i] * i % MOD;
    for(unsigned long i = 1; i < MOD; ++i)inv[i] = ifr[i] * fr[i - 1] % MOD;
    unsigned long Q;
    cin >> Q;
    for(unsigned long iter = 0, x, d, n; iter < Q; ++iter){
        cin >> x >> d >> n;
        auto beg = (inv[d] * x + MOD - 1) % MOD;
        cout << (d ? beg + n >= MOD ? 0 : modpow(fr[beg + n] * ifr[beg], d, n) : modpow(1UL, x, n)) << endl;
    }
    return 0;
}

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

class Program
{

    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var inputs = Console.ReadLine().Split(' ');
        var L = new int[N];
        var maxIndex = 0;
        var max = 0;
        for (int i = 0; i < N; i++)
        {
            L[i] = int.Parse(inputs[i]);
            if (max < L[i])
            {
                maxIndex = i;
                max = L[i];
            }
        }

        var sum = 0;
        for (int i = 0; i < N; i++)
        {
            if (i == maxIndex)
            {
                continue;
            }

            sum += L[i];
        }

        string result = max < sum ? "Yes" : "No";
        Console.WriteLine(result);

    }
}



Measured memory_bytes: 13140
#!/usr/bin/env python3
import sys


def solve(N: str):
    if N[-1]=="3":
        print("bon")
    elif N[-1]=="0" or N[-1]=="1" or N[-1]=="6" or N[-1]=="8":
        print("pon")
    else:
        print("hon")
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = str(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9064
#include <iostream>
using namespace std;
int S[100005];
int p[100005];

int isPrime( int d )
{
  if( d < 2 ) return 0;
  if( d == 2 ) return 1;
  if( d == 3 ) return 1;
  if( d % 2 == 0 ) return 0;
  for( int i=3; i*i<=d; i+=2 ){
    if( d % i == 0 ) return 0;
  }
  return 1;
}

int main( void )
{
  ios::sync_with_stdio(false);
  int Q, l, r;
  p[2] = 1;
  for( int i=1; i<=100000; i++ ){
    if( i % 2 == 0 ){
      S[i] = S[i-1];
      continue;
    }
    int a = isPrime( i );
    p[i] = a;
    if( p[i] && p[(i+1)/2] ){
      S[i] = S[i-1] + 1;
    } else {
      S[i] = S[i-1];
    }
  }
  cin >> Q;
  for( int i=0; i<Q; i++ ){
    cin >> l >> r;
    cout << S[r] - S[l-1] << '\n';
  }
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <functional>
using namespace std;
vector<long long> code(24, 0);

vector<long long> a(0, 0);
vector<long long> b(0, 0);


int main() {

	string S;
	cin >> S;

	for (char i = 'a'; i <= 'z'; i++)
	{
		if (S.find(i) == -1) {
			cout << i << endl;
			return 0;
		}
	}

	cout << "None" << endl;

	return 0;
}

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

int main(){

  ll N=0;
  ll K=0;

  cin>>N>>K;
  
  int H[N];
  
  rep(i,N){

    cin>>H[i];

  }
  
  sort(H,H+N,greater<int>());
  
  if(K>=N)cout<<0;
  else{
	ll sum=0;
    adrep(i,K,N){
		sum+=H[i];
    }
  
    cout<<sum;
  }
  
  
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

int comb(int a,int num){
    if(num == 1){
        return 1;
    }
    else{
        int count = 0;
        for(int i = 0; i <= min(a,9); i++){
            if(a - i <= 9*(num-1)) count = count + comb(a-i, num-1);
        }
        return count;
    }

}

int main(){
    int n,k;
    while(cin >> n){
        cout << comb(n,4) << endl;
    }

}

Measured memory_bytes: 3068
from collections import Counter
from itertools import accumulate
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,*A = map(int, read().split())

    B = [0] + list(accumulate(A))
    t = Counter(B)
    
    ans = 0
    for v in t.values():
        ans += v * (v-1) // 2

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 42000
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    bool enable = false;
    for (size_t i = 0; i <= n; i += 7) {
        if (n == i) {
            enable = true;
            break;
        }
        for (size_t j = 0; j <= n - i; j += 4) {
            if (n - i == j) {
                enable = true;
                break;
            }
        }
        if (enable) break;
    }
    cout << (enable ? "Yes" : "No") << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<string>
#include<sstream>
using namespace std;int main(){int m,n,i;set<int> p;set<int>::iterator q;string s;stringstream t;while(cin>>m>>n,m|n){p.clear();for(i=1;i<=m;i++)p.insert(i);q=p.begin();for(i=1;i<=n;i++){cin>>s;if(p.size()==1)continue;t.str("");if(i%3&&i%5){t<<i;}else{if(!(i%3))t<<"Fizz";if(!(i%5))t<<"Buzz";}if(s!=t.str())p.erase(q++);else q++;if(q==p.end())q=p.begin();}for(q=p.begin();q!=p.end();q++){if(q!=p.begin())cout<<" ";cout<<*q;}cout<<endl;}}

Measured memory_bytes: 972
#include <stdio.h>
#define MAX 100000000
#define noParent -1

struct Node{
	int id, l, r;
};

struct Node box[MAX];

void preParse(int u){
	if ( u == noParent ) return;
	printf(" %d", u);
	preParse(box[u].l);
	preParse(box[u].r);
}

void inParse(int u){
	if ( u == noParent ) return;
	inParse(box[u].l);
	printf(" %d", u);
	inParse(box[u].r);
}

void postParse(int u){
	if ( u == noParent ) return;
	postParse(box[u].l);
	postParse(box[u].r);
	printf(" %d", u);
}

int main () {
	int i,n,id,left,right,root;
	
	scanf("%d",&n);
	for(i=0;i<n;i++) {
		box[i].id = noParent;
	}
	
	for(i=0;i<n;i++) {
		scanf("%d %d %d",&id,&left,&right);
		box[id].l = left;
		box[id].r = right;
		if ( left != noParent ) box[left].id = id;
		if ( right != noParent ) box[right].id = id;
	}
	
	for ( i = 0; i < n; i++ ) {
		if ( box[i].id == noParent ) root = i;
	}
	
	for (i = 0;i < n; i++)  if ( box[id].id == noParent ) root = i;
	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");

	return 0;
}













Measured memory_bytes: 2072
def readInts():
 return list(map(int, input().split()))

def main():
  a = input()
  a =a.split(" ")
  x = int(a[0])
  n = int(a[1])
  if n == 0:
    print(x)
    return
    
  p = readInts()
  i= x 
  j = x + 1
  
  while i  in p:
    i -=1
    
  while j  in p:
    j += 1
 
  if abs(x-i) <= abs(x-j):
    print(i)
  else:
    print(j)
  
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 9200
def main():
    import math
    import sys

    input = sys.stdin.readline

    n = int(input())
    c_1 = 0

    for i in range(n):
        for j in range(n):
            for k in range(n):
                c_1 += math.gcd(math.gcd(i+1,j+1),k+1)

    print(c_1)

if __name__ ==  "__main__":
    main()

Measured memory_bytes: 67868
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main() {
    int n,ans=0, n_max=0; char c;
    cin>>n;
    rep(i,n){
        cin>>c;
        if(c=='I'){
            n_max++;
        }else{
            n_max--;
        }
        ans = max(ans,n_max);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  string A, B;
  cin >> A >> B;
  int X = A.size();
  int Y = B.size();
  int co = 0;
  if(X > Y) {
    cout << "GREATER" << endl;
  }
  else if(X < Y) {
    cout << "LESS" << endl;
  }
  else {
    rep(i, X) {
      if(A.at(i) > B.at(i)) {
        cout << "GREATER" << endl;
        break;
      }
      else if(A.at(i) < B.at(i)) {
        cout << "LESS" << endl;
        break;
      }
      else {
        co++;
      }
    }
  }
  if(co == X) {
    cout << "EQUAL" << endl;
  }
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n,m;cin>>n>>m;

    if(n==m)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt();
        long sum = 0;
        for(int a=1; a<=k; a++) {
            for(int b=1; b<=k; b++) {
                int b2 = gcd(a, b);
                for(int c=1; c<=k; c++) {
                    sum += gcd(b2, c);
                }
            }
        }
        System.out.println(sum);
    }
    private static int gcd(int a, int b) {
        if(a==b) {
            return a;
        }
        if(b>a) {
            // swap
            int s = a;
            a = b;
            b = s;
        }
        while(true) {
            int mod = a % b;
            if(mod==0) {
                return b;
            }
            a = b;
            b = mod;
        }
    }
}


Measured memory_bytes: 35788