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

using namespace std;

int main()
{
	string str;
	int n,t;
	int a = 0;
	int b = 0;
	int sum = 0;
	//string a,b,c;
	//int num = 0;
	//int cnt = 0;
	//sort(v.begin(),v.end());
	//vector<pair<int, int> > v;

    cin >> n >> t;

    for(int i=0;i<n;i++){
    	if(i==0){
    		cin >> a;
    	}else{
    		a = b;
       		cin >> b;
       		if(b-a >= t){
       			sum += t;
       		}else{
       			sum += b-a;
       		}
    	}

    }
    sum = sum + t;
    cout << sum << endl;

    return 0;
}


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

    for(i=0;i<n;i++){
        cin>>a[i];s+=a[i];
    }
    int k=0;
    for(i=0;i<n;i++){
        if(a[i]>=((.25*s)/m)){
            k++;
        }
    }
        if(k>=m){
                cout<<"Yes";
            }
        else
            cout<<"No";
} 

Measured memory_bytes: 256
X, N = map(int, input().split())
p = sorted(list(map(int, input().split())))

if X not in p:
    print(X)
else:
    for i in range(1, 101):
        if X - i not in p:
            print(X - i)
            exit()
        elif X + i not in p:
            print(X + i)
            exit()


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
int main (){
  int M;
  double price; 
  string unit;
  double total = 0;
  cin >> M;
  for(int i = 0; i < M; i++){
    cin >> price >> unit;
    if(unit == "BTC"){
      price = price * 380000;
    }
    total = total + price;
  }
  cout << total << endl;
}

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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); ++i)
#define REP(i,start,end) for(int i=(start);i<=(end);++i)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	string s,t;
	cin >> s >> t;
	cout << t << s << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
from scipy.sparse import csr_matrix
s = np.array(list(input()), dtype='U1')
n = len(s)
child = np.ones(n,dtype=np.int32)
rows = np.arange(n)
cols = np.where(s == 'R', rows+1, rows-1)
x = csr_matrix((np.ones(n,dtype=np.int32),(rows,cols)),(n,n))

def power(x,n):
    if n == 1:
        return x
    y = power(x,n//2)
    y = y*y
    return x*y if n&1 else y

x = power(x,10**100)
print(*(child*x))


Measured memory_bytes: 23316
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define all(r)(r).begin(),(r).end()
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define inf 1000000000000000000
#define N 207
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};


//=============================================ASIFAZAD==============================================//

int32_t main()
{
    io;
    int n;
    cin>>n;
    vll inp(n);
    for(auto& x: inp) cin>>x;
    ll ans = 0;
    sort(all(inp));
    for(int i =0 ; i< n;i++)
        for(int j = i+1; j<n ;j++)
            for(int k = j+1; k< n;k++)
                if(inp[i] != inp[j] && inp[j] != inp[k] && inp[i] + inp[j] > inp[k]){
                    ans++;
//                    dbg(inp[i]);
//                    dbg(inp[j]);
//                    dbg(inp[k]);
                }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const ll INF = (1LL << 31) - 1;
const double pi=acos(-1);

ll n,m;
vector<ll>dp(100010,1);

int main(){
  cin >> n >> m;
  rep(i,m){
    ll a;
    cin >> a;
    dp[a]=0;
  }
  rep(i,n+10){
    if(dp[i] && i>=2)dp[i]=(dp[i-1]+dp[i-2])%MOD;
  }
  cout << dp[n] << endl;
  
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int H, W;
vector<vector<int> > field;
vector<int> A;

const int dh[4] = {0, 1, 0, -1};
const int dw[4] = {1, 0, -1, 0};

void dfs(int h, int w, int cur_dir, int n, int counter) {
    if(counter>=A[n]) {
        n++;
        counter=0;
    }
    // cout << h << ", " << w << endl;
    field[h][w] = n+1;
    counter++;

    int nh = h+dh[cur_dir];
    int nw = w+dw[cur_dir];
    if(nh<0 || nh>=H || nw<0 || nw>=W) {
        cur_dir = (cur_dir+1)%4;
        nh = h+dh[cur_dir];
        nw = w+dw[cur_dir];
    }
    if(nh<0 || nh>=H || nw<0 || nw>=W) return;
    if(field[nh][nw]!=0) {
        cur_dir = (cur_dir+1)%4;
        nh = h+dh[cur_dir];
        nw = w+dw[cur_dir];
    }
    if(nh<0 || nh>=H || nw<0 || nw>=W || field[nh][nw]!=0) return;
    dfs(nh, nw, cur_dir, n, counter);
}

int main() {
    cin >> H >> W;
    int N;
    cin >> N;
    A.resize(N);
    for(int n=0; n<N; n++) {
        cin >> A[n];
    }
    
    field.resize(H, vector<int>(W, 0));

    // for(int h=0; h<H; h++) {
    //     for(int w=0; w<W; w++) {
    //         cout << field[h][w] << " ";
    //     }
    //     cout << endl;
    // }


    // cout << "execute dfs ... " << endl;
    dfs(0, 0, 0, 0, 0);
    
    // cout << "dfs done. " << endl;
    
    
    for(int h=0; h<H; h++) {
        for(int w=0; w<W; w++) {
            cout << field[h][w] << " ";
        }
        cout << endl;
    }

    return 0;
    
}

Measured memory_bytes: 384
import sys
from heapq import heappush, heappop
from collections import defaultdict
input = sys.stdin.readline

num, person = map(int, input().split())
arr = []

for i in range(num):
    s, t, x = map(int, input().split())
    arr.append((s - x - 0.5, 1, x, i))
    arr.append((t - x - 0.5, -1, x, i))

for i in range(person):
    d = int(input())
    arr.append((d,))

arr.sort()

heap = []
done = defaultdict(int)

for elem in arr:
    if len(elem) == 1:
        d = elem[0]
        while heap and done[heap[0][1]] and d > done[heap[0][1]]:
            heappop(heap)
        if heap:
            print(heap[0][0])
        else:
            print(-1)
        continue

    time, kind, x, i = elem
    if kind == 1:
        heappush(heap, (x, i))
    elif kind == -1:
        done[i] = time


Measured memory_bytes: 113596
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())

n=int(input())
ar=[]
for _ in range(n):
    ar.append(input())
from collections import Counter
c=Counter(ar)
print("AC x",c["AC"])
print("WA x",c["WA"])
print("TLE x",c["TLE"])
print("RE x",c["RE"])

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

using namespace std;

const unsigned long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    string s; cin >> s;
    int n = s.size();

    if(s[0] == s[1]){
        cout << "1 2\n";
        return 0;
    }

    for(int i = 2; i < n; ++i){
        if(s[i] == s[i - 1] || s[i] == s[i - 2]){
            cout << i - 1 << " " << i + 1 << "\n";
            return 0;
        }
    }

    cout << "-1 -1\n";

    return 0;

}


Measured memory_bytes: 512
import java.util.*;
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		int k=sc.nextInt();
		char[][] c=new char[h][w];
		
		for(int i=0;i<h;i++) {
			String s=sc.next();
			c[i]=s.toCharArray();
		}
		
		int ans=0;
		for(int i=0;i<(Math.pow(2, h));i++) {
			for(int j=0;j<(Math.pow(2, w));j++) {
				int count=0;
				for(int row=0;row<h;row++) {
					for(int col=0;col<w;col++) {
						if(((i>>row & 1)==1) && ((j>>col & 1)==1)) {
							if (c[row][col] == '#')count++;
							//ystem.out.println(c[row][col]);
						}
					}
				}	
				if(count==k)ans++;
			}
		}
		
	    System.out.println(ans);
	}
}


Measured memory_bytes: 35868
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	ll n, m;
	cin >> n >> m;
	if (abs(n - m) >= 2) {
		cout << "0" << endl;
	}
	else {
		ll ans = 1;
		for (int i = 1; i <= n; i++) {
			ans *= i;
			ans %= inf;
		}
		ll ans2 = 1;
		for (int i = 1; i <= m; i++) {
			ans2 *= i;
			ans2 %= inf;
		}
		if (n == m) {
			cout << ans * ans2 * 2 %inf<< endl;
		}
		else {
			cout << ans * ans2%inf << endl;
		}
		return 0;
	}
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    static final long MOD=1000000007;
    static long[] fact;
    static long[] invfact;
    static final int N=3000;
    static void initialize() {
	fact = new long[N];
	invfact = new long[N];
	fact[0] = invfact[0] = 1;
	for (int i = 1; i < N; ++i) {
	    fact[i] = (i * fact[i - 1]) % MOD;
	    invfact[i] = powerMod(fact[i], MOD - 2);
	}
    }
    static long powerMod(long x, long exponent) {
	long prod = 1;
	for (int i = 63; i >= 0; --i) {
	    prod = (prod * prod) % MOD;
	    if ((exponent & 1L << i) != 0) {
		prod = (prod * x) % MOD;
	    }
	}
	return prod;
    }
    static long comb(int x, int y) {
	if (x < 0) {
	    return 0;
	}
	if (y < 0 || y > x) {
	    return 0;
	}
	long r= (fact[x] * powerMod((fact[x - y] * fact[y]) % MOD, MOD - 2)) % MOD;
	return r;
    }
    static long f(int m, int i, int k){
        long t=fact[m]*invfact[m-i*k]%MOD;
        t=t*invfact[k]%MOD;
        return t*powerMod(invfact[i],k)%MOD;
    }
    public static void main(String[] args) {
        initialize();
        Scanner scan = new Scanner(System.in);
        int n=scan.nextInt();
        int a=scan.nextInt();
        int b=scan.nextInt();
        int c=scan.nextInt();
        int d=scan.nextInt();
        long[][]dp=new long[b+2][n+1];
        dp[a][n]=1;
        for(int i=a;i<=b;++i){
            for(int j=0;j<=n;++j){
                dp[i+1][j]=dp[i][j];
                for(int k=c;k<=Math.min(d,j/i);++k){
                    dp[i+1][j-i*k]+=f(j,i,k)*dp[i][j]%MOD;
                    dp[i+1][j-i*k]%=MOD;
                }
            }
        }
        System.out.println(dp[b+1][0]);
    }
}


Measured memory_bytes: 30548
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


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

    cout << 800*n - n/15*200 << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    // input
    cout << fixed << setprecision(10);
    int N; cin >> N;

    // variable
    int ans = 0;
    // solve
    bool ok = false;
    for(int i=1; i<2000; i++){
        if(2 * N == i * (i+1)){
            ok = true;
            ans = i;
        }
    }
    if(!ok){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    vector<vector<int> > vv(ans+1);
    int h = 0;
    int now = 1;
    print(ans+1);
    rep(i, ans * (ans + 1) / 2){
        int num = i + 1;
        if(ans < now){
            h++;
            now = h+1;
        }
        vv[h].push_back(num);
        vv[now].push_back(num);
        now++;
    }
    rep(j, ans+1){  
        cout << ans;
        rep(i, ans){
            cout << " ";
            cout << vv[j][i];
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 2304
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
    ArrayList<Integer> xors = new ArrayList<Integer>();
    int n;
    n = scanner.nextInt();
    int x;
    int fin = 0;
    for(int i = 0;i < n; i++){
      x = scanner.nextInt();
      xors.add(x);
      fin = fin ^ x;
    }
    
    for(int i = 0; i< n;i++) {
      System.out.print((fin ^ xors.get(i)) + " ");
    }
  }
}

Measured memory_bytes: 66964
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

int main(){
  fastio
  string s;
  cin>>s;
  ll ans=0;
  ll c=0;
  if(s[0]=='R'){
    c++;
    if(s[1]=='R'){
      c++;
      if(s[2]=='R'){
        c++;
      }
    }
  }
  else if(s[1]=='R'){
    c++;
    if(s[2]=='R'){
        c++;
      }

  }
  else if(s[2]=='R'){
    c++;
  }
  cout<<c<<"\n";
  
  return 0; 
}


Measured memory_bytes: 3636
<?php
class node
{
    public $a;
    public $b;
    public function __construct($var1,$var2)
    {
        $this->a = $var1;
        $this->b = $var2;
    }
}
$arr = array();
fscanf(STDIN,"%d %d",$N,$M);
for($i = 0;$i < $M;$i++)
{
    fscanf(STDIN,"%d %d",$a,$b);
    if(!isset($arr[$b]))
       $arr[$b] = $a;
    else{
        $arr[$b] = max($arr[$b],$a);
    }
}
$len = count($arr);
if($len === 0)
{
    echo "0\n";
}
else 
{
    $cnt = 0;
    $maxx = -2;
    ksort($arr);
    foreach($arr as $key=>$value)
    {
      if($maxx < $value)
      {
        $maxx = $key-1;
        $cnt++;
      }
    }
    echo $cnt."\n";
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr int INF = std::numeric_limits<int>::max() / 2;
constexpr ll INFLL = std::numeric_limits<ll>::max() / 2;
int S[110], K;
int N;
int dp[110][30];

void DP(){
    for(int i=0;i+1<N;++i){
        for(int j=0;j<26;++j){
            int cost = j != S[i+1];

            for(int k=0;k<27;++k){
                if(j == k){continue;}

                dp[i+1][j] = std::min({dp[i+1][j], dp[i][k] + cost, INF});
            }
        }
    }
}

void merge(ll &cur_11, ll &cur_1x, ll &cur_x1, ll &cur_xx, ll cost_11, ll cost_1x, ll cost_x1, ll cost_xx){
    ll new_11 = std::min({cur_11 + cost_x1, cur_1x + cost_11, INFLL}),
       new_1x = std::min({cur_11 + cost_xx, cur_1x + cost_1x, INFLL}),
       new_x1 = std::min({cur_x1 + cost_x1, cur_xx + cost_11, INFLL}),
       new_xx = std::min({cur_x1 + cost_xx, cur_xx + cost_1x, INFLL});

    cur_11 = new_11;
    cur_1x = new_1x;
    cur_x1 = new_x1;
    cur_xx = new_xx;
}

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

    std::string S_;
    std::cin >> S_ >> K;

    N = S_.size();

    if(N == 1){
        std::cout << K / 2 << std::endl;
        return 0;
    }

    for(int i=0;i<N;++i){
        S[i] = S_[i] - 'a';
    }

    std::fill(&dp[0][0], &dp[0][0] + 110 * 30, INF);

    dp[0][S[0]] = 0;

    DP();

    ll cost_11 = dp[N-1][S[0]], cost_1x = INFLL;
    for(int i=0;i<26;++i){
        if(i == S[0]){continue;}
        cost_1x = std::min<ll>(cost_1x, dp[N-1][i]);
    }

    std::fill(&dp[0][0], &dp[0][0] + 110 * 30, INF);

    dp[0][26] = 1;

    DP();

    ll cost_x1 = dp[N-1][S[0]], cost_xx = INFLL;
    for(int i=0;i<26;++i){
        if(i == S[0]){continue;}
        cost_xx = std::min<ll>(cost_xx, dp[N-1][i]);
    }

    // std::cout << "11, 1x, x1, xx" << std::endl;
    // std::cout << cost_11 << ", " << cost_1x << ", " << cost_x1 << ", " << cost_xx << std::endl;

    ll cur_11 = 0, cur_1x = 0, cur_x1 = 0, cur_xx = 0;

    for(int i=0;i<30;++i){
        if(K >> i & 1){
            merge(cur_11, cur_1x, cur_x1, cur_xx,
                  cost_11, cost_1x, cost_x1, cost_xx);
        }

        merge(cost_11, cost_1x, cost_x1, cost_xx,
              cost_11, cost_1x, cost_x1, cost_xx);
    }

    ll res = std::min({cur_11, cur_1x, cur_x1, cur_xx});
    std::cout << res << std::endl;
}


Measured memory_bytes: 256
from fractions import Fraction
def inverse(f):
    return Fraction(f.denominator,f.numerator)

n=int(input())
a = list(map(int, input().split()))

all=0
if 1 <= n <=100:
    for i in a[0:n]:    
        b=Fraction(i,1)
        all=all+inverse(b)
    print(float(inverse(all)))

Measured memory_bytes: 5344
#include <iostream>
#include <string>

using namespace std;

int main() {
    string str;
    getline(cin, str);
    size_t pos = 0;
    while((pos=str.find("apple", pos)) != string::npos) {
        str.replace(pos, 5, "_____");
        pos += 5;
    }
    pos = 0;
    while((pos=str.find("peach", pos)) != string::npos) {
        str.replace(pos, 5, "apple");
        pos += 5;
    }
    pos = 0;
    while((pos=str.find("_____", pos)) != string::npos) {
        str.replace(pos, 5, "peach");
        pos += 5;
    }
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 0
N = int(input())
S = input()
R = S.count("R")
G = S.count("G")
B = S.count("B")

def f(S):
    N = len(S)
    ret = 0
    for i in range(N):
        for j in range(i+1, N):
            k = j + j - i
            if k >= N: break
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                ret += 1
    return ret

ans = R * G * B - f(S)
print(ans)

Measured memory_bytes: 9204
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int N = sc.nextInt();
		long[] S = new long[N+2];
		S[0] = 0;
		for(int i = 1;i <= N;i++) {
			S[i] = S[i-1] + sc.nextLong();
		}
		S[N+1] = Long.MAX_VALUE;
		sc.close();
		Arrays.sort(S);
		long res = 0;
		long cnt = 1;
		for(int i = 0;i <=N;i++) {
			if(S[i] == S[i+1]) {
				cnt++;
			}else {
				res += cnt * (cnt - 1) / 2;
				cnt = 1;
			}
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 80860
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll w[100000];
//この状態から1周試す
//無理な場合は-1
int ty(ll s,ll t,int d)
{
	int ret=-1;
	for(int i=0;i<d;i++)
	{
		if(s<=t)
		{
			ret=i;
			break;
		}
		s+=w[i];
		if(s<=t)
		{
			ret=i+1;
			break;
		}
	}
	return ret;
}
int main()
{
	ll s,t;int d;
	ll ans=0;
	cin>>s>>t>>d;
	for(int i=0;i<d;i++)
		cin>>w[i];
	ll sum=0;
	ll tani=1e14-1;//変化量の中で最も小さいところ
	int taniind=-1;
	for(int i=0;i<d;i++)
	{
		sum+=w[i];
		if(sum<tani)
		{
			tani=sum;
			taniind=i;
		}
	}
	//cerr<<sum<<" "<<tani<<endl;
	if(sum>=0)
	{
		cout<<ty(s,t,d)<<endl;
		return 0;
	}
	ans=ty(s,t,d);
	if(ans!=-1)
	{
		cout<<ans<<endl;
		return 0;
	}
	sum*=-1;
	tani*=-1;
	ll cnt=ceill((double)max((s-t-tani),0LL)/(double)sum);
	s-=cnt*sum;
	ans=cnt*d+ty(s,t,d);
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  string str;
  getline(cin,str);
  for(int i=0;i<(int)str.size();i++){
    if('A' <= str[i] && str[i] <= 'Z'){
      str[i]+=32;
    }else if('a' <= str[i] && str[i] <= 'z'){
      str[i]-=32;
    }
  }
  cout<<str<<endl;
  return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;
typedef pair<int,int> P;
bool prime[1000001];
int n,m;
int fie[1200][1200];
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};
int numx[1000001],numy[1000001];
int dp[1201][1201];

void seive(){
	for(int i=2;i<=1000000;i++)prime[i]=true;
	prime[0]=prime[1]=false;
	for(int i=2;i<=1000000;i++){
		if(prime[i]){
			for(int j=i*2;j<=1000000;j+=i)prime[j]=false;
		}
	}
	int x=501,y=501,i=1,cnt=0,d=0,cnt2=1;
	while(i<=1000000){
		fie[x][y]=i;
		numx[i]=x;
		numy[i]=y;
		x+=dx[d];
		y+=dy[d];
		cnt++;
		if(cnt2==cnt){
			d++;
			if(d==2)cnt2++;
			if(d==4)cnt2++,d=0;
			cnt=0;
		}
		i++;
	}
}

int main(void){
	seive();
	while(1){
		scanf("%d%d",&m,&n);
		if(m+n==0)break;
		memset(dp,-1,sizeof(dp));
		int mk=0;
		if(prime[n])mk++;
		dp[numx[n]][numy[n]]=mk;
		for(int i=0;i<=1100;i++){
			for(int j=0;j<=1100;j++){
				if(dp[j][i]>=0){
					for(int k=-1;k<=1;k++){
						if(fie[j+k][i+1]>=1 && fie[j+k][i+1]<=m){
							int mc=0;
							if(prime[fie[j+k][i+1]])mc++;
							dp[j+k][i+1]=max(dp[j+k][i+1],dp[j][i]+mc);
						}
					}
				}
			}
		}
		int res2=0,res3=0;
		for(int i=0;i<=1100;i++){
			for(int j=0;j<=1100;j++){
				if(prime[fie[j][i]]){
					if(dp[j][i]>=1 && (dp[j][i]>res2 ||(dp[j][i]==res2 && fie[j][i]>res3))){
						res2=dp[j][i];
						res3=fie[j][i];
					}
				}
			}
		}
		printf("%d %d\n",res2,res3);
	}
	return 0;
}

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

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            bool None = true;
            for(int i = 0 ; i < 26 ; i++)
            {
                char c = (char)(97+i);
                if(!s.Contains(c))
                {
                    Console.WriteLine(c);
                    None = false;
                    break;
                }
            }
            if(None) Console.WriteLine("None");
            

        }
        
    }
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int  f2(ll md, const VL& a){
	int n=sz(a);
	VL b(n+1);
	b[0]=md;
	rep(i, n){
		b[i+1] = a[i] * 2 - b[i];
	}
	if(b[n] == b[0]){
	 rep(i, n) cout<<b[i] <<" "; cout<<"\n";
	}
	//dbg(md, b[0]-b[n]);
	return b[0] - b[n];
}


void f(const VL& a){
	int n=sz(a);
	ll hi=max(a[0], a[n-1])*2+10, lw=0-1;
	while(hi - lw > 1){
		ll md= (hi + lw) >> 1;
		if( f2(md, a) == 0) break;
		if( f2(md, a) > 0)  hi = md;
		else lw = md;
	}
}


int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n);
	rep(i, n) cin >>a[i];
	
	f(a);
	return 0;
 }



Measured memory_bytes: 2928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
 

int main(){
	ll N,K,X,Y;
    cin>>N>>K>>X>>Y;
    ll M;
    if(N>=K){
        M=N-K;
        cout<<(K*X+M*Y)<<endl;
    }
    else if(N<K){
        M=0;
        cout<<(N*X)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <inttypes.h>

int compare_int(const void *a, const void *b){//qsort 整数比較<
	return *(int*)a - *(int*)b;
}
int compare_int2(const void *a, const void *b){//qsort 整数比較>
	return *(int*)b - *(int*)a;
}

int main(void){
	int n;

	scanf("%d",&n);
	if(n%1000==0){
		printf("0");
		return 0;
	}
	printf("%d",(1000-n%1000));

	return 0;
}


Measured memory_bytes: 1732
# -*- coding: utf-8 -*-
# m-solutions2019/m_solutions2019_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    print((N - 2) * 180)
    return

main()


Measured memory_bytes: 3064
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7
MAX = 10**18
n = int(input())
a = list(map(int,input().split()))
ans = MAX
for i in range(-100,101):
    cost = 0
    for j in range(n):
        cost += (i-a[j])**2
    ans = min(ans,cost)
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define fi first
#define se second
#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)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
#define chmin(x,y) x = min(x,y)

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}

vector<int> to[2505];
vector<int> rto[2505];
bool reachablefrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachablefrom1[v]) return;
  reachablefrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  ll n = in();
  for (int i = 1; i <= 9; i++) {
    for (int j = i; j <= 9; j++) {
      if (n == i*j) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
#define X 0
#define Y 1

		/*Op`ÌÊÏÌl*/
double calTriArea(double A[],double B[],double C[])
{
	double a,b,c,
		   s;
	
	a = sqrt( pow(B[X]-C[X],2) + pow(B[Y]-C[Y],2) );
	b = sqrt( pow(C[X]-A[X],2) + pow(C[Y]-A[Y],2) );
	c = sqrt( pow(A[X]-B[X],2) + pow(A[Y]-B[Y],2) );
	
	s = (a+b+c)/2;
	return sqrt( s*(s-a)*(s-b)*(s-c) );
}

int main()
{
	double A[2],B[2],C[2],D[2],
		   S[2];
	int flag,
		i;
	
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf"
				,&A[X],&A[Y],&B[X],&B[Y],&C[X],&C[Y],&D[X],&D[Y]) != EOF)
	{
		flag = 0;		/*ÅÍfalthÅZbg*/
		S[0] = 0;
		S[1] = 0;
		
		S[0] += calTriArea(A,B,C) + calTriArea(A,C,D);
		S[1] += calTriArea(A,B,D) + calTriArea(B,C,D);
		
		/*ë·ÅÍËçêéÆ¢âÈÌÅALøº3®ç¢Å*/
		if( (S[0] - 0.0005) <= S[1] && S[1] <= (S[0] + 0.0005) ) flag = 1;
		
		/*	fobOp
		printf("S[0] = %lf  S[1] = %lf\n",S[0],S[1]);
		printf("flag = %d\n",flag);
		printf("%d %d\n\n",(S[0] - 0.0005) <= S[1],S[1] <= (S[0] + 0.0005));
		*/
		
		
		if(flag){
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	
	return 0;
}

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

a, b, c = MAP()
if a <= c <= b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 5332
import           Control.Arrow ((***))
import           Data.List     (partition)

main :: IO ()
main = print . solve . map fromChar =<< getLine

data Cube =
    Red
  | Blue
  deriving (Eq)

fromChar :: Char -> Cube
fromChar '0' = Red
fromChar '1' = Blue
fromChar _   = error "unexpected character"

solve :: [Cube] -> Int
solve = (2 *) . uncurry min . (length *** length) . partition (Red ==)


Measured memory_bytes: 7164
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>

using namespace std;
using Graph = vector<vector <bool>>;

int main(){
    int s, w;
    cin >> s >> w;
    if(w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}


Measured memory_bytes: 3636
n,m = map(int,raw_input().strip().split(' '))
graph = [[] for i in range(n)]
for i in range(m):
  s,t = map(int,raw_input().strip().split(' '))
  graph[s].append(t)
  graph[t].append(s)
color = {}
c = 0
for i in range(n):
  if not i in color:
     que = [i]
     color[i] = c
     while len(que) > 0:
       u = que[0]
       for v in graph[u]:
          if not v in color:
             color[v] = c
             que.append(v)
       del que[0]
     c += 1
q = int(raw_input())
for i in range(q):
    s,t = map(int,raw_input().strip().split(' '))
    if color[s] == color[t]:
        print 'yes'
    else:
        print 'no'

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

int main() {
  int a, b;
  cin >>a >>b;
  int ans = 0;
  int outlet = 1;
  while (outlet < b) {
    --outlet;
    outlet += a;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;
int DigVal(int n) {

	int s = 0;
	while (n > 0)
	{
		s += n % 10;
		n /= 10;
	}
	return s;
}
void DigitsSum() {
	int N;
	cin >> N;
	int res = 1000000;
	int left,right;
	
	for (int i = 1; i < N; i++)
	{
		left = DigVal(i);
		right = DigVal(N - i);
		res = min(left + right, res);
	}
	cout << res;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste
// #include "UnionFind.h"
// #include "power.h"

int H, W;
vector<vector<char>> A(10, vector<char>(10, '.'));
vector<vector<bool>> check(10, vector<bool>(10, false));

int ans = 0;
void dfs(int x, int y, int z) {
    check[x][y] = true;
    if (A[x + 1][y] == '#') dfs(x + 1, y, z + 1);
    if (A[x][y + 1] == '#') dfs(x, y + 1, z + 1);
    ans = max(ans, z);
}

signed main() {
    cin >> H >> W;
    int c = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> A[i][j];
            if (A[i][j] == '#') ++c;
        }
    }
    dfs(0, 0, 1);
    if (ans == c) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    cout<<[](ll n){return n*n*n;}(in())<<endl;
}

Measured memory_bytes: 256
#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: 3096
#include <bits/stdc++.h>
 
typedef long long ll;

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

#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 REPA(i,a) for(ll i=0;i<(ll)(a.size());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--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

const double PI=3.14159265358979323846; // or M_PI


void Main() {
    ll x, y, a, b;
    cin >> x >> y;

    REP(i, 101) {
        REP(j, 101){
            if ((2 * i + 4 * j == y) and (i + j == x)) {
                COUT("Yes");
                return;
            }
        }
    }


    COUT("No");

}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3644
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.call(in,out);
        out.close();
    }

    static class TaskA {
        public void call(InputReader in, PrintWriter out) {
            int n ,x =0, y ,sum=0 , count=0;
            n = in.nextInt();
            x = n*n;
            y = x*n;
            out.println(n+x+y);




        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }


    }
}

Measured memory_bytes: 32840
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}



int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long H;
    scanf("%lld",&H);
    long long M;
    scanf("%lld",&M);

    double angh = 360*H/12.0+30*M/60.0;
    double angm = 360*M/60.0;
    double angd = min(abs(angh-angm), 360-abs(angh-angm));
    double rad = angd*PI/180.0;
    // debg(angh)debg(angm)debg(angd)debg(rad)
    double c = A*A + B*B - 2*A*B*cos(rad);
    sp(sqrt(c))

    return 0;
}


Measured memory_bytes: 4144
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define ll long long
#define mod 1000000007
using namespace std;
int n, k, ans, l, a[100010];
map<int, int>mp;
inline int pow(int y, int x){
	int s=1, t=y;
	while(x){if(x&1)s=(ll)s*t%mod; t=(ll)t*t%mod; x>>=1;}
	return s;
}
int main(){
	scanf("%d%d", &n, &k);
	l=0; mp.clear();
	for(int i=1; i*i<=n; i++)if(n%i==0){
		a[++l]=i; mp[i]=pow(k, (i+1)/2);
		if(i*i<n){a[++l]=n/i; mp[n/i]=pow(k, (n/i+1)/2);}
	}
	sort(a+1, a+1+l);
	for(int i=2; i<=l; i++){
		for(int j=1; j*j<=a[i]; j++)if(a[i]%j==0){
			mp[a[i]]=(mp[a[i]]-mp[j]+mod)%mod;
			if(j*j<a[i]&&j>=2)mp[a[i]]=(mp[a[i]]-mp[a[i]/j]+mod)%mod;
		}
	}
	ans=0;
	for(int i=1; i<=l; i++){
		if(a[i]&1)ans=(ans+(ll)a[i]*mp[a[i]]%mod)%mod;
		else ans=(ans+(ll)(a[i]/2)*mp[a[i]]%mod)%mod;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 384
val sz = 100
fun f(x:Int,y:Int,z:Int):Int {
    return x*x+y*y+z*z+x*y+y*z+z*x
}
fun main() {
    val n = readLine()!!.toInt()
    var ans = MutableList<Int>(n+1,{_ -> 0})
    for(x in 1..sz){
        for(y in 1..sz){
            for(z in 1..sz){
                val v = f(x,y,z)
                if(v in 1..n){
                    ans[v]++
                }
            }
        }
    }

    for(i in 1..n) {
        println(ans[i])
    }
}


Measured memory_bytes: 37508
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int n;
string str[100];
set<string> st;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	rep(n){
		cin >> str[i];
		if(i>0) if(str[i][0]!=str[i-1][sz(str[i-1])-1]||st.count(str[i])){
			print1("No");
			return 0;
		}
		st.insert(str[i]);
	}
	print1("Yes");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

int main(){
    string s; cin >> s;
    string a="Sunny";
    string b="Cloudy";
    string c="Rainy";
    if(s==a) cout << b << endl; 
    if(s==b) cout << c << endl; 
    if(s==c) cout << a << endl; 
return 0;
}




Measured memory_bytes: 256
package main

import (
        "fmt"
)

func solution(n, a, b int, s string) []string {
        ans := make([]string, 0, n)

        in, ext := 0, 0
        for _, r := range s {
                res := "No"
                switch r {
                case 'a':
                        if a+b > in+ext {
                                res = "Yes"
                                in++
                        }
                        ans = append(ans, res)
                case 'b':
                        if a+b > in+ext && b >= ext+1 {
                                res = "Yes"
                                ext++
                        }
                        ans = append(ans, res)
                default:
                        ans = append(ans, "No")
                }
        }
        return ans
}

func main() {
        var n, a, b int
        var s string
        fmt.Scan(&n, &a, &b, &s)
        for _, text := range solution(n, a, b, s) {
                fmt.Println(text)
        }
}

Measured memory_bytes: 4864
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
        // TODO: メモリの使用量がやばいので Token ごとに読む
        // Reference: https://atcoder.jp/contests/abc148/submissions/9067537
        bufsize := 100 * 1024 * 1024
        sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
}
func readInt() int              { return readIntArray()[0] }
func readInt2() (int, int)      { a := readIntArray(); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(); return a[0], a[1], a[2] }
func readIntArray() []int {
        a := make([]int, 0, 1000)
        sc.Scan()
        for _, v := range strings.Split(sc.Text(), " ") {
                vv, _ := strconv.Atoi(v)
                a = append(a, vv)
        }
        return a
}
func readString() string            { return readStringArray()[0] }
func readString2() (string, string) { a := readStringArray(); return a[0], a[1] }
func readStringArray() []string     { sc.Scan(); return strings.Split(sc.Text(), " ") }

func main() {
        a, b, k := readInt3()

        if a > k {
                a -= k
        } else {
                k -= a
                a = 0
                if b > k {
                        b -= k
                } else {
                        b = 0
                }
        }

        fmt.Printf("%d %d\n", a, b)
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    int s,arr[100],m,a,b;
    int sum=0;
    cin>>s;
    for(int i=0; i<s; ++i)
    {
        cin>>arr[i];
    }
    cin>>m;
    while(m--)
    {
        sum=0;
        cin>>a>>b;
        for(int i=0; i<s; ++i)
        {
            if(i==a-1)
                sum+=b;
            else
            sum+=arr[i];
        }
        cout<<sum<<endl;
    }



}


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

int gcd(int u, int v){
	while(u > 0){
		int t;
		if(u < v){ t = u; u = v; v = t; }
		u = u % v;
	}
	return v;
}

int main(){
	int a, b;
	while(cin >> a >> b){
		int g;
		int l;
		g = gcd(a,b);
		l = a / g * b;
		cout << g << " " << l << endl;
	}
	return 0;
}

Measured memory_bytes: 0