akhauriyash/Code-Regression huggingface dataset:
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string s, t;
  cin >> s >> t;
  string u;
  cin >> u;
  s[0] += 'A'-'a';
  t[0] += 'A'-'a';
  u[0] += 'A'-'a';
  cout << s[0] << t[0] << u[0] << "\n";
}


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

int main(void){
    string s;
    cin >> s;
    if ((int)s.size() == 2 && s[0] == s[1]) {
        cout << "1 2" << endl;
        return 0;
    }
    int n = s.size();
    rep(i,n-2){
        string sub = s.substr(i,3);
        if (sub[0] == sub[1] || sub[1] == sub[2] || sub[2] == sub[0]) {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}


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

int main(){
    int W, H, x, y, r;
    bool over;
    cin >> W >> H;
    cin >> x >> y >> r;
    
    over = false;
    if(x+r>W){
        over=true;
    } else if(x-r<0){
        over=true;
    } else if(y+r>H){
        over=true;
    } else if(y-r<0){
        over=true;
    }
    
    if(over==true){
        cout << "No" << endl;
    } else{
        cout << "Yes" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3076
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

class RAQ_RMQ:
    def __init__(self, n, a=None, F=min, e=float("inf")):
        self.n = n
        self.n0 = 2**(n-1).bit_length()
        self.e = e
        self.F = F
        self.lazy = [0]*(2*self.n0)
        if a is None:
            self.data = [e]*(2*self.n0)
        else:
            self.data = [0]*(2*self.n0)
            self.construct(a)

    def construct(self, a):
        for i, x in enumerate(a):
            self.data[i+self.n0] = x
        for i in range(self.n0-1, 0, -1):
            self.data[i] = self.F(self.data[2*i], self.data[2*i+1])

    def bottomup(self, i):
        i += self.n0
        k = i//(i & -i)
        c = k.bit_length()
        for j in range(c-1):
            k >>= 1
            self.data[k] = self.F(self.data[2*k], self.data[2*k+1]) + self.lazy[k]

    def topdown(self, i):
        i += self.n0
        k = i//(i & -i)
        c = k.bit_length()
        for j in range(c-1):
            idx = k >> (c - j - 1)
            ax = self.lazy[idx]
            if not ax:
                continue
            self.lazy[idx] = 0
            self.data[2*idx] += ax
            self.data[2*idx+1] += ax
            self.lazy[2*idx] += ax
            self.lazy[2*idx+1] += ax

    def query(self, l, r):
        self.topdown(l)
        self.topdown(r)
        L = l+self.n0
        R = r+self.n0

        s = self.e
        while L < R:
            if R & 1:
                R -= 1
                s = self.F(s, self.data[R])
            if L & 1:
                s = self.F(s, self.data[L])
                L += 1
            L >>= 1
            R >>= 1
        return s

    def add(self, l, r, x):
        L = l+self.n0
        R = r+self.n0

        while L < R :
            if R & 1:
                R -= 1
                self.data[R] += x
                self.lazy[R] += x
            if L & 1:
                self.data[L] += x
                self.lazy[L] += x
                L += 1
            L >>= 1
            R >>= 1

        self.bottomup(l)
        self.bottomup(r)

n,m = map(int, input().split())

memo = [[] for i in range(n+2)]
for i in range(m):
    l,r,a = map(int, input().split())
    memo[l].append((l,a))
    memo[r+1].append((l,-a))

seg = RAQ_RMQ(n+2, a=[0]*(n+2), F=max, e=-float("inf"))

for i in range(1, n+2):
    for j, a in memo[i]:
        seg.add(0, j, a)
    tmp = seg.query(0, i)
    seg.add(i, i+1, tmp)

ans = seg.query(0, n+1)
print(ans)

Measured memory_bytes: 107468
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	string s,t;
	cin >> s >> t;
	if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0])
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val (N, D) = readInts()
  val X = (1..N).map { readInts() }
  var cnt = 0
  for (i in 0 until N - 1) {
    for (j in i + 1 until N) {
      val a = X[i]
      val b = X[j]
      var sum = 0
      for (k in 0 until D) {
        sum += (a[k] - b[k]) * (a[k] - b[k])
      }
      val d = Math.sqrt(sum.toDouble()).toInt()
      if (sum == d * d) cnt++
    }
  }
  println(cnt)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    long long x;
    for(x = 0; x * x <= n; x++);
    cout << (x - 1)*(x - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
int main() {
  lli A,B=0,C=0;
  cin >> A;
  vector<int>P(A+1),G(P);
  for(int i=0;i<A+1;i++)cin >> P[i];
  for(int i=0;i<A;i++)cin >> G[i];
  for(int i=0;i<A;i++){
	  if(P[i]+P[i+1]<=G[i]){
		  B+=P[i]+P[i+1];
		  P[i]=0;
		  P[i+1]=0;
	  }else{
		  if(P[i]<=G[i]){
			  B+=G[i];
			  P[i+1]=P[i+1]-G[i]+P[i];
		  }else B+=G[i];
	  }
  }
  cout << B << endl;
}


Measured memory_bytes: 1024
import math
import copy
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputNum():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
metroNum = 6
transLim = getSomeInputInt(metroNum-1)

neck = min(transLim)

tmpans = math.ceil(n/neck)
ans = tmpans + metroNum - 2

print(ans)

Measured memory_bytes: 13640
#include <stdio.h>

//選択整列法
void selection(int a[], int l, int r);


int main(void)
{

  int n, x;
  int a[110];

  scanf("%d %d", &n, &x);

  for (int i=0; i < n; i++) {scanf("%d", &a[i]);}
  selection(a, 0, n);
  int ans = 0;
  for (int i=0; i < n; i++) {
    if (x >= a[i]) {
      ans++;
      x -= a[i];
      }
  }
  if (x > 0&&ans == n) {--ans;}
  printf("%d\n", ans);

  return 0;
}

//選択整列法
void selection(int a[], int l, int r)
{

  for (int i=l; i < r-1; i++) {
    int min = i;
    for (int j=i+1; j < r; j++) { if (a[j] < a[min]) { min = j;} }
    int t = a[i];
        a[i] = a[min];
        a[min] = t;
  }
}


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

namespace abc070_d
{
	class Program
	{
		static List<Tuple<int, long>>[] d;
		static bool[] visited;
		static long[] dist;
		static void dfs(int start, long cost)
		{
			visited[start] = true;
			dist[start] = cost;
			foreach (var tup in d[start])
			{
				if (!visited[tup.Item1])
				{
					dfs(tup.Item1, cost + tup.Item2);
				}
			}
			//visited[start] = false;
		}
		static void Main(string[] args)
		{
			int V = int.Parse(Console.ReadLine());
			d = new List<Tuple<int, long>>[V]; visited = new bool[V]; dist = new long[V];
			for (int i = 0; i < V; i++) d[i] = new List<Tuple<int, long>>();
			for (int i = 0; i < V - 1; i++)
			{
				int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
				x[0]--; x[1]--;
				d[x[0]].Add(new Tuple<int, long>(x[1], x[2]));
				d[x[1]].Add(new Tuple<int, long>(x[0], x[2]));
			}
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
			dfs(a[1] - 1, 0);
			for (int i = 0; i < a[0]; i++)
			{
				int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
				x[0]--; x[1]--;
				Console.WriteLine(dist[x[0]] + dist[x[1]]);
			}
		}
	}
}

Measured memory_bytes: 45960
#include <iostream>
using namespace std;
int n, k, a[(1<<20)];
int main () {
    cin >> n >> k;
    int ind1 = -1;
    for ( int i = 0 ; i < n ; i ++ ) {
        cin >> a[i];
        if ( a[i] == 1 ) { ind1 = i; }
    }
    int ans = 1<<20;
    for ( int s = 0 ; s < n ; s ++ ) {

        int f = min( s+k, n );

        if ( ind1 < s || ind1 >= f ) { continue; }

//        cout << s << " : " << 1 << "+" << ( (s+k-2)/(k-1) ) << "+" << ( (n-f+k-2)/(k-1) ) << "\n";

        ans = min( ans, 1 + ( (s+k-2)/(k-1) ) + ( (n-f+k-2)/(k-1) ) );
    }
    cout << ans << "\n";
    return 0;
}


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

int main() {
    int n, x;
    cin >> n;
    
    vector<int> arr(n+1,0);
    for(int i=1; i<n; i++) {
        cin >> x;
        ++arr[x];
    }
    
    for(int i=1; i<=n; i++)
        cout << arr[i] << endl;

	return 0;
}

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

int main(){
    int a[2];
    for(int i = 0; i < 2; i++){
        cin >> a[i];
        if(a[i] == 1) a[i] = 14;
    }
    if(a[0] > a[1]) cout << "Alice" << endl;
    else if(a[0] < a[1]) cout << "Bob" << endl;
    else cout << "Draw" << endl;


}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    double prob = 0,buf;
    int n,k,point;
    scanf("%d %d",&n,&k);

    for (int i = 1; i <= n; i++)
    {
        buf = 1.0 / (double)n;
        point = i;
        while (point < k)
        {
            point *= 2;
            buf /= 2;
        }
        prob += buf;
    }
    printf("%.15f",prob);
}

Measured memory_bytes: 128
import java.util.*;

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

    String s = sc.next();

    String[] day = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};

    for(int i = 0; i < 7; i++){
      if(s.equals(day[i])){
        System.out.println(i + 1);
        break;
      }
    }
  }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int x,y,z;
  cin>>x>>y>>z;
  int ans=1;
  rep(i,100000) if(y*i+z*(i+1)<=x)ans=max(ans,i); else break;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
    AUTHOR : TANMAY SINHA
    INFORMATION TECHNOLOGY
    BIT MESRA ,RANCHI
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define rep(i,L,R) for(i=L;i<R;i++)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
const ll INF = 1e18l+10,N = 1e5,MAX = 5000000;
#define sq(X) ((X)*(X))

int main()
{
    ll n,m,i,j,f=1;
    cin>>n>>m;
    ll a[n];
    for(i=0;i<n;i++)
    a[i]=-1;
    if(m==0)
    {
        a[n-1]=1;
        if(n==1)
        a[0]=0;
        for(i=n-1;i>=0;i--)
        if(a[i]==-1)
        cout<<0;
        else cout<<a[i];
        cout<<"\n";
        return 0;
    }
    while(m--)
    {
        cin>>i>>j;
        if(a[n-i]!=-1&&(a[n-i]!=j))
        f=0;
        else a[n-i]=j;
    }
    if(a[n-1]==0)
    f=0;
    if(a[n-1]==-1)
    a[n-1]=1;
    if(n==1&&a[0]==0)
    f=1;
    if(f==0)
    cout<<"-1\n";
    else for(i=n-1;i>=0;i--)
    {
        if(a[i]==-1)
        cout<<0;
        else cout<<a[i];
    }
    cout<<"\n";
}

Measured memory_bytes: 256
from functools import reduce
import math
import collections
## エラトステネスの篩
def eratosthenes(num):
    is_prime = [1]*num
    is_prime[0] = 0
    is_prime[1] = 0
    for i in range(2,num):
        if is_prime[i] == 1:
            for j in range(i*i,num,i):
                is_prime[j] = 0
    return is_prime
            
def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    Q = int(input())
    l = []
    r = []
    for i in range(Q):
        s1, s2 = (int(_) for _ in input().split())
        l.append(s1)
        r.append(s2)
    cnt = 1
    is_prime = eratosthenes(100005)

    c = [0]*100005
    for i in range(3,100005,2):
        if is_prime[i] ==1 and is_prime[(i+1)//2] ==1:
            c[i] = 1

    for i in range(1,100004):
        c[i+1] += c[i]
    ans = []    
    for i in range(Q):
        ans.append(c[r[i]]-c[l[i]-1])
            
    print('\n'.join(str(_) for _ in ans))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 24420
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

void Go(const vector<int>& A, int pos, int prod, int& result) {
  if (pos == A.size()) {
    if (prod == 0) {
      ++result;
    }

    return;
  }

  for (int delta = -1; delta <= 1; ++delta) {
    int b = A[pos] + delta;
    Go(A, pos + 1, prod * (b % 2), result);
  }
}

int main() {
//  freopen("../Console/1.txt", "rb", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int N;
  cin >> N;

  vector<int> A(N);
  for (int& a : A) {
    cin >> a;
  }

  int result;
  Go(A, 0, 1, result);
  cout << result << '\n';

  return 0;
}


Measured memory_bytes: 256
n = int(input())
probs = [float(c) for c in input().split()]

dp = [[0] * (n+1) for _ in range(n+1)]
dp[0][0] = 1
for coin in range(1, n+1):
    for heads in range(n+1):
        dp[coin][heads] = dp[coin-1][heads] * (1 - probs[coin-1])
        if heads > 0:
            dp[coin][heads] += dp[coin-1][heads-1] * probs[coin-1]

ans = 0
for i in range(n//2 + 1, n+1):
    ans += dp[n][i]

print(ans)

Measured memory_bytes: 252424
#include<iostream>
#include<algorithm>
using namespace std;
const int INF = 111111111;
int main(void){
  int n,m,a,b,cost,time,l,p,q,r;
  int c[105][105],t[105][105];
  for( ; ; ){
    cin >> m >> n;
    if(!m && !n) break;

    for(int i = 1;i <= n; i++){
      for(int j = 1;j <= n; j++){
	if(i == j) c[i][j] = t[i][j] = 0;
	else c[i][j] = t[i][j] = INF;
      }
    }

    for(int i = 0;i < m; i++){
      cin >> a >> b >> cost >> time;
      c[a][b] = c[b][a] = cost;
      t[a][b] = t[b][a] = time;
    }

    for(int k = 1;k <= n; k++)
      for(int i = 1;i <= n; i++)
	for(int j = 1;j <= n; j++) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);

    for(int k = 1;k <= n; k++)
      for(int i = 1;i <= n; i++)
	for(int j = 1;j <= n; j++) t[i][j] = min(t[i][j], t[i][k] + t[k][j]);

    cin >> l;
    for(int i = 0;i < l; i++){
      cin >> p >> q >> r;
      cout << (r ? t[p][q] : c[p][q]) << endl;
    }
  }
}


Measured memory_bytes: 1244
#include <stdio.h>
#include <string.h>
#include <map>
using namespace std;
map <int, int>mp;
#define N 100
int n, a, m;
int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i){
        scanf("%d", &a);
        mp[a]++;
    }
    scanf("%d", &m);
    for (int i = 1; i <= m; ++i){
        scanf("%d", &a);
        if (!mp[a]){
            printf("NO\n");
            return 0;
        }
        mp[a]--;
    }
    printf("YES\n");
}

Measured memory_bytes: 9600
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int get() { int r; cin >> r; return r; }
double x[1234], y[1234];
signed main() {
	x[1] = 1; y[1] = 0;
	for1(i, 1000) {
		double p = (double)1 / sqrt(x[i] * x[i] + y[i] * y[i]);
		x[i + 1] = x[i] - p * y[i];
		y[i + 1] = y[i] + p * x[i];
	}
	int n; while (cin >> n, n >= 0)printf("%.5f\n%.5f\n", x[n], y[n]);
}


Measured memory_bytes: 3084
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




ll dp[50][500][500];

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

  ll inf = 10e9;
  ll N ; cin >> N;
  ll ma, mb; cin >> ma >> mb;
  vector<ll> a,b,c;
  
  rep(i,N){
    ll ai,bi,ci;
    cin >> ai >> bi >> ci;
    a.pb(ai);
    b.pb(bi);
    c.pb(ci);
  }
  
  rep(i,50)rep(j,500)rep(k,500)
    dp[i][j][k] = inf;
  
  dp[0][0][0] = 0;


  rep(i,N+1)rep(j,500)rep(k,500){
    if(dp[i][j][k] == inf) continue;
    //cerr <<"debug" << endl;
    dp[i+1][j][k] = min(dp[i+1][j][k] , dp[i][j][k]);
    dp[i+1][j+a[i]][k+b[i]] = min(dp[i][j][k] + c[i], dp[i][j+a[i]][k+b[i]]);
  }
    
  ll ans = inf;
  rep(ai,500)rep(bi,500){
    if(ai==0 || bi==0) continue;
    if(ai*mb == bi*ma){
      ans = min(ans, dp[N][ai][bi]);
    }
  }
  if(ans == inf) ans = -1;
  cout << ans << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

using namespace std;

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

const uint64_t MOD = 1e+9 + 7;

class ModuloOps
{
private:
  std::vector<uint64_t> _fact, _fact_inv;

  void _calc_fact(uint64_t n)
  {
    for (uint64_t i = 2; i <= n; ++i) {
      _fact[i] = (_fact[i - 1] * i) % MOD;
      _fact_inv[i] = inv(_fact[i]);
    }
  }

public:
  ModuloOps(uint64_t n)
  {
    _fact = std::vector<uint64_t>(n + 1);
    _fact_inv = std::vector<uint64_t>(n + 1);

    _fact[0] = 1;
    _fact[1] = 1;
    _fact_inv[0] = 1;
    _fact_inv[1] = 1;

    _calc_fact(n);
  }

  uint64_t power(uint64_t x, uint64_t y) const
  {
    if (y <= 1) {
      return (y == 0) ? 1 : (x % MOD);
    }

    uint64_t w = power(x, y >> 1);
    uint64_t z = (w * w) % MOD;

    if (y % 2 == 1) {
      z = (x * z) % MOD;
    }

    return z;
  }

  uint64_t inv(uint64_t n) const { return power(n, MOD - 2); } 

  uint64_t fact(uint64_t n) const { return _fact[n]; }
  uint64_t fact_inv(uint64_t n) const { return _fact_inv[n]; }

  uint64_t perm(uint64_t n, uint64_t k) const
  {
    return (_fact[n] * _fact_inv[n - k]) % MOD;
  }

  uint64_t comb(uint64_t n, uint64_t k) const
  {
    return (perm(n, k) * _fact_inv[k]) % MOD;
  }

  uint64_t prem_rep(uint64_t k, uint64_t l) const
  {
    uint64_t x = _fact[k + l];
    x = (x * _fact_inv[k]) % MOD;
    x = (x * _fact_inv[l]) % MOD;
    return x;
  }

  uint64_t prem_rep(const std::vector<uint64_t> &a) const
  {
    uint64_t n = std::accumulate(a.begin(), a.end(), 0);
    uint64_t x = _fact[n];
    for (uint64_t y : a) {
      x = (x * _fact_inv[y]) % MOD;
    }
    return x;
  }

  uint64_t comb_rep(uint64_t n, uint64_t k) const
  {
    return comb(n + k - 1, k);
  }
};

int main()
{
  int64_t N, K;
  cin >> N >> K;

  vector<int64_t> A(N);
  N_TIMES(n, N) { cin >> A[n]; }

  vector<int64_t> B(A), C(A);
  sort(B.begin(), B.end(), less<int64_t>());
  sort(C.begin(), C.end(), greater<int64_t>());
  N_TIMES(n, N) {
    B[n] = (B[n] + MOD) % MOD;
    C[n] = (C[n] + MOD) % MOD;
  }

  ModuloOps mod_ops(N);

  int64_t T_max = 0, T_min = 0;
  N_TIMES(n, N) {
    if (n < K - 1) { continue; }

    int64_t t_max = (mod_ops.comb(n, K - 1) * B[n]) % MOD;
    int64_t t_min = (mod_ops.comb(n, K - 1) * C[n]) % MOD;
    T_max = (T_max + (MOD + t_max)) % MOD;
    T_min = (T_min + (MOD + t_min)) % MOD;
  }

  int64_t T = ((T_max + MOD) - T_min) % MOD;
  cout << T << endl;

  return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>

  int gcd(int a,int b){
    while(b!=0){
      int r = a%b;
      a = b;
      b = r;
    }
    return a;
  }
  

int main (){
  int K;
  scanf("%d",&K);
  int ans =0;
  
  for (int i=1;i<=K;i++){
    for (int b=1;b<=K;b++){
      for (int c=1;c<=K;c++){
        ans+=gcd(gcd(i,b),c);
      }
    }
  }
  printf("%d",ans);
  return 0;
}
  


Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
#define debug(...) { printf("#  "); printf(__VA_ARGS__); puts(""); }
#define fi first
#define se second
#define endl "\n" 
using ll = long long;
using ull = unsigned long long; 
using pII = pair <int, int>;
using pLL = pair <ll, ll>;
using VI = vector <int>;
using VL = vector <ll>;
constexpr int mod = 1e9 + 7;
template <class T1, class T2> inline void chadd(T1 &x, T2 y) { x += y; while (x >= mod) x -= mod; while (x < 0) x += mod; } 
template <class T1, class T2> inline void chmax(T1 &x, T2 y) { if (x < y) x = y; }
template <class T1, class T2> inline void chmin(T1 &x, T2 y) { if (x > y) x = y; }
inline int rd() { int x; cin >> x; return x; }
template <class T> inline void rd(T &x) { cin >> x; }
template <class T> inline void rd(vector <T> &vec) { for (auto &it : vec) cin >> it; }
template <class T> inline void pt(T s) { cout << s << "\n"; }
template <class T> inline void pt(vector <T> &vec) { for (auto &it : vec) cout << it << " "; cout << endl; } 
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll qpow(ll base, ll n) { ll res = 1; while (n) { if (n & 1) res = res * base % mod; base = base * base % mod; n >>= 1; } return res; }
constexpr int N = 1e6 + 10;
int n, a[N], ans[N]; pII f[N];  
void run() {
	a[1 << n] = -mod;
	for (int i = 0; i < 1 << n; ++i) cin >> a[i];
	for (int i = 0; i < 1 << n; ++i) f[i] = pII(i, 1 << n);
	for (int i = 0; i < n; ++i) {	
		for (int j = 0; j < 1 << n; ++j) {
			if ((j >> i) & 1) {
				int k = j ^ (1 << i);
				if (a[f[k].fi] > a[f[j].fi]) {
					f[j].se = f[j].fi;
					f[j].fi = f[k].fi;
				//	cout << j << " " << f[j].fi << " " << f[j].se << endl;
				} 
				if (f[k].fi != f[j].fi && a[f[k].fi] > a[f[j].se]) {
					f[j].se = f[k].fi;
				}
				if (f[k].se != f[j].fi && a[f[k].se] > a[f[j].se]) {
					f[j].se = f[k].se;
				} 
			//	cout << j << " " << f[j].fi << " " << f[j].se << endl;
			}
		}
	}
	memset(ans, 0, sizeof ans);
	for (int i = 1; i < 1 << n; ++i) {
		ans[i] = ans[i - 1];
	//	cout << i << " " << f[i].fi << " " << f[i].se << endl;
		if (f[i].fi != f[i].se && f[i].se != (1 << n)) {
			chmax(ans[i], a[f[i].fi] + a[f[i].se]);
		}
		pt(ans[i]);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cout << fixed << setprecision(20);
	while (cin >> n) run();
	return 0;
}


Measured memory_bytes: 15360
//
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define maxnn 2010
ll n;
ll ry[maxnn][maxnn];
ll ru[maxnn];
ll d=0;
ll mark[maxnn];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<n;j++)
	{
		scanf("%lld",&ry[i][j]);
		ru[i]=1;
	}
	}
	while(1)
	{
		d++;
		for(int i=1;i<=n;i++)
{
		mark[i]=0;
}
		int tt=0;
		int tr=0;
		for(int i=1;i<=n;i++)
{
		if(ru[i]==n)	{continue;}
		if(mark[i]) {continue;}
		if(ry[ry[i][ru[i]]][ru[ry[i][ru[i]]]]!=i) 
	{
		tt++;
	} 
	else
	if(!mark[i]&&!mark[ry[i][ru[i]]])
	{
			ru[ry[i][ru[i]]]++;
			mark[i]=1;
			mark[ry[i][ru[i]]]=1;
			ru[i]++;
	}
}
	for(int i=1;i<=n;i++)
	if(ru[i]==n) tr++;
	if(tr==n) {cout<<d;return 0;}
	if(n-tr==tt) {cout<<-1;return 0;}
	}
} 

Measured memory_bytes: 16128
#include<bits/stdc++.h>
#define avjo ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    avjo;
    long n,m;
    cin>>n>>m;
    long long a[n],i,k=0;
    for(i=0;i<m;i++)
    {
        cin>>a[i];
        k+=a[i];
    }
    cout<<max(-1LL,n-k);

    return 0;
}


Measured memory_bytes: 3700
i = list(map(int, input().split()))

N = int(i[0])
A = int(i[1])
B = int(i[2])

count_blue = 0

syou = N // (A + B)
amari = N % (A + B)

if amari > A:
    count_blue = A * syou + A
else:
    count_blue = A * syou + amari

print(count_blue)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

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

		//??¨????????????????????????
		for(int i=1; i<=13; i++){
			list.add("S " + i);
		}
		for(int i=1; i<=13; i++){
			list.add("H " + i);
		}
		for(int i=1; i<=13; i++){
			list.add("C " + i);
		}
		for(int i=1; i<=13; i++){
			list.add("D " + i);
		}

		int num = Integer.parseInt(br.readLine());
		for(int i=0; i<num; i++){
			int a = list.indexOf(br.readLine());
			list.remove(a);
		}

		for(String card: list){
			System.out.println(card);
		}
	}
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}
ll l[87];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    l[0] = 2;
    l[1] = 1;
    FOR(i, 2, 87) {
      l[i] = l[i - 1] + l[i - 2];
    }
    int n;  cin >> n;
    cout << l[n] << '\n';

    return 0;
}


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

const double eps = 1e-9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define FORD(i,a,b) for (int i = int(b)-1; i >= (a); i--)
#define FORIT(i,c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define mp make_pair
#define pb push_back

vi primes;
bool hasEdge(int n){
    if(n == 1)return false;
    if(n%2 == 0)return false;
    for(auto p: primes){
        if(p*p > n)return true;
        if(n%p==0)return false;
    }
    return true;
}

vi adj[128];
int prev_[128];
bool mark[128];

bool find_match(int n){
    if(n == -1)return true;
    if(mark[n])return false;
    mark[n] = true;
    for(auto it: adj[n])if(find_match(prev_[it])){
        prev_[it] = n;
        return true;
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    for(int i = 3; i < 10000; i++){
        bool ok = true;
        for(auto p: primes)if(i%p==0){
            ok = false;
            break;
        }
        if(ok)primes.pb(i);
    }
    int N;
    set<int> nums;
    cin >> N;
    FOR(i,0,N){
        int x;
        cin >> x;
        if(nums.find(x) != nums.end())nums.erase(x);
        else nums.insert(x);
        if(nums.find(x+1) != nums.end())nums.erase(x+1);
        else nums.insert(x+1);
    }
    vi even, odd;
    for(auto it: nums){
        if(it%2==0)even.pb(it);
        else odd.pb(it);
    }
    int E = sz(even);
    int O = sz(odd);
    FOR(i,0,E)adj[i].clear();
    FOR(e,0,E)FOR(o,0,O)if(hasEdge(abs(even[e]-odd[o]))){
        adj[e].pb(o);
    }
    assert(max(E,O) < 128);
    FOR(i,0,O)prev_[i] = -1;
    int M = 0;
    FOR(i,0,E){
        FOR(j,0,E)mark[j] = 0;
        if(find_match(i))M++;
    }
    int res = M;
    E -= M;
    O -= M;
    res += 2 * (E / 2);
    E%=2;
    res += 2 * (O / 2);
    O %= 2;
    if(E)res += 3;
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
from math import floor

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

result = 0
for i in range(n+1):
    i_str = str(i)
    sum = 0
    for j in range(i_str.__len__()):
        sum += int(i_str[j])
    
    if sum >= a and sum <= b:
        result += i

print(result)

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

int main(){
	double x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	cout << fixed << setprecision(8) << sqrt(pow(y2 - y1, 2) + pow(x2 - x1, 2)) << endl;

	return 0;	
}


Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
int k,cnt,a=1,res;
int main()
{
    cin>>k;
    while (cnt<=k)
    {
        cnt++;
        res+=a*7;
        res%=k;
        a=a*10%k;
        if (res==0) break;
    }
    if (cnt<=k) cout<<cnt<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
typedef long long ll;

ll min(ll a, ll b);
using namespace std;


int main(){
    ll n,k,x,x_buf;
    cin >> n >> k;
    if(n < k){
        x = n;
    }else{
        x = n % k;
    }
    x_buf = x - k;
    cout << min(x,llabs(x_buf)) << endl;
    return 0;
}

ll min(ll a, ll b){
    if(a >= b){
        return b;
    }else{
        return a;
    }
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

vector<int> g[maxn];
vector<vector<int>> dp;
//wb
void dfs(int u, int p = -1) {
    for (auto x: g[u])
        if (x != p) {
            dfs(x, u);
            dp[u][0] *= (dp[x][0] + dp[x][1]);
            dp[u][0] %= MOD;
            dp[u][1] *= dp[x][0];
            dp[u][1] %= MOD;
        }
}

void solve() {
    int n;
    cin >> n;

    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;

        g[a].push_back(b);
        g[b].push_back(a);
    }
    dp = vector<vector<int>>(n + 1, vector<int>(2, 1));
    dfs(1, -1);
    cout << (dp[1][0] + dp[1][1]) % MOD << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 21000
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

llong gojosa(llong n,llong m){
    llong ans = n*n*n*n*n-m*m*m*m*m;
    return ans;
}

int main(){
    llong x;
    cin >> x;
    for(llong a=0;a<=120;a++) for(llong b=-120;b<=120;b++){
        if(gojosa(a,b) == x){
            cout << a << " " << b << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3588
#include <iostream>

using namespace std;



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

    int n, m;
    cin >> n >> m;
    cout << (n * (n - 1)) / 2 + (m * (m - 1)) / 2 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


int K;


void solve() {
    int tmp = 0;
    for (int i = 1; i < 1e8; i++) {
        tmp *= 10;
        tmp += 7;
        tmp %= K;
        if (tmp == 0) {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

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

    cin >> K;


    solve();
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;
ll comb(ll n, ll r){
  ll ret=1;
  for(ll i=n;i>n-r;i--){
    ret*=i;
    ret/=n+1-i;
  }
  return ret;
}
int main(){
  int n, a, b;cin>>n>>a>>b;
  vector<ll> v(n);for(auto& e: v)cin>>e;
  sort(v.begin(), v.end(), greater<ll>());
  double avg;ll sum=0;
  for(int i=0;i<a;i++){
  	sum += v[i];
  }
  avg = sum/(double)a;
  cout<<fixed<<setprecision(10)<<avg<<endl;
  int count=0, inner_count=0;
  for(int i=0;i<n;i++){
    if(v[i]==v[a-1]){
      count++;
      if(i<a)inner_count++;
    }
  }
  ll ans=0;
  if(double(abs(avg-v[a-1]))<(1e-8)){
    for(int i=inner_count;i<=min(count,b-(a-inner_count));i++){
      ans += comb((ll)count, (ll)i);
      // printf("%d, %llu\n", i, comb((ll)count, (ll)i));
    }
  }else{
  	ans = comb((ll)count, (ll)inner_count);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = tuple(map(int, input().split()))

plus = {}
minus = {}
for i in range(n):
    p = i + 1 + a[i]
    m = i + 1 - a[i]
    if p not in plus:
        plus[p] = 0
    if m not in minus:
        minus[m] = 0
    plus[p] += 1
    minus[m] += 1

cnt = 0
for i in plus.keys():
    if i in minus:
        cnt += plus[i]*minus[i]

print(cnt)

Measured memory_bytes: 146340
s=input()
s=sorted(s)
a=1
if len(s)%2==1:
  a=0
else:
  for i in range(len(s)//2):
    if s[2*i]==s[2*i+1]:
      a*=1
    else:
      a*=0
if a==1:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void){
  char S[10];
  scanf("%s",S);

  long long ans = 0;
  long long len = (long)pow(2,strlen(S)-1);
  for(int i = 0;i < len;i++){
    int j = i;
    int cnt = 0;
    long long res = 0;
    while(cnt < strlen(S)){
      res *= 10;
      res += S[cnt]-48;
      if(j%2 != 0){
        ans += res;
        res = 0;
      }
      j /= 2;
      cnt++;
    }
    ans += res;
  }
  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 128
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while (false)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main(); return 0;
}
#endif

void Main() {
  int a, b; cin >> a >> b;
  for(int i = 1; i <= 1000; i++) {
    int A = i * 8 / 100, B = i * 10 / 100;
    if(a == A && b == B) {
      cout << i << "\n";
      return;
    }
  }
  cout << "-1\n";
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  vector<int64> f(n+1,0);
  for(int32 x = 1; x * x <= n; ++x){
    for(int32 y = 1; y * y <= n; ++y){
      for(int32 z = 1; z * z <= n; ++z){
        if(x * x + y * y + z * z + x * y + y * z + z * x <= n){
          f[x * x + y * y + z * z + x * y + y * z + z * x]++;
        }
      }
    }
  }
  FOR(i,1,n+1)ANS(f[i]);
  return 0;
}

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


int main() 
{
	int N;
  	cin>>N;
    
  	int ai;
  	int max_wk=-1000000;
  	int min_wk=1000000;
  	long sum=0;
	for(int i=0;i<N;i++){
      cin>>ai;
      max_wk=max(max_wk,ai);
      min_wk=min(min_wk,ai);
      sum+=ai;
    }
  
  	cout<<min_wk<<' '<<max_wk<<' '<<sum<<endl;
    return 0;
}




Measured memory_bytes: 3112
#include <cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	int n;
	cin >> n;
	pair<string, int>menu[105];
	pair<pair<string,int>, int>p[105];
	for (int i = 0; i < n; i++) {
		cin >> menu[i].first >> menu[i].second;
		menu[i].second *= -1;
		p[i] = make_pair(menu[i], i + 1);
	}
	sort(p, p + n);
	for (int i = 0; i < n; i++) {
		cout << p[i].second << endl;
	}
	return 0;
}


Measured memory_bytes: 256
from collections import Counter
from functools import reduce
# import statistics
import bisect
import copy
import fractions
import operator
import math
import pprint
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)


n = II()
s = sorted([II() for _ in range(n)])
ans = sum(s)
tmp = 0
while ans % 10 == 0:
    if s[tmp] % 10 != 0:
        ans -= s[tmp]
        print(ans)
        exit()
    tmp += 1
    if tmp == n:
        print(0)
        exit()
print(ans)


Measured memory_bytes: 6348
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double t = sc.nextDouble();
		double a = sc.nextDouble();
		int[] arr = new int[n];
		double min = Double.MAX_VALUE;
		int res = -1;
		for (int i = 0; i<n; i++) {
			double tmp = Math.abs(a - (t - 0.006 * sc.nextInt()));
			if (tmp < min) {
				res = i+1;
				min = tmp;
			}
		}
		System.out.println(res);

	}
}


Measured memory_bytes: 25172
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv;

void main() {
  auto a = map!(x => x.to!int)(readln.chomp.split);
  if (a[0] + a[1] == a[2] + a[3]) {
    writeln("Balanced");
  } else if (a[0] + a[1] < a[2] + a[3]) {
    writeln("Right");
  } else {
    writeln("Left");
  }
}


Measured memory_bytes: 256
S=input()
a,b,c=0,0,0
for i in range(len(S)):
  if S[i]=="a":
    a+=1
  if S[i]=="b":
    b+=1
  if S[i]=="c":
    c+=1
m=min(a,b,c)
a,b,c=a-m,b-m,c-m
#print(a,b,c)

print("YES" if max(a,b,c)<=1 else "NO")

Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>

int d,n;
int fie[101][101];
int xmax[101];
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};

int max(int a,int b){
	if(a>b)return a;
	return b;
}

int main(void){
	scanf("%d",&d);
	for(int data=0;data<d;data++){
		if(data>0)printf("\n");
		scanf("%d",&n);
		memset(fie,0,sizeof(fie));
		memset(xmax,0,sizeof(xmax));
		for(int i=0;i<n;i++){
			fie[0][i]=1;
		}
		int len=0,mlen=n-1,x=0,y=0,dir=1,cnt=0;
		while(mlen>0){
			x+=dx[dir];
			y+=dy[dir];
			xmax[y]=max(xmax[y],x);
			fie[x][y]=1;
			len++;
			if(len==mlen){
				cnt++;
				if(mlen==1)break;
				dir=(dir+1)%4;
				len=0;
			}
			if(cnt==2){
				mlen-=2;
				cnt=0;
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				printf("%c",fie[j][i]==1?'#':' ');
			}
			printf("\n");
		}
	}
	return 0;
}

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

int main() {
    long int N;

    cin >> N;


    long int sum=0;

    for(int i=1;i<=N;i++){

        if(i%5!=0&&i%3!=0){
            sum=sum+i;
        }


    }

    cout << sum << endl;






    
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int a, b, x;

constexpr double pi = acos(-1);

int main()
{
    cin >> a >> b >> x;
    int volum = a * a * b;
    if (x <= volum / 2)
    {
        double dx = (2.0 * x) / (b * a);
        cout << fixed << setprecision(9) << atan2(b, dx) * 180 / pi;
    }
    else
    {
        int dif_vol = volum - x;
        double h = 1.0 * dif_vol / (a * a);
        cout << fixed << setprecision(9) << 90 - atan2(a, 2 * h) * 180 / pi;
    }
    return 0;
}


Measured memory_bytes: 256