akhauriyash/Code-Regression huggingface dataset:
N=int(input())
S=input()
r=[1 if S[0]=="R" else 0]
g=[1 if S[0]=="G" else 0]
b=[1 if S[0]=="B" else 0]

for i in range(1,N):
  if S[i]=="R":
    r.append(r[-1]+1)
    g.append(g[-1])
    b.append(b[-1])
  elif S[i]=="G":
    r.append(r[-1])
    g.append(g[-1]+1)
    b.append(b[-1])
  else:
    r.append(r[-1])
    g.append(g[-1])
    b.append(b[-1]+1)

#print(r)
#print(g)
#print(b)

st={"R","G","B"}

def calc(i,j):
  tmp={i,j}
  ans=st-tmp
  return ans.pop()

#print(calc("R","G"))
ans=0

for i in range(0,N-2):
  for j in range(i+1,N-1):
    if S[j]==S[i]:
      pass
    else:            
      tmp=calc(S[i],S[j])
      if tmp=="R":
        #print(i,j,tmp,r[-1],r[j])
        ans += r[-1]-r[j]
        if j+(j-i)<=N-1:
          if S[j+(j-i)]==tmp:
            ans -=1
      elif tmp=="G":
        #print(i,j,tmp,g[-1],g[j])
        ans += g[-1]-g[j]
        if j+(j-i)<=N-1:
          if S[j+(j-i)]==tmp:
            ans -=1
      else:
        #print(i,j,tmp,b[-1],b[j])
        ans += b[-1]-b[j]
        if j+(j-i)<=N-1:
          if S[j+(j-i)]==tmp:
            ans -=1

print(ans)

Measured memory_bytes: 74776
import java.io.*;
import java.util.StringTokenizer;

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

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {
            long n = in.nextLong();
            long s = n * (n+1) / 2;
            for (long i = 3; i <= n; i+=3) {
                s -= i;
            }
            for (long i = 5; i <= n; i+=5) {
                s -= i;
            }
            for (long i = 15; i <= n; i+=15) {
                s += i;
            }
            out.println(s);
        }
    }

    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 long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

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

        public char nextChar() {
            return next().charAt(0);
        }

        public String nextLine() throws IOException {
            return reader.readLine().trim();
        }
    }
}


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

int const N = 100;
int x[N];

int main(){
	int n;
	scanf("%d", &n);
	f(i, 0, n)scanf("%d", x + i);
	int s = 0;
	f(i, 0, n)x[i] *= n, s += x[i];
	s /= n;
	int an = 0;
	f(i, 1, n)if (abs(x[i] - s) < abs(x[an] - s))an = i;
	printf("%d\n", an);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

bool Bl[100][100];
int main(){
    int A, B;
    cin >> A >> B;
    int H,W;
    H = W = 100;
    printf("%d %d\n", H, W);

    for(int i = 0; i < H/2; i++){
        REP(j,W){
            Bl[i][j] = true;
        }
    }

    int a = 0;
    int idx = 0;
    while(a < A-1){
        Bl[2*(idx/W)][idx%W] = false;
        idx += 2;
        a++;
    }

    int b = 0;
    idx = 0;
    while(b < B-1){
        Bl[1+H/2+2*(idx/W)][idx%W] = true;
        idx += 2;
        b++;
    }

    REP(i,H){
        REP(j,W){
            if(Bl[i][j])
                printf("#");
            else
                printf(".");
        }
        printf("\n");
    }
    return 0;
}


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

int main() {
	int H, W;

	while(true) {
		cin >> H >> W;
		if((H == 0) && (W == 0)) {
			break;
		}

		for(int h = 0; h < H; ++h) {
			for(int w = 0; w < W; ++w) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3104
from bisect import bisect_left
N = int(input())
A = [0]*N
B = [0]*((N+1)//2)
for i in range(N):
    a = int(input())
    A[i] = a
    if i % 2 == 0:
        B[i//2] = a
A.sort()

ct = 0
for i in range((N+1)//2):
    if bisect_left(A, B[i]) % 2 == 1:
        ct += 1
print(ct)


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

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

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (p[i] == i) {
            if (i < N - 1) {
                ans++;
                swap(p[i], p[i + 1]);
            } else {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef long long LL;
LL a,b,c,k;
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
	if(k%2==0) printf("%lld\n",a-b);
	else printf("%lld\n",b-a);
}

Measured memory_bytes: 256
N,K = map(int,input().split())
li = []
count = 0
for i in range(K):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        li.append(a[j])

for i in range(N):
    if i+1 not in li:
        count += 1

print(count)

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

namespace id_0505cs
{
    public class Place
    {
        int _pn, _points;
        public Place(int placeNum)
        {
            _pn = placeNum;
        }

        public int GetPn()
        {
            return _pn;
        }

        public int GetPoints()
        {
            return _points;
        }

        public void AddPoints(int p)
        {
            _points += p;
        }
    }
    public class Quattionaires
    {
        int _n, _m;
        List<Place> _answer;

        public Quattionaires(int n,int m)
        {
            _n = n;
            _m = m;
            _answer = new List<Place>();
            for(int i = 0; i < _m; i++)
            {
                _answer.Add(new Place(i));
            }
        }
        public void Add(int[] vs)
        {
            for (int i = 0; i < _m; i++)
            {
                _answer[i].AddPoints(vs[i]);
            }
        }
        public int[] Results()
        {
            var result = _answer.OrderBy(x => x.GetPn()).OrderByDescending(x => x.GetPoints());
            return result.Select(x => x.GetPn()).ToArray();
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var vs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if (vs[0] == 0 && vs[1] == 0) return;
                var n = vs[0];
                var m = vs[1];
                Quattionaires myqu = new Quattionaires(n, m);
                foreach (var i in Enumerable.Range(0, n))
                {
                    myqu.Add(Console.ReadLine().Split(' ').Select(int.Parse).ToArray());
                }
                int[] res = myqu.Results();
                Console.WriteLine(string.Join(" ", res.Select(x => (x+1).ToString())));
            }
        }
    }
}



Measured memory_bytes: 20504
from collections import deque

n = int(input())
g = [None] * n
visited = [0] * n
dist = [-1] * n
Q = deque()

while n:
    l = list(map(int, input().split()))
    g[l[0]-1] = [i-1 for i in l[2:]]
    n -= 1

Q.append((0, 0)) 
visited[0] = 1

while Q:
    i, d = Q.popleft()         
    dist[i] = d
    for c in g[i]:
        if not visited[c]:
            visited[c] = 1
            Q.append((c, d+1))

for i, d in enumerate(dist):
    print(i+1, d)


Measured memory_bytes: 6032
-- AtCoder My Practice
-- author: Leonardone @ NEETSDKASU
 
-- 解説読後
-- http://agc004.contest.atcoder.jp/data/agc/004/editorial.pdf

import qualified Data.ByteString.Char8 as C
import Data.Array (listArray, accum, (!))
 
main = print . solve .map red . C.words =<< C.getContents
    where
        red x = case C.readInteger x of Just v -> fst v; _ -> 0

solve (n:x:a) = ans where
    sm = sum a
    aa = listArray (0, n - 1) a
    ans = f n sm aa
    f 1 r _  = r
    f c r ar = f (c - 1) r2 ar2 where
        ar2 = accum min aa [(i, ar ! (mod (i + n - 1) n)) | i <- [0 .. n - 1]]
        r2 = minimum [r, (n - c + 1) * x + sum ar2]


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

int main(){
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  int z;
  vector<int> a(n), b(m);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> b[i];
  int miny = *min_element(b.begin(), b.end());
  int maxx = *max_element(a.begin(), a.end());
  if (miny <= y && x <= maxx && maxx < miny)
    cout << "No War" << endl;
  else
    cout << "War" << endl;
  return 0;
}


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

int board[12][12];
int used[12][12];

bool lastCheck(){
	for(int y=0;y<10;y++){
		for(int x=0;x<10;x++){
			if(board[y][x])return false;
		}
	}
	return true;
}

bool allow(int n){
	for(int i=0;i<n;i++){
		int y = i / 10;
		int x = i % 10;

		if(board[y][x] == 0)continue;

		bool ok = false;
		for(int j=n;j<100;j++){
			int ny = j / 10;
			int nx = j % 10;

			int dy = abs(ny - y);
			int dx = abs(nx - x);

			if(dy >= 2)break;
			if(dy + dx <= 1){
				ok = true;
				break;
			}
		}

		if(!ok)return false;
	}
	return true;
}

int pattern[] = {
    0,1,0,
    1,1,1,
    0,1,0
};

void flip(int y, int x){
	int sy = y - 1;
	int sx = x - 1;
	for(int i=0;i<3;i++)for(int j=0;j<3;j++){
		int ny = sy + i;
		int nx = sx + j;
		if(ny < 0 || ny >= 10 || nx < 0 || nx >= 10)continue;

		if(pattern[i*3+j]){
			board[ny][nx] ^= 1;
		}
	}
}

bool dfs(int n){
	if(n >= 10 * 10){
		return lastCheck();
	}
	if(!allow(n)){
		return false;
	}
	int y = n / 10;
	int x = n % 10;

	if(dfs(n + 1)){
		return true;
	}

	flip(y, x);
	used[y][x] = 1;

	if(dfs(n + 1))return true;
	
	used[y][x] = 0;
	flip(y, x);

	return false;
}

void solve(){
	memset(used, 0, sizeof(used));
	if(!dfs(0)){
		while(1);
	}
}
int main()
{
	int n;
	cin >> n;

	for(int t=0;t<n;t++){
		for(int y=0;y<10;y++){
			for(int x=0;x<10;x++)cin >> board[y][x];
		}
		solve();
		for(int y=0;y<10;y++){
			for(int x=0;x<10;x++){
				if(x > 0)cout << " ";
				cout << used[y][x];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
def main():
    H1, M1, H2, M2, K = map(int, input().split())

    t1 = 60*H1 + M1
    t2 = 60*H2 + M2

    d = 0
    if t1 <= t2:
        d = t2 - t1
    else:
        d = 60*24 - t1 + t2

    print(max(0, d - K))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9136
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

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

	int a, b;
	while(cin >> a >> b){
		int sum = a + b;
		cout << to_string(sum).size() << '\n';
	}
	return 0;
}
// Write Here



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

int main() {
  int64_t X;
  cin >> X;
  
  for (int64_t i = 0; i < 121; i++) {
    int flag = 0;
    
    for (int64_t j = -119; j < 120; j++) {
      
      if (i*i*i*i*i - j*j*j*j*j == X) {
        cout << i << " " << j << endl;
        flag = 1;
        break;
      }
      
      if (flag)
        break;
    }
    
    if (flag)
      break;
  }
      
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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() {
  int a, b;
  cin >> a >> b;
  P((a + b + 1) / 2);
  return 0;
}



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

int main() {
  int N,M;
  cin >> N >> M;
  
  vector<int> A(N,0);
  int T;
  for (int i = 0; i < M * 2;i++) {
    cin >> T;
    for (int j = 0; j < N; j++) {
      if (j+1 == T) {
        A.at(j)++;
      }
    }
  }
  
  for (int i = 0; i < N; i++) {
    cout << A.at(i) << endl;
  }
}


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

int main(){
    int n,k;
    cin >> n >> k;
    int i = k;
    int ans = 1;
    while(true){
        if(n<i){
            cout << ans << endl;
            break;
        }else{
            i*=k;
            ans++;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int sigma = 26;

int i, act, j;
string s, ans;
bool used[sigma];

int main()
{
    //freopen("test.in","r",stdin);

    cin >> s;
    if (s.size() != 26) {
        for (auto e : s) used[e - 'a'] = true;
        for (i = 0; used[i]; i++);
        s += (char)('a' + i);
        ans = s;
    } else {
        ans = s;

        for (i = 0; i < s.size(); i++) {
            act = s[i] - 'a';
            used[act] = true;
            for (j = act; j < sigma; j++)
                if (!used[j])
                    break;

            if (j < sigma) {
                ans = s;

                ans[i] = (char)('a' + j);
                while (ans.size() - 1 > i) ans.pop_back();
            }
        }
    }

    if (ans.size() == sigma) {
        cout << -1;
        return 0;
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


		String[] str = br.readLine().split(" ");

		int N = Integer.parseInt(str[0]);
		int M = Integer.parseInt(str[1]);

		int L[] =new int[M];
		int R[] =new int[M];

		int Lmax = 0;
		int Rmin = 0;


		for(int i=0;i<M;i++) {

			String[] str1 = br.readLine().split(" ");
			L[i] = Integer.parseInt(str1[0]);
			R[i] = Integer.parseInt(str1[1]);

			if(L[i]>Lmax) {
				Lmax = L[i];
			}

			if(i == 0) {
				Rmin = R[i];
			}

			if(R[i]<Rmin) {
				Rmin = R[i];
			}
		}

		int ans = Rmin - Lmax + 1;

		if(ans > 0) {
			System.out.print(ans);
		}else {
			System.out.print(0);
		}


	}

}


Measured memory_bytes: 49164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    char c;
    cin >> c;
    string s;
    s = "abcdefghijklmnopqrstuvwxyz";

    rep(i,26)
    {
        if (s[i]==c)
        {
            cout << s[i+1] << endl;
        }
    }
    
}




Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

if A == B:
  print(A*2)
elif A > B:
  print(A*2 - 1)
elif A < B:
  print(B*2 - 1)

Measured memory_bytes: 5312
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
    
int main(){
	int n,k;
    cin>>n>>k;
    vector<int> a(n);
    REP(i,n){
        cin>>a.at(i);
    }
    vector<ll> s(n+1,0);
    s.at(0)=0;
    REP(i,n){
        s.at(i+1)=a.at(i)+s.at(i);
    } 
    for(int i=1;i<=n;i++){
        s.at(i)=(s.at(i)-i)%k;
    }
    map<int,int> m;
    ll ans=0;
    for(int i=n;i>=0;i--){
        if(i+k<n+1) m[s.at(i+k)]--;
        ans+=m[s.at(i)];
        m[s.at(i)]++;
    }
    OUT(ans);
	return 0;
}

Measured memory_bytes: 12032
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define max 200001
int main(){
 char s[max];long long i,j;
 scanf("%s",s);
 long long len=strlen(s);
  
 long long a[len],x,mod[len+1],y,b=1,cnt[2019]={0};
 mod[len]=0;cnt[0]++;
 for(x=len-1;x>=0;x--){
  a[x]=s[x]-'0';
  mod[x]=(a[x]*b)%2019;
  mod[x]=(mod[x]+mod[x+1])%2019;
  b=(b*10)%2019;
  cnt[mod[x]]++; 
 }
 long long ans=0;
 for(x=0;x<2019;x++)
  ans+=(cnt[x]-1)*cnt[x]/2;
 printf("%lld\n",ans);

return 0;} 

Measured memory_bytes: 5068
N = int(input())
A = list(map(int, input().split()))

A.sort()
C = [0] * A[-1]
for Ai in A:
    if C[Ai - 1] >= 1:
        C[Ai - 1] += 1
        continue
    i = Ai
    while i <= A[-1]:
        C[i - 1] += 1
        i += Ai
print(sum([C[Ai - 1] == 1 for Ai in A]))


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

int main() {
    ll n, m;
    cin >> n >> m;
    if(n==2 || m==2){
        cout << 0 << endl;
        return 0;
    }
    if(n==1 && m==1){
        cout << 1 << endl;
        return 0;
    }
    if(n==1 || m==1){
        cout << n*m-2 << endl;
        return 0;
    }
    cout << (n-2)*(m-2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if (a<b)
		swap(a,b);
	if (a-b>1)
	{
		printf("0");
		return 0;
	}
	long long ans=1;
	for (int i=1;i<=a;++i)
		(ans*=i)%=1000000007;
	for (int i=1;i<=b;++i)
		(ans*=i)%=1000000007;
	if (a==b)
		(ans*=2)%=1000000007;
	printf("%d",(int)ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#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 itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());


int main(){
    string s,t;
    cin >> s >> t;
    int i=0;
    while(1){
        if(i < s.length()) cout << s[i];
        else{
            cout << endl;
            return 0;
        }
        if(i < t.length()) cout << t[i];
        else{
            cout << endl;
            return 0;
        }
        i+=1;
    }
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		for (int i = 1; i < n; i++) {
		    x = gcd(x, sc.nextInt());
		}
		System.out.println(x);
	}
	
	static int gcd(int x, int y) {
	    if (x % y == 0) {
	        return y;
	    } else {
	        return gcd(y, x % y);
	    }
	}
}


Measured memory_bytes: 45912
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
char c[2] = {'+', '-'};
int main() {
  string S;
  int A, B, C, D;
  cin >>S;
  A = S[0]-'0', B = S[1]-'0', C = S[2]-'0', D = S[3]-'0';
  REP(i, 2) {
    REP(j, 2) {
      REP(k, 2) {
        int num = A;
        char a[3];
        if (i == 0) {
          num += B;
          a[0] = '+';
        } else {
          num -= B;
          a[0] = '-';
        }
        if (j == 0) {
          num += C;
          a[1] = '+';
        } else {
          num -= C;
          a[1] = '-';
        }
        if (k == 0) {
          num += D;
          a[2] = '+';
        } else {
          num -= D;
          a[2] = '-';
        }
        if (num == 7) {
          cout << A << a[0] << B << a[1] << C << a[2] << D << "=7" << endl;
          return 0;
        }
      }
    }
  }
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

vector<ll> gTmp[200010], g[200010];
ll ans[200010], pls[200010];


int main()
{
    m0(ans);
    ll n,q;
    cin>>n>>q;    

    for (int i = 0; i < n-1; i++)
    {
        ll a,b;
        cin>>a>>b;
        a--;
        b--;
        gTmp[a].push_back(b);
        gTmp[b].push_back(a);
    }
    unordered_set<ll> se;
    se.insert(0);
    queue<ll> qGraph;
    qGraph.push(0);
    while (qGraph.size()>0)
    {
        ll now = qGraph.front();
        qGraph.pop();
        for (int i = 0; i < gTmp[now].size(); i++)
        {
            ll next = gTmp[now][i];
            if(se.find(next)==se.end()) //mada yattenai
            {
                se.insert(next);
                qGraph.push(next);
                g[now].push_back(next);
            }
        }
    }
    
    for (int i = 0; i < q; i++)
    {
        ll p,x;
        cin>>p>>x;
        p--;
        pls[p]+=x;
    }

    queue<ll> qCalc;
    qCalc.push(0);
    while (qCalc.size()>0)
    {
        ll now = qCalc.front();
        qCalc.pop();
        ans[now]=pls[now];
        for (int i = 0; i < g[now].size(); i++)
        {
            ll next = g[now][i];
            qCalc.push(next);
            pls[next]+=pls[now];
        }

    }
    
    for (int i = 0; i < n; i++)
    {
        if(i>0) cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;
    
    return 0;
}

Measured memory_bytes: 35656
#include<stdio.h>
#define min(a,b) (a)<(b)?(a):(b)
int main(void)
{
  long long min=10000000000,n,a[100010],judge=1;
  scanf("%lld",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",&a[i]);
    min=min(min,a[i]);
  }

  while(judge){
    for(int i=0;i<n;i++){
      if(a[i]%min){
        a[i]=a[i]%min;
        min=min(min,a[i]);
      }
    }
    judge=0;
    for(int i=0;i<n;i++){
      if(a[i]%min){
        judge++;
      }
    }
  }
  printf("%lld",min);
  return 0;
}


Measured memory_bytes: 896
N,K = gets.split.map(&:to_i)
has = Array.new(N, false)
 
K.times {
  gets
  a = gets.split.map(&:to_i)
  a.each { |_a|
    has[_a-1] = true
  }
}
 
cnt = 0
#p has
has.each { |v|
  if v == false
    cnt += 1
  end
}
 
puts cnt

Measured memory_bytes: 14336
from math import ceil
from itertools import permutations

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

s = [a, b, c, d, e]

t = []
for i in permutations(list(range(5))):
    c = 0
    for j in range(4):
        c += ceil(s[i[j]] / 10) * 10
    c += s[i[4]]
    t.append(c)

print(min(t))


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x,y;
		while(true) {
			x=scan.nextInt();
			y=scan.nextInt();
			if(x==0&&y==0)break;
			if(x<y)System.out.println(x+" "+y);
			else System.out.println(y+" "+x);
		}
		scan.close();
	}

}


Measured memory_bytes: 34412
#if defined(LOCAL)
#define PROBLEM_NAME "c"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ii = pair<int,int>; using lu = unsigned long long; using l = long long;
using vs = vector<string>; using vii = vector<ii>;
using vl = vector<l>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));

void solve(istream& cin, ostream& cout) {
  l n; cin >> n;
  vl v(n); F(i, 0, n) cin >> v[i];
  l t = 0;
  bool ok = v[0] == 0;
  l z = 0;
  B(i, 0, n) {
    if (v[i] > t - 1) {
      z += v[i];
    }
    ok = ok and (v[i] >= t - 1);
    t = v[i];
  }
  if (not ok) z = -1;
  cout << z << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 1792
#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 <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int N, t;
  cin >> N;
  vector<int> a(N, -1);
  for (int i = 0; i < N; i++)
  {
    cin >> t;
    a.at(t - 1) = i + 1;
  }
  for (auto aa : a)
  {
    cout << aa << " ";
  }
  cout << endl;
}


Measured memory_bytes: 3196
while 1:
	W, H = map(int,raw_input().split(" "))
	if W == H == 0: 
		break
	field = [[c for c in raw_input()] for _ in range(H)]
	secret = [0, ""]
	for j in range(H):
		for i in range(W):
			if not field[j][i].isdigit():
				continue
			pre = left = top = ""
			if i > 0 and field[j][i-1].isdigit() and field[j][i-1] != "0":
				left = field[j][i-1]
			if j > 0 and field[j-1][i].isdigit() and field[j-1][i] != "0":
				top = field[j-1][i]
			if len(left) == len(top):
				pre = left if left > top else top
			else :
				pre = left if len(left) > len(top) else top
			field[j][i] = pre + field[j][i]
			length = len(field[j][i])
			if length > secret[0]:
				secret[1] = field[j][i]
				secret[0] = length
			elif length == secret[0] and field[j][i] > secret[1]:
				secret[1] = field[j][i]
	print secret[1]

Measured memory_bytes: 4308
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
const int N = 1e6 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
//int dx[] = {1, 0, -1, 0};
//int dy[] = {0, 1, 0, -1}; //4 Direction
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction


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

  int n;
  cin >> n;
  string s;
  cin >> s;  
  int l = 0 , r = n-1 , cnt = 0;
  while (l < r)
  {
    if(s[l] == 'R'){ 
      l++;
      continue;
    }
    if(s[r] == 'W'){
      r--;
      continue;
    }
    cnt++;
    l++ , --r;
  }
  printf("%d\n" , cnt);


  return 0;
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NW = Console.ReadLine().Split(' ').Select(s=>int.Parse(s)).ToArray();
            var N = NW[0];
            var W = NW[1];
            var wvs = new List<int[]>();
            for(var i=0;i<N;i++)
            {
                wvs.Add(Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray());
            }
            var dp = new long[110, 100010];
            Action<int, int, long> chmax =
            (i1, i2, val) =>
            {
                if (dp[i1,i2] < val) dp[i1,i2] = val;
            };

            for(var i=0;i<N;i++)
            {
                for(var sumW=0; sumW <= W; sumW++)
                {
                    if(0<=sumW-wvs[i][0])
                    {
                        chmax(i + 1, sumW, dp[i, sumW - wvs[i][0]] + wvs[i][1]);
                    }
                    chmax(i + 1, sumW, dp[i, sumW]);
                }
            }
            Console.WriteLine(dp[N, W]);
        }

    }
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)
int n1000,n100,n10,n1,n10000;
long sum=0;

int main(void){
  int a,b;
  string s,ans="Yes";

  cin>>a>>b>>s;
  r(i,s.size()){
    if(s.at(a)!='-'){ans="No";break;}
    if(i!=a){
      if(s.at(i)=='-'){ans="No";break;}
    }
  }
  cout<<ans<<endl;

return 0;}


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

int main() {
    int n;
    cin >> n;
    switch(n % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        return 0;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        return 0;
    case 3:
        cout << "bon" << endl;
        return 0;
    }
}


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

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

  vector<int> city(N, 0);
  for (int i = 0; i < M; i++)
  {
    int a, b;
    cin >> a >> b;
    city.at(a - 1)++;
    city.at(b - 1)++;
  }
  for (int i : city)
  {
    cout << i << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N=25004,K=403,M=1000000007;
using namespace std;
int n,k,m,x,fi,ls,occ[K],
ans,h[K],
s1[N][K],s2[N][K],f1[N],f2[N];
bool fl;
inline int ksm(long long x,int t){
	int y=1;
	for(;t;t>>=1)
	t&1?y=y*x%M:0,x=x*x%M;
	return y;
}
inline void sol(int f[N][K],int*g){
	for(int i=0;i<=n;i++){
		for(int j=0;j<=k;j++)h[j]=0;
		if(i)
		for(int j=i>1;j<k;j++)
		if(x=f[i-1][j])
		h[j]=(h[j]-(k-j-1ll)*x)%M,h[j+1]=(h[j+1]+1ll*(k-j)*x)%M;
		for(int j=k-1;j>=!!i;j--)
		(h[j]+=h[j+1])%=M,
		(f[i][j]+=h[j])%=M,
		(g[i]+=f[i][j])%=M;
	}
}
int main(){
	scanf("%d%d%d",&n,&k,&m);
	for(int i=1;i<=m;i++){
		scanf("%d",&x);
		if(occ[x])
		fi=fi?fi:i,ls=max(ls,occ[x]);
		if(ls+k==i)fl=1;
		occ[x]=i;
	}
	if(!fl){
		if(fi){
			s1[0][fi-1]=s2[0][m-ls]=1;
			sol(s1,f1),sol(s2,f2);
			for(int i=0;i<=n-m;i++)
			ans=(ans+1ll*f1[i]*f2[n-m-i])%M;
		}
		else{
			s1[0][0]=1;
			sol(s1,f1);
			for(int i=0;i<=n;i++)
			for(int j=m;j<k;j++)
			s2[i][j]=s1[i][j];
			sol(s2,f2);
			ans=f2[n];
			for(int i=k;i>k-m;i--)
			ans=1ll*ans*ksm(i,M-2)%M;
		}
	}
	printf("%d",((ksm(k,n-m)*(n-m+1ll)-ans)%M+M)%M);
}

Measured memory_bytes: 79104
loop do
  line = gets.chomp.split
  h = line[0].to_i
  w = line[1].to_i

  break if h == 0 && w == 0

  for i in 1..h
    for j in 1..w
      if (i+j) % 2 == 0
        print '#'
      else
        print '.'
      end
    end
    puts
  end

  puts
end

Measured memory_bytes: 6112
#include <stdio.h>

int main()
{
	int a, b, c, tmp;
	scanf("%d%d%d", &a, &b, &c);
	if (b<a) {
		tmp = a;
		a = b;
		b = tmp;
	}
	if (c<b) {
		tmp = b;
		b = c;
		c = tmp;
	}
	if (b < a) {
		tmp = a;
		a = b;
		b = tmp;
	}

	printf("%d", b + a);


	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef set<int> si;
typedef multiset<int> mi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;
 
int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	//ofstream cout ("fileName.txt");
	//ifstream cin ("fileName.txt");
 	
	ll n;
	cin>>n;
	
	int length=0;
	for(int k=10; k>=1; k/=2)
		while(26*(pow(26,length+k)-1)/(25)<n) 
			length+=k;
			
	++length;
	
	n-=(pow(26,length)-1)/25;
	
	string s="";
	
	while(length--) {
		s+='a'+char(n%26);
		n/=26;
	}
	
	reverse(s.begin(),s.end());
	cout<<s<<"\n";

	return 0;
}


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

using namespace std;

long long N, X;

long long solve (long long A, long long B)
{
    if (A == B) return A;
    if (A < B)
    {
        ///(A, B) -> (A, B - A) cu 2A
        long long steps = (B - 1) / A;
        return 2LL * A * steps + solve (A, B - 1LL * steps * A);
    }
    ///(A, B) -> (A - B, B) cu 2B
    long long steps = (A - 1) / B;
    return 2LL * B * steps + solve (A - 1LL * steps * B, B);
}

void Ans (long long val)
{
    printf ("%lld\n", val);
    exit (0);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%lld %lld", &N, &X);
if (2LL * X == N) Ans (3LL * X);
if (X <= N - X) Ans (X + (N - X) + X + X + solve (X, N - 2LL * X));
Ans (X + (N - X) + solve (X, N - X));
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll x, k, d; cin >> x >> k >> d;
    if(0<abs(x)){
        ll nk = min(abs(x)/d, k);
        x = abs(x)-nk*d;
        k -= nk;
    }
    x = abs(abs(x)-k%2*d);
    cout << x << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)

int main() {
	double t1[] = {35.5, 37.5, 40, 43, 50, 55, 70};
	double t2[] = {71, 77, 83, 89, 105, 116, 148};
	string s[] = {"AAA", "AA", "A", "B", "C", "D", "E"};
	double a, b;
	while(cin >> a >> b) {
		bool f = 1;
		rep(i,7) {
			if(t1[i] > a && t2[i] > b) {
				cout << s[i] << endl;
				f = 0;
				break;
			}
		}
		if(f) cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
using System;
 
namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            var ticket = new [] { 6000, 4000, 3000, 2000 };
            for(int i = 0; i < 4; ++i) {
                var input = Console.ReadLine().Split();
                Console.WriteLine(ticket[input[0][0] - '1'] * int.Parse(input[1]));
            }
        }
    }
}

Measured memory_bytes: 11732
def main():
  from collections import Counter
  n = int(input())
  s = input()
  mod = 10**9+7
  c = Counter(s)
  cv = list(c.values())
  cl = len(cv)
  ans = 1
  for i in range(cl):
    ans *= (cv[i]+1)
  print((ans-1)%mod)
main()

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

const int N = 1e5 + 5;
typedef long long LL;

int n, x;
struct node {
	int b, l, r;
} t[N];
LL l, r, mid, sum[N], suf[N];

LL calc(node a) {
	return (x - a.b)*a.r + a.b*a.l;
}

bool check(LL s) {
	LL ans = -1e10;
	int k = s/x, r = s - k*x;
	if(k >= n) return true;
	for(int i = 1; i <= n; i++) {
		if(i <= k) ans = max(ans, sum[k + 1] - calc(t[i]) + t[i].b*t[i].l + suf[k + 2] + ((r >= t[i].b) ? t[i].r : t[i].l)*(r - t[i].b));
		else ans = max(ans, sum[k] + suf[k + 1] + t[i].b*t[i].l + ((r >= t[i].b) ? t[i].r : t[i].l)*(r - t[i].b));
	}
	return ans >= 0;
}

bool cmp(node a, node b) {
	return calc(a) > calc(b);
}

signed main() {
	cin>>n>>x;
	for(int i = 1; i <= n; i++)
		cin>>t[i].b>>t[i].l>>t[i].r, r += t[i].b;
	sort(t + 1, t + n + 1, cmp);
	for(int i = 1; i <= n; i++) sum[i] = sum[i - 1] + calc(t[i]) - t[i].b*t[i].l;
	for(int i = n; i; i--) suf[i] = suf[i + 1] - t[i].b*t[i].l;  
	while(l < r) {
		mid = (l + r)>>1;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	cout<<l<<endl;
	return 0;
}

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

using namespace std;

int main(void){
  int a, b;
  cin >> a >> b;
  
  if(a % 3 == 0) cout << "Possible" << endl;
  else if(b % 3 == 0) cout << "Possible" << endl;
  else if((a+b) % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

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

    string ans;
    rep(i, n) {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
a, b, c, d = gets.strip.split.map(&:to_i)

all = b - a + 1
c_mul = b / c - (a - 1) / c
d_mul = b / d - (a - 1) / d
lcm = c.lcm(d)
lcm_mul = b / lcm - (a - 1) / lcm

puts all - (c_mul + d_mul - lcm_mul)

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main()
{
	int n, m, s;
	int **matrix, *vector;
	cin >> n >> m;
	matrix = new int*[n];
	vector = new int[m];

	for(int i=0; i<n; ++i)
	{
		matrix[i] = new int[m];
		for(int j=0; j<m; ++j)
			cin >> matrix[i][j];
	}
	for(int i=0; i<m; ++i)
		cin >> vector[i];

	for(int i=0; i<n; ++i)
	{
		s = 0;
		for(int j=0; j<m; ++j)
			s+=matrix[i][j]*vector[j];
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3148
#include<iostream>
#include <algorithm>
using namespace std;
int main(void) {
	int A,B,M;
     cin >> A>> B>>M;
    int A_i[A],B_i[B];
    int min_A=1000000,min_B=1000000;
    int x_i,y_i,c_i;
    int money_min,money;
    for(int i=0;i<A;i++){
      cin >> A_i[i];
      if(min_A>A_i[i])min_A=A_i[i];
      //cout << A_i[i];
    }
    for(int i=0;i<B;i++){
      cin >> B_i[i];
      if(min_B>B_i[i])min_B=B_i[i];
      //cout << B_i[i];
    }
    money_min=min_A+min_B;
    for(int i=0;i<M;i++){
      cin >> x_i>>y_i>>c_i;
      money=A_i[x_i-1]+B_i[y_i-1]-c_i;
      //cout <<"koko"<<endl;
      if(money_min>money)money_min=money;
    }  
    cout << money_min<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

const int N=200005;
int BIT[N];

void bit_add(int BIT_t,int BIT_a,int BIT_n){//place,add,n
	for(int BIT_i=BIT_t+1;BIT_i<=BIT_n;BIT_i+=(BIT_i&(-BIT_i))){
		BIT[BIT_i-1]+=BIT_a;
	}
}

void bit_init(int BIT_n,int *BIT_a){//配列ごと加算
	for(int BIT_i=0;BIT_i<BIT_n;BIT_i++){
		bit_add(BIT_i,BIT_a[BIT_i],BIT_n);
	}
}

int bit_sum(int BIT_t){
	int BIT_s=0;
	for(int BIT_i=BIT_t+1;BIT_i!=0;BIT_i-=(BIT_i&(-BIT_i))){
		BIT_s+=BIT[BIT_i-1];
	}
	return BIT_s;
}

long long int t[N][2];
vector<pair<long long int,int> > v;

int main(){
	int n,m;
	int i,j,k;
	long long int a,b,c;
	long long int s=0;
	cin>>n>>m;
	v.push_back(make_pair(0,0));
	for(i=0;i<n;i++){
		cin>>a;
		t[i+1][0]=t[i][0]+a-m;
		v.push_back(make_pair(t[i+1][0],i+1));
	}
	sort(v.begin(),v.end());
	for(i=0;i<v.size();i++){
		a=v[i].second;
		t[a][1]=i;
	}
	for(i=0;i<=n;i++){
		s+=bit_sum(t[i][1]);
		bit_add(t[i][1],1,n+1);
	}
	cout<<s<<endl;
	return 0;
}


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

int main ()
{
  int N;
  string S;
  cin >> N;
  cin >> S;
  int count = 0;
  for (int i = 0; i < N; i++)
  {
    if (S[i] == 'A')
    {
      if (i == N -1) break;
      if (S[i+1] == 'B')
      {
        if (i==N-2) break;
        if (S[i+2] == 'C') count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
use std::io::*;

fn main() {
  let input = {
    let mut buf = vec![];
    stdin().read_to_end(&mut buf);
    unsafe { String::from_utf8_unchecked(buf) }
  };
  let mut lines = input.splitn(2, '\n');

  let (n, m, d) = {
    let line = lines.next().unwrap();
    let mut iter = line.split(' ').map(|s| s.parse().unwrap());

    (iter.next().unwrap(), iter.next().unwrap(), iter.next().unwrap())
  };

  if n < d && m < d { println!("0"); return }

  let mut chars = lines.next().unwrap().bytes();

  let mut table = vec![0; m];
  let mut cnt = 0;

  for _ in 0..n {
    let mut x = 0;

    for (ch, y) in chars.by_ref().zip(table.iter_mut()) {
      if ch == b'.' {
        x += 1;
       *y += 1;
      }
      else {
        if  x >= d { cnt +=  x - d + 1; }
        if *y >= d { cnt += *y - d + 1; }
        x = 0;
       *y = 0;
      }
    }

    if x >= d { cnt += x - d + 1; }
  }

  for y in table {
    if y >= d { cnt += y - d + 1; }
  }

  println!("{}", cnt);
}



Measured memory_bytes: 5028
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    x = li()
    for i in range(len(x)):
        if x[i] == 0:
            print(i+1)


main()




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

int main(){
	int N;
	cin >> N;
	vector<pair<string,int>> track(N);
	for(int i=0;i<N;i++){
		cin >> track[i].first >> track[i].second;
	}
	string X;
	cin >> X;
	
	int ans=0;
	bool sleep=false;
	for(int i=0;i<N;i++){
		if(sleep)ans+=track[i].second;
		if(track[i].first==X)sleep=true;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import Data.Bits

main = do
    [a, b] <- map read . words <$> getLine :: IO [Int]
    putStrLn $ show $ xor (foldr xor 0 [((a-1) `div` 4) * 4..(a-1)]) (foldr xor 0 [(b `div` 4) * 4..b])

Measured memory_bytes: 508
#include <stdio.h>
#include <math.h>
int main(void){
  int N;
  long long a[100010];
  int i;
  long long prod=1;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%lld",&a[i]);
  }
  int zero=0;
  for(i=0;i<N;i++){
    if(a[i]==0){
      zero++;
    }
    if(zero>0){
      printf("0\n");
      return 0;
  }
  }
 for(int i=0;i<N;i++){
  if(a[i ] <=1000000000000000000/ prod ){
   prod *=a[i];
   }else{
     printf("-1\n");
     return 0;
  }
}
printf("%lld\n",prod );
  return 0;
}

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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    string s, t;
    cin >> s >> t;

    LL ls = s.size(), lt = t.size();

    if(ls < lt)
        return cout << "LESS\n", 0;
    if(ls > lt)
        return cout << "GREATER\n", 0;

    for(LL i = 0; i < ls; i++){
        if(s[i] > t[i])
            return cout << "GREATER\n", 0;
        if(s[i] < t[i])
            return cout << "LESS\n", 0;
    }

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



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

#define pb(x) push_back(x)
using vint = vector<int>;

auto getisprime(int n) {
    vint isprime(n + 1, true);
    isprime[0] = isprime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (isprime[i]) {
            for (int j = i * 2; j <= n; j += i) {
                isprime[j] = false;
            }
        }
    }
    return isprime;
}

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

    auto isprime = getisprime(200);
    vint exps;

    for (int p = 2; p < 200; p++) {
        if (!isprime[p])
            continue;
        int k = 0;
        for (int d = p; d <= n; d *= p) {
            k += n / d;
        }
        exps.pb(k);
    }

    int len = exps.size();
    int ans = 0;

    for (int i = 0; i < len; i++) {
        int a = exps[i];
        if (a >= 74)
            ans++;
        for (int j = i + 1; j < len; j++) {
            int b = exps[j];
            if (a >= 2 && b >= 24)
                ans++;
            if (a >= 24 && b >= 2)
                ans++;
            if (a >= 4 && b >= 14)
                ans++;
            if (a >= 14 && b >= 4)
                ans++;
            for (int k = j + 1; k < len; k++) {
                int c = exps[k];
                if (a >= 2 && b >= 4 && c >= 4)
                    ans++;
                if (a >= 4 && b >= 4 && c >= 4)
                    ans++;
                if (a >= 4 && b >= 4 && c >= 2)
                    ans++;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 256