akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pii x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<cd> vcd;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pii>> vvpii;
typedef vector<vector<pll>> vvpll;
typedef unordered_map<int, int, int_hash> umpii;
typedef unordered_map<ll, ll, int_hash> umpll;
typedef unordered_set<int, int_hash> usi;
typedef unordered_set<ll, int_hash> usll;
typedef unordered_set<pii, pair_hash> uspii;
typedef queue<int> qi;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = numeric_limits<int>::max();
const int MX = 100001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s; cin >> s;
    vi occ(3, 0);
    for(char c : s) occ[c - 'a']++;
    cout << (*max_element(all(occ)) - *min_element(all(occ)) < 2 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000003

ll modpow(ll a, ll n, ll m){
  ll tmp = a, val = 1;
  while(n){
    if(n % 2) val = val * tmp % m;
    tmp = tmp * tmp % m;
    n >>= 1;
  }
  return val;
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
  ll Q;
  cin >> Q;
  ll x[Q], d[Q], n[Q];
  rep(i, Q) scanf("%lld %lld %lld", x+i, d+i, n+i);

  vector<ll> fact(1, 1);
  rep(i, 2*MOD) fact.push_back(fact[i] * (i + 1) % MOD);

  rep(i, Q){
    ll ans;
    if(d[i] == 0){
      ans = modpow(x[i], n[i], MOD);
    }
    else{
      ll xdinv = x[i] * modinv(d[i], MOD) % MOD;
      if((xdinv + n[i]) > MOD){
        ans = 0;
      }
      else{
        ans = modpow(d[i], n[i], MOD) * fact[xdinv+n[i]-1] * modinv(fact[xdinv-1], MOD) % MOD;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 20840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 1e18;
constexpr ll MOD = 998244353;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    if(vec.at(N - 1) - vec.at(0) >= 2) {
        cout << "No" << endl;
    }
    else if(vec.at(N - 1) == vec.at(0)) {
        if(2 * vec.at(0) <= N || vec.at(0) == N - 1) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else {
        int cnt = 0;
        for(int i = 0;i < N;i++) {
            if(vec.at(i) == vec.at(0)) {
                cnt++;
            }
        }
        if(cnt <= vec.at(0) && 2 * (vec.at(N - 1) - cnt) <= N - cnt) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}

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

int main(void)
{
    int i,flag=0,af=0,bf=0;
    char s[4],a,b=0;
    cin >> s;
    a = s[0];
    for(i=0;i<4;i++){
        if(s[i]!=a){
            b = s[i];
        }
    }
    for(i=0;i<4;i++){
        if(s[i]!=a) af++;
        if(s[i]!=b) bf++;
    }
    
    if(af==2 && bf==2) cout << "Yes";
    else cout << "No";

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0;i < n;i++){
    cin >> a[i];
  }
  vector<int> r(n);
  for (int i = 0;i < n;i++){
    r[a[i]-1] = i+1;
  }
  for (int i = 0;i < n;i++){
    cout << r[i] << endl;
  }
}

Measured memory_bytes: 3896
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i--)
#define db double
#define ld long db
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=405;
const int mod=1e9+7;
int n,c,l[N],r[N],power[N][N],su[N][N],f[N][N];
signed main(){
	//freopen("a","r",stdin);
	n=read(),c=read();rep(i,1,n)l[i]=read();rep(i,1,n)r[i]=read();
	rep(i,1,400){power[i][0]=1;rep(j,1,c)power[i][j]=1ll*power[i][j-1]*i%mod;}
	rep(i,0,c)rep(j,1,400)su[i][j]=(su[i][j-1]+power[j][i])%mod;
	f[0][0]=1;
	rep(i,0,n-1)rep(j,0,c)if(f[i][j])rep(k,0,c-j)f[i+1][j+k]=(f[i+1][j+k]+1ll*(su[k][r[i+1]]-su[k][l[i+1]-1]+mod)%mod*f[i][j]%mod)%mod;
	return cout<<f[n][c],signed();
}

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

using namespace std;

#define L long long int
#define in(x) L x; cin>>x;
#define vi vector<L>
#define pb push_back
#define re(i,n) for(L i=0; i<n; i++) 
#define mp make_pair
#define pi(v) vector<pair<L,L>> v;
#define bi begin();3

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

double gcd(double a, double b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, double(int(a) % int(b)));  
      
}

L power(L b,L e,L m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    in(n);
    L z=0,ans=-1;
    re(i,n)
    {
        in(x);in(y);
        if(x==y){
            z++;
            if(z>=3)
                ans=1;
        }
        else
            z=0;
    }
    if(ans==-1)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int N,C;
int D[30][30];
int table[500][500];
int COST[3][30];


int main(){

	scanf("%d %d",&N,&C);

	for(int from = 0; from < C; from++){
		for(int to = 0; to < C; to++){

			scanf("%d",&D[from][to]);
		}
	}

	for(int row = 0; row < N; row++){
		for(int col = 0; col < N; col++){

			scanf("%d",&table[row][col]);
			table[row][col]--;
		}
	}

	for(int i = 0; i <= 2; i++){//剰余
		for(int to_C = 0; to_C < C; to_C++){ //新しい色

			int tmp = 0;

			for(int row = 0; row < N; row++){
				for(int col = 0; col < N; col++){
					if((row+col)%3 != i)continue;

					tmp += D[table[row][col]][to_C];
				}
			}
			COST[i][to_C] = tmp;
			//printf("COST[%d][%d]:%d\n",i,to_C,tmp);
		}
	}

	int ans = BIG_NUM;

	if(N == 1){

		for(int a = 0; a < C; a++){
			ans = min(ans,COST[0][a]);
		}

	}else{

		for(int a = 0; a < C; a++){
			for(int b = 0; b < C; b++){
				if(a == b)continue;
				for(int c = 0; c < C; c++){
					if(c == a || c == b)continue;

					ans = min(ans,COST[0][a]+COST[1][b]+COST[2][c]);
				}
			}
		}
	}

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

	return 0;
}


Measured memory_bytes: 4688
#include<iostream>
#include<string>
#include<set>
#include<cmath>
#include<cctype>
#include<vector>
#include<sstream>

using namespace std;

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

  int num = stoi(s);
  int count = 0;
  for(int i = 0; i < s.size(); i++){
    int a = s[i] - '0';
    count += a;
  }

  if(num % count == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


  return 0;
}



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

int D; double E,ans;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    while(cin >> D >> E,D){
        ans=110;
        for (int x=0;x<=D;++x){
            ans=min(ans,abs(sqrt(x*x+(D-x)*(D-x))-E));
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3308
s = input()

#s = list(s)

mae = int(s[:2])
usi = int(s[2:])
#print(mae,usi)


if(mae >= 1 and mae <= 12 and usi >= 1 and usi <= 12):
  print("AMBIGUOUS")
elif(usi >= 1 and usi <= 12):
  print("YYMM")
elif(mae >= 1 and mae <= 12):
  print("MMYY")
else:
  print("NA")


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
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; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
static const int mod = 1e9+7;
static const long long INF = 1LL << 60;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<int> dp(n+1);
    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        dp[i] = 1 + dp[i-1];
        int pow6 = 1;
        while(pow6*6 <= i){
            pow6 *= 6;
            dp[i] = min(dp[i], 1+dp[i-pow6]);
        }
        int pow9 = 1;
        while (pow9 * 9 <= i)
        {
            pow9 *= 9;
            dp[i] = min(dp[i], 1+dp[i-pow9]);
        }
    }   
    cout << dp[n] << endl;
}


Measured memory_bytes: 640
/* ex 9_2
   KKOO */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SIZE 100001

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void){
    char decoy, cube[SIZE];
    int num, count=0;
    //最初のノードの指す先
    node *first = NULL;

    scanf("%s", cube);
    num = strlen(cube);

    for(int i=0; i<num; i++){
        //追加しようとしている要素が先頭の要素と同じであればスタックにノードを追加
        if(first == NULL || first->elem == cube[i]){
            push(&first, cube[i]);
        }
        //追加しようとしている要素が先頭の要素と異なっていればスタックの先頭ノードを取り出す
        else if(first->elem != cube[i]){
            decoy = pop(&first);
            count += 2;
        }
    }

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

    return 0;
}


Measured memory_bytes: 4952
import math
n,d = map(int,input().split())
x = [list(map(int,input().split())) for N in range(n)]
cnt = 0
for i in range(n):
    for j in range(i + 1,n):
        alls = 0
        a = x[i]
        b = x[j]
        for D in range(d):
            alls += (a[D] - b[D]) ** 2
        if math.sqrt(alls) % 1 == 0:
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int n, m;
        n = int.Parse(s[0]);
        m = int.Parse(s[1]);
        Graph g = new Graph(n);
        for (int i = 0; i < m; i++)
        {
            s = Console.ReadLine().Split(' ');
            int l, r, d;
            l = int.Parse(s[0]);
            r = int.Parse(s[1]);
            d = int.Parse(s[2]);
            g.SetEdge(l, r, d);
            g.SetEdge(r, l, -d);
        }
        for (int i = 1; i <= n; i++)
            g.DFS(i);
        Console.WriteLine("Yes");
    }
}
class Node
{
    public int id;
    public bool IsVisited { get; set; }
    public List<Node> parent = new List<Node>();
    public List<Edge> edge = new List<Edge>();
    public Node(int id) { this.id = id; }
    public long value = 11451419194545810;
}
class Edge
{
    public int Length { get; set; }
    public Node S;
    public Node G;
    public Edge(Node S, Node G, int l)
    {
        this.Length = l;
        this.S = S;
        this.G = G;
    }
}
class Graph
{
    public Node[] node;
    public Graph(int n)
    {
        node = new Node[n];
        for (int i = 0; i < n; i++)
            node[i] = new Node(i + 1);
    }
    public void SetEdge(int n1, int n2, int l)
    {
        if (n1 > node.Length || n1 <= 0 || n2 > node.Length || n2 <= 0)
            return;
        Edge e = new Edge(node[n1 - 1], node[n2 - 1], l);
        node[n1 - 1].edge.Add(e);
        node[n2 - 1].parent.Add(node[n1 - 1]);
    }
    public void DFS(int r)
    {
        if (r > node.Length || r <= 0)
            return;
        if (node[r - 1].IsVisited)
            return;

        if (node[r - 1].value == 11451419194545810)
            node[r - 1].value = 0;
        foreach (var e in node[r - 1].edge)
        {
            if (e.G.value != node[r - 1].value + e.Length && e.G.value != 11451419194545810)
            {
                Console.WriteLine("No");
                Environment.Exit(0);
            }
            e.G.value = node[r - 1].value + e.Length;
        }

        node[r - 1].IsVisited = true;
        for (int i = 0; i < node[r - 1].edge.Count; i++)
            if (!node[r - 1].edge[i].G.IsVisited)
                DFS(node[r - 1].edge[i].G.id);
    }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

int main()
{
  int gyou, retu, masu, ancer;
  
  cin >> gyou >> retu >> masu;
  
  if(gyou > retu)
  {
    if(masu % gyou == 0)
      ancer = masu / gyou;
    else
      ancer = masu / gyou + 1;
  }
  
  else if(retu > gyou)
  {
    if(masu % retu == 0)
      ancer = masu / retu;
    else
      ancer = masu / retu + 1;
  }
  
  else
  {
    if(masu % retu == 0)
      ancer = masu / retu;
    else
      ancer = masu / retu + 1;
  }
  
  cout << ancer << endl;
  
}

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

int main() {
	int n;
	cin >> n;
	vector<long long> arr(n);
	unordered_map<long long, long long> cnt;
	for (int i=0; i<n; i++) {
		cin >> arr[i];
		cnt[arr[i]]++;
	}
	long long sm = accumulate(arr.begin(), arr.end(), 0LL);
	int q;
	cin >> q;
	while (q--) {
		long long b, c;
		cin >> b >> c;
		sm -= cnt[b] * b;
		sm += cnt[b] * c;
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout << sm << endl;
	}
}


Measured memory_bytes: 7844
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
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 H,W;
    int h,w;
    cin >> H >> W;
    cin >> h >> w;
    PRINTD(H*W - (h*W + H*w) + h*w);
}






Measured memory_bytes: 256
function Main(input){
    input = input.split("\n");
    var l = 0;
    var dp = new Array(20001);
    for(var i = 0;i <= 20000;i++)
        dp[i] = new Array(256);
    while(1){
        input[l] = input[l].split(" ");
        var n = parseInt(input[l][0],10);
        var m = parseInt(input[l++][1],10);
        if(n == 0 && m == 0)
            break;

        var c = [],x = [];

        for(var i = 1;i <= m;i++)
            c[i] = parseInt(input[l++],10);

        for(var i = 1;i <= n;i++)
            x[i] = parseInt(input[l++],10);
        for(var i = 0;i <= 20000;i++)
            for(var j = 0;j < 256;j++)
                dp[i][j] = 1000000000000;
        dp[0][128] = 0;

        for(var i = 0;i < n;i++){
            for(var j = 0;j < 256;j++){
                for(var k = 1;k <= m;k++){
                    var a = j + c[k];
                    if(a < 0)
                        a = 0;
                    if(a > 255)
                        a = 255;
                    var b = dp[i][j] + (a - x[i + 1]) * (a - x[i + 1]);
                    if(dp[i + 1][a] > b)
                        dp[i + 1][a] = b;
                }
            }
        }

        var min = 1000000000000;

        for(var i = 0;i < 256;i++)
            if(min > dp[n][i])
                min = dp[n][i];

        console.log(min);
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 108644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
  ll N;
  cin >> N;
  vector<ll> X(N), Y(N);
  vector<char> U(N);
  map<ll, map<ll, char>> yzahyou;
  map<ll, map<ll, char>> xzahyou;
  map<ll, map<ll, char>> wa;
  map<ll, map<ll, char>> sa;
  rep(i, N){
    cin >> X.at(i) >> Y.at(i) >> U.at(i);
    yzahyou[Y.at(i)][X.at(i)] = U.at(i);
    xzahyou[X.at(i)][Y.at(i)] = U.at(i);
    wa[X.at(i) + Y.at(i)][Y.at(i)] = U.at(i);
    sa[X.at(i) - Y.at(i)][Y.at(i)] = U.at(i);
  }
  bool safe = true;
  ll time = INF;
  for(auto a : yzahyou){
    char pd = 'X';
    ll pp = 0;
    for(auto b : a.second){
      if(pd == 'R' && b.second == 'L'){
        chmin(time, (b.first - pp)*5);
        safe = false;
      }
      pd = b.second;
      pp = b.first;
    }
  }
  for(auto a : xzahyou){
    char pd = 'X';
    ll pp = 0;
    for(auto b : a.second){
      if(pd == 'U' && b.second == 'D'){
        chmin(time, (b.first - pp)*5);
        safe = false;
      }
      pd = b.second;
      pp = b.first;
    }
  }
  for(auto a : wa){
    char pd = 'X';
    ll pp = 0;
    for(auto b : a.second){
      if(pd == 'U' && b.second == 'R'){
        chmin(time, (b.first-pp)*10);
        safe = false;
      }
      if(pd == 'L' && b.second == 'D'){
        chmin(time, (b.first-pp)*10);
        safe = false;
      }
      pd = b.second;
      pp = b.first;
    }
  }
  for(auto a : sa){
    char pd = 'X';
    ll pp = 0;
    for(auto b : a.second){
      if(pd == 'U' && b.second == 'L'){
        chmin(time, (b.first-pp)*10);
        safe = false;
      }
      if(pd == 'R' && b.second == 'D'){
        chmin(time, (b.first-pp)*10);
        safe = false;
      }
      pd = b.second;
      pp = b.first;
    }
  }
  if(safe){
    cout << "SAFE" << endl;
  }
  else{
    cout << time << endl;
  }
}

Measured memory_bytes: 124120
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//s[i]-'0'で文字→数に;


int main() {
  int x;
  cin >> x;
  string s = to_string(x);
  int n = s.size();
  
  
  int sum = 0;
  rep(i,n) {
  sum+=s[i]-'0';
  }
  
  cout << (x%sum==0?"Yes":"No") << endl;

}

Measured memory_bytes: 256
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  r = InputLine.to_f

  puts (2 * r * Math::PI).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL a, b, c;
    cin >> a >> b >> c;
    LL l = 4 * a * b;
    LL r = c - (a + b);

    if(r >= 0) {
        if(l < r * r) cout << "Yes";
        else cout << "No";
    } else {
        cout << "No";
    }
    cout << endl;

    return 0;
}


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

bool isPrime(int n);

int main(void){
    
    int n, cnt = 0;
    
    while(cin >> n)
    {
        if(isPrime(n))
        {
            cnt++;
        }
    }
    
    cout << cnt << endl;
}

bool isPrime(int n)
{
    for(int i=2; i <= sqrt(n); i++)
    {
        if(n % i == 0)
        {
            return false;
        }
    }
    
    return true;
}


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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  long long x,y;

  cin>>x>>y;

  if(x<0&&y<0){
    if(x<y){
      cout<<labs(x)-labs(y)<<endl;
    }else{
      cout<<max(labs(x),labs(y))-min(labs(x),labs(y))+2<<endl;
    }
  }
  else if(x>=0&&y<0){
    cout<<max(labs(x),labs(y))-min(labs(x),labs(y))+1<<endl;
  }else if(x<0&&y>0){
   cout<<max(labs(x),labs(y))-min(labs(x),labs(y))+1<<endl;
  }else if(x>y){
    if(y==0){
      cout<<labs(x)+1<<endl;
    }else{
      cout<<max(labs(x),labs(y))-min(labs(x),labs(y))+2<<endl;
    }
  }else if(x<0&&y<0){
    cout<<labs(y)-labs(x)<<endl;
  }else{
    if(y==0){
      cout<<labs(x)<<endl;
    }else{
      cout<<labs(y)-labs(x)<<endl;
    }
  }
    
  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
using namespace std;
long long n,x,y,mx[111],a,b;
pair<long long,long long> ans;
vector<long long> g[111];
void dfs(long long i,long long fa,long long dep)
{
	long long s=0;
	for (long long j=0;j<g[i].size();j++)
	{
		long long to=g[i][j];
		if (to==fa) continue;
		dfs(to,i,dep+1);
		s++;
	}
	mx[dep]=max(mx[dep],s);
}
int main()
{
	ans=make_pair(1e9,1e9);
	cin>>n;
	for (long long i=1;i<n;i++)
	{
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);  
	}
	for (long long i=1;i<=n;i++)
	{
		memset(mx,0,sizeof(mx));
		dfs(i,0,1);
		a=1;
		for (b=1;mx[b];b++)
		{
			a*=mx[b];
		}
		ans=min(ans,make_pair(b,a));
	}
	for (long long i=1;i<=n;i++)
	{
		for (long long j=0;j<g[i].size();j++)
		{
			memset(mx,0,sizeof(mx));
			dfs(i,g[i][j],1);
			dfs(g[i][j],i,1);
			a=2;
			for (b=1;mx[b];b++)
			{
				a*=mx[b];
			}
			ans=min(ans,make_pair(b,a));
		}
	}
	cout<<ans.first<<" "<<ans.second<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N;
    cin >> N;
    cout << (N-1)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    int N;
    std::vector<int> D;
    int M;
    std::vector<int> T;

    std::cin >> N;
    for (int i; i < N; i++) {
        int d;
        std::cin >> d;
        D.push_back(d);
    }

    std::cin >> M;
    for (int i = 0; i < M; i++) {
        int t;
        std::cin >> t;
        T.push_back(t);
    }

    std::sort(D.begin(), D.end());
    std::sort(T.begin(), T.end());

    int n = 0, m = 0;
    for (n = 0; n < N; n++) {
        if (D[n] == T[m]) {
            m++;
            if (m == M) {
                std::cout << "YES" << std::endl;
                return 0;
            }
        } else if (D[n] < T[m]) {
        } else {
            std::cout << "NO" << std::endl;
            return 0;
        }
    }

    std::cout << "NO" << std::endl;

    return 0;
}

Measured memory_bytes: 2548
(stdin => {
  // Define Function
  const sortArray = f => (...args) => args.sort(f)
  const ascendNumber = (a, b) => a - b
  // Declare Variable
  const inputs = stdin.toString().trim().split('\n')
  const [a, b, c] = Array.from(inputs[0].split(' '), Number)

  // display
  console.log(sortArray(ascendNumber)(a, b, c).join(' '))

})(require('fs').readFileSync('/dev/stdin', 'utf8'))



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

using namespace std;

int main(){
    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    bool ok = false;
    for(int i = a; i <= b; i++){
        if(i%n == 0) ok = true;
    }
    if(ok) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}


Measured memory_bytes: 3592
from fractions import gcd

def lcm(a, b):
    if a == 0 or b == 0:
        return 0
    return int(a * b // gcd(a, b))
  
def solve():
    n = int(input())
    tl = [int(input()) for _ in range(n)]
    ans = tl[0]
    for elem in tl[1:]:
        ans = lcm(ans, elem)
    print(ans)
 
if __name__=="__main__":
    solve()

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

#define null				""
#define all(dat)			dat.begin(), dat.end()
#define over(msg)			cout << msg << endl, exit(0);
#define loop(i, to)			for (int i = 0; i < to; ++i)
#define cont(i, to)			for (int i = 1; i <= to; ++i)
#define foreach(i, dat)		for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long			num;

using namespace std;

int mod = 1e9 + 7;

struct mat {
	int n, m;
	vector<vector<int>> w;
	mat() {}
	mat(int n, int m) {
		this->n = n;
		this->m = m;
		this->w.resize(n, vector<int>(m));
	}
	mat inline operator * (mat b) {
		mat res = mat(this->n, b.n);
		loop (i, this->n) {
			loop (j, b.m) {
				loop (k, b.n) {
					res.w[i][j] += (num) this->w[i][k] * b.w[k][j] % mod;
					if (res.w[i][j] >= mod) {
						res.w[i][j] -= mod;
					}
				}
			}
		}
		return res;
	}
};

int n, ans;
num k;
mat a, res;

void inline qpow(num p) {
	while (p) {
		if (p & 1) {
			res = res * a;
		}
		a = a * a;
		p >>= 1;
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	a = mat(n, n);
	res = mat(n, n);
	loop (i, n) {
		loop (j, n) {
			cin >> a.w[i][j];
		}
		res.w[i][i] = 1;
	}
	qpow(k);
	loop (i, n) {
		loop (j, n) {
			ans += res.w[i][j];
			if (ans >= mod) {
				ans -= mod;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  long long *h = (long long *)calloc(n, sizeof(long long));

  for(int i=0;i<n;i++){
    scanf("%d", h+i);
  }
  sort(h, h+n);

  long long buf = pow(10, 9);
  for(int i=0;i<n-(k-1);i++){
    if(buf>(h[i+k-1]-h[i]))buf = (h[i+k-1]-h[i]);
  }

  cout << buf << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

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

	vector<vector<lint>> a(H, vector<lint>(W));
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> a[i][j];

	vector<pair<int, int>> ans;
	for (int i = 0; i < H; i++) {
		if (i % 2 != 0) {
			for (int j = W - 1; j >= 0; j--) {
				if (a[i][j] % 2 == 1) {
					ans.emplace_back(i, j);
					if (j == 0) {
						if(i < H - 1){
							a[i + 1][j]++;
							ans.emplace_back(i + 1, j);
						}
					}
					else {
						a[i][j - 1]++;
						ans.emplace_back(i, j - 1);
					}
				}
			}
		}		
		else {
			for (int j = 0; j < W; j++) {
				if (a[i][j] % 2 == 1) {
					ans.emplace_back(i, j);
					if (j == W - 1) {
						if (i < H - 1) {
							a[i + 1][j]++;
							ans.emplace_back(i + 1, j);
						}
					}
					else {
						a[i][j + 1]++;
						ans.emplace_back(i, j + 1);
					}
				}
			}
		}
	}

	int N = (int)ans.size();
	cout << N / 2 << "\n";
	for (int i = 0; i < N - N % 2; i += 2) {

		cout << ans[i].first + 1 << " ";
		cout << ans[i].second + 1 << " ";
		cout << ans[i + 1].first + 1 << " ";
		cout << ans[i + 1].second + 1 << "\n";

	}

	return 0;
}




Measured memory_bytes: 6128
#include<bits/stdc++.h>
#include<bitset>
#define N 305
#define LL long long
using namespace std;
const int mo=1e9+7;
int n,m,f[N][N],pw[N*N],ans;
bitset<N> c,p[N];
LL fpm(LL x,LL y){ LL s=1; while(y){ if(y&1) s=(s*x)%mo; y>>=1,x=(x*x)%mo;} return s;}
int main()
{
	int i,j,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++)
			scanf("%d",&x),c[j]=x;
		for(j=1;j<=n;j++){
			if(c[j]==0) continue;
			if(p[j]==0){ p[j]=c,m++; break;}
			else c^=p[j];
		  }
	  }
	pw[0]=1;
	for(i=1;i<=n*n;i++)
		pw[i]=(pw[i-1]*2)%mo;
	f[0][0]=1;
	for(i=0;i<=n;i++)
		for(j=0;j<=i;j++){
			f[i+1][j+1]=(f[i+1][j+1]+1LL*(pw[n]-pw[j]+mo)*f[i][j])%mo;
			f[i+1][j]=(f[i+1][j]+1LL*pw[j]*f[i][j])%mo;
		  }
	for(i=m;i<=n;i++)
		ans=(ans+1LL*f[n][i]*pw[n*(n-i)]%mo*f[i][m])%mo;
	ans=1LL*ans*fpm(f[n][m],mo-2)%mo;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
N = int(input())
cnt = 0
st_cnt = 0
end_cnt =0
same_cnt =0

for k in range(N):
    s = input()
    cnt +=s.count("AB")

    if (s[0] =='B') & (s[-1]=='A'):
        same_cnt += 1
    elif (s[0] =='B'):
        st_cnt +=1
    elif (s[-1] == 'A'):
        end_cnt += 1
if same_cnt==0:
    print(cnt + same_cnt + min(st_cnt, end_cnt))
elif (st_cnt==0) and (end_cnt==0):
    print(cnt+same_cnt-1)
else:print(cnt+same_cnt+min(st_cnt,end_cnt))

Measured memory_bytes: 74800
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main(void)
{
  int i,is,ip;
  string s,p,sp,ans="No";

  cin >> s;
  cin >> p;

  ip = p.size();
  is = s.size();
  sp = s + s.substr(0,ip-1);

  for(i = 0; i <= is-1; i++){
    if(p == sp.substr(i,ip))
      ans="Yes";
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3204
import java.util.Scanner;

public class Main {

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

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[][] m = new int[n][n];
		for (int i = 0; i < n; i++) {
			int u = scanner.nextInt();
			int k = scanner.nextInt();
			u--;
			for (int j = 0; j < k; j++) {
				int v = scanner.nextInt();
				v--;
				m[u][v] = 1;
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				System.out.print(m[i][j]);
				System.out.print(j == n - 1 ? '\n' : ' ');
			}
		}

	}
}

Measured memory_bytes: 27948
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    
    minA = minB = float('inf')
    maxA = maxB = - float('inf')
    
    for i in range(N):
        x, y = MI()
        x2, y2 = x - y, x + y
        minA = min(minA, x2)
        maxA = max(maxA, x2)
        minB = min(minB, y2)
        maxB = max(maxB, y2)
    
    print(max(maxA - minA, maxB - minB))
        
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 74620
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  ll n ; cin>> n ;
  vector<ll> A(n) ; rep(i,n) cin>>A[i] ;
  map<ll,map<ll,ll>> mp ;
  rep(i,n){
    ll k= A[i] ;
    ll cnt = 0;
    while(k%2==0){
      k/=2 ;
      cnt++ ;
    }
    cnt-- ;
    mp[cnt][n-k]++ ; //大小逆に入れる
  }
  ll ans= 0;
  for( auto u : mp){
    ll plus=0 ;
    auto v= u.se ;
    for(auto t: v ){
      if(t.se<=0) continue ;
      ll x= n- (t.fi) ;
      ll base = 1ll ;
      while(base<= x){
        base*= 2 ;
      }
       if(x==1){
         plus = (t.se)/2 ;
       }
       else{
         plus = min(v[n-(base-x)],t.se) ;
       }
       ans+= plus ;
       v[n-(base-x)]-= plus ;
       
    }
  }
  cout<<ans<<endl ;
 return 0 ; 
}



Measured memory_bytes: 35880
import java.io.*;
import java.util.*;
import static java.lang.Math.min;
import static java.lang.Math.max;
public class Main {

    private static void solver(InputReader sc, PrintWriter out) throws Exception {
          long n = sc.nextLong();
          String ans = "";
          String arr[] = {"a","b","c","d","e","f","g","h", "i", "j", "k", "l", "m",
          "n", "o", "p", "q", "r", "s","t","u","v","w","x","y","z"};
          //out.println(arr.length);
          while(n > 0){
              long mod = n%26;mod--;
              if(mod < 0) {
                  mod = 25; n= n/26;
                  n--;
              }else n = n/26;
              ans += (arr[(int) mod]);
          }
          for(int i=ans.length()-1; i>=0; i--) out.print(ans.charAt(i));
    }

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}
class Pair implements Comparable<Pair>{
    int x,y;
    Pair(int x, int y){
        this.x = x;
        this.y = y;
    }
    public int compareTo(Pair p){
        return (int)(this.x - p.x);
    }
}
class Tuple{
    String s;
    int x, y;

    public Tuple(String s, int x, int y) {
        this.s = s;
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Tuple tuple = (Tuple) o;
        return x == tuple.x &&
                y == tuple.y &&
                s.equals(tuple.s);
    }

    @Override
    public int hashCode() {
        return Objects.hash(s, x, y);
    }
}

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

int N;
int B[100000];

int main() {
  cin >> N;
  rep(i,N-1) cin >> B[i];

  int cnt = B[0];
  cnt += B[N-2];
  rep(i,N-1) cnt += min(B[i],B[i+1]);
  cout << cnt << endl;
}

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


int main()
{
    int k ;
    cin >> k  ;
    ll ans =  0 ;
    for(int i = 1 ; i <= k ; ++i)
    {
        for(int j = 1 ; j <= k ; ++j)
        {
            int sum = __gcd(i,j);
            for(int l = 1 ; l <=  k ;++l)
            {
                int t = __gcd(sum, l) ;
                ans += t ;
            }
        }
    }
    cout << ans ;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;
int main(){
    int N,idx,prev_idx,ans=1;
    cin >> N;
    vector<int>P(N,0);
    vector<int>ref(N,0);
    for(int i=0;i<N;i++){
        cin>>P[i];
        ref[P[i]-1] = i;        
        }

    prev_idx = ref[0];
    for(int i=2;i<=N;i++){
        idx = ref[i-1];
        if(prev_idx>idx){
            ans +=1;
            prev_idx = idx;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void) {
    int water,charge;
    while (1) {
        scanf("%d",&water);
        if (water==-1) break;
        charge=1150;
        water-=10;
        if (water>0) {
            if (water<=10) {
                charge+=water*125;
            } else {
                charge+=10*125;
            }
            water-=10;
        }
        if (water>0) {
            if (water<=10) {
                charge+=water*140;
            } else {
                charge+=10*140;
            }
            water-=10;
        }
        if (water>0) charge+=water*160;
        printf("%d\n",4280-charge);
    }
    return 0;
}

Measured memory_bytes: 596
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,k,l,r,ans,i
    integer(int64),parameter:: md=1000000007

    read*, n,k

    l=0
    r=n
    ans=0
    do i=1,n+1
        if (i >= k) ans=mod(ans+(r+1-l),md)
        l=l+i
        r=r+(n-i)
    end do
    print*, ans
end program name

Measured memory_bytes: 2876
#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 <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)

int count(int N)
{

        int cnt = 0;
        while (N)
        {
                cnt += N % 10;
                N /= 10;
        }
        return cnt;
}

int main()
{
        int N, K;
        cin >> N >> K;
        vector<int> A(N + 1);
        rep(i, N)
        {
                int a;
                cin >> a;
                A[a - 1]++;
        }
        sort(all2(A, N));
        reverse(all2(A, N));
        int ans = 0;

        rep(i, K)
        {
                ans += A[i];
        }
        cout << N - ans << endl;

        return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector<pair<int, int>> x;
    for (int i = 0; i < n; i++) {
        if (i % 6 == 1) {
            for (int j = 0; j < n; j++) {
                if (j % 2 == 0) {
                    x.push_back({i, j});
                }
            }
        } else if (i % 6 == 4) {
            for (int j = 0; j < n; j++) {
                if (j % 2 == 1) {
                    x.push_back({i, j});
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if ((n-1 + i) % 2 == 1) {
            x.push_back({i, n-1});
            x.push_back({n-1, i});
        }
        if ((0 + i) % 2 == 1) {
            x.push_back({i, 0});
            x.push_back({0, i});
        }
    }
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    cout << x.size() << endl;
    for (int i = 0; i < x.size(); i++) {
        cout << x[i].first << " " << x[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 2928
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (A, B, C, D) = next().toList().map { it.toString().toInt() }
    val op = listOf('+', '-')
    for (op1 in 0..1) {
        val a = if (op1 == 0) A + B else A - B
        for (op2 in 0..1) {
            val b = if (op2 == 0) a + C else a - C
            for (op3 in 0..1) {
                val c = if (op3 == 0) b + D else b - D
                if (c == 7) {
                    println("$A${op[op1]}$B${op[op2]}$C${op[op3]}$D=7")
                    return
                }
            }
        }
    }
}

Measured memory_bytes: 38308
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  scanf("%d", &k);
  if (k == 1) return puts("1\n1"), 0;
  int n = (k / 4 + !!(k % 4)) << 1;
  printf("%d\n", n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      printf("%d ", (i + j) % n + 1 + ((i & 1) && (i + j) % n + n < k ? n : 0));
    }
    puts("");
  }
}


Measured memory_bytes: 1152
#include <stdio.h>

int main (){
	int i;
	for(i=1;i<10;i++){
		printf("%dx1=%d\n",i,i*1);
		printf("%dx2=%d\n",i,i*2);
		printf("%dx3=%d\n",i,i*3);
		printf("%dx4=%d\n",i,i*4);
		printf("%dx5=%d\n",i,i*5);
		printf("%dx6=%d\n",i,i*6);
		printf("%dx7=%d\n",i,i*7);
		printf("%dx8=%d\n",i,i*8);
		printf("%dx9=%d\n",i,i*9);
	}
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int n;
	cin >> n;
	vector <string> a(n);
	for (int i =0;i<n ; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int count = 1;
	for (int i =1; i < n; i++) {
		if (a[i] != a[i-1]) count++;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 7528
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	mod = 10^9+7
	n = readline() |> parseInt
	dp = zeros(Int,n,64)
	for i in 0:3
		for j in 0:3
			for k in 0:3
				if (i,j,k)!=(0,2,1) && (i,j,k)!=(0,1,2) && (i,j,k)!=(2,0,1)
					dp[3,16*i+4*j+k+1] = 1
				end
			end
		end
	end
	for z in 4:n
		for i in 0:3
			for j in 0:3
				for k in 0:3
					if (i,j,k)==(0,2,1) || (i,j,k)==(0,1,2) || (i,j,k)==(2,0,1)
						dp[z,16*i+4*j+k+1] = 0
					elseif (i,j)==(2,1)||(i,j)==(1,2)||(j,k)==(2,1)||(i,k)==(2,1)
						dp[z,16*i+4*j+k+1] = (dp[z-1,16+4*i+j+1] + dp[z-1,32+4*i+j+1] + dp[z-1,48+4*i+j+1])%mod
					elseif (i,j)==(0,1)
						dp[z,16*i+4*j+k+1] = (dp[z-1,4*i+j+1] + dp[z-1,16+4*i+j+1] + dp[z-1,48+4*i+j+1])%mod		
					else
						dp[z,16*i+4*j+k+1] = (dp[z-1,4*i+j+1] + dp[z-1,16+4*i+j+1] + dp[z-1,32+4*i+j+1] + dp[z-1,48+4*i+j+1])%mod
					end	
				end
			end
		end
	end
	println(sum(dp[n,:])%mod)
end

main()

Measured memory_bytes: 114952