akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define bll long long
#define dou double
#define For(i,a,b) for (int i=(a),_##i=(b); i<=_##i; ++i)
#define Rof(i,a,b) for (int i=(a),_##i=(b); i>=_##i; --i)
#define Mem(a,b) memset(a,b,sizeof(a))
#define Cpy(a,b) memcpy(a,b,sizeof(b))
 
const int maxn=1e5+100;
int N,M,u[maxn],link[maxn];
int dlt[maxn];
 
int get_u(int x,int &ret)
{
    if (x==u[x]) return x;
    u[x]=get_u(u[x],ret);
    ret+=dlt[x];
    dlt[x]=ret;
    return u[x];
}
 
bool check(int x,int y,int d)
{
    int rx=0,ry=0;
    int a=get_u(x,rx),b=get_u(y,ry);
    if (a==b) return (dlt[y]-dlt[x]==d);
    if (link[a]<link[b]) swap(a,b),swap(x,y),d=-d;
    u[b]=a;
    link[a]+=(link[a]==link[b]);
    dlt[b]=dlt[x]-dlt[y]+d;
    return 1;
}
 
int main()
{
    for (; scanf("%d%d",&N,&M)!=EOF; )
    {
        bool flag=1;
        For(i,1,N) u[i]=i,link[i]=0,dlt[i]=0;
        For(i,1,M)
        {
            int x,y,d;
            scanf("%d%d%d",&x,&y,&d);
            if (flag) flag=check(x,y,d);
        }
        if (flag)
            printf("Yes");
        else
            printf("No");
    }
}

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

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

    ll n, m;
    cin >> n >> m;

    if(n==2 || m==2) cout << 0 << endl;
    else if(min(n, m) == 1) cout << max(n, m) - 2 + 2*(max(n, m) == 1) << endl;
    else cout << (n-2) * (m-2) << endl;

}

Measured memory_bytes: 256
#import numpy as np
import math
#from fractions import gcd

def main():

    ##get int
    first_input = list(map(lambda x:int(x), input().split(" ")))
    #second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    #first_input = input().split(" ")

    R = first_input[0]

    print(R*2*math.pi)

if __name__ == '__main__':
    main()


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

ans = float('inf')
s = sum(A)
x = A[0]
y = s - x
d = abs(x-y)
ans = min(ans, d)

for i in range(1, N-1):
    x += A[i]
    y = s - x
    d = abs(x-y)
    ans = min(ans, d)

print(ans)


Measured memory_bytes: 24812
def main():
    a,b = map(int,input().split())

    ax,bx = 0,0
    from math import floor
    # 100/0.08 = 1250
    for i in range(1,1251):
        ax = floor(i*0.08)
        bx = floor(i*0.1)
        if ax == a and bx == b:
            print(i)
            return 0
    print(-1) 

if __name__ == '__main__':
    main()


Measured memory_bytes: 39024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	string s;
	cin >> s;
	ll sum = 0;
	vector<ll>seiM(s.size() + 1,-1);
	vector<ll>seiA(s.size() + 1, -1);
	vector<ll>sei(s.size() + 1, -1);
	seiM[0] = 0;
	seiA[s.size()] = 0;
	for (ll i = 0; i < s.size(); i++) {
		if (s[i] == '<') {
			seiM[i + 1] = seiM[i] + 1;
		}
		else {
			seiM[i + 1] = 0;
		}
	}
	for (ll i = s.size()-1; i >= 0; i--) {
		if (s[i] == '>') {
			seiA[i] = seiA[i+1] + 1;
		}
		else {
			seiA[i] = 0;
		}
	}
	for (ll i = 0; i < s.size()+1; i++) {
		sei[i] = max(seiA[i], seiM[i]);
		//cout << seiM[i] <<" ";
		sum += sei[i];
	}
	cout << endl;
	for (ll i = 0; i < s.size() + 1; i++) {
		sei[i] = max(seiA[i], seiM[i]);
		//cout << seiA[i] << " ";
		//sum += sei[i];
	}
	cout << endl;
	for (ll i = 0; i < s.size() + 1; i++) {
		sei[i] = max(seiA[i], seiM[i]);
		//cout << sei[i] << " ";
		//sum += sei[i];
	}
	cout << endl;
	cout << sum << endl;

}


Measured memory_bytes: 12548
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
#define REP(i,N) for(ll i=0;i<N;++i)

struct Node {
	Node(){};
	~Node() {
		delete left;
		delete right;
	};	
	long long key; 
	Node *parent;
	Node *left;
	Node *right;
};

// root node is not nullptr
void insert(Node *root, Node *z) {
	Node *y = nullptr;
	Node *x = root;
	while (x != nullptr) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	z->parent = y;
	if (z->key < y->key) {
		y->left = z;
	} else {
		y->right = z;
	}
}

void print_by_preorder(Node *node) {
	if (node == nullptr) return;
	cout << " " << node-> key; 
	print_by_preorder(node->left);
	print_by_preorder(node->right);
}

void print_by_inorder(Node *node) {
	if (node == nullptr) return;
	print_by_inorder(node->left);
	cout << " " << node-> key; 
	print_by_inorder(node->right);
}

int main () {
	ll m;
	cin >> m;
	Node *root = new Node();
	REP(i,m) {
		string s;
		cin >> s;
		ll key;
		if (s[0] == 'i') {
			cin >> key;
			// initialize root node
			if (i==0) {
				// root node
				root->left = root->right = nullptr;
				root->key = key;
				continue;
			}
			Node *node = new Node();
			node->key = key;
			node->left = nullptr; // caution
			node->right= nullptr; // caution
			insert(root, node);
		} else if (s[0] == 'p') {
			print_by_inorder(root);
			cout << endl;
			print_by_preorder(root);
			cout << endl;
		}
	}
	delete root; 
	return 0;
}




Measured memory_bytes: 26580
#include<stdio.h>

void Dice(char p, int []);

int Count(int[]);
 
int main(void){
    int d[6], d2[6], i, flg = 0;
    char str[2][4] = { "No","Yes" };
    for (i = 0; i < 6; i++)  scanf("%d", &d[i]);
    for (i = 0; i < 6; i++)  scanf("%d", &d2[i]);
    if (Count(d) >= 10) { printf("Yes\n"); return 0; }
    if (d[0] == d2[0]);
    else if (d[5] == d2[0]) Dice('N', d), Dice('N', d);
    else if (d[1] == d2[0]) Dice('N', d);
    else if (d[4] == d2[0]) Dice('S', d);
    else if (d[2] == d2[0]) Dice('W', d);
    else if (d[3] == d2[0]) Dice('E', d);
    if (d[1] == d2[1]);
    else if (d[4] == d2[1]) Dice('L', d), Dice('L', d);
    else if (d[2] == d2[1]) Dice('R', d);
    else if (d[3] == d2[1]) Dice('L', d);
    for (i = 3; i < 6; i++) {
        if (d[i] != d2[i]) break;
        if(i==5) flg = 1;
    }
    printf("%s\n", str[flg]);
    return 0;
}
 
void Dice(char p, int d[]) {
    int tmp;
    if (p == 'S') { tmp = d[0]; d[0] = d[4]; d[4] = d[5]; d[5] = d[1]; d[1] = tmp; }
    if (p == 'W') { tmp = d[0]; d[0] = d[2]; d[2] = d[5]; d[5] = d[3]; d[3] = tmp; }
    if (p == 'E') { tmp = d[0]; d[0] = d[3]; d[3] = d[5]; d[5] = d[2]; d[2] = tmp; }
    if (p == 'N') { tmp = d[0]; d[0] = d[1]; d[1] = d[5]; d[5] = d[4]; d[4] = tmp; }
    if (p == 'L') { tmp = d[1]; d[1] = d[3]; d[3] = d[4]; d[4] = d[2]; d[2] = tmp; }
    if (p == 'R') { tmp = d[1]; d[1] = d[2]; d[2] = d[4]; d[4] = d[3]; d[3] = tmp; }
}
 
int Count(int d[]){
    int cnt = 0, i, j;
    for (i = 0; i < 5; i++) {
        for (j = i + 1; j < 6; j++)
            if (d[i] == d[j])++cnt;
    }
    return cnt;
}

Measured memory_bytes: 580
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N;

int main() {
    cin >> N;

    vvi A(N, vi(2));
    for (int i = 0; i < N; i++) {
        cin >> A[i][0];
        A[i][1] = i + 1;
    }

    sort(A.begin(), A.end(), [](vi l, vi r) { return l[0] < r[0]; });

    for (int i = 0; i < N; i++) {
        cout << A[i][1] << ' ';
    }
    cout << endl;

    return 0;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

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

  vector<int> v(n);
  REP (i, n) {
    cin >> v[i];
  }

  int ans = v[0];
  REP (i, n) {
    if (ans > v[i]) ans = gcd(v[i], ans);
    else ans = gcd(ans, v[i]);
  }
  cout << ans << endl;

}


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

int main(){
  int n;
  list<int> L;
  char str[15];
  scanf("%d",&n);
  for(int i=0,num;i<n;i++){
    scanf("%s",str);
    if(str[0]=='i'){
      scanf("%d",&num);
      L.push_front(num);
    }
    else if(str[6]=='F'){
      L.pop_front();
    }
    else if(str[6]=='L'){
      L.pop_back();
    }
    else{
      scanf("%d",&num);
      for(list<int>::iterator it=L.begin();it!=L.end();it++){
	if(*it==num){
	  L.erase(it);
	  break;
	}
      }
    }
  }
  int i=0;
  for(list<int>::iterator it=L.begin();it!=L.end();it++){
    if(i++)printf(" ");
    printf("%d",*it);
  }
  printf("\n");
}
  
  

Measured memory_bytes: 32236
#ABC126-C

n,k = map(int,input().split())
coin_count = 0
dice_count = 0
def func(point,cointoss): #何回コインを投げるかを再帰でカウント
	if point >= k: #終了条件:点数がkに達した
		return cointoss #コインを投げた回数を返す
	return func(point*2,cointoss+1) #ポイントを２倍にして、カウント+1

for i in range(1,n+1):
	if not i >= k:
		coin_count += (1/2)**func(i,0) #１事象ごとに確率を算出
	else: #サイコロを投げた時点でkを超えてた
		coin_count += 1

print(coin_count/n) #nで割って確率を算出

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
 template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
using namespace std;

const long long INF=9000000000000000;
int main(){
  int n,a,b,aa=0,bb=1;
  cin>>n>>a>>b;
  char m[n];
  for(int i=0;i<n;i++){
    cin>>m[i];
    if(m[i]=='c')
      cout<<"No"<<endl;
    else if(m[i]=='a'){
      if(aa<a+b){
        cout<<"Yes"<<endl;
        aa++;
      }
      else
        cout<<"No"<<endl;
    }
    else{
      if(aa<a+b and b>=bb){
        cout<<"Yes"<<endl;
        aa++;
        bb++;
      }
      else
        cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    bool isok = false;
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
            if(i*j==n){
                isok = true;
            }
        }
    }
    if(isok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs,random
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

d = onem()

for i in range(d):
	print(random.randrange(1,27))



Measured memory_bytes: 76808
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int h,w;
	string field[50],ans[50];
	cin >> h >> w;
	for(int i = 0;i < h;i++) cin >> field[i];
	for(int i = 0;i < h;i++){
		ans[i] = "";
		for(int j = 0;j < w;j++) ans[i] += ".";
	}
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w - 1;j++){
			if(field[i][j] == '#' && field[i][j + 1] == '#'){
				ans[i][j] = '#';
				ans[i][j + 1] = '#';
			}
		}
	}
	for(int i = 0;i < w;i++){
		for(int j = 0;j < h - 1;j++){
			if(field[j][i] == '#' && field[j + 1][i] == '#'){
				ans[j][i] = '#';
				ans[j + 1][i] = '#';
			}
		}
	}
	bool flag = true;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(field[i][j] != ans[i][j]) flag = false;
		}
	}
	if(flag) Yes();
	else No();
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N, M; cin >> N >> M; 
	vector<int> E[100010]; 
	for(int i = 0; i < M; i++){
		int a, b; cin >> a >> b; 
		E[a].push_back(b); 
		E[b].push_back(a);
	}
	queue<int> que; 
	int INF = 114514; 
	int D[100010] = {}; 
	int F[100010] = {};
	que.push(1); 
	for(int i = 2; i <= N; i++) D[i] = INF;  
	while(que.size()){
		int p = que.front(); que.pop(); 
		for(auto v : E[p]){
			if(D[v] == INF){
				F[v] = p; 
				que.push(v); 
				D[v] = D[p] + 1; 
			}
		}
	}
	cout << "Yes" << "\n"; 
	for(int i = 2; i <= N; i++){
		cout << F[i] << "\n"; 
	}
}

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

class Program
{
	static void Main(string[] args)
	{
		int[] intArray = Console.ReadLine().Split(' ').Select(q => int.Parse(q)).ToArray();
		int N = intArray[0];
		int X = intArray[1];
		int[] xi = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
		for (int i = 0; i < N; i++)
			xi[i] = Math.Abs(xi[i] - X);
		if(N == 1)
        {
			Console.WriteLine(xi[0]);
			return;
		}
		int ans = xi[0];
		for (int i = 1; i < N; i++)
			ans = Math.Min(ans, Gcd(xi[i], ans));
		Console.WriteLine(ans);
	}

	/// <summary>
	/// アナグラム
	/// </summary>
	/// <param name="word1"></param>
	/// <param name="word2"></param>
	/// <returns></returns>
	static bool IsAnagramOf(string word1, string word2)
	{
		return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
	}
	/// <summary>
	/// 最小公倍数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static int Lcm(int a, int b)
	{
		return a * b / Gcd(a, b);
	}

	/// <summary>
	/// 最大公約数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static int Gcd(int a, int b)
	{
		if (a < b)
			// 引数を入替えて自分を呼び出す
			return Gcd(b, a);
		while (b != 0)
		{
			var remainder = a % b;
			a = b;
			b = remainder;
		}
		return a;
	}
}




//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();
//Console.WriteLine(cnt);

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];


Measured memory_bytes: 21728
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: [usize1; n],
        b: [i64; n],
        c: [i64; n - 1],
    }
    let mut tot = 0;
    for i in 0..n {
        tot += b[a[i]];
        if i >= 1 && a[i - 1] + 1 == a[i] {
            tot += c[a[i - 1]];
        }
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p = 0;
    cin >> n;
    x = n/500;
    sum += x*1000;
    y = n%500;
    sum += (y/5)*5;
    cout << sum;

    return 0;
}


Measured memory_bytes: 256
N,A,B=map(int,input().split())
S=input()
qual=0
foreignQual=0
for t in S:
    if qual<A+B:
        if t=="a":
            qual+=1
            print("Yes")
        elif t=="b" and foreignQual<B:
            qual+=1
            foreignQual+=1
            print("Yes")
        else:print("No")
    else:print("No")

Measured memory_bytes: 4016
#include<stdio.h>
int main(){
int x,y,z,zz;
long w;
int p[100][100];
int q[100][100];
for(int i=0;i<100;i++){
for(int j=0;j<100;j++){
p[i][j]=0;
q[i][j]=0;

}}
scanf("%d",&x);scanf("%d",&y);scanf("%d",&z);
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
scanf("%d",&zz);p[i][j]=zz;
}}
for(int i=0;i<y;i++){
for(int j=0;j<z;j++){
scanf("%d",&zz);q[i][j]=zz;
}}
w=0;
for(int i=0;i<x;i++){
for(int j=0;j<z;j++){
for(int k=0;k<y;k++){
w+=p[i][k]*q[k][j];
}
if(j<z-1)printf("%ld ",w);
else if(j==z-1)printf("%ld\n",w);
w=0;
}
}
return 0;

}

Measured memory_bytes: 1108
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;

	int go;
	
	if(n & 1) {
		go = n;
	}
	else {
		go = n + 1;
	}

	vector<pair<int,int>> edges;

	for(int i = 1; i <= n; i++) {
		for(int j = i + 1; j <= n; j++) {
			if(j + i == go) continue;
			edges.push_back(make_pair(i, j));
		}
	}

	cout << edges.size() << "\n";

	for(auto x : edges) cout << x.first << " " << x.second << "\n";
	
	return 0;
}


Measured memory_bytes: 384
/*input
2 1
1 10

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

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

  int n;
  cin >> n;
  for (int i = 1; i <= 9; i++) {
    int d = n / i;
    if (d <= 9 && d * i == n) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  puts("No");

  return 0;
}

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

int main() {
  int n, h;
  cin >> n >> h;
  vector<int> a(n), b(n);
  vector<pair<int, int>> s;
  int i;
  for (i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    s.push_back(make_pair(a[i], 1));
    s.push_back(make_pair(b[i], 0));
  }
  sort(s.begin(), s.end());
  int result = 0;
  for (i = s.size() - 1; i >= 0 && h > 0; i--) {
    if (s[i].second) {
      result += (h + s[i].first - 1) / s[i].first;
      h = 0;
    } else {
      result++;
      h -= s[i].first;
    }
  }
  cout << result << endl;
  return 0;
}


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

bool check(string s ){
  if ( s.size() < 6 ) return false;
  int d = 0, u = 0, l = 0;
  for ( int i = 0; i < s.size(); i++ ){
    char ch = s[i];
    if ( '0' <= ch && ch <= '9' ) d++;
    if ( 'a' <= ch && ch <= 'z' ) l++;
    if ( 'A' <= ch && ch <= 'Z' ) u++;
  }

  if ( d == 0 || u == 0 || l == 0 )  return false;
  return true;
}

main(){
  string s;
  cin >> s;
  if ( check(s) ) cout << "VALID" << endl;
  else cout << "INVALID" << endl;
}

Measured memory_bytes: 1184
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int n;
  cin >> n;
  map<string,ll>m;
  rep(i,n){
    string t;
    cin >> t;
    m[t]++;
  }
  cout << m.size() << endl;
  return 0;
}


Measured memory_bytes: 19256
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

fn main() {
    let a: u64 = read!();
    let b: f64 = read!();
    println!("{}", a * ((b * 1000.0) as u64) / 1000);
}


Measured memory_bytes: 2204
#include <iostream>
using namespace std;
int main() {
	int t, cont = 0,cont2 = 0;
	cin >> t;
	int a[t], b[t];
	for (int i = 0; i < t; i++)
	{
		cin >> a[i] >> b[i];
	}
	
	for (int i = 0; i < t - 2; i++)
	{
		cont = 0;
		if (a[i] == b[i]) {
			cont++;
		}
		if (a[i + 1] == b[i + 1])
		{
			cont++;
		}
		if (a[i + 2] == b[i + 2]) 
		{
			cont++;
		}
		if (cont == 3)
		{
			cont2++;
		}
	}
	
	if (cont2 > 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
}

Measured memory_bytes: 3036
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
    double r,d,s,pi;
    cin >> r;
    pi = 3.141592653589;
    d = 2*pi*r;
    s = pi*r*r;
    cout << fixed;
    cout << setprecision(5) << s << " " << d << "\n";
}


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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int A, B;
    cin >> A >> B;
    if (A == B)
        cout << A * 2;
    else
        cout << max(A, B) * 2 - 1;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

struct Edge {
  int src, dst;
  Edge(int s, int d) : src(s), dst(d) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

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

  Graph g(N);
  REP(i,N - 1) {
    g[a[i]].push_back(Edge(a[i], b[i]));
    g[b[i]].push_back(Edge(b[i], a[i]));
  }

  vector<int> prev(N, -2);
  queue<Edge> que;
  que.push(Edge(-1, 0));
  while(!que.empty()) {
    Edge q = que.front();
    que.pop();
    prev[q.dst] = q.src;
    for(Edge e: g[q.dst]) {
      if(prev[e.dst] != -2) continue;
      que.push(e);
    }
  }

  vector<int> path;
  int pos = N - 1;
  while(pos != -1) {
    path.push_back(pos);
    pos = prev[pos];
  }

  vector<int> c(N, 0);
  REP(i, path.size()) {
    if(i < path.size() / 2) c[path[i]] = -1;
    else c[path[i]] = 1;
  }

  queue<int> que2;
  REP(i, N) if(c[i] != 0) que2.push(i);
  while(!que2.empty()) {
    int q = que2.front();
    que2.pop();
    for(Edge e: g[q]) {
      if(c[e.dst] != 0) continue;
      c[e.dst] = c[e.src];
      que2.push(e.dst);
    }
  }

  int sum = 0;
  REP(i,N) sum += c[i];
  string ret = (sum > 0) ? "Fennec" : "Snuke";
  cout << ret << endl;

  return 0;
}



Measured memory_bytes: 8056
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <cmath>
#include <limits>
#include <iomanip>
using namespace std;
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; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))



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

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

int x[10], y[10];
double dist(int i, int j) {
	double dx = x[i] - x[j];
	double dy = y[i] - y[j];
	return pow(dx * dx + dy * dy, 0.5);
}

int main() {
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> x[i] >> y[i];
	}
	double sum = 0.0;
	vector<int> v(N);
	for (int i = 0; i < N; i++) v[i] = i + 1;
	do {
		for (int i = 0; i < N - 1; i++) sum += dist(v[i], v[i + 1]);
	} while (next_permutation(v.begin(), v.end()));

	int Factorial = 1;
	for (int i = 2; i <= N; i++)Factorial *= i;
	cout << fixed << setprecision(10) << sum / Factorial << endl;
}


Measured memory_bytes: 256
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;

int main()
{
    ll a,b,x;
    in a>>b>>x;

    if(a==0)
    {
        cout<<b/x+1<<endl;
        return 0;
    }

    ll ans=b/x-(a-1)/x;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if(a%3==0 || b%3==0 || (a+b)%3==0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main
{
   public static void main(String[] args) throws IOException
   {

      BufferedReader br =
       new BufferedReader(new InputStreamReader(System.in));

      String str = br.readLine();
      int S = Integer.parseInt(str);
	int h = S/3600;
	int m = S%3600/60;
	int s = S%60;
      System.out.println( h+":"+m+":"+s);

   }
}

Measured memory_bytes: 24240
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		TreeSet<Double> mountains = new TreeSet<Double>();
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()) {
			mountains.add(Double.valueOf(scan.next()));
		}
		System.out.println(mountains.last() - mountains.first());
		scan.close();
	}

}


Measured memory_bytes: 26424
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int i, j ,k;
	int n;
	cin >> n;
	vector<int> d(n);
	for (i = 0; i < n; i++){
		cin >> d[i];
	}

	sort(d.begin(), d.end());

	int a = d[n / 2 - 1];
	int b = d[n / 2];
	cout << b - a << endl;
}

Measured memory_bytes: 640
#include <iostream>

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

	int n;
	int m;
	std::cin >> n >> m;
	int sum = 0;

	for (int i = 1; i <= m; i++) {
		int now;
		std::cin >> now;
		sum += now;
	}

	if (n - sum >= 0) {
		std::cout << n - sum;
	}
	else {
		std::cout << -1;
	}

	return 0;
}

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

using namespace std;

const int N = 2e5 + 5;

int n;
long long a[N];
long long sum[N];

long long getsum(int l, int r) {
  return l == 0 ? sum[r] : sum[r] - sum[l - 1];
}

void divide(int l, int r, long long &p, long long &q) {
  long long tar = getsum(l, r) / 2;
  int low = l;
  int high = r;
  while (high - low > 5) {
    int mid = (low + high) / 2;
    if (getsum(l, mid) <= tar) {
      low = mid;
    } else {
      high = mid;
    } 
  }
  p = getsum(l, r);
  q = 0;
  for (int i = low; i <= high; ++i) {
    if (abs(getsum(l, i) - getsum(i + 1, r)) <= abs(p - q)) {
      p = getsum(l, i);
      q = getsum(i + 1, r);
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (i == 0) {
      sum[i] = a[i];
    } else {
      sum[i] = sum[i - 1] + a[i];
    }
  }
  long long ans = LLONG_MAX;
  for (int i = 1; i < n - 2; ++i) {
    long long p, q, l, r;
    divide(0, i, p, q);
    divide(i + 1, n - 1, l, r);
    ans = min(ans, max(max(p, q), max(l, r)) - min(min(l, r), min(p, q)));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

void swap(int *num1, int *num2)
{
	int swp = *num1;
	*num1 = *num2;
	*num2 = swp;
}

void sort(int ary[100], int n)
{
	int i, p;
	
	for(i=0; i<n; i++){	//すべての配列を
		for(p=n-1; 0<p; p--){	//先頭から小さい順に並べ替え
			if(ary[p-1] > ary[p]){
				swap(&ary[p-1], &ary[p]);
			}
			if(p == i)
				break;
		}
	}
}

int main(void)
{
	int n;
	int score[100] = { 0 };
	int sum;
	int i;
	
	scanf("%d", &n);
	for(sum=0,i=0; i<n; i++){
		scanf("%d", &score[i]);
		sum += score[i];
	}
	
	sort(score, n);
	
	for(i=0; i<n; i++){
		if(sum%10 == 0){
			if(score[i]%10 == 0){
				if(i == n-1){
					sum = 0;
					break;
				}
				continue;
			}
			else{
				sum -= score[i];
				break;
			}
		}
		else
			break;
	}
	
	printf("%d\n", sum);
	
	return 0;
}


Measured memory_bytes: 128
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ALDS1_1-D

Getting Started - Maximum Profit
????????¶??? : 1 sec, ?????¢?????¶??? : 65536 KB
?????§?????????

FX????????§????????°?????????????????¨????????????????????¨??§????????????????????????????????¨?????§????????????????????°????????????100???????????? 1000???????????????????????????????????? 1?????? 108???????????£??????????£??????¨???(108??? - 100???) \times 1000?????? = 8000??????????????????????????¨?????§????????????

???????????¨????????????????????? t ?????????????????? R_t (t = 0, 1, 2 ,,, n-1)?????\?????¨??????????????????????????§??????????????? R_j - R_i (????????????j > i ??¨??????) ????????§???????±??????????????????????
??\???

?????????????????´??° n ?????????????????????????¶???? n ????????´??° R_t (t = 0, 1, 2 ,,, n-1) ?????????????????????????????????
??????

?????§??????????????????????????????????????????
??¶?´?

    2 \leq n \leq 200,000
    1 \leq R_t \leq 10^9

??\?????? 1

6
5
3
1
3
4
3

??\?????? 1 ??????????????????

3

??\?????? 2

3
4
3
2

??\?????? 2 ??????????????????

-1

=end

class Fx
  def initialize(v)
    @len = v.length
    @v = Array.new(@len, 0)
    (0..(@len-1)).each {|i|
      @v[i] = v[i]}
  end

  def srch1
    maxdif = -1000000000
    (0..(@len-1)).each {|i|
      ((i+1)..(@len-1)).each {|j|
        #puts "i=#{i} j=#{j} "
        if @v[j]-@v[i] > maxdif then
          maxdif = @v[j]-@v[i]
          #puts "maxdif=#{maxdif}"
        end
      }
    }
    maxdif
  end

  def srch2
    pmin = @v[0]
    pmax = @v[1..(@len-1)].max
    maxdif = pmax - pmin
    (2..(@len-1)).each{|k|
      if (pmin > @v[k-1]) then
        pmin = @v[k-1]
      end
      if (pmax == @v[k-1]) then
        pmax = @v[k..(@len-1)].max
      end

      if pmax - pmin > maxdif then
        maxdif = pmax - pmin
      end
    }
    maxdif
  end
end


class Main
  def initialize
#    fh = open("ALDS1_1_D_in.txt")
    fh = STDIN
    n = fh.gets.chomp.to_i
    count=0
    r = Array.new(n,0)
    (0..(n-1)).each {|i|
      r[i] = fh.gets.chomp.to_i
    }

    fx = Fx.new(r)
    #puts fx.srch1()
    puts fx.srch2()
  end
end

if $0==__FILE__ then
  Main.new()
end

Measured memory_bytes: 11988
import java.util.Scanner;

public class Main {
  public static int head, tail;
  private final static int MAX = 100000;
  private static char[] Queue = new char[MAX];

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    while (true) {
      char[] S = sc.next().toCharArray();
      initialize();
      for (char s : S)
        enqueue(s);
      if (Character.toString(S[0]).equals("-"))
        break;
      int n = sc.nextInt();
      for (int i = 0; i < n; i++) {
        int m = sc.nextInt();
        for (int j = 0; j < m; j++) {
          enqueue(dequeue());
        }
      }
      for (int i = head; i < tail; i++) {
        System.out.print(Queue[i]);
      }
      System.out.println();
    }
  }

  private static void initialize() {
    head = tail = 0;
  }

  private static boolean isEmpty() {
    return head == tail;
  }

  private static boolean isFull() {
    return head == (tail + 1) % MAX;
  }

  private static void enqueue(char x) {
    if (isFull()) {
      throw new Error("Queue Over Flow");
    }
    Queue[tail] = x;
    tail = (tail + 1) % MAX;
  }

  private static char dequeue() {
    if (isEmpty()) {
      throw new Error("Queue Under Flow");
    }
    char x = Queue[head];
    head = (head + 1) % MAX;
    return x;
  }

}


Measured memory_bytes: 26612
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
inline int addmod(int x)
{
	return x>=mod?x-mod:x;
}
inline int submod(int x)
{
	return x<0?x+mod:x;
}
int fpow(int x,int y)
{
	int ans=1;
	while(y)
	{
		if(y&1) ans=1ll*ans*x%mod;
		x=1ll*x*x%mod;
		y/=2;
	}
	return ans;
}
int t,n,m,pn=1e5,fr[100005],infr[100005],a[2][100005],b[2][100005];
int C(int x,int y)
{
	if(x<0||y<0||x<y) return 0;
	return 1ll*fr[x]*infr[y]%mod*infr[x-y]%mod;
}
int getans(int x)
{
	int ans=0;
	for(int i=1;i<=x;i++)
	{
		int nw=C((x-i)/2+5,5);
		ans=addmod(ans+1ll*nw*C(i+4,9)%mod);
	}
	return ans;
}
int F(int x,int fl)
{
	int ans=0;
	for(int i=1;i<=m;i++)
	{
		int mul=b[fl][i];
		for(int j=1;j<=m;j++)
			if(j!=i) mul=1ll*mul*submod(x-a[fl][j])%mod*fpow(submod(a[fl][i]-a[fl][j]),mod-2)%mod;
		ans=addmod(ans+mul);
	}
	return ans;
}
int main()
{
	fr[0]=infr[0]=1;
	for(int i=1;i<=pn;i++)
		fr[i]=1ll*fr[i-1]*i%mod;
	infr[pn]=fpow(fr[pn],mod-2);
	for(int i=pn-1;i;i--)
		infr[i]=1ll*infr[i+1]*(i+1)%mod;
	m=50;
	for(int i=1;i<=m;i++)
	{
		a[1][i]=2*i+1;
		b[1][i]=getans(a[1][i]);
	}
	for(int i=1;i<=m;i++)
	{
		a[0][i]=2*i;
		b[0][i]=getans(a[0][i]);
	}
	/*for(int i=m+1;i<=200;i++)
	{
		int nw=2*i+1;
		printf("nw=%d,F=%d,getans=%d\n",nw,F(nw),getans(nw));
	}*/
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		printf("%d\n",F(n,n%2));
	}
	return 0;
}

Measured memory_bytes: 2504
#include <bits/stdc++.h> 
using namespace std;
 
bitset<2000007> dp;
int main()
{
    int n;
    cin >> n;
    vector <int> arr(n);
    int sum=0;
    dp[0]=1;
  	for(int i=1;i<=n;i++)
    {
      int x;
      cin>>x;
      sum=sum+x;
      dp=(dp|dp<<x);
    }
  
  int target= (sum+1)/2;
  
  for(int i=target;i<=sum;i++)
  {
    if(dp[i])
    {
      cout<<i;
      break;
    }
  }
  return 0;
}
  	

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
#include<numeric>
#include<set>
#include<iterator>
#include<cstdio>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)
int INF=1e9;
const long long mod=1e9+7;
#define ll long long

int main(){
  int N;
  cin>>N;
  int sum=0;
  for(int i=1;i<=N;i++){
    sum+=i;
  }
  cout<<sum<<endl;
  return 0;
}

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

int main(){
    int n,h;
    cin>>n>>h;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    int huru=a[n-1];
    long long nageru=0;
    int ans=0;
    for(int i=n-1;i>=0;i--){
        if(b[i]<huru) break;
        nageru+=b[i];
        ans++;
        if(nageru>=h) break;
    }
    if(h-nageru>0){
        ans+=(h-nageru)/huru;
        if((h-nageru)%huru) ans++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1024
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN           PIC X(8).
01 N            PIC 9(3).
01 R            PIC 9(4).
01 ans          PIC Z(3)9.

PROCEDURE DIVISION.
    ACCEPT LN.
    UNSTRING LN DELIMITED BY SPACE INTO N R.
    IF 10 <= N
        MOVE R TO ans
    ELSE
        COMPUTE ans = R + 100 * (10 - N)
    END-IF.
    DISPLAY ans.
    STOP RUN.


Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
int main()
{
  int n;
  cin>>n;
  int c=(n%10);
  if((c==2)||(c==4)||(c==5)||(c==7)||(c==9))
  {
    cout<<"hon"<<endl;
  }
  else if(c==3)
  {
    cout<<"bon"<<endl;
  }
  else
  {
    cout<<"pon"<<endl;
  }
}

Measured memory_bytes: 3632
n = gets.to_i
a = n.times.map { gets.split.map(&:to_i) }
d = a.map(&:dup)
n.times do |k|
  dk = d[k]
  n.times do |i|
    di = d[i]
    dik = di[k]
    ai = a[i]
    next if i == k
    (i + 1...n).each do |j|
      next if i == j || j == k
      tmp = dik + dk[j]
      if (dij = di[j]) > tmp
        puts -1
        exit
      elsif tmp == dij
        ai[j] = a[j][i] = 0
      end
    end
  end
end
p a.flatten.inject(&:+) / 2


Measured memory_bytes: 5756
'use strict';
function Main(input) {

  const n = Number(input[0]);
  const ary = (input[1].split(" ")).map(str => Number(str));
  const sum = ary.reduce((a,b) => a+b);
  const average = Math.round(sum/n);

  let result = 0;
  for (let i=0; i<n; i++) {
    result += (ary[i]-average)*(ary[i]-average);
  }

  console.log(result);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

template<typename T> struct comb {
	T n,k;
	LL numerator = 1;   //分子
	LL denominator = 1; //分母
	LL ans = 1;
	comb(T a, T b) : n(a), k(b) {set_nd();}

	// function
	/// 分子分母の設定
	void set_nd() {
		for (T i = 0, j = n; i < k; i++,j--) {
			numerator *= j;
			numerator %= MOD;
		}
		for (T i = 1; i < k + 1; i++) {
			denominator *= i;
			denominator %= MOD;
		}
	}
	/// a^b%pの計算
	LL calcInv(LL a,LL b,LL p) {
		if (b == 0) {
			return 1;
		}
		if (b % 2 == 0) {
			LL d = calcInv(a,b/2,p);
			return (d*d)%p;
		}
		return (a * calcInv(a,b-1,p)) % p;
	}

	LL getans() {
		denominator = calcInv(denominator,MOD-2,MOD);
		return (numerator * denominator) % MOD;
	}

};
//main code

int main(int argc, char const* argv[])
{
	string l;
	cin >> l;
	LL ans = 0;
	VVL dp(l.size()+1, VL(2,0)); // dp[i][j] i:上からi桁目まで見たとき j:0->i桁一致, 1->L未満が確定している
	dp[0][0] = 1;
	for (int i = 1; i <= l.size(); i++) {
		// i桁目が0で，
		if (l[i-1] == '0') {
			// a+bで0にする時
			// i-1でj=0 だった個数をそのまま
			dp[i][0] += dp[i-1][0];
			// j=1も同じ
			dp[i][1] += dp[i-1][1];
			// a+bで1にする時
			// j=0はありえない
			// j=1はi-1の時の*2になる(aで1を立てる or bで1を立てる
			dp[i][1] += (dp[i-1][1]*2)%MOD;
		}
		// i桁目が1で，
		else {
			// a+bで0にする時
			// i-1でのj=0,1どちらもj=1になる
			dp[i][1] += dp[i-1][0] + dp[i-1][1];
			// a+bで1にする時
			// j=0,j=1はそれぞれi-1の時の*2になる
			dp[i][0] += (dp[i-1][0]*2)%MOD;
			dp[i][1] += (dp[i-1][1]*2)%MOD;
		}
	}
	ans = (dp[l.size()][0] + dp[l.size()][1])%MOD;
	cout << ans << endl;
	return 0;
}


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

double dp[3005][3005];//当前概率[当前硬币数][向上硬币数] 
double p[3005];

signed main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)
	cin>>p[i];
	
	dp[1][0]=1-p[1],dp[1][1]=p[1];
	for(int i=2;i<=n;i++)
		for(int j=0;j<=n;j++){
			if(j==0)dp[i][0]=dp[i-1][0]*(1-p[i]);
			else dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
		}
	
	double ans=0;
	for(int i=1;i<=n;i++){
		if(i>n-i)ans+=dp[n][i];
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 74144
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (;n>0;n--) {
			p = 0;
			line = sc.next();
			System.out.println(formula());
		}
	}
	
	int p; String line;
	char next() {
		return line.charAt(p++);
	}
	
	int formula() {
		return exp();
	}
	
	int exp() {
		int a = term();
		char op = next();
		while (op == '+' || op == '-') {
			int b = term();
			if (op == '+') a += b;
			else a -= b;
			op = next();
		}
		p--;
		return a;
	}
	
	int term() {
		int a = num();
		char op = next();
		while(op == '*' || op == '/') {
			int b = num();
			if (op == '*') a *= b;
			else a /= b;
			op = next();
		}
		p--;
		return a;
	}
	
	int num() {
		char c = next();
		if (c == '(') {
			int num = exp(); p++; return num;
		}
		String num = "";
		while('0' <= c && c <= '9') {
			num += c; c = next();
		}
		p--;
		return Integer.parseInt(num);
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17212
#include<stdio.h>
int main()
{
    int H,A,S=0;
    scanf("%d %d",&H,&A);
    //for(S=H;S<=0;S=S-4)
    while(H>0)
    {
          H=H-A;
          S=S+1;
    }
    printf("%d\n",S);
    return 0;
}


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

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second

vector<int> pi_function(const string &s)
{
	int n = s.length();
	vector<int> pi(n);

	for (int i = 1, k = 0; i < n; ++i)
	{
		while (k && s[i] != s[k])
			k = pi[k - 1];
		k += s[i] == s[k];
		pi[i] = k;
	}

	return pi;
}

int main()
{
	#ifdef TurnRed
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	string s;
	cin >> n >> s;

	int ans = 0;
	for (int i = 1; i < n; ++i)
	{
		string x = s.substr(i, n-i) + "$" + s.substr(0, i);
		auto p = pi_function(x);
		ans = max(ans, *max_element(p.end() - i, p.end()));
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256