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


Measured memory_bytes: 2044
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

using namespace std;

typedef long long ll;

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

    int p, q, r;
    cin >> p >> q >> r;
    int result = 0;
    int result1 = p + q;
    int result2 = q + r;
    int result3 = p + r;
    if (result1 < result2) {
        result = result1;
    } else {
        result = result2;
    }
    if (result < result3) {
        cout << result << endl;
    } else {
        cout << result3 << endl;
    }
}


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

// ABC046A - RGB Cards
int main(){
  int r, g, b;
  cin >> r >> g >> b;

  cout << ((r * 100 + g * 10 + b) % 4 == 0 ? "YES" : "NO") << endl;
  return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main(){
  int n, x, t; cin >> n >> x >> t;
  cout << (int)ceil((double)n/x)*t << endl;
}


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

int main(){
  int N,K,C;
  string S;
  cin >> N >> K >> C;
  cin >> S;

  int before[N+2];
  int after[N+2];
  for(int i=0;i<N+2;i++){
    before[i]=0;
    after[i]=0;
  }
  for(int i=1;i<N+1;i++){
    if(S[i-1]=='o'){
      before[i]+=before[i-1]+1;
      for(int j=i;i<j+C&&i<N+1;i++){
        before[i+1]=before[i];
      }
      //cout << i << endl;
    }else {
      before[i]=before[i-1];
    }
  }
  for(int i=N;i>0;i--){
    if(S[i-1]=='o'){
      after[i]+=after[i+1]+1;
      for(int j=i;i>j-C&&i>0;i--){
        after[i-1]=after[i];
      }
    }else {
      after[i]=after[i+1];
    }
  }
  for(int i=1;i<N+1;i++){
        //cout << before[i-1] << " " << after[i+1] << " " << i << endl;
    if(before[i-1]+after[i+1]<K){
        cout << i << endl;
    }
  }
}


Measured memory_bytes: 3332
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stdio.h>
typedef long long ll;
const int INF = 1e9+1;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;

int main() {
	int n;
	long long int tate = 0, yoko = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	sort(a.begin(), a.end(), greater<>());

	for (int i = 0; i < n-1; i++) {
		if (a.at(0) == a.at(1)) {
			tate = a.at(0);
			a.erase(a.begin(), a.begin() + 2);
			break;
		}
		else a.erase(a.begin());
	}
	if (tate == 0) {
		cout << 0 << endl;
		return 0;
	}
	int m = a.size();
	for (int i = 0; i <m ; i++) {
		if (a.at(0) == a.at(1)) {
			yoko = a.at(0);
			//a.erase(a.begin(), a.begin() + 2);
			break;
		}
		else a.erase(a.begin());
	}
	//cout << tate << " " << yoko << endl;
	cout << tate * yoko << endl;
	return 0;
}

Measured memory_bytes: 3780
n = int(input())
s = input()

alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
len_alpha = len(alpha)
len_s = len(s)
ss = []

for i in range(len_s):
    index_ss = (alpha.index(s[i])+n)%len_alpha
    ss += alpha[index_ss]
ans = "".join(ss)
print(ans)

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

int main(){
    int a[3], n, count=0;
    cin >> a[0] >> a[1] >> a[2] >> n;
    sort(a, a+3);
    for(int i=n/a[2];i>=0;i--){
        int N = n;
        N -= a[2] * i;
        for(int j=N/a[1];j>=0;j--){
            if((N-(a[1] * j))%a[0]==0){
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

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

void solve() {
    ll X;
    cin >> X;
    ll c = 1;
    ll a = 100;
    while(true) {
        a += (ll)(a * 0.01);
        if (X <= a) {
            cout << c << endl;
            return;
        }
        c++;
    }
}

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


Measured memory_bytes: 3600
#include<stdio.h>

int main(void)
{
	
	int W,H;	//????????¢????§??????§?¨????W,H???
	int x,y;	//?????????????????§?¨????x,y???
	int r;		//????????????
	
    scanf("%d %d %d %d %d",&W, &H, &x, &y, &r);
    
    if(x+r <= W && x-r >= 0 && y+r <= H && y-r >= 0)
    	printf("Yes\n");
    else
    	printf("No\n");
    return 0;
}

Measured memory_bytes: 584
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():

    class WeightedUnionFind():
        def __init__(self, n):
            self.nodes = [-1 for _ in range(n)]
            self.weight = [0] * n

        def get_root(self, x):
            if self.nodes[x] < 0:
                return x
            else:
                y = self.get_root(self.nodes[x])
                self.weight[x] += self.weight[self.nodes[x]]
                self.nodes[x] = y
                return y

        def unite(self, x, y, w):
            w += self.weight[x]-self.weight[y]
            root_x = self.get_root(x)
            root_y = self.get_root(y)
            if root_x != root_y:
                # 大きい木の方につないだほうが計算量が減る
                if self.nodes[root_x] > self.nodes[root_y]:
                    root_x, root_y = root_y, root_x
                    w *= -1
                self.nodes[root_x] += self.nodes[root_y]
                self.nodes[root_y] = root_x
                self.weight[root_y] = w

        def diff(self, x, y):
            return self.weight[y] - self.weight[x]

        def same(self, x, y):
            return get_root(x) == get_root(y)
    N, M = MI()
    uf = WeightedUnionFind(N)
    get_root, unite, nodes, diff, same = uf.get_root, uf.unite, uf.nodes, uf.diff, uf.same
    for _ in range(M):
        l, r, d = MI_()
        d += 1
        if same(l, r) and diff(l, r) != d:
            print("No")
            exit()
        else:
            unite(l, r, d)
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 10268
# import numpy as np
import sys
from collections import defaultdict
import math
import itertools
import bisect
from copy import deepcopy
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000)

H , W = map(int,readline().split())
board = ["#" for _ in range(W+2)]
for  _ in range(H):
    board += ["#"] + list(readline().rstrip()) + ["#"]
board += ["0" for _ in range(W+2)]
white = 0
for tile in board:
    if tile == ".":
        white += 1
H , W = H+2 , W+2
visit = [-1 for _ in range(W*H)]
D = [ [1,0] , [0,1] , [-1,0] , [0,-1] ]

def bfs():
    root = W + 1
    q = deque([root])
    visit[root] = 1
    while q :
        index = q.popleft()

        if index == (H-2)*W+W-2:
            break

        x =  index // W
        y =  index % W
        for d in D :
            dx , dy = d
            X , Y = x+dx , y+dy
            if 1<=X and X<= H-1 and 1<=Y and Y <= W-1:
                dot = X*W+Y
                if visit[dot] == -1 and board[dot] == ".":
                    visit[dot] = visit[index] + 1
                    q.append(dot)

    length = visit[(H-2)*W+W-2]
    if  length == -1:
        return -1
    else:
        return white - length


def solve():
    print(bfs())

if __name__ == "__main__":
    solve()
    # print(board)

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define ll long long


using namespace std;

const int MAXN = (int) 1e5;

pair <int, int> v[MAXN + 1];

int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    ll N;
    ios::sync_with_stdio(false);
    cin >> N;
    for(ll n = 1; n <= 3500; n++)
      for(ll h = 1; h <= 3500; h++) {
          if(4 * h * n > N * (n + h) && (N * h * n) % (4 * h * n - N * (n + h)) == 0) {
              cout << h << " " << n << " " << (N * h * n) / (4 * h * n - N * (n + h));
              return 0;
          }
      }
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int ans = 0;
void dfs(int n,int s,int d){
	if (s < 0) return; 
	if (s == 0 and n == 0){ // 
		ans++;
		return;
	}
	if (n == 0) return;	
	d++;
	if (d == 10)return;
	//???????????´???
	dfs(n-1,s-d,d);
	//?????°????????£?????´???
	dfs(n,s,d);
return;
}

int main(){
	while(1){
		ans = 0;
		int n,s; cin >> n >> s;
		if (n + s == 0)	break;
		dfs(n,s,-1);
		cout << ans << endl;
	}

return 0;
}

Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()

	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextInt64() int64 {
	sc.Scan()

	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextF64() float64 {
	sc.Scan()

	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	d := nextInt()
	x := nextInt()

	var a []int
	var cnt int
	for i := 0; i < n; i++ {
		a = append(a, nextInt())
	}

	for _, val := range a {
		for i := 1; i <= d; i += val {
			cnt++
		}
	}
	fmt.Println(cnt + x)
}


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

template<typename T, typename E, typename F, typename G, typename H>
class LazySegmentTree {
  int n, height;
  F f; G g; H h; const T ti; const E ei;
  vector<T> dat; vector<E> laz; vector<int> highest;

  void propagate(int k) {
    if(laz[k] != ei) {
      laz[2*k] = h(laz[2*k],laz[k]); laz[2*k+1] = h(laz[2*k+1],laz[k]);
      dat[k] = g(dat[k],laz[k],n/highest[k]);
      laz[k] = ei;
    }
  }
  inline void recalc(int k) {
    while(k >>= 1) dat[k] = f(g(dat[2*k],laz[2*k],n/highest[2*k]),g(dat[2*k+1],laz[2*k+1],n/highest[2*k+1]));
  }
  inline void thrust(int k) {
    for(int i = height; i > 0; i--) propagate(k >> i);
  }
public:
  LazySegmentTree(int _n, F f, G g, H h, T ti, E ei): f(f), g(g), h(h), ti(ti), ei(ei) {
    n = 1; height = 0;
    while(n < _n) n <<= 1, height++;
    dat.assign(2*n,ti); laz.assign(2*n,ei); highest.assign(2*n,0);
    int c = 1;
    for(int i = 1; i < 2*n; i++) {
      if(c*2 <= i) c <<= 1;
      highest[i] = c;
    }
  }
  void set(int k, T x) {
    dat[k+n] = x;
  }
  void build() {
    for(int i = n-1; i >= 0; i--) {
      dat[i] = f(dat[2*i],dat[2*i+1]);
    }
  }
  void update(int a, int b, const E x) {
    thrust(a += n); thrust(b += n-1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) laz[l] = h(laz[l],x), ++l;
      if(r & 1) --r, laz[r] = h(laz[r],x);
    }
    recalc(a); recalc(b);
  }
  T query(int a, int b) {
    thrust(a += n); thrust(b += n-1);
    T l = ti, r = ti; b++;
    while(a < b) {
      if(a & 1) l = f(l,g(dat[a],laz[a],n/highest[a])), a++;
      if(b & 1) b--, r = f(g(dat[b],laz[b],n/highest[b]),r);
      a >>= 1; b >>= 1;
    }
    return f(l,r);
  }
};

int main(){
  ll n, q;
  cin >> n >> q;
  auto f = [](ll a, ll b){return min(a,b);};
  auto g = [](ll a, ll b, int l){return min(a,b);};
  auto h = [](ll a, ll b) {return min(a,b);};
  LazySegmentTree<ll,ll,decltype(f),decltype(g),decltype(h)> lsth(n,f,g,h,INF,INF), lstw(n,f,g,h,INF,INF);
  rep(i,n) lsth.set(i,n-1), lstw.set(i,n-1);
  lsth.build(); lstw.build();
  ll ans = (n-2) * (n-2);
  rep(i,q) {
    ll t, x, y;
    cin >> t >> x;
    x--;
    if(t == 1) {
      y = lstw.query(x,x+1);
      ans -= y - 1;
      lsth.update(0,y,x);
    } else {
      y = lsth.query(x,x+1);
      ans -= y - 1;
      lstw.update(0,y,x);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 23748
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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 N; cin >> N;
  vi a(N); REP(i,N) cin >> a[i];

  int cnt[100002] = {0};
  REP(i,N) {
    cnt[a[i]]++;
  }

  int ans = 0;
  FOR(X,1,100001) {
    ans = max(ans, cnt[X-1]+cnt[X]+cnt[X+1]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n, k;
    cin >> n >> k;
    ll A[n+1];
    rep(i,1,n+1)    cin>>A[i];
    ll vis[n+1] = {0};
    V v;
    ll st=1;
    ll cycle=0;
    ll beg;
    ll cnt=1;
    while(1){
        if(vis[st]){
            beg = st;
            cycle = (cnt - vis[st]); 
            break;
        }
        vis[st] = cnt;
        v.pb(st);
        cnt++;
        st = A[st];
    }
    if(k <= vis[beg]){
        cout << v[k] << endl;
    }
    else{
        k -= (vis[beg]-1);
        k %= cycle;
        cout << v[vis[beg]+k-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 8456
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);

void solve(){
    ll n; cin >> n;
    ll sum = 0;
    for(int i=1; i<=n; i++){
        if(i%3 ==0 && i%5==0){
            continue;
        }
        else if(i%3 == 0){
            continue;
        }
        else if(i%5==0){
            continue;
        }
        else{
            sum += i;
        }
    }
    cout << sum << endl;
}

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

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N,D;
    cin >> N >> D;
    vector<P> cor(N);
    REP(i,N){
        ll X,Y;
        cin >> X >> Y;
        cor[i] = mp(X,Y);
    }
    ll count = 0;
    REP(i,N){
        if(cor[i].F*cor[i].F+cor[i].S*cor[i].S <= D*D)count++;
    }
    cout << count << "\n";
}

Measured memory_bytes: 6360
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
string str[305];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin >> str[i];
	}
	int ans=0;
	for(int i=0;i<n;i++){
		bool flag=true;
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				if(str[j][k]!=str[k][j])flag=false;
			}
		}
		if(flag)ans+=n;
		for(int j=0;j<n;j++){
			str[j]=str[j].substr(n-1,1)+str[j].substr(0,n-1);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
n = input()

ans = 0
for i in range(0, int(n) + 1):
    r3 = i % 3
    r5 = i % 5

    if not (((r3 == 0) and (r5 == 0)) or (r3 == 0) or (r5 == 0)):
        ans += i

print(ans)


Measured memory_bytes: 9168
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long X = sc.nextLong();

        long[] positionArr = new long[N];
        long[] cumulativeSum = new long[N+1];

        for (int i = 0; i < N; i++) {
            positionArr[i] = sc.nextLong();
            cumulativeSum[i+1] = cumulativeSum[i] + positionArr[i];
        }

        long sum = X * N + 5 * cumulativeSum[N];

        for (int i = 1; i < N; i++) {
            long cost = X * i + 5 * (cumulativeSum[N] - cumulativeSum[N - i]);
            for (int j = 5, k = N - i; k >= 0; j += 2, k -= i) {
                if (cost > sum) {
                    break;
                }
                cost += j * (cumulativeSum[k] - cumulativeSum[Math.max(k - i, 0)]);
            }
            sum = Math.min(sum, cost);
        }
        System.out.println(sum + X * N);

    }
}


Measured memory_bytes: 90652
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long now = 100l;
    long year = 0l;
    while(now < x){
      year++;
      now += now / 100;
    }
    System.out.println(year);
  }
}


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

int main() {
	int n;cin>>n;
  	int t,x,y,dx=0,dy=0,dt=0;
  	for(int i=0;i<n;i++){
    	cin>>t>>x>>y;
      	if(abs(dx-x)+abs(dy-y)>(t-dt) || (abs(dx-x)+abs(dy-y)-(t-dt))%2!=0){
        	cout<<"No"<<endl;
          	return 0;
        }else{
        	dx=x; dy=y; dt=t;
        }
    }
	cout<<"Yes"<<endl;
}


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

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

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

int main()
{
  long long H, N;
  cin >> H >> N;
  vector<long long> A(N), B(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A[i] >> B[i];
  }
  vector<vector<long long>> dp(N + 1, vector<long long>(H + 1, INF));
  dp[0][0] = 0;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j <= H; j++)
    {
      chmin(dp[i + 1][j], dp[i][j]);

      chmin(dp[i + 1][j], dp[i + 1][max(0LL, j - A[i])] + B[i]);
    }
  }
  cout << dp[N][H] << endl;
}

Measured memory_bytes: 78592
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;

using namespace std;
using Graph = vector<vector<int>>;
Graph G;

/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}

int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/
int main()
{
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	/*
	swap(a, b);
	swap(a, c);

	ll N, K;
	cin >> N >> K;
	int ans = 0;
	while (N>=0)
	{
		ans = abs(N - K)%mod;
		if (ans >= N)
		{
			ans = N;
			break;
		}
		else if (ans == 0)
		{
			break;
		}
		N = ans;
		
	}

	cout << ans << endl;*/
	int N, M;
	cin >> N >> M;
	vector<int> data(N);
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> data[i];
		sum += data[i];
	}
	int cnt = 0;
	for (auto& i : data)
	{
		if (i >= sum / (4 * M)) cnt++;
	}
	
	if (cnt>=M)
	{
		cout << "Yes" << endl;

	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a,b,c,n[3][3];cin>>a>>b>>c;n[0][0]=a,n[0][1]=b,n[1][1]=c;
    n[2][0]=n[0][0]+n[0][1]-n[1][1];
    n[1][2]=n[2][0]+n[0][0]-n[1][1];
    n[0][2]=n[0][0]+n[1][1]-n[1][2];
    n[1][0]=n[0][1]+n[0][2]-n[2][0];
    n[2][1]=n[0][2]+n[1][2]-n[2][0];
    n[2][2]=n[0][2]+n[1][1]-n[2][1];
    cout<<n[0][0]<<" "<<n[0][1]<<" "<<n[0][2]<<endl;
    cout<<n[1][0]<<" "<<n[1][1]<<" "<<n[1][2]<<endl;
    cout<<n[2][0]<<" "<<n[2][1]<<" "<<n[2][2]<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]

ans = 0
res = 0
for i in range(n):
   sum_a1 = sum(a[0][0:i + 1])
   sum_a2 = sum(a[1][i:n])
   res = max(res, sum_a1 + sum_a2)
print(res)

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

using namespace std;

#define 	fo(i,n)		for(i=0; i<n; i++)
#define		Fo(i,k,n)	for(i=k; k<n? i<n: i>n; k<n? i+=1 : i-=1)
#define 	ll 			long long
#define 	vi 			vector<int>
#define		vll			vector<long long int>
#define		unsi		unordered_set<int>
#define		unsll		unordered_set<long long int>
#define 	pb 			push_back
#define 	sortall(x) 	sort(all(x)) 
#define 	all(x) 		x.begin(), x.end()
#define		rall(x)		x.rbegin(), x.rend()
#define 	si(x) 		scanf("%d",&x)
#define 	sl(x) 		scanf("%lld",&x)
#define 	ss(s) 		scanf("%s",s)
#define 	pi(x) 		printf("%d\n",x)
#define 	pl(x) 		printf("%lld\n",x)
#define 	ps(s) 		printf("%s\n",s)
#define 	deb(x) 		cout << #x << "=" << x <<"\n"
#define 	deb1(x, y) 	cout << #x << "=" << x << "," << #y << "=" << y <<"\n"


// atcoder 173a soln

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

		int N;
		cin >> N;
        int change, give=1000; 
		
  		if (N == 0){
        	cout << 0 <<"\n";
        }

  		else if (N <= 1000){
			change = 1000 - N;
			cout << change <<"\n";
		}

		else{
			for(int i=2; give<N; i++){
				give = give + 1000;	
			}
			change = give - N;
			cout << change <<"\n";
		}
	return 0;
}


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

int main(){
	int N, K;
	cin >> N >> K;
	int l[N], i;
	for(i=0; i<N; i++){
		cin >> l[i];
	}
	int a, j;
	for(i=0; i<N-1; i++){
		for(j=0; j<N-1; j++){
			if(l[j] < l[j+1]){
				a = l[j];
				l[j] = l[j+1];
				l[j+1] = a;
			}
		}
	}
	
	int sum=0;
	for(i=0; i<K; i++){
		sum += l[i];
	}
	
	cout << sum << endl;
	
	return 0;
}


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

int main(){
    int n;
    while(true){
        cin >> n;
        if(n == 0)
            break;

        vector<int> k(n);
        for(int i=0; i<n; i++)
            cin >> k[i];
        string s;
        cin >> s;

        int pos = 0;
        for(int i=0; i<s.size(); i++){
            for(int j=0; j<k[pos]; j++){
                if(s[i] == 'a')
                    s[i] = 'Z';
                else if(s[i] == 'A')
                    s[i] = 'z';
                else
                    s[i]--;
            }
            pos = (pos+1)%n;
        }
        cout << s << endl;
    }
  
    return 0;
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
  int n;
  float t, a;
  cin >> n >> t >> a;
  int h[n];
  rep(i,n) cin>>h[i];
  
  float min=100000;
  int ans=0;
  rep(i,n){
    float T=t-h[i]*0.006;
    if(min>abs(a-T)){
      min=abs(a-T);
      ans=i;
    }
  }
  cout << ans+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  while(true){
    int n = getInt();
    int p = getInt();
    int q = getInt();

    if(n+p+q == 0) break;

    int dd = q - p + 1;
    vector<int> chk(dd, n);

    REP(i,n){
      int m = getInt();
      REP(j,m){
	int s = getInt() - p;
	int e = getInt() - p;
	while(s < e) chk[s++]--;
      }
    }

    int ans = 0;
    int cont = 0;
    REP(i,dd-1){
      //printf("%d: %d\n",i+p,chk[i]);
      if(chk[i] == 0){
	ans = max(ans, cont);
	cont= 0;
      }else{
	cont++;
      }
      if((i + p) % 100 == 59){
	i += 40;
      }
    }
    ans = max(ans, cont);
    print(ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, K;
int ans = 1;

int main()
{
	in >> N >> K;

	rep(i, N)
	{
		if (ans * 2 < ans + K) { ans *= 2; }
		else { ans += K; }
	}

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
'use strict'

const main = (input) => {
    const a = input.split('\n')[0].split(' ')[0]
    const b = input.split('\n')[0].split(' ')[1]
    if(a === b){
        console.log('H')
    }else{
        console.log('D')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 100001
#define dmp make_pair
#define dpb push_back
#define P pair<int,int>
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int dp[101][101][2][2];
int main(){
	int w, h;
	while(1){
		scanf("%d%d", &w, &h);
		if(!w)break;
		for(int i = 1;i <= w;i++){
			for(int j = 1;j <= h;j++){
				dp[i][j][0][0] = dp[i][j-1][0][0]+dp[i][j-1][1][0];
				dp[i][j][0][1] = dp[i-1][j][0][1]+dp[i-1][j][1][1];
				dp[i][j][1][0] = dp[i-1][j][0][1];
				dp[i][j][1][1] = dp[i][j-1][0][0];
				rep(x,2)rep(y,2)dp[i][j][x][y] = dp[i][j][x][y]%100000;
				dp[1][2][0][0] = dp[2][1][0][1] = 1;
				dp[1][2][1][1] = dp[2][1][1][0] = 1;
			}
		}
		int ans = 0;
		rep(i,2)ans += dp[w][h][0][i];
		printf("%d\n", ans%100000);
	}
	return 0;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int getsum(const vl& sum,int a,int b)
{
	int n=sum.size();
	if(n<=a)
		return b-a;
	else if(n<=b)
		return (sum[a]+b-n+MOD)%MOD;
	else
		return (sum[a]-sum[b]+MOD)%MOD;
}

int solve(int n)
{
	vl res(n),sum(n);
	res[n-1]=sum[n-1]=n;
	per(i,n-1){
		res[i]=res[i+1];
		res[i]+=getsum(sum,i+3,i+n+2);
		res[i]+=ll(n-1)*(n-1);
		res[i]%=MOD;
		sum[i]=(sum[i+1]+res[i])%MOD;
	}
	return res[0];
}

int main()
{
	for(int n;cin>>n&&n;){
		cout<<solve(n)<<endl;
	}
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 300003;

class dijkstra{ 
//0indexed 
public: 
	int v,startv; 
	vector<int> d; 
	vector<vector<pair<int,int> > >e; 

	void initsize(int n0){ 
		d.resize(n0); 
		for(int i=0;i<n0;i++)d[i]=INT_MAX; 
		vector<pair<int,int> > ep; 
		for(int i=0;i<n0;i++)e.push_back(ep); 
		v=n0; 
	} 

	void initstart(int s){ 
		startv=s;
		d[s]=0;
	}

	void make_edge(int x,int y,int cost){ 
		e[x].push_back(make_pair(y,cost)); 
		e[y].push_back(make_pair(x,cost)); 
	}

	void make_edgedir(int x,int y,int cost){ 
		e[x].push_back(make_pair(y,cost)); 
	}

	void calcdistance(){ 
		// <-cost,x> 
		//cost startv->x 
		priority_queue<pair<int,int> > q; 
		pair<int,int> p; 
		vector<bool> did; 
		for(int i=0;i<v;i++)did.push_back(false); 
		did[startv]=true; 
		for(int i=0;i<e[startv].size();i++){ 
			p.first=-e[startv][i].second; 
			p.second=e[startv][i].first; 
			q.push(p); 
		}
		while(q.size()!=0){
			pair<int,int> p;
			p=q.top();
			q.pop();
			int x,costsx;
			x=p.second;
			costsx=-p.first;
			if(did[x]==true)continue;
			did[x]=true;
			d[x]=costsx;
			for(int i=0;i<e[x].size();i++){
				p.first=-(d[x]+e[x][i].second);
				p.second=e[x][i].first;
				if(did[p.second]==false)q.push(p);
			}
		}
	}
};
int k;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	dijkstra di;
	cin>>k;
	di.initsize(k);
	FOR(i,1,k){
		di.make_edgedir(i,(i+1)%k,1);
		di.make_edgedir(i,i*10%k,0);
	}
	di.initstart(1);
	di.calcdistance();
	cout<<di.d[0]+1<<endl;
	return 0;
}


Measured memory_bytes: 7408
import sys
import math

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


n, d = List()
a = []
for _ in range(n):
    x, y = List()
    a.append(math.sqrt(x**2 + y**2))
a.sort()
c = 0
for i in a:
    if i <= d:
        c += 1
print(c)


Measured memory_bytes: 17712
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	string s;
	int ans = 0;
	vector<vector<int>> dp;
	vector<int> hoge;
	
	cin>>N;
	
	cin>>s;
	
	s += '0';
	
	for(int i = 0, c = 0; i < s.size(); i++){
		if(s[i] == '1') {
			c++;
		} else {
			hoge.push_back(c);
			c = 0;
		}
	}
	
	dp.resize(3, vector<int>(hoge.size()+1, -INF));
	
	dp[1][0] = 0;

	N = hoge.size();
	
	for(int i = 0; i < N; i++){
		if(i+1 < N && hoge[i+1] && hoge[i]) dp[0][i+1] = max(dp[0][i+1], dp[0][i] + hoge[i] - 1);
		if(i+1 < N && hoge[i+1]) dp[0][i+1] = max(dp[0][i+1], dp[1][i] + hoge[i]);
		if(i+1 < N && hoge[i+1]) dp[0][i+1] = max(dp[0][i+1], dp[2][i] + hoge[i]);
		
		dp[1][i+1] = max(dp[1][i+1], dp[0][i]);
		dp[1][i+1] = max(dp[1][i+1], dp[1][i]);
		dp[1][i+1] = max(dp[1][i+1], dp[2][i] + hoge[i]);
		
		if(hoge[i] >= 2) dp[2][i+1] = max(dp[2][i+1], dp[0][i]);
		if(hoge[i]) dp[2][i+1] = max(dp[2][i+1], dp[2][i] + hoge[i]-1);
		if(hoge[i]) dp[2][i+1] = max(dp[2][i+1], dp[1][i]);
		
		
	}
	
	ans = max(ans,*max_element(dp[0].begin(), dp[0].end()));
	ans = max(ans,*max_element(dp[1].begin(), dp[1].end()));
	ans = max(ans,*max_element(dp[2].begin(), dp[2].end()));
	
	cout<<ans<<endl;

	return 0;
}

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


int main(){
  long long int n; cin>>n;
  vector<long long int> a(5);
  cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
  sort(a.begin(),a.end());
 if(n%a[0]==0){
 cout<<5+n/a[0]-1<<endl;
 }else{
   cout<<5+n/a[0]<<endl;
 }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#pragma warning (disable: 4996)

long double Gauss(vector<vector<long double>>a, vector<long double>b) {
	int N = a.size();
	if (N == 1) return b[0] / a[0][0];

	vector<vector<long double>> c = a;
	vector<long double> d = b;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) c[i][j] = a[i][j] / a[i][0];
		d[i] = b[i] / a[i][0];
	}

	vector<vector<long double>> e(N - 1, vector<long double>(N - 1, 0));
	vector<long double> f(N - 1, 0);

	for (int i = 0; i < N - 1; i++) {
		for (int j = 0; j < N - 1; j++) {
			e[i][j] = c[i + 1][j + 1] - c[i][j + 1];
		}
		f[i] = d[i + 1] - d[i];
	}

	return Gauss(e, f);
}

vector<long double> Gauss_Erase(vector<vector<long double>> e, vector<long double>f) {
	int N = e.size(); vector<long double> res;

	for (int i = 0; i < N; i++) {
		long double T = Gauss(e, f);
		res.push_back(T);
		
		vector<vector<long double>> a(e.size() - 1, vector<long double>(e.size() - 1, 0));
		vector<long double> b(e.size() - 1, 0);
		
		for (int j = 0; j < N - 1 - i; j++) {
			for (int k = 0; k < N - 1 - i; k++) a[j][k] = e[j][k];
			b[j] = f[j] - T * e[j][e.size() - 1];
		}
		e = a;
		f = b;
	}

	reverse(res.begin(), res.end());
	return res;
}

vector<long double> getans(vector<pair<long double, long double>> J) {
	int N = J.size();
	vector<vector<long double>> a(N, vector<long double>(N, 0));
	vector<long double> b(N, 0);

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) a[i][j] = 1.0L * pow(J[i].first, 1.0L*(N - 1 - j));
		b[i] = J[i].second;
	}
	
	vector<long double> ret = Gauss_Erase(a, b);
	return ret;
}

bool different(vector<long double> A, vector<long double> B) {
	for (int i = 0; i < A.size(); i++) {
		if (fabs(A[i] - B[i]) > 1e-2) return true;
	}
	return false;
}

int solve(vector<long double> S) {
	int N = S.size() - 3;
	for (int i = 0; i <= N + 2; i++) {
		vector<long double> goal; bool flag = false;
		for (int j = 0; j <= N + 2; j++) {
			if (i == j) continue;
			vector<pair<long double, long double>> G;
			for (int k = 0; k <= N + 2; k++) {
				if (k != i && k != j) G.push_back(make_pair(1.0L * k + 1.0L, S[k]));
			}
			vector<long double> V = getans(G);
			if (goal.size() == 0) goal = V;
			else if (different(goal, V) == true) flag = true;
		}
		if (flag == false) return i;
	}
	return -1;
}

int main() {
	while (true) {
		int N; cin >> N; if (N == 0) break;
		vector<long double> A(N + 3, 0);
		for (int i = 0; i < N + 3; i++) cin >> A[i];

		int ans = solve(A);
		cout << ans << endl;
	}
	return 0;
}


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

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

  ll N; cin >> N;
  ll M; cin >> M;
  vector<ll> A(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());

  ll l = 0, r = A[N - 1] * 2 + 1;
  while (l + 1 < r) {
    ll m = (l + r) / 2;
    ll cnt = 0;
    for (int i = 0; i < N; i++) {
      cnt += (A.end() - lower_bound(A.begin(), A.end(), m - A[i]));
    }
    if (cnt >= M) {
      l = m;
    } else {
      r = m;
    }
  }

  vector<ll> SUM(N, 0);
  SUM[N - 1] = A[N - 1];
  for (int i = N - 2; i >= 0; i--) {
    SUM[i] = SUM[i + 1] + A[i];
  }

  ll ans = 0;
  ll mcnt = 0;
  for (int i = 0; i < N; i++) {
    ll temp = (A.end() - upper_bound(A.begin(), A.end(), l - A[i]));
    mcnt += temp;
    if (temp == 0) continue;
    ans += (A[i] * temp + SUM[N - temp]);
  }

  ans += (M - mcnt) * l;

  cout << ans << '\n';

  return 0;
}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (s); i <= (t); ++i)
#define repD(i,t,s) for(int i = (t); i >= (s); --i)
#define rep(i,n) repU(i,0,n - 1)
#define rep1(i,n) repU(i,1,n)
#define all(v) begin(v),end(v)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1) / (d) + 1)
#define parity(a,b) (((a)^(b)) & 1 ^ 1)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = (1 << 30) - 1;
const ll INF_64 = (1LL << 62) - 1;
const int MOD = 1e9 + 7;

ll n,s;

bool judge(ll b){
	ll t = n,p = 0;
	while(t){
		p += t % b;
		t /= b;
	}
	return p == s;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> n >> s;
	if(n >= s){
		if(n == s){
			cout << n + 1 << endl;
			return 0;
		}
		ll b = INF_64;
		for(ll d = 1; d * d <= n - s; ++d){
			if((n - s) % d) continue;
			ll a = (n - s) / d;
			if(judge(d + 1)) b = min(b,d + 1);
			if(judge(a + 1)) b = min(b,a + 1);
		}
		if(b < INF_64){
			cout << b << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}





Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
      Scanner scanner = new Scanner(System.in);
      String tokens[] = scanner.nextLine().split(" ");
      
      int g = Integer.parseInt(tokens[1]);
      int b = Integer.parseInt(tokens[2]);
      
      if((10*g+b)%4 == 0){
        System.out.println("YES");
      }
      else{
        System.out.println("NO");
      }
      
      
    }
}

Measured memory_bytes: 21588
#include<stdio.h>
int main(){
  int n,a,b,s1,s2,i;
  while(1){
    scanf("%d",&n);
    if(!n)break;
    s1=0;
    s2=0;
    for(i=0;i<n;i++){
      scanf("%d %d",&a,&b);
      if(a==b){
	s1+=a;
	s2+=b;
      }
      else if(a<b)s2+=a+b;
      else        s1+=a+b;
    }
    printf("%d %d\n",s1,s2);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
 using namespace std;
 int main(){
 long long a, b, k;
cin >> a >> b >> k;
if(k <= a){
cout << a - k << ' ' << b <<endl;
 }else if(k <= a+b){
 cout << 0 << ' ' << b - (k-a) <<endl;
 }else{
cout << 0 << ' ' << 0 <<endl;
 }
 }


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define inf 10000000000000007
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}


int n, a[100010];
int ta, cnt = 1;

signed main() {
	cin >> n;
	ta = 0;
	cin >> a[0];
	for (int i = 1; i < n; i++) {
		cin >> a[i];
		if (ta == 0) {
			if (a[i] == a[i - 1])ta = 0;
			else if (a[i] > a[i - 1])ta = 1;
			else if (a[i] < a[i - 1])ta = 2;
		}
		else if (ta == 1) {
			if (a[i] < a[i - 1]) {
				ta = 0;
				cnt++;
			}
		}
		else {
			if (a[i] > a[i - 1]) {
				ta = 0;
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n; cin >> n;
    vi use(26, inf), tmp;
    string s;
    rep(_,n) {
        tmp.assign(26, 0);
        cin >> s;
        for(auto ch : s) {
            ++tmp[ch-'a'];
        }
        rep(i,26) {
            chmin(use[i], tmp[i]);
        }
    }

    rep(i,26) if(use[i]!=inf) {
        rep(j, use[i]) cout << (char)('a'+i);
    }
    printf("\n");

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Cnter(string a,string b){
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int ret = 0;
  for(int i = 'a'; i <= 'z'; ++i){
    ret += binary_search(a.begin(),a.end(),i)&&binary_search(b.begin(),b.end(),i);
  }
  return ret;
}

int main(){
  int n; cin >> n;
  for(int i = 0; i < 100; ++i){
    for(int j = 0; j < 100; ++j){
      if(i * 4 + 7 * j == n){
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3632