akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <cmath>
#include <sstream>
#define F first
#define S second
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
bool deb(int x){cout<<x<<":ok"<<endl;return true;}
bool deb(){cout<<"ok"<<endl;return true;}
int main() {
	bool a[20][20]={};
	char e;
	while(cin>>e)
	{
		if(e=='1')a[0][0]=true;
				else a[0][0]=false;
		for(int x=0;x<8;x++)
		{
			for(int y=0;y<8;y++)
			{
				
				if(x==0&&y==0)continue;
				cin>>e;
				if(e=='1')a[y][x]=true;
				else a[y][x]=false;

			}
		}
		
		bool end=false;
		for(int x=0;x<8;x++)
		{
			for(int y=0;y<8;y++)
			{
				if(a[x][y]&&a[x+1][y]&&a[x][y+1]&&a[x+1][y+1])
				{
					cout<<"A"<<endl;
					end=true;
				}
				if(a[x][y]&&a[x][y+1]&&a[x][y+2]&&a[x][y+3])
				{
					cout<<"B"<<endl;
					end=true;
				}
				if(a[x][y]&&a[x+1][y]&&a[x+2][y]&&a[x+3][y])
				{
					cout<<"C"<<endl;
					end=true;
				}
				if(a[x+1][y]&&a[x][y+1]&&a[x+1][y+1]&&a[x][y+2])
				{
					cout<<"D"<<endl;
					end=true;
				}
				if(a[x][y]&&a[x+1][y]&&a[x+1][y+1]&&a[x+2][y+1])
				{
					cout<<"E"<<endl;
					end=true;
				}
				if(a[x][y]&&a[x][y+1]&&a[x+1][y+1]&&a[x+1][y+2])
				{
					cout<<"F"<<endl;
					end=true;
				}
				if(a[x+1][y]&&a[x+2][y]&&a[x][y+1]&&a[x+1][y+1])
				{
					cout<<"G"<<endl;
					end=true;
				}

				if(end)break;
			}
			if(end)break;
		}


	}
}

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

typedef long long ll;

ll h,cnt,ans;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>h;
    cnt=1;
    while(h){
        ans+=cnt;
        h>>=1;
        cnt<<=1;
        
    }
    cout<<ans<<endl;

    return 0;
}

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

int main() {

  long long N,K,R,S,P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;


  vector<char> player;
  for(long long i=0;i<N;i++){
    if(T[i] == 'r'){
      if(i >= K && player[i-(K)] == 'p'){
        player.push_back('a');
      }else{
        player.push_back('p');
      }
    }else if(T[i] == 's'){
      if(i >= K && player[i-(K)] == 'r'){
        player.push_back('a');
      }else{
        player.push_back('r');
      }
    }else if(T[i] == 'p'){
      if(i >= K && player[i-(K)] == 's'){
        player.push_back('a');
      }else{
        player.push_back('s');
      }
    }
  }

  long long score=0;
  for(int i=0;i<player.size();i++){
    if(player[i] == 'r'){
      score += R;
    }else if(player[i] == 's'){
      score += S;
    }else if(player[i] == 'p'){
      score += P;
    }
  }

  cout << score << endl;

}


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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define int ll
#define tcase int t; cin>> t; for( ; t; --t)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

int32_t main(){
	fastio;
	cin>> n;
	vi d(n);
	int ans = 0;
	for(int i = 0; i<n; ++i) cin>> d[i];
	for(int i = 0; i<n; ++i){
		for(int j = i+1; j<n; ++j) ans += d[i]*d[j];
	}
	cout<< ans<< endl;
	return 0;
}


Measured memory_bytes: 3572
package main

import (
  "bufio"
  "fmt"
  "os"
  "sort"
  "strconv"
  "strings"
)

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var t int
  t,_ = strconv.Atoi(NextLine())
  return t
}
func NextInts() (int,int,int) {
  var s []string = strings.Split(NextLine()," ")
  var n,c,k int
  n,_ = strconv.Atoi(s[0])
  c,_ = strconv.Atoi(s[1])
  k,_ = strconv.Atoi(s[2])
  return n,c,k
}

func main() {
  var n,c,k int = NextInts()
  var t []int
  t = make([]int,n)
  for i:=0;i<n;i++ {
    t[i] = NextInt()
  }
  sort.Ints(t)
  var m,x int = 0,0
  var i,j int = 0,0
  for {
    if t[j] <= t[i]+k {
      j++
      if j == n {
        m++
        break
      }
      x++
      if x == c {
        i = j
        m++
        x = 0
      }
    } else {
      i = j
      m++
      x = 0
    }
  }
  fmt.Println(m)
}

Measured memory_bytes: 5504
#include<stdio.h>
 #include<vector>
 #include<algorithm>
 using namespace std;
 typedef long long ll;
 int main()
 {
 int a, b, x, y;
 scanf("%d%d%d%d", &a, &b, &x, &y);
 printf("%lf %d\n", double(a)*double(b) / 2, x + x == a&&y + y == b);
 }

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	cin>>s;
	if(s=="SUN"){
		cout << 7;
	}
	else if(s=="MON"){
		cout << 6;
	}
	else if(s=="TUE"){
		cout << 5;
	}
	else if(s=="WED"){
		cout << 4;
	}
	else if(s=="THU"){
		cout << 3;
	}
	else if(s=="FRI"){
		cout << 2;
	}
	else {
		cout << 1;
	}
//SUN,MON,TUE,WED,THU,FRI,SAT 	
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    vector<pair<int,int> >v;
    for(int i=1;i<=n;i++){
        int a;
        cin>>a;
        v.push_back({a,i});
    }
    sort(all(v));
    for(auto i:v)
        cout<<i.second<<" ";

    return 0;
}


Measured memory_bytes: 4260
from collections import defaultdict, deque


N, *AB = map(int, open(0).read().split())
g = defaultdict(set)
edges = []
for a, b in zip(*[iter(AB)] * 2):
    a -= 1
    b -= 1
    g[a].add(b)
    g[b].add(a)
    edges.append((a, b))

q = deque([0])
visited = [False] * N
visited[0] = True
used = [0] * N
colors_cnt = 1
ans = {}
while q:
    v = q.popleft()
    color = 1
    for nv in g[v]:
        if visited[nv]:
            continue
        if color == used[v]:
            color += 1
        used[nv] = color
        ans[(min(v, nv), max(v, nv))] = color
        color += 1
        q.append(nv)
        visited[nv] = True
    colors_cnt = max(colors_cnt, color - 1)
print(colors_cnt)
[print(ans[(a, b)]) for a, b in edges]



Measured memory_bytes: 79480
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define BUF_SIZE 30

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

struct range {
    int64_t start;
    int64_t end;
};

int asc_by_end(const void *a1, const void *a2) {
    struct range *ra1 = (struct range*)a1;
    struct range *ra2 = (struct range*)a2;
    int64_t ans = ra1->end - ra2->end;
    if(ans<0) return -1;
    if(ans==0) return 0;
    return 1;
}

#define NUM_MAX 100000

int main(void) {
    int num = get_int();
    struct range ranges[NUM_MAX];
    int i;
    for(i = 0; i < num; i++) {
        int center, len;
        get_int2(&center, &len);
        ranges[i] = (struct range){center-len, center+len};
    }

    qsort(ranges, num, sizeof(struct range), asc_by_end);

    int64_t prev = ranges[0].end;
    int cnt = 1;
    for(i = 1; i < num; i++) {
        int64_t cur = ranges[i].end;
        if(prev > ranges[i].start) continue;
        cnt++;
        prev = cur;
    }
    printf("%d\n", cnt);
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        int[,] c = new int[3,3];

        for(int i=0; i<3; i++){
            string[] input = Console.ReadLine().Split(' ');
            for(int j=0; j<3; j++){
                c[i,j] = int.Parse(input[j]);
            }
        }

        bool yes = false;

        for(int a1=0; a1<=c[0,0]; a1++){
            int b1 = c[0,0] - a1;
            int b2 = c[0,1] - a1;
            int b3 = c[0,2] - a1;
            int a2 = c[1,0] - b1;
            int a3 = c[2,0] - b1;

            if(c[1,1]==a2+b2 && c[1,2]==a2+b3 && c[2,1]==a3+b2 && c[2,2]==a3+b3){
                Console.WriteLine("Yes");
                yes = true;
                break;
            }
        }
        if(!yes){
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b,k;
	cin>>a>>b>>k;
	for(int i=0;i<k;i++){
		a=a/2;
		b=b+a;
		swap(a,b);
	}
	if(k%2!=0){
		swap(a,b);
	}
	cout << a << " " << b;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(m), b(m);
	for (int i = 0; i < m; i++) cin >> a.at(i) >> b.at(i);

	vector<int> num(n);
	for (int i = 0; i < m; i++) {
		num.at(a.at(i) - 1)++;
		num.at(b.at(i) - 1)++;
	}

	for (int i = 0; i < n; i++) {
		cout << num.at(i) << endl;
	}

 	return 0;
 }

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

#const
dxdy=((1,0),(0,1))
#my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())
from math import gcd

#your code here!
def resolve():
    N,M=pin()
    A=(pin())
    t=(N)-sum(A)
    #print(t)
    ans=t if t>-1 else -1
    print(ans)

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """41 2
5 6"""
        output = """30"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10 2
5 6"""
        output = """-1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """11 2
5 6"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3"""
        output = """9"""
        self.assertIO(input, output)


if __name__ == "__main__":
    #unittest.main()


    resolve()



Measured memory_bytes: 16884
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<int,int> P;

int dh[2][9] = {{2,1,0,-1,-2,1,0,-1,0},{2,1,0,-1,-2,1,0,-1,0}};
int dw[2][9] = {{1,1,1,1,1,2,2,2,3},{-1,-1,-1,-1,-1,-2,-2,-2,-3}};

int cost[2][60][30];
int w, h;
int brd[60][30];
vector<P> st,goal;

void func(int hh, int ww, int ty){
	priority_queue<P, vector<P>, greater<P> > que;
	que.push(P(0,hh*10000+ww*100+ty));
	while(true){
		if(que.size() == 0) break;
		P q = que.top();
		que.pop();
		int H = q.second/10000, W = (q.second%10000)/100, TY = q.second%100;
		if(cost[TY][H][W] < q.first) continue;
		rep(i,9){
			if(0>H+dh[TY][i]||H+dh[TY][i]>=h||0>W+dw[TY][i]||W+dw[TY][i]>=w) continue;
			if(brd[H+dh[TY][i]][W+dw[TY][i]] == INF) continue;
			if(cost[(TY+1)%2][H+dh[TY][i]][W+dw[TY][i]] <= cost[TY][H][W]+brd[H+dh[TY][i]][W+dw[TY][i]]){
				continue;
			}
			cost[(TY+1)%2][H+dh[TY][i]][W+dw[TY][i]] = cost[TY][H][W]+brd[H+dh[TY][i]][W+dw[TY][i]];
			que.push(P(cost[(TY+1)%2][H+dh[TY][i]][W+dw[TY][i]],(H+dh[TY][i])*10000+(W+dw[TY][i])*100+(TY+1)%2));
		}
	}
}

void solve(){
	st.clear(); goal.clear();
	rep(i,2) rep(j,60) rep(k,30) cost[i][j][k] = INF;
	rep(i,h) rep(j,w){
		char tmp; cin >> tmp;
		if(tmp == 'X') brd[i][j] = INF;
		else if(tmp == 'T'){
			brd[i][j] = 0;
			goal.push_back(P(i,j));
		} else if(tmp == 'S'){
			brd[i][j] = 0;
			rep(k,2) cost[k][i][j] = 0;
			st.push_back(P(i,j));
		} else{
			brd[i][j] = tmp-'0';
		}
	}
	rep(i,st.size()){
		rep(j,2){
			func(st[i].first,st[i].second,j);
		}
	}
	int ans = INF;
	rep(i,goal.size()){
		rep(j,2){
			ans = min(ans,cost[j][goal[i].first][goal[i].second]);
		}
	}
	if(ans == INF) ans = -1;
	cout << ans << endl;
}

int main(){
	while(true){
		cin >> w >> h;
		if(w == 0 && h == 0) break;
		solve();
	}
}

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

vector<vector<int>> adj;
vector<int> memo;

int dfs(int x)
{
	if (memo[x] != -1)
		return memo[x];
		
	memo[x] = 0;
	for (int a : adj[x])
		memo[x] = max(memo[x], dfs(a) + 1);
	return memo[x];
}

int main()
{
	int N, M;
	cin >> N >> M;
	adj.resize(N);
	memo.resize(N, -1);
	for (int i = 0; i < M; ++i)
	{
		int x, y;
		cin >> x >> y;
		adj[--x].push_back(--y);
	}
	
	int ans = 0;
	for (int i = 0; i < N; ++i)
		ans = max(ans, dfs(i));
	cout << ans << '\n';
}


Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int R, G, B, N; cin >> R >> G >> B >> N;

	ll cnt = 0LL;
	for (int r = 0; R*r <= N; r++) {
		for (int g = 0; G*g <= N; g++) {
			ll num = N - R * r - G * g;
			if (0 <= num && num%B==0) cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = Counter(list(map(int, input().split())))
edge = []
for key, value in a.items():
    if value > 1:
        edge.append(key)
    if value > 3:
        edge.append(key)
edge.sort()
print(edge[-1] * edge[-2] if len(edge) > 1 else 0)

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

int n;
string s;
string nd;
int res;

bool Check()
{
    int pnt = 0;
    for (int i = 0; i < n && pnt < 3; i++)
        if (s[i] == nd[pnt]) pnt++;
    return pnt >= 3;
}

int main()
{
    cin >> n;
    cin >> s;
    nd.resize(3);
    for (nd[0] = '0'; nd[0] <= '9'; nd[0]++)
        for (nd[1] = '0'; nd[1] <= '9'; nd[1]++)
            for (nd[2] = '0'; nd[2] <= '9'; nd[2]++)
                if (Check()) res++;
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var s = ReadLine();
            var N = s.Length;
            if (N == 2)
            {
                if (s[0] == s[1])
                    WriteLine("1 2");
                else
                    WriteLine("-1 -1");
                return;
            }
            for (var i = 0; i < N - 2; ++i)
            {
                if (s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2])
                {
                    WriteLine($"{i + 1} {i + 3}");
                    return;
                }
            }
            WriteLine("-1 -1");
        }
    }
}

Measured memory_bytes: 26100
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		System.out.println(scan.nextLine().substring(0, 1)
				+ scan.nextLine().substring(1, 2)
				+ scan.nextLine().substring(2, 3));

	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef string str;
const long long INF = INT64_MAX / 2;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve() {
    ll N;
    cin >> N;
    str s;
    cin >> s;
    vll w(N), b(N), WW(N), BB(N);
    for(int i = 0; i < N; i++) {
        w[i] = (s[i] == '.' ? 1 : 0);
        b[i] = (s[i] == '#' ? 1 : 0);
    }
    reverse(w.begin(), w.end());
    partial_sum(w.begin(), w.end(), WW.begin());
    reverse(WW.begin(), WW.end());
    partial_sum(b.begin(), b.end(), BB.begin());
    ll ans = INF;
    for(int i = 0; i < N; i++) {
        ans = min(ans, BB[i] + WW[i] - 1);
    }
    cout << ans << endl;
}

int main() {
    FIO;
    solve();
    return 0;
}

Measured memory_bytes: 6804
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int S=2501;
int M_MAX=200;
int main()
{
  int n,q,qq,i,j,k,t,t1,t2,u,u1,u2,l,r,res;
  int co[M_MAX][S][26];
  string s;
  char c,b;
  bool f;
  cin >> n >> s >> q;
  for(i=0;i<M_MAX;i++)
    fill(co[i][0],co[i][0]+26,0);
  for(i=0;i<n;i++){
    t=i/(S-1);
    u=i%(S-1);
    copy(co[t][u],co[t][u]+26,co[t][u+1]);
    co[t][u+1][(int)(s[i]-'a')]++;
  }
  for(i=0;i<q;i++){
    cin >> qq;
    if(qq==1){
      cin >> j >> c;
      j--;
      b=s[j];
      s[j]=c;
      t=j/(S-1);
      u=j%(S-1);
      for(k=u+1;k<S;k++){
        co[t][k][(int)(b-'a')]--;
        co[t][k][(int)(c-'a')]++;
      }
    }else{
      cin >> l >> r;
      l--;
      r--;
      res=0;
      t1=l/(S-1);
      u1=l%(S-1);
      t2=r/(S-1);
      u2=r%(S-1);
      if(t1==t2){
        for(k=0;k<26;k++)
          if(co[t1][u2+1][k]-co[t1][u1][k]>0)
            res++;
      }else{
        for(k=0;k<26;k++){
          if(co[t1][S-1][k]-co[t1][u1][k]>0){
            res++;
            continue;
          }
          f=0;
          for(j=t1+1;j<t2;j++){
            if(co[j][S-1][k]-co[j][0][k]>0){
              res++;
              f=1;
              break;
            }
          }
          if(f==1)
            continue;
          if(co[t2][u2+1][k]-co[t2][0][k]>0){
            res++;
          }
        }
      }
      cout << res << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 54648
N,M = map(int,input().split())

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

sumvote = sum(A)


count = 0
for i in A:
    if i >= -(-sumvote//(4*M)):
        count += 1
        
if count >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
from collections import deque
n = int(input())
A = deque(map(int, input().split()))

cnt = 0
flag_empty = False
flag_end = False
if not 1 in A:
  cnt = -1
else:
  for i in range(1, n+1):
    if not i in A:
      cnt += len(A)
      break
    while 1:
      a = A.popleft()
      if len(A) == 0: 
        flag_empty = True
        break
      if a != i:
        cnt += 1
      else:
        break
    if flag_empty:
      break
   
print(cnt)

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

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

    vector<long long int> a(k);
    for(int i=0; i<k; i++){
        cin >> a[i];
    }
    reverse(a.begin(),a.end());

    if(a[0] != 2){
        cout << -1 << endl;
        return 0;
    }

    long long int nmax = 2, nmin = 2;
    for(int i=0; i+1<k; i++){
        //cout << nmax << " " << nmin << endl;
        long long int x = (nmax + a[i] - 1) / a[i+1] * a[i+1];
        long long int y = ((nmin - 1) / a[i+1] + 1) * a[i+1];

        if(x < y){
            cout << -1 << endl;
            return 0;
        }
        
        nmax = x;
        nmin = y;
    }
    nmax += a[k-1] - 1;
    cout << nmin << " " << nmax << endl;
    return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;
string s,t;
int a,b;
string u;

bool check(string s,string u){
    if(s.size()!=u.size())return false;

    for(int i=0;i<s.size();i++){
        if(s[i]!=u[i])return false;
    }
    return true;

}
void input(){

    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
}

void solve(){

    if(check(s,u))a--;

    else    b--;
    cout<<a<<" "<<b<<endl;

}



int main(){

    input();
    solve();

    return 0;

}
/*


*/


Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  if (a > b)
    cout << "a > b" << endl;
  else if (a < b)
    cout << "a < b" << endl;
    else 
      cout << "a == b" << endl;
  
  return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
typedef long long ll;
using namespace std;

const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main()
{
    int K;
    string S;
    cin >> K >> S;
    if(S.size() <= K) cout << S << endl;
    else
    {
        for(int i = 0; i < K; i++)
        {
            cout << S.at(i);
        }
        cout << "..." << endl;
    }
    return(0);

 }

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
signed main()
{
  int n,k,i;
  cin>>n>>k;
  int mi[n+2],ma[n+2];
  mi[1]=0;
  for(i=2;i<=n+1;i++)
  mi[i]=mi[i-1]+i;
  ma[n+1]=n;
  for(i=n;i>=1;i--)
  ma[i]=ma[i+1]+i;
  int ans=0;
  for(i=k;i<=n+1;i++)
  {
    ans+=ma[n+2-i]-mi[i]+1;
    ans%=mod;
  }
  cout<<ans;
  return 0;
}

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

using namespace std;

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


Measured memory_bytes: 1792
#include<cstdio>
const int MAXN = 3 * (1E5);
int a[MAXN + 5];
inline int min(int a, int b) {
	return a<b?a:b;
}
int main() {
	int N, A, B;
	scanf("%d%d%d", &N, &A, &B);
	if( A + B > N+1 || 1ll * A * B < N ) {
		printf("%d\n", -1);
		return 0;
	}
	for(int i=1;;i++) {
		int lim = min(i*B, N);
		for(int j=lim;j>(i-1)*B;j--)
			a[lim - j + (i-1)*B + 1] = j;
		if( lim == N ) break;
	}
	if( B == N ) {
		for(int i=1;i<N;i++)
			printf("%d ", a[i]);
		printf("%d ", a[N]);
		return 0;
	}
	for(int i=(N-1)/B+1;i>=1;i--) {
		int lim = min(i*B, N);
		if( N-(i-1)*B + (i-1) >= A ) {
			int cnt = A - (N - lim + (i-1));
			for(int j=1;j<=(i-1)*B;j++)
				printf("%d ", a[j]);
			for(int j=(i-1)*B+1;j<=lim-cnt;j++)
				printf("%d ", a[j]);
			for(int j=lim;j>=lim-cnt+1;j--)
				printf("%d ", a[j]);
			for(int j=lim+1;j<=N;j++)
				printf("%d ", j);
			break;
		}
	}
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),tot=0;
    if(n&1)tot=(n-1)*(n-2)/2-(n-1)/2+n-1;
	else tot=n*(n-1)/2-n/2;
	pr2(tot);
    if(n&1)
    {
    	for(int i=1;i<n;i++)pr1(i),pr2(n);
    	n--;
    }
    for(int i=1;i<=n;i++)
    {
    	for(int j=i+1;j<=n;j++)
    	{
    		if(i+j==n+1)continue;
    		pr1(i),pr2(j);
    	}
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long gcd(int a, int b)
{
    if(a % b == 0)return b;
    return gcd(b, a % b);
}

int main(){
    long long int a,b,i=1,co=0,co2=0;
    int c,d;
    cin>>a>>b>>c>>d;
    long long int e;
    e = (long long)c * (long long)d / gcd(c, d);
    cout<< b-a+1-(b/c-(a-1)/c+b/d-(a-1)/d)+(b/e-(a-1)/e)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

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

    int res = 0;

    string back = "";
    int left = 0;
    int size = 1;
    while(left + size <= S.size()) {
        if (back != S.substr(left, size)) {;
            ++res;
            back = S.substr(left, size);
            left += size;
            size = 1;
        } else {
            ++size;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1010;

int f(int x){
if(x%100==0)return 1+f(x/100);
else return 0;
}

int main(){

int n,d;
cin>>d>>n;

for(int i=1;i;i++){
    if( f(i)==d )n--;
    if(!n){
        cout<<i<<endl;
        break;
    }
}


return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <algorithm>
typedef long long ll;
using namespace std;


set<ll> prime_factor(ll n) {
  set<ll> ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret.insert(i);
      n /= i;
    }
  }
  if(n != 1) ret.insert(n);
  return ret;
}

ll disjoint_set_of_common_divisors(ll a, ll b) {
  set<ll> aa = prime_factor(a);
  set<ll> bb = prime_factor(b);
  set<ll> merged;
  set_intersection(aa.begin(), aa.end(), bb.begin(), bb.end(), inserter(merged, merged.end()));
  return merged.size() + 1;
}

int main() {
  ll a, b;
  cin >> a >> b;
  cout << disjoint_set_of_common_divisors(a, b);
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
void dfs(int s,int dp[],int visited[],vector<int> adj[])
{
    visited[s]=1;
    for(int i=0;i<adj[s].size();i++)
    {
        if(visited[adj[s][i]]==0)
        {
            dfs(adj[s][i],dp,visited,adj);
        }
        dp[s]=max(dp[s],1+dp[adj[s][i]]);
    }   
}
int main()
{
    int n,e;
    cin>>n>>e;
    vector<int> adj[n];
    for(int i=0;i<e;i++)
    {
        int s,d;
        cin>>s>>d;
        adj[s-1].push_back(d-1);
    }
    int dp[n]={0};
    int visited[n]={0};
    for(int i=0;i<n;i++)
    {
        if(visited[i]==0)
        {
            dfs(i,dp,visited,adj);
        }
    }
    int res=INT_MIN;
    for(int i=0;i<n;i++)
    {
        res=max(res,dp[i]);
    }
    cout<<res;
    return 0;
}

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

using namespace std;

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

int main(){
   
   int n,k,a,ans = 0;
   cin >> n >> k;
   vector<int> vec;

   rep(i,n){
      cin >> a;
      vec.push_back(a);
   }

   sort(vec.rbegin(), vec.rend());

   rep(i,k){
      ans += vec[i];
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second

using namespace std;
typedef long long ll;
const int MAXN = 200005;
inline int readint()
{
	int res = 0, f = 1;
	char c = 0;
	while(!isdigit(c))
	{
		c = getchar();
		if(c=='-')
			f = -1;
	}
	while(isdigit(c))
		res = res*10+c-'0', c = getchar();
	return res*f;
}
int n,a[MAXN],b[MAXN];
inline int calc(int x)
	{ return (x+n-1)%n+1; }
priority_queue<pii> pq;

int main()
{
	n = readint();
	for(int i = 1; i<=n; i++)
		a[i] = readint();
	for(int i = 1; i<=n; i++)
		b[i] = readint();
	for(int i = 1; i<=n; i++)
		if(b[i]<a[i])
		{
			cout << -1 << endl;
			return 0;
		}
	for(int i = 1; i<=n; i++)
		if(a[i]<b[i])
			pq.push(mp(b[i],i));
	ll ans = 0;
	while(!pq.empty())
	{
		pii now = pq.top();
		pq.pop();
		int id = now.se;
		int dt = b[calc(id-1)]+b[calc(id+1)];
		//cout << "test " << id << " " << dt << endl;
		if(b[id]-a[id]<dt)
		{
			cout << -1 << endl;
			return 0;
		}
		ans += (b[id]-a[id])/dt;
		b[id] = a[id]+(b[id]-a[id])%dt;
		if(a[id]<b[id])
			pq.push(mp(b[id],id));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
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; }

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

map<int, int> m;

void calcPrime(ll p){
    int rn = sqrt(p);
    int i = 2, cnt = 0;
    while(i <= rn){
        if (p % i == 0){
            p /= i;
            m[i]++;
        } else{
            i++;
        }
    }
    if (p != 1){
        m[p]++;
    }
}

int main(){
    ll n, p;
    cin >> n >> p;
    if (n == 1){
        cout << p << endl;
        return 0;
    }
    calcPrime(p);
    ll ans = 1;
    for(auto mi = m.begin(); mi != m.end(); mi++){
        ans *= pow(mi->first,mi->second / n);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cctype>
#include<algorithm>
using namespace std;
const int N=1e5;
int n,a[N+1];
int read()
{
	int ret=0;
	char c=getchar();
	while(!isdigit(c)) {
		c=getchar();
	}
	while(isdigit(c)) {
		ret=ret*10+c-'0';
		c=getchar();
	}
	return ret;
}
int main()
{
	n=read();
	for(int i=1;i<=n;++i) {
		a[i]=read();
	}
	sort(a+1,a+n+1,[](const int x,const int y) {
		return x>y;
	});
	int x=0;
	while((x<n)&&(x+1<=a[x+1])) {
		++x;
	}
	if(a[x]-x&1) {
		puts("First");
	} else {
		int y=x;
		while((y<n)&&(x<=a[y+1])) {
			++y;
		}
		puts((y-x)&1?"First":"Second");
	}
	return 0;
}


Measured memory_bytes: 1920
from math import fabs


def main():
    N, K = map(int, input().split())
    h = [int(input()) for _ in range(N)]

    h.sort()
    min = fabs(h[0] - h[N-1])
    for i in range(N - K + 1):
        min_temp = fabs(h[i] - h[i + K - 1])
        if min > min_temp:
            min = min_temp
    print(int(min))


if __name__ == "__main__":
    main()


Measured memory_bytes: 7512
//By MagicSpark
/*Prob:AGC030C Main Idea:Create Status:1000pts*/
#include<bits/stdc++.h>
using namespace std;
inline int calc(int i,int j,int n,int k){int c=n+(i+j)%n;if(c>=k)c-=n;return c+1;}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int k;cin>>k;if(k==1){cout<<"1\n1\n";return 0;}
	int n=(k+3)/4*2;
	cout<<n<<endl;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(i&1){cout<<calc(i,j,n,k)<<(j==n-1?'\n':' ');}else{cout<<1+(i+j)%n<<(j==n-1?'\n':' ');}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
using namespace std;
const int inf=1e9+10;
const int mod=1e9+7;
const int maxn=1e5+10;
int n,x[110];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		cin>>x[i];
	}
	int ans=inf;
	for(int i=1;i<=100;i++){
		int ret=0;
		for (int j = 0; j < n; ++j)
		{
			ret+=(x[j]-i)*(x[j]-i);	
		}
		ans=min(ans,ret);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
//
// Created by hide on 2020/05/15.
//

//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード(アルファベット順,bits/stdc++.hは使わない派閥)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N){
        cin>>a[i];
    }

    int answer=0;
    REP(i, N){
        while(a[i]%2==0){
            a[i]/=2;
            answer+=1;
        }
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
  long x = 0;
  long times = 0;
  scanf("%ld",&x);
  times = (x / 11)*2;
  if(x % 11 != 0 && x % 11 <= 6){
    times += 1;
  }else if(x % 11 >= 7){
    times += 2;
  }
  
  printf("%ld",times);
  return 0;
}
    
  
  

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
int digit(int a){
    int count = 0;
    for (int i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }     
    }
    return count;
}
//pow(x,n) == x^n

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

int n,k,sum = 0;
cin >> n >> k;
vector <int> l(n);
rep(i,n) cin >> l[i];
Sort(l);

for (int i = n-1; i > n-1-k; i--)
{
    sum += l[i];
}
cout << sum << endl;



//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
    char op;
    int a,b;
    int sum;
    
    while(1){ 
        
        scanf("%d %c %d",&a,&op,&b);
    
    
        switch(op){
        
            case '+':
                        sum = a + b;
                        break;
            case '-':
                        sum = a - b;
                        break;
            case '*':
                        sum = a * b;
                        break;
            case '/':
                        sum = a / b;
                        break;
        }  
        
        if(op == '?'){
            break;
        }
    
        printf("%d\n",sum);
    }
    return 0;
    
}

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

int main( ) {
  double ax,ay,bx,by,cx,cy,dx,dy;
  while(cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy) {
    if(fabs((ax-bx)*(cx-dx)+(ay-by)*(cy-dy))<1e-10) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 1216
#include <stdio.h>

int ar[17] = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289}, n, cnt;

int saiki(int a) {
  if(!a) {
    ++cnt;
    return 0;
  }
  int i;
  for(i = 0; i * ar[a] <= n; ++i) {
    n -= ar[a] * i;
    saiki(a - 1);
    n += ar[a] * i;
  }
  return 0;
}

int main(void) {
  int i, j, k;
  while( 1 ) {
    cnt = 0;
    scanf("%d", &n);
    if(!n) break;
    saiki(16);
    printf("%d\n", cnt);
  }
  return 0;
}


Measured memory_bytes: 2668
#include <bits/stdc++.h>
//#include "Local_Debug.h"
using namespace std;
#define Endl endl
typedef long long ll;
const int MAXN = (int)2e5 + 5;
ll n, m, t, a[MAXN];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n)
	{
		for (ll i = 1; i <= n&&cin >> a[i]; ++i);
		sort(a + 1, a + 1 + n);
		double tmp = a[1];
		for (ll i = 2; i <= n; ++i)
			tmp = (tmp + double(a[i])) / 2.0;
		cout << tmp << endl;
	}
}
/*
2
3 4

3
500 300 200

5
138 138 138 138 138
*/

Measured memory_bytes: 256
A,B,C,D=list(map(int,input().split()))
x=max(C,D)
y=min(C,D)
if x%y==0:
    gcd=C*D//y
else:
    while x%y!=0:
        z=x%y
        x=y
        y=z
    gcd=C*D//z
print(B-A+1-(B//C-(A-1)//C+B//D-(A-1)//D-B//gcd+(A-1)//gcd))

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

int main()
{
	while (true)
	{
		int n;
		cin >> n;
		if (n == 0)
		{
			return 0;
		}
		vector<int> v(n);
		long double sum = 0;
		long double beki = 0;
		for (int i = 0; i < n; i++)
		{
			cin >> v[i];
			sum += v[i];
			beki += v[i] * v[i];
		}
		long double average = sum / n;
		long double deviation = 0;


		cout << fixed << sqrtl(beki/n - (sum/n * sum/n)) << endl;
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i <= b; i++)


int main() {
	int a; 
	int b;
	cin >> a >> b;
	int summation {1};
	int result {0};
	while(summation < b){
		summation += a - 1;
		++result;
	}
	cout << result << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int W, H, N;
	cin >> W >> H >> N;
	int MX = 0;
	int mx = W;
	int MY = 0;
	int my = H;
	vector<int>X(N);
	vector<int>Y(N);
	vector<int>A(N);
	rep(i, N) {
		cin >> X[i] >> Y[i] >> A[i];
	}
	rep(i, N) {
		if (A[i] == 1) {
			MX = max(MX, X[i]);
		}
		if (A[i] == 2) {
			mx = min(mx, X[i]);
		}
		if (A[i] == 3) {
			MY = max(MY, Y[i]);
		}
		if (A[i] == 4) {
			my = min(my, Y[i]);
		}
	}
	if (my >= MY && mx >= MX) {
		cout << (my - MY)* (mx - MX) << endl;
	}
	else {
		cout << 0 << endl;
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<int> l(0);
    int input = 0;
    for(int i=0;i<n;i++){
        cin >> input;
        l.push_back(input);
    }
    sort(l.begin(),l.end());
    int ans = 0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k = j+1 ; k<n ; k++){
                int a = l.at(i);
                int b = l.at(j);
                int c = l.at(k);
                if(a+b <= c) continue;
                if(a<(b+c) && ( b<(c+a) && c<(a+b))) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    string s; cin >> s;
    int cnt=s.size()-1;
    while(cnt>0){
        if(s[cnt-6]=='d' && s[cnt-5]=='r' && s[cnt-4]=='e' && s[cnt-3]=='a' && s[cnt-2]=='m' && s[cnt-1]=='e' && s[cnt]=='r'
        ) cnt -= 7;

        else if(s[cnt-5]=='e' && s[cnt-4]=='r' && s[cnt-3]=='a' && s[cnt+-2]=='s' && s[cnt-1]=='e' && s[cnt]=='r'
        ) cnt -= 6;

        else if (s[cnt-4]=='d' && s[cnt-3]=='r' && s[cnt-2]=='e' && s[cnt-1]=='a' && s[cnt]=='m' ||
                 s[cnt-4]=='e' && s[cnt-3]=='r' && s[cnt-2]=='a' && s[cnt-1]=='s' && s[cnt]=='e'
        ) cnt -= 5;

        else break;
    }
    cout << (cnt==-1 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
    int A,B;
    cin >> A >> B;
    int ans=0;

    for(int i=0;i<2;i++){
       if(A>=B){
            ans+=A;
          A--;
        }
        else {
            ans+=B;
            B--;
        }
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i,c,d;
    string s;
    cin>>s;
    a=s[0]-'0';b=s[1]-'0';c=s[2]-'0';d=s[3]-'0';
    if(a+b+c+d==7) cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
    else if(a-b-c-d==7) cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
    else if(a+b+c-d==7) cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
    else if(a+b-c+d==7) cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
    else if(a+b-c-d==7) cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
    else if(a-b-c+d==7) cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
    else if(a-b+c-d==7) cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
    else if(a-b+c+d==7) cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n";
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
void bl(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void bl2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class DRGBTriplets {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n;
	    string s;
	    in >> n >> s;

	    map<char, ll> mp;
	    for(int i=0; i<n; i++){
	        mp[s[i]]++;
	    }

	    ll res = mp['R'] * mp['G'] * mp['B'];

	    for(int i=0; i<n-2; i++){
	        for(int k=i+2; k<n; k++){
                if((k-i)%2 != 0) continue;
                int j = (k+i)/2;
                if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) res--;
	        }
	    }

	    out << res << endl;
	}
};


int main() {
	DRGBTriplets solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3644