akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<array>
#include<algorithm>

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

using namespace std;

int main()
{
    int n[4];

    rep(i, 4) cin >> n[i];

    int ch[4] = {0};
    rep(i, 4){
        switch(n[i]){
            case 1 : ch[0] = true; break;
            case 9 : ch[1] = true; break;
            case 7 : ch[2] = true; break;
            case 4 : ch[3] = true; break;
        }
    }
    if(ch[0] == true && ch[1] == true && ch[2] == true && ch[3] == true)
        cout << "YES";
    else
        cout << "NO";

    cout << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;

template<typename T> inline void getint(T &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int N, L[205], ans = 0;

int main(){
	getint(N), N <<= 1;
	for(register int i = 1; i <= N; i++) getint(L[i]);
	sort(L + 1, L + N + 1);
	for(register int i = 1; i <= N; i += 2) ans += L[i];
	return printf("%d\n", ans), 0;
}

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

using namespace std;

int main(){

  int D, N;
  int i = 100, ans = 0;
  
  cin >> D >> N;

  i = pow(i, D);

  if(N == 100){
    N++;
  }

  ans = i * N;

  cout << ans << "\n";
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n;
    char s[200001] = {};
    int memo[200001][2] = {};
    int countf, countb, result;
    int i;
    
    scanf("%d", &n);
    scanf("%s", s);
    
    countf = 0;
    for(i = 0; i <= n; i++){
        memo[i][0] = countf;
        if(s[i] == '#'){
            countf++;
        }
    }
    
    countb = 0;
    for(i = n; i >= 0; i--){
        if(s[i] == '.'){
            countb++;
        }
        memo[i][1] = countb;
    }
    
    result = 200001;
    for(i = 0; i <= n; i++){
        if(memo[i][0] + memo[i][1] < result){
            result = memo[i][0] + memo[i][1];
        }
    }
    
    printf("%d\n", result);
    
    return 0;
}

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

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; cin >> N;
  string S; cin >> S;

  int ans = 1;
  rep(i, 1, N) {
    if (S[i] == S[i-1])
      continue;
    ++ans;
  }
  out(ans);

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll x,y,z,k;

int main(){
	cin >> x >> y >> z >> k;
	vector<ll> a(x);
	vector<ll> b(y);
	vector<ll> c(z);
	rep(i,x)cin >> a[i];
	rep(i,y)cin >> b[i];
	rep(i,z)cin >> c[i];
	vector<ll> v;
	rep(i,x){
		rep(j,y){
			v.push_back(a[i]+b[j]);
		}
	}
	ll ic[2] = {},iv[2] = {};
	sort(ALL(c));
	reverse(ALL(c));
	sort(ALL(v));
	reverse(ALL(v));
	vector<ll> ans;
	rep(i,min((ll)v.size(),k)){
		rep(j,z){
			ans.push_back(v[i]+c[j]);
		}
	}
	sort(ALL(ans));
	reverse(ALL(ans));
	rep(i,k)cout << ans[i] << endl;
}

Measured memory_bytes: 43240
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    ll n, a, b; cin >> n >> a >> b;

    if (n == 1 && a == b) {
        cout << 1 << endl;
        return 0;
    }
    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }
    if (a > b) {
        cout << 0 << endl;
        return 0;
    }
    if (n == 2) {
        cout << a + b << endl;
        return 0;
    }
    n -= 2;
    ll base = a + b;
    ll minn = base + a*n;
    ll maxx = base + b*n;
    cout << maxx - minn + 1 << endl;
    return 0;
}


Measured memory_bytes: 3628
object Main {
  val judge = (ret: Boolean, ok: String, ng: String) => if (ret) println(ok) else println(ng)
  val canPay = (a: Int, n: Int) => if (n % 500 <= a) true else false

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n, a = sc.nextInt
    val ret = canPay(a,n)
    judge(ret, "Yes", "No")
  }
}


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

int N;
const int MAX_N = 1.0e5 + 100;
string S[MAX_N];

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

    ll MARCH[5] = {0, 0, 0, 0, 0};
    for (int i = 0; i < N; i++) {
        if (S[i][0] == 'M') MARCH[0]++;
        else if (S[i][0] == 'A') MARCH[1]++;
        else if (S[i][0] == 'R') MARCH[2]++;
        else if (S[i][0] == 'C') MARCH[3]++;
        else if (S[i][0] == 'H') MARCH[4]++;
    }
    
    ll ans = 0;
    for (int i = 0; i <= 2; i++) {
        for (int j = i+1; j <= 3; j++) {
            for (int k = j+1; k <= 4; k++) {
                ans += MARCH[i] * MARCH[j] * MARCH[k];
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  while(1){
    int n,r;
    cin>>n>>r;
    if(n==0) break;
    int p,c;
    int a[n];
    for(int i=n-1;i>=0;i--){
      a[i]=n-i;
    }
    for(int i=0;i<r;i++){
      cin>>p>>c;
      rotate(a,a+p-1,a+p+c-1);
    }
    cout<<a[0]<<endl;
  }
    

  return 0;
}


Measured memory_bytes: 3180
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<cmath>
#include<deque>

using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
const int MOD = 1000000007;
int main(void) {
	int N, t = 0, p, c = 0;
	scanf("%d", &N);
	rep(i, 0, N) {
		p = t;
		scanf("%d", &t);
		if (p < t)c += t - p;
	}
	printf("%d\n", c);
	return 0;
}
int gcd(int a, int b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}

	return b ? gcd(b, a % b) : a;
}
long long modpow(long long a, long long n) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}/*
int main() {
	int N, K;
	ll s = 0;
	scanf("%d%d", &N, &K);
	rep(l, 1, K + 1) {
		s += (modpow(K - l + 1,N) - modpow(K - l, N)) % MOD + modpow(K / l, N - 1) * (l - 1);
		printf("%lld %lld \n",s, (modpow(K - l + 1, N) - modpow(K - l, N)) % MOD, N - 1);
		s %= MOD;
	}
	printf("%lld\n", s);
	return 0;
}*/

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

int d[11111] = {1};
int main() {
    int n, p;
    string s;
    cin >> n >> p >> s;
    long r = 0;
    if(p == 2 || p == 5) {
        for(int i = 0; i < n; i++)
            if((s[i] - '0') % p == 0)
                r += i + 1;
        cout << r << endl;
        return 0;
    }
    int a = 1, x = 0;
    for(int i = n; i--;) {
        (x += a * (s[i] - '0')) %= p, a = a * 10 % p;
        r += d[x], d[x]++;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 644
fun main() = Thread(null, ::msolutions2020d, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun msolutions2020d() {
    val n = readLine()!!.toInt()
    val prices = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    val highestMoneys = LongArray(n) { 1000 }

    for (dayToBuy in 0 until n) for (dayToSell in dayToBuy + 1 until n) {
        val stock = highestMoneys[dayToBuy] / prices[dayToBuy]
        highestMoneys[dayToSell] = maxOf(
            highestMoneys[dayToSell],
            highestMoneys[dayToBuy],
            highestMoneys[dayToBuy] + stock * (prices[dayToSell] - prices[dayToBuy])
        )
    }

    val answer = highestMoneys.last()

    println(answer)
}


Measured memory_bytes: 40528
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;

int main() {
  ll x;
  cin >> x;
  ll result = 0;
  ll div = x / 11;
  ll mod = x % 11;
  result += div * 2;
  if (0 < mod && mod <= 6) {
    ++result;
  } else if (6 < mod && mod <= 11) {
    result += 2;
  }
  cout << result << endl;
}


Measured memory_bytes: 256
S =input()
K =int(input())

if len(set(S))==1:
    ans =(len(S)*K)//2

else:
    S_ans =  0
    cnt = 1
    for i in range(1,len(S)):
        if S[i] == S[i-1]:
            cnt += 1
            if i ==len(S)-1:
                S_ans += cnt//2
        else:
            S_ans += cnt//2
            cnt = 1
    ans =S_ans*K

    if S[0] == S[-1]:
        a, i =1, 1
        while S[0]==S[i]:
            a += 1
            i += 1
        b, i =1, 1
        while S[-1]==S[-1- i]:
            b += 1
            i += 1
        ans = ans - (a//2 +b//2 -(a+b)//2)*(K-1)        
    

print(ans) 

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[][] array = new String[h][];
        int sum = 0;
        for (int i = 0; i < h; i++) {
            array[i] = sc.next().split("");
            for (int j = 0; j < array[i].length; j++) {
                if (array[i][j].equals("#")) {
                    sum++;
                }
            }
        }

        System.out.println(sum == h + w - 1 ? "Possible" : "Impossible");
    }
}

Measured memory_bytes: 21716
# Aizu Problem 0305: Yueki's Audio Room

import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


N = int(input())
for f in range(N):
    d, a = [int(_) for _ in input().split()]
    if d % 100 == 0 and a % 30 == 0:
        # on crossing of lines and ring segments:
        print(5 * (a // 30) + d // 100)
    elif d % 100 == 0:
        # on ring segment but not on crossing:
        print(5 * (a // 30) + d // 100, 5 + 5 * (a // 30) + d // 100)
    elif a % 30 == 0:
        # on line but not on ring segment:
        print(5 * (a // 30) + d // 100, 5 * (a // 30) + d // 100 + 1)
    else:
        print(' '.join([str(_) for _ in [5 * (a // 30) + d // 100, 5 * (a // 30) + d // 100 + 1,
                5 + 5 * (a // 30) + d // 100, 5 + 5 * (a // 30) + d // 100 + 1]]))

Measured memory_bytes: 7872
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        int H = sc.nextInt();
        int W = sc.nextInt();
        c = new int[10, 10];
        var A = new int[H, W];
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i, j] = sc.nextInt();
            }
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                A[i, j] = sc.nextInt();
            }
        }

        var cost = new int[10];
        for (int i = 0; i < 10; i++) {
            if (i == 1) {
                cost[i] = 0;
                continue;
            }

            minCost = int.MaxValue;
            var dist = new bool[10];
            Sub(i, 0, dist);
            cost[i] = minCost;
        }

        long ans = 0;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (A[i, j] == -1) continue;
                ans += cost[A[i, j]];
            }
        }
        WriteLine(ans);
    }

    int[,] c;
    int minCost;

    void Sub(int i, int cost, bool[] distBase) {
        var dist = new bool[10];
        Array.Copy(distBase, dist, 10);
        dist[i] = true;

        for (int j = 0; j < 10; j++) {
            if (j == i || dist[j]) continue;

            if (j == 1) {
                minCost = Math.Min(cost + c[i, 1], minCost);
            } else {
                Sub(j, cost + c[i, j], dist);
            }
        }
    }

}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 17320
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int N;
  N=S.size();
  int count=0;
  for(int i=0;i<S.size()-1;i++){
    if(S.at(i)=='1'&&S.at(i+1)=='1'){
      S.at(i+1)='0';
      count=count+1;
    }
    else if(S.at(i)=='0'&&S.at(i+1)=='0'){
      S.at(i+1)='1';
      count=count+1;
    }
    else{
    }
  }
  cout<<min(count,N-count)<<endl;
}

Measured memory_bytes: 512
def factorial(n):
    ret = 1
    for i in range(n):
        ret *= (i + 1)
    return ret

def calc_order(A, N):
    l = [i + 1 for i in range(N)]
    order = 1
    for i in range(N):
        a = A[i]
        len_l = N - i
        index = l.index(a)
        # print(a, index, factorial(len_l - 1), order)
        order += index * factorial(len_l - 1)
        del l[index]
    return order

def main():
    N = int(input())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))
    ord_p = calc_order(P, N)
    ord_q = calc_order(Q, N)
    ans = abs(ord_p - ord_q)
    # print(ord_p, ord_q)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)

int count(int n) {
    vector<int> data;
    for(int i=1; i*i<=n; i++) {
        if(n%i == 0) {
            data.push_back(i);
            if (n/i != i) data.push_back(n/i);
        }
    }
    return data.size();
}

int main() {
    int n, ans=0;
    cin >> n;
    vector<int> data(n);
    FOR(i, 1, n-1) data.at(i-1) = count(i);
    FOR(i, 1, n-1) ans += data.at(i-1);
    cout << ans << endl;
}


Measured memory_bytes: 7216
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long count = 0;
		long money = sc.nextLong();
		long curent = 100l;
		while (curent < money) {
			++count;
			curent += curent / 100l;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 35888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numM = 0;

		try {
			scanner = new Scanner(System.in);
			numM = scanner.nextInt();

			System.out.println(24 + 24 - numM);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 22868
package main

import (
	"fmt"
)

func main() {
	var (
		a, b, c, x, count int
	)
	fmt.Scan(&a, &b, &c, &x)
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if i*500+j*100+k*50 == x {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pcont(x) for(auto i: x){cout << i << " ";} cout << "\n";

int main(){
    IOS;
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int sum = 0;
    for(int i = 0; i<k; i++){
        sum += a[i];
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int L, R, d; cin >> L >> R >> d;
	int ans = 0;
	for (int i = L; i <= R; ++i)
	{
		if (i % d == 0) ++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3592
d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for _ in range(d)]
C=sum(c)
tot=0
mem=[0]*26
for i in range(d):
	for j in range(26):
		s[i][j]-=c[j]
	a=max(s[i])
	b=s[i].index(a)
	print(b+1)

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

using namespace std;

#define INPUT_OUTPUT { \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout); \
}
#define Pi acos(-1)
#define ll long long

int main()
{
    // INPUT_OUTPUT;
    int a, b;
    cin >> a >> b;
    int k = (a+b)/2;
    if(abs(a-k)==abs(b-k)) cout << k << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

using namespace std;

void call(int n){
    int i = 1;

int run = 0;
do{
    run = 0;
    int x = i;
    if ( x % 3 == 0 ){
        cout << " " << i;
        if ( ++i <= n ){
            run = 1; continue;
        }else{
            break;
        }
    }
    
    do{
        if ( x % 10 == 3 ){
            cout << " " << i;
            break;
        }
        x /= 10;
    }while ( x );

    if ( ++i <= n ){
        run = 1; continue;
    }else{
        break;
    }

}while(run);
}

int main()
{
    int n;
    cin >> n;
    call(n);
    cout << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	string S; cin >> S;
	sort(ALL(S));
	if (S == "abc") puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
S = input()
S = S[::-1]
d = 1
mods = [0]
counter = [0]*2019
counter[0] += 1
for s in S:
  s = int(s)
  mods.append((mods[-1]+s*d)%2019)
  counter[mods[-1]] += 1
  d *= 10
  d %= 2019

print(sum([i*(i-1)//2 for i in counter]))


Measured memory_bytes: 16588
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.datetime, std.bigint;

immutable long mod = 10^^9 + 7;
int n;
int[] t, a;

void main() {
    scan(n);
    t = readln.split.to!(int[]);
    a = readln.split.to!(int[]);

    auto L = new int[](n);
    auto H = new int[](n);

    L[0] = H[0] = t[0];

    foreach (i ; 1 .. n) {
        if (t[i - 1] < t[i]) {
            L[i] = H[i] = t[i];
        }
        else {
            L[i] = 1;
            H[i] = t[i];
        }
    }

    if (!(L[n - 1] <= a[n - 1] && a[n - 1] <= H[n - 1])) {
        writeln(0);
        return;
    }

    L[n - 1] = H[n - 1] = a[n - 1];

    foreach_reverse (i ; 0 .. n - 1) {
        if (a[i] > a[i + 1]) {
            if (L[i] <= a[i] && a[i] <= H[i]) {
                L[i] = H[i] = a[i];
            }
            else {
                writeln(0);
                return;
            }
        }
        else {
            H[i] = min(H[i], a[i]);
        }
    }

    long ans = 1;

    foreach (i ; 0 .. n) {
        (ans *= (H[i] - L[i] + 1)) %= mod;
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

#define int long long
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);


main(){
	FIO
	int n;
	cin>>n;
	int arr[n],i,j,k;
	for(i=0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	int sum=arr[n-1];
	int c=2;
	for(i=n-2;i>=0;i--){
		if(c<n){
			c++;
			sum+=arr[i];
		}
		if(c<n){
			c++;
			sum+=arr[i];
		}
		//cout<<sum<<" "<<c<<endl;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 5208
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz size
#define rep(i,n) for(int i=(0);i<(n);i++)
#define rep2(i,n) for(int i=(1);i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1e5+1;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if(!e)return 1;
    if(e&1) return qpow(b,e-1)*b;
    int pwur=qpow(b,e>>1);
    return pwur*pwur;
}

/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n;
    cin>>n;
    set<char>st;
    rep(i,n){
        char c;
        cin>>c;
        st.insert(c);
    }
    cout<<((st.size()==3)?"Three":"Four");

    return 0;
}


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

int main(void){
    string str1,str2,ans;
    ans = "";
    cin >> str1 >> str2;
    str1 = str1 + str1;
    for (int i = 0; i < str1.size(); i++){
        if (str1[i] == str2[0]){
            for(int k = i; k < str2.size() + i; k++){
                ans += str1[k];
            }
            if (ans == str2){
                cout << "Yes" << endl;
                return 0;
            }
            ans = "";
        }
    }
    cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 3196
import sys
input = sys.stdin.buffer.readline
from math import hypot
from scipy.sparse.csgraph import dijkstra,csgraph_from_dense
import numpy as np

def main():
	sx, sy, gx, gy = map(int, input().split())
	n = int(input())
	v = [(sx, sy, 0), (gx, gy, 0)]
	for _ in range(n):
		v.append(tuple(map(int, input().split())))
	d = np.full((n + 2, n + 2), np.inf)
	for i, p1 in enumerate(v):
		for j, p2 in enumerate(v[i + 1:]):
			d[i][i + j + 1] = max(0, hypot(p1[0] - p2[0], p1[1] - p2[1]) - p1[2] - p2[2])
	print(dijkstra(csgraph_from_dense(d,null_value=np.inf),False,0)[1])

if __name__ == '__main__':
	main()


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    char x ;
    cin >> x ;
    if (x >= 'a' and x <= 'z')  cout << "a" ;
    else if (x >= 'A' and x <= 'Z') cout << "A" ;

    return 0 ;
}


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

const int inf=INT_MAX;

struct segTree{
	int n;
	vector<int> sg;
	int op(int x,int y){return min(x,y);}
	int id=INT_MAX;
	segTree(){};
	segTree(int n_){
		n=1;
		while(n<n_)n*=2;
		sg.resize(n*2,id);
	};
	void update(int k,int x){
		k+=n;
		sg[k]=x;
		while(k/2>0){
			k/=2;
			sg[k]=op(sg[2*k],sg[2*k+1]);
		}
	}
	int query(int l,int r){
		int vl=id,vr=id;
		l+=n;r+=n;
		while(l<=r){
			if(l%2==1){vl=op(vl,sg[l++]);}
			if(r%2==0){vr=op(sg[r--],vr);}
			l/=2;r/=2;
		}
		return op(vl,vr);
	}

};

signed main(){
	int n,q;cin>>n>>q;
	segTree st(n);
//	for(auto&& u:st.sg)cout<<u<<" ";cout<<endl;
//  	cout <<st.n<<endl;
  while(q--){
		int x,y,z;
		cin>>x>>y>>z;
		if(x==0){
			st.update(y,z);
		}else{
			cout<<st.query(y,z)<<endl;
		}
	}
  
  
}




Measured memory_bytes: 3804
import bisect

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
B.sort()
C.sort()

ans=0

for _ in range(N):
    ans += bisect.bisect_left(A,B[_])*(N-bisect.bisect_right(C,B[_]))

print(ans)

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    int MX, sum;
    MX = sum = 0;
    while(n--){
        int aux ; cin >> aux;
        sum += aux;
        MX = max(MX, aux);
    }    
    cout <<((sum - MX > MX) ? "Yes" : "No" ) << "\n"; 
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int d; cin>>d;
    vector<int> c(26);
    for(int i=0; i<26; i++) cin>>c[i];
    vector<vector<int>> s(d, vector<int>(26));
    for(int i=0; i<d; i++){
        for(int j=0; j<26; j++) cin>>s[i][j];
    }
    
    vector<int> l(26, 0);
    ll ans = 0;
    for(int i=0; i<d; i++){
        int t; cin>>t;
        t--;
        ans += s[i][t];
        l[t] = i + 1;
        for(int j=0; j<26; j++){
            ans -= c[j] * (i + 1 - l[j]);
        }
        cout << ans << endl;
    }

    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi a(n);
    bool ng=true;
    rep(i,n){
        cin>>a[i];
        if (a[i]==1) ng = false;
    }
    if (ng){
        cout<<"-1\n";
        return 0;
    }

    int l=1, r=n+1; //RがNG
    while(r-l>1){
        int mid = (l+r)/2;
        int now=1;
        rep(i,n){
            if (a[i]==now){
                now++;
                if (now>mid) break;
            }
        }
        if (now>mid){
            l = mid;
        }else{
            r = mid;
        }
    }
    cout<<n-l<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int arr[200];
int main() {
    int n;
    scanf("%d", &n);
    n <<= 1;
    for (int i = 0; i < n; ++i) {
        scanf("%d", arr + i);
    }
    sort(arr, arr + n);
    int sum = 0;
    for (int i = 0; i < n; i += 2) {
        sum += arr[i];
    }
    printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void A();

int main()
{
	A();
	fflush(stdout);
	return 0;
}

static void A()
{
	int D, T, S;
	get(D, T, S);

	const char* ans = "No\n";
	if (S * T >= D) ans = "Yes\n";
	printf(ans);
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define inf 1e9+100

int n, u, k, v, c, d[100];
vector<pair<int,int> > e[100];

void dijkstra(int n, vector<pair<int,int> > e[], int *d, int s) {
	priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > > que;
	fill(d, d+n, inf), d[s] = 0;
	que.push({0,s});
	while(!que.empty()) {
		int v = que.top().second, dis = que.top().first; que.pop();
		if (d[v]<dis) continue;
		for (int i = 0; i < e[v].size(); ++i) {
			int to = e[v][i].first, cost = e[v][i].second;
			if (d[to] > d[v] + cost) {
				d[to] = d[v] + cost;
				que.push({d[to], to});
			}
		}
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> u >> k;
		for (int j = 0; j < k; ++j) {
			cin >> v >> c;
			e[u].push_back({v, c});
		}
	}
	dijkstra(n,e,d,0);
	for (int i = 0; i < n; ++i) cout << i << ' ' << d[i] << endl;
}


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

//segment tree実装
constexpr size_t next_pow2(size_t n){
    if((n & (n - 1)) == 0) return n;

    size_t ret = 1;
    while(n > ret){
        ret <<= 1;
    }

    return ret;
}

template<typename Tp, typename Pred>
class segment_tree{
    private:
        size_t bottom_;
        const Tp init_;
        std::vector<Tp> data_;
        Pred pred_;
    public:
        segment_tree(const std::vector<Tp>& in, Tp init, Pred pred) : bottom_(next_pow2(in.size())), init_(init), data_(2 * bottom_ - 1, init), pred_(pred) {
            for(size_t i = 0; i < in.size(); i++){
                data_.at(i + bottom_ - 1) = in.at(i);
            }

            for(long i = bottom_ - 2; i >= 0; i--){
                data_.at(i) = pred_(data_.at(2 * i + 1), data_.at(2 * i + 2));
            }
        }

        // 元の配列のindexをvalに更新
        void update(size_t index, Tp val){
            index += bottom_ - 1;

            data_[index] = val;

            while(index != 0){
                index = (index - 1) / 2;
                data_[index] = pred_(data_.at(2 * index + 1), data_.at(2 * index + 2));
            }
        }

        // 区間[begin, end)の探索
        Tp find(size_t begin, size_t end){
            begin += bottom_ - 1;
            end += bottom_ - 1;

            Tp left = init_;
            Tp right = init_;

            while(begin < end){
                if(begin % 2 == 0){
                    left = pred_(left, data_.at(begin));
                }

                if(end % 2 == 0){
                    right = pred_(right, data_.at(end - 1));
                }

                begin /= 2;
                end = (end - 1) / 2;
            }

            return pred_(left, right);
        }

        Tp at(size_t n){
            return data_.at(n + bottom_ - 1);
        }

        // debug
        void print(){
            for(const auto& e : data_){
                std::cout << e << std::endl;
            }
        }
};

int main(){

    size_t n, q;
    std::cin >> n >> q;

    std::vector<size_t> v(n, 0);
    auto pred = [](size_t a, size_t b){ return a + b; };
    segment_tree<size_t, decltype(pred)> st(v, 0, pred);

    for(size_t i = 0; i < q; i++){
        size_t command, x, y;
        std::cin >> command >> x >> y;

        if(command == 0){
            st.update(x - 1, st.at(x - 1) + y);
        }else{
            std::cout << st.find(x - 1, y) << std::endl;
        }
    }

    return 0;
}



Measured memory_bytes: 5720
#include <random>
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld eps = 1e-12;
constexpr int inf = numeric_limits<int>::max() / 2;
constexpr ll mod = 1e9 + 7;
mt19937_64 rnd{random_device()()};

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  int n;
  cin >> n;
  vector<ll> a(n + 1);
  for (int i = 0; i <= n; i++) {
    cin >> a[i];
  }
  vector<ll> mi(n + 1), ma(n + 1);
  mi[n] = ma[n] = a[n];
  for (int i = n - 1; i >= 0; i--) {
    mi[i] = ma[i] = a[i];
    mi[i] += (mi[i + 1] + 1) / 2;
    ma[i] += ma[i + 1];
    assert(mi[i] <= ma[i]);
  }
  if (mi[0] > 1) {
    cout << -1 << endl;
    return 0;
  }
  ll ret = 1, cur = 1;
  for (int i = 1; i <= n; i++) {
    ret += min(cur * 2, ma[i]);
    cur = min(cur * 2, ma[i]) - a[i];
  }
  cout << ret << endl;
}


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

using namespace std;

int main() {
  int N, M, p, y;
  cin >> N >> M;
  vector<vector<pair<int, int>>> V(N);
  for (int i = 0; i != M; ++i) {
    cin >> p >> y;
    V[--p].emplace_back(y, i);
  }

  vector<pair<int, int>> A(M);
  for (int i = 0; i != N; ++i) {
    sort(begin(V[i]), end(V[i]));
    for (int j = 0, n = V[i].size(); j != n; ++j)
      A[V[i][j].second] = {i + 1, j + 1};
  }

  for (auto &a : A) printf("%06d%06d\n", a.first, a.second);
}


Measured memory_bytes: 9440
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;

  while(1){
    cin >> n;
    if(n == 0) break;

    int a[n],b[n-1];
    long long sum=0;
    for(int i=0;i<n;i++){
      cin >> a[i];
      sum += a[i];
    }
    for(int i=0;i<n-1;i++){
      cin >> b[i];
    }
    sort(b, b+n-1);

    long long temp,ans = sum * n;
    for(int i=n-2;i>=0;i--){
      sum += b[i];
      temp = sum*(i+1);
      //cout << temp << endl;
      ans = max(temp, ans);
    }

    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3684
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int T,A,B,C,D,res;
template <typename _Tp> inline void IN(_Tp&x) {
	char ch;bool flag=0;x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(flag) x=-x;
}

int main() {
	IN(T);while(T--) {
		IN(A),IN(B),IN(C),IN(D);
		int l=0,r=A+B+1,mid,_0,_1;
		res=(max(A,B)-1)/(min(A,B)+1)+1;
		while(l<r) {
			mid=(l+r)>>1;
			_0=A-mid/(res+1)*res-mid%(res+1),_1=B-mid/(res+1);
			(_1<=1ll*_0*res)?l=mid+1:r=mid;
		}
		_0=A-l/(res+1)*res-l%(res+1),_1=B-l/(res+1),r=l+_1-_0*res+1;
		for(int i=C;i<=min(D,l);++i) putchar(i%(res+1)?'A':'B');
		for(int i=max(C,l+1);i<=D;++i) putchar((i-r)%(res+1)?'B':'A');
		puts("");
	}
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
#define TABLE_SIZE ((row + 1) * (col + 1))
#define CURRENT_INDEX (i * (col + 1) + j)
#define R_TOTAL_INDEX (i * (col+1) + col)
#define C_TOTAL_INDEX (row * (col + 1) + j)
#define TOTAL_INDEX (TABLE_SIZE - 1)
	int row, col, size, num;
	cin >> row >> col;
	int* table = new int[TABLE_SIZE];
	for (int i = 0; i < TABLE_SIZE; i++) {
		table[i] = 0;
	}
	for (int i = 0; i < row; i++) {
		for (int j = 0; j < col; j++) {
			cin >> num;
			table[CURRENT_INDEX] = num;
			table[R_TOTAL_INDEX] += num;
			table[C_TOTAL_INDEX] += num;
			table[TOTAL_INDEX] += num;
		}
	}
	for (int i = 0; i < row + 1; i++) {
		for (int j = 0; j < col + 1; j++) {
			cout << table[CURRENT_INDEX] << (j < col ? " ":"\n");
		}
	}
	delete[] table;
	return 0;
}

Measured memory_bytes: 1232
n = int(input())
nums = list(map(int,input().split()))
for i in range(1,n):
  nums[i] += nums[i-1]
result = {}
for num in nums:
  if num not in result:
    result[num] = 1
  else:
    result[num] += 1
total = 0
for k,v in result.items():
  if k == 0:
    total += v
  if 1 < v:
    total += v*(v-1)//2
print(total)

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n;
    cin >> n;
    vector<ll> a(n+1);
    for (int i = 0;i < n;++i) cin >> a[i];
    a[n] = 0;
    ll x = 1000,y = 0;
    for (int i = 0;i < n;++i) {
        if (a[i] < a[i+1]) {
            y += x/a[i];
            x %= a[i];
        } else if (a[i] > a[i+1]) {
            x += y*a[i];
            y = 0;
        }
    }
    cout << x << endl;
}

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

using namespace std;
bool cal(int n){
	int now=0;
	while(n){
		now++;
		n/=10;
	}
	return now&1;
}
int main(){
	int n;
	cin>>n;int ans=0;
	for(int i=1;i<=n;i++){
		if(cal(i)) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
#define v(T) vector<T>
#define vv(T) vector<v(T)>
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
template<class T>bool chmax(T &a, const T &b){
    if (a < b) {a = b; return true;}
    return false;
}
template<class T>bool chmin(T &a, const T &b){
    if (a > b) {a = b; return true;}
    return false;
}
bool dp[110000];
int main()
{
    int n, k;
    cin >> n>> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    rep(i, k+1){
        for (int x : a){
            if (i+x <=k and dp[i]==0) dp[i+x] = 1;
        }
    }
    if (dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <sstream>
#include <cstdlib>
using namespace std;

string makebottom(string s) {
  int x[10000],size;
  string news = "";
  stringstream ss;
  size = s.size();

  for(int i=0;i<size;i++) {
    x[i] = atoi(s.substr(i,1).c_str());
  }

  for(int i=0;i<size-1;i++) {
    ss << (x[i] + x[i+1]) % 10;
    news += ss.str();
    ss.str("");
    ss.clear(stringstream::goodbit);
  }

  if(news.size() != 1)
    return makebottom(news);
  else if(news.size() == 1)
    return news;
}


  int main() {
    string str;
    while(cin >> str) {
      cout << makebottom(str) << endl;
    }
  }

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

int main()
{
    int n, a, b;
    std::cin >> n >> a >> b;

    if ((b - a) % 2) {
        std::cout << "Borys" << std::endl;
    } else {
        std::cout << "Alice" << std::endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		long[] b=new long[n];
		long sum=0;
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			b[a[i]-1]++;
		}
		for(int i=0;i<n;i++) {
			sum+=b[i]*(b[i]-1)/2;
		}
		for(int i=0;i<n;i++) {
			System.out.println(sum-(b[a[i]-1]-1));
		}
	}
}


Measured memory_bytes: 101188
#include <iostream>
#include <string>
#include <queue>

struct Process {
  std::string name;
  int time;
};

int main() {
  int n, q;
  std::cin >> n >> q;
  std::queue<Process> que;
  std::string name;
  int time;
  for (int i=0; i<n; i++) {
    std::cin >> name >> time;
    Process p = {name, time};
    que.push(p);
  }
  
  int cur_time = 0;
  while(!que.empty()) {
    if (que.front().time > q) {
      que.front().time -= q;
      que.push(que.front());
      que.pop();
      cur_time += q;
    } else {
      cur_time += que.front().time;
      std::cout << que.front().name << ' ';
      std::cout << cur_time << std::endl;
      que.pop();
    }
  }
  
  return 0;
}



Measured memory_bytes: 6336
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

string s;

void main() {
    scan(s);

    if (s.canFind('N') == s.canFind('S') && s.canFind('W') == s.canFind('E')) {
        writeln("Yes");
    }
    else {
        writeln("No");
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

int main(){
    int n,flag=0;
    cin >> n;
    vector<string> s(n);
    string tmp;

    for(int i=0;i<n;i++){
        cin >> s.at(i);
    }
    sort(s.begin(),s.end());
    s.erase(unique(s.begin(),s.end()),s.end());
    cout << s.size() << endl;
 }

Measured memory_bytes: 9600