akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std ;
typedef long long ll;
typedef string str;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef pair<int, int> pii;
typedef vector<pii> vpii ;

#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  cin >> n ;
  vll num(n) ;
  set<ll> S ;
  REP(i,n){
    cin >> num[i] ;
    S.insert(num[i]) ;
  }
  if(SZ(S)>=4){
    no() ;
  }
  else{
    if(SZ(S)==1){
      auto itr = S.begin() ;
      ll a = (*itr) ;
      if((a^a)==a){
        yes() ;
      }
      else{
        no() ;
      }
    }
    else if(SZ(S)==2){
      auto itr = S.begin() ;
      ll a = (*itr) ;
      itr++ ;
      ll b = (*itr) ;
      int cnta = 0 ;
      int cntb = 0 ;
      REP(i,n){
        if(num[i]==a){
          cnta++ ;
        }
        else{
          cntb++ ;
        }
      }
      if(2*cnta==cntb && (a^b)==b){
        yes() ;
      }
      else{
        no() ;
      }
    }
    else{
      auto itr = S.begin() ;
      ll a = (*itr) ;
      itr++ ;
      ll b = (*itr) ;
      itr++ ;
      ll c = (*itr) ;
      if((a^b)!=c){
        no() ;
        return 0 ;
      }
      int cnta = 0 ;
      int cntb = 0 ;
      int cntc = 0 ;
      REP(i,n){
        if(num[i]==a){
          cnta++ ;
        }
        else if(num[i]==b){
          cntb++ ;
        }
        else if(num[i]==c){
          cntc++ ;
        }
      }
      if(max({cnta,cntb,cntc})==min({cnta,cntb,cntc})){
        yes() ;
      }
      else{
        no() ;
      }
    }
  }

  return 0 ;
}




Measured memory_bytes: 4480
#include <iostream>
#include<string.h> 
using namespace std;
 
int main()
{
int n ,x ,mx= -1;
scanf("%d",&n);
char s;
for(int i=0;i<=n;i++){
	scanf("%c",&s);
	if(s=='I'){
	x++;
	}
mx= max(x,mx);
	 if(s=='D'){
	x--;
	} }
printf("%d",mx);}

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

using namespace std;

int n,k,m;
int dp[305][305];
int sum[305][305];
int C[305][305];

int main()
{
	scanf("%d%d%d",&n,&k,&m);
	for(int i = 0;i <= k; ++ i) dp[1][i] = 1,sum[1][i] = k - i + 1;
	C[0][0] = 1;
	for(int i = 1;i <= 300; ++ i)
	{
		C[i][0] = 1;
		for(int j = 1;j <= i; ++ j)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % m;
	}
	for(int i = 2;i <= n + 1; ++ i)
		for(int j = k - 1;j >= 0; -- j)
		{
			for(int l = 1;l < i; ++ l)
				dp[i][j] = (dp[i][j] + dp[l][j] * 1ll * sum[i - l][j + 1] % m * C[i - 2][l - 1] % m) % m;
			sum[i][j] = sum[i][j + 1] + dp[i][j],sum[i][j] %= m;
		}
	printf("%d\n",dp[n + 1][0]);
}

Measured memory_bytes: 1280
import java.util.*;

class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int cnt = sc.nextInt(); //入力データ数用
		int fst;				//比較初期値
		int min = 0;			//最大値用変数とりあえず０で初期化
		int max = 0;			//最小値用変数とりあえず０で初期化
		long sum = 0;     		//合計用変数
		for(int i = 0; i < cnt; i++){
			fst = sc.nextInt();
			if(i == 0){min = max = fst;}
			if(min > fst){ min = fst;}
			if(max < fst){ max = fst;}
			sum += fst;
		}
		System.out.println(min + " " + max + " " + sum);
	}
}

Measured memory_bytes: 31776
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
bitset<100005> vis;
vector<int> ans;

void dfs(int v1) {
	vis[v1]=true;
	ans.push_back(v1);
	for (int i=0; i<adj[v1].size(); i++) {
		if (!vis[adj[v1][i]]) {
			dfs(adj[v1][i]);
			break;
		}
	}
}

int main() {
	int n,m;
	scanf("%d%d", &n, &m);
	for (int i=0; i<m; i++) {
		int a,b;
		scanf("%d%d", &a, &b);
		a--; b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(0);
	reverse(ans.begin(),ans.end());
	for (int i=0; i<adj[0].size(); i++) {
		if (!vis[adj[0][i]]) {
			dfs(adj[0][i]);
			break;
		}
	}
	printf("%d\n", ans.size());
	for (int i=0; i<ans.size(); i++) {
		printf("%d%c", ans[i]+1, i==ans.size()-1 ? '\n' : ' ');
	}
}


Measured memory_bytes: 9720
object Main extends App {
  import scala.io.StdIn._
  import scala.math._
  val n = readInt()
  val series = 0L +: readLine.trim.split(' ').map(_.toLong) :+ 0L
  val diff = series.indices.tail.map{i ⇒ series(i) - series(i - 1)}.toArray
  var diffCount = (0 to n / 2).count(i ⇒ diff(i) != -diff(n - i))
  for (_ ← 0 until readInt()) {
    val Array(l, r, x) = readLine.trim.split(' ').map(_.toInt)
    if (l + r != n + 1) {
      if (diff(l - 1) == -diff(n - l + 1)) diffCount += 1
      diff(l - 1) += x
      if (diff(l - 1) == -diff(n - l + 1)) diffCount -= 1
      if (diff(r) == -diff(n - r)) diffCount += 1
      diff(r) -= x
      if (diff(r) == -diff(n - r)) diffCount -= 1
    }
    println(if (diffCount == 0) 1 else 0)
  }
}


Measured memory_bytes: 278072
package main

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

func main() {
  //fmt.Print("Input :")
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  var h int
  var w int

  for {
    if sc.Scan() { h, _ = strconv.Atoi(sc.Text()) }
    if sc.Scan() { w, _ = strconv.Atoi(sc.Text()) }

    if h == 0 && w == 0 { break }
    for i := 0; i < h; i++ {
      for j := 0; j < w; j++ {
        if (i+j)%2 == 0 {
          fmt.Print("#")
        } else {
          fmt.Print(".")
        }
      }
      fmt.Println()
    }
    fmt.Println()
  }
}



Measured memory_bytes: 1132
# -*- coding: utf-8 -*-
import sys
#s,t = map(list, input().split())
s = list(input())
t = list(input())

if len(s) < len(t):
    t2 = t.copy()
    for l in s:
        if l in t2:
            del t2[t2.index(l)]
        else:
            break
    else:
        print('Yes')
        sys.exit()

s.sort()
t.sort()

if s[0] < t[-1]:
    print ('Yes')
    sys.exit()
    
print('No')


Measured memory_bytes: 3060
fn main() {
    let mut input;
    loop {
        input = String::new();
        std::io::stdin().read_line(&mut input).expect("Input error");
        let mut n = input.trim().parse::<u64>().expect("Error parse");
        if n == 0 {
            break;
        }
        let mut zero = 0;
        while n >= 5 {
            zero += n / 5;
            n = n / 5;
        }
        println!("{}", zero);
    }
}



Measured memory_bytes: 5032
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        //int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        string input = Console.ReadLine();
        int total = 0;
        for(int a = 0; a < input.Length; a++)
        {
            total += int.Parse(input[a].ToString());
        }
        Console.WriteLine(total);


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

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

        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();

        int sum = 0;
        for(int i=1; i<=n; i++) {
            int num = i;
            int tmp = 0;
            while(true) {
                if(num > 0) {
                    tmp += num % 10;
                    num /= 10;
                } else {
                    break;
                }
            }
            if(tmp >= a && tmp <= b) {
                sum += i;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;

long long n, m, xx[100010], yy[100010], sum, v, mod = 1000000007, w;

int main()
{
	ios_base::sync_with_stdio( 0 );
	cin.tie( 0 );
	cin>>n>>m;
	for( int a = 1; a <= n; a++ )cin>>xx[a];
	for( int a = 1; a <= m; a++ )cin>>yy[a];
	sort( yy + 1, yy + m + 1 );
	for( int a = 2; a <= m; a++ )
	{
		w = yy[a] - yy[a-1];
		w *= (a-1);
		w %= mod;
		w *= ( m - a + 1);
		w %= mod;
		sum += w;
		sum %= mod;
	}
	sort( xx + 1, xx + n + 1 );
	for( int a = 2; a <= n; a++ )
	{
		w = xx[a] - xx[a-1];
		w *= (a-1);
		w %= mod;
		w *= ( n - a + 1);
		w %= mod;
		v += w;
		v %= mod;
	}
	//cout<<sum<<" "<<v<<endl;
	sum *= v;
	sum %= mod;
	cout<<sum<<endl;
	
	return 0;
}
 



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

using namespace std;

int main(){

  int N,D;
  cin >> N >> D;
  if( N % ( 2 * D + 1 ) != 0)
  cout << N / ( 2 * D + 1 ) + 1;
  else 
  cout << N / ( 2 * D + 1 );

  
 return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<ll> x(5);
    rep(i,5) cin >> x[i];
    rep(i,5){
        if (x[i] == 0){
            PRINT(i+1);
            return 0;
        }
    }
}


Measured memory_bytes: 3620
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>

using namespace std;

int main()
{
    // 整数の入力
    long long H,W,N,ai,i,j;
    vector<long long> A;
    cin >> H >> W;
    cin >> N;
    for (i= 0;i<N;i++){
        cin >> ai;
        A.push_back(ai);
    }
    int **arr = new int*[H];
	// 配列の各要素でintの配列を動的生成
	for( int i=0; i<H; i++ ){
		arr[i] = new int[W];
	}

    long total = 0;
    for (i=0;i<N;i++){
        for (j= 0;j<A[i];j++){
            if ((total+j)/W % 2 == 0){
            arr[(total+j)/W][(total+j)%W]= i+1;
            }else{
                arr[(total+j)/W][W - 1 - (total+j)%W]= i+1;
            }
        }
        total += A[i];
    }

    for (i = 0;i<H;i++){
        for (j = 0;j<W;j++){
            cout << arr[i][j];
            if (j != W-1){
                cout << " ";
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n,m;
  cin >>n>>m;
  vector<int> l(m),r(m);
  for(int i=0; i<m; i++) cin >> l[i] >> r[i];
  sort(l.begin(),l.end());
  sort(r.begin(),r.end());
  
if(r[0]<l[m-1]) cout << 0 << endl;
 else cout << r[0]-l[m-1]+1 << endl;
  
  
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
int a[111111];

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	rep(i,n){
		cin>>a[i]; a[i]--;
	}
	int res=0;
	rep(v,n){
		if(v==a[a[v]])res++;
	}
	cout<<res/2<<endl;
	return 0;
}


Measured memory_bytes: 640
n,m,k=map(int,input().split())
A= list(map(int, input().split()))
B= list(map(int, input().split()))
a,b=[0],[0]
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

ans,j=0,m
for i in range(n+1):
    if a[i]>k:
        break
    while b[j]>k-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)


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

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

  if(K==0){
    cout << "Yes" << endl;
    return 0;
  }

  for(int i=0;i<=N;i++){
    for(int j=0;j<=M;j++){
      int tmp=i*j+(N-i)*(M-j);
      if(tmp==K){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int ma=-LINF,mi=LINF;
  for(int i=0;i<N;i++)ma=max(ma,v[i]);
  for(int i=0;i<N;i++)mi=min(mi,v[i]);
  if(ma+mi>0){
    int j;
    for(int i=0;i<N;i++)if(ma==v[i])j=i+1;
    cout<<2*N-1<<endl;
    for(int i=0;i<N;i++)cout<<j<<" "<<i+1<<endl;
    for(int i=1;i<N;i++)cout<<i<<" "<<i+1<<endl;
  }
  else{
    int j;
    for(int i=0;i<N;i++)if(mi==v[i])j=i+1;
    cout<<2*N-1<<endl;
    for(int i=0;i<N;i++)cout<<j<<" "<<i+1<<endl;
    for(int i=N-1;i>0;i--)cout<<i+1<<" "<<i<<endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int i,j=0,a,b,g,sum=0,x,min,h,n[36],nsave[36];
  char y,m[36],msave[36];
  scanf("%d",&g);
  for(i=0;i<g;i++){
    scanf(" %c%d",&m[i],&n[i]);
      }
  for(i=0;i<g;i++){
    msave[i] = m[i];
    nsave[i] = n[i];
  }
while(1){
    
    for(i=g-1;i>j;i--){
      if(n[i]<n[i-1]){
	x = n[i-1];
	n[i-1] = n[i];
	n[i] = x;
        y = m[i-1];
	m[i-1] = m[i];
	m[i] = y;
      }}
    j++;
    if(j==g-1)break;
   }
 
 for(i=0;i<g;i++){
    printf("%c%d",m[i],n[i]);
    if(i<g-1)printf(" ");
  }
  printf("\nStable\n");
  

  
  for(i=0;i<g;i++){
    min = i;
    h=0;
    for(j=i;j<g;j++){
      if(nsave[j] < nsave[min]){
	min = j;
        h++;}
    }
    if(h>0){
	x = nsave[i];
	nsave[i] = nsave[min];
	nsave[min]= x;
	y = msave[i];
	msave[i] = msave[min];
	msave[min] = y;
    }}

  for(i=0;i<g;i++){
    printf("%c%d",msave[i],nsave[i]);
    if(i<g-1)printf(" ");
  }
  printf("\n");
  for(i=0;i<g;i++){
    if(m[i] == msave[i])sum++;}
  if(sum==g)printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}

Measured memory_bytes: 612
#include<iostream>
using namespace std;
int N;

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

Measured memory_bytes: 256
#include<algorithm>
#include<bits/allocator.h>
#include<bits/basic_ios.h>
#include<bits/basic_string.h>
#include<bits/basic_string.tcc>
#include<bits/c++config.h>
#include<bits/char_traits.h>
#include<bits/cpp_type_traits.h>
#include<bits/cxxabi_forced.h>
#include<bits/ios_base.h>
#include<bits/locale_classes.h>
#include<bits/localefwd.h>
#include<bits/ostream_insert.h>
#include<bits/postypes.h>
#include<bits/range_access.h>
#include<bits/stl_algobase.h>
#include<bits/stl_function.h>
#include<bits/stl_iterator.h>
#include<bits/stl_iterator_base_funcs.h>
#include<bits/stl_iterator_base_types.h>
#include<bits/stringfwd.h>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwchar>
#include<cwctype>
#include<debug/debug.h>
#include<deque>
#include<exception>
#include<ext/atomicity.h>
#include<ext/numeric_traits.h>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int n,a[5][200];
int main()
{
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[0][i];
	for (int i=0;i<n;i++) cin>>a[1][i];
	for (int i=0;i<n-1;i++) a[0][i+1]+=a[0][i];
	a[1][0]+=a[0][0];
	for (int i=1;i<n;i++) a[1][i]+=max(a[1][i-1],a[0][i]);
	cout<<a[1][n-1];
	return 0;
}

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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

using namespace std;

// int solve(int m) {
// }

signed main() {
	int n, m; cin >> n;
	map<string, int> M;
	rep(i, n) {
		string x; cin >> x; M[x] = 1;
	}
	bool open = false;
	cin >> m;
	rep(i, m) {
		string id; cin >> id;
		if (M[id]) {
			if (!open) cout << "Opened by " << id << endl;
			else cout << "Closed by " << id << endl;
			open = !open;
		} else {
			cout << "Unknown " << id << endl;
		}
	}
}




Measured memory_bytes: 3256
#include<iostream>
#include<vector> 
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    int N;  cin >> N;
    long long bi, sm, cnt, ans;
    vector<int> v(N), u(N);
    for(int i=0; i<N; i++)  cin >> v[i];
    for(int i=0; i<N; i++)  cin >> u[i];

    bi = 0;
    sm = 0;
    cnt = 0;

    for(int i=0; i<N; i++){
        if(v[i] > u[i]){
            bi = bi + v[i] - u[i];
        }
        if(v[i] < u[i]){
            sm = sm + u[i] - v[i];
            if((u[i]-v[i])%2==1)    cnt++;
        }
    }
    if(sm-cnt >= 2*bi)  cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3680
/*-----------------------------------------------
*	Filename: D.cpp
*	Author: zhuyutian
*	Date: 2018.08.25
-----------------------------------------------*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
using namespace std;

#define ll long long
#define pii pair<int, int>
#define mpii(a, b) make_pair(a, b)
const int maxn = 200005;
const int INF = 1 << 30;
const double eps = 1e-6;
const int mod = 1000000007;

struct BIT {
	int n;
	int cnt[maxn];
	
	void init(int sz) { 
		memset(cnt, 0, sizeof cnt); 
		n = sz;
	}

	void add(int x) {
		while(x <= n) {
			cnt[x] += 1;
			x += x & -x;
		}
	}

	int sum(int x) {
		int res = 0;
		while(x) { res += cnt[x]; x -= x & -x; }
		return res;
	}

}bit;

int n,a[maxn];
ll larges,s[maxn];

bool check(int x) {
	s[0] = 0;
	for(int i = 1; i <= n; i++) {
		s[i] = (a[i] >= x ? 1 : -1);
		s[i] += s[i - 1];
	}
	bit.init(n * 2 + 2);
	ll cnt = 0;
	for(int i = 0; i <= n; i++) {
		cnt += bit.sum(s[i] + n + 1);
		bit.add(s[i] + n + 1);
	}
	return cnt >= larges;
}

int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	scanf("%d",&n);
	ll tot = 1ll * n * (n + 1) / 2;
	larges = (tot + 1) / 2;
	for(int i = 1; i <= n; i++) {
		scanf("%d",a + i);
	}
	int l = 1,r = mod;
	while(r - l > 1) {
		int mid = (l + r) >> 1;
		if(check(mid)) l = mid;
		else r = mid;
	}
	printf("%d\n",l);
	return 0;
}


Measured memory_bytes: 2176
#include <cstdio>
#include <cstdlib>

long long x;

void test(long long d)
{
	long long o = x / d;
	for (long long m = 0; m < 1000; m++){
		long long u =
			(m - d) * (m - d) * (m - d) * (m - d) +
			(m - d) * (m - d) * (m - d) * m +
			(m - d) * (m - d) * m * m +
			(m - d) * m * m * m +
			m * m * m * m;
		if (u == o){
			printf ("%lld %lld\n", m, m - d);
			exit(0);
		}
	}
}

int main()
{
	scanf ("%lld", &x);
	for (int d = 1; d <= 10000; d++) if (x % d == 0) test(d);

	return 0;
}

Measured memory_bytes: 1736
import sys

sys.setrecursionlimit(1000000)


def dfs(g: {}, v: int, path_list: [], added: {}):
    path_list.append(v)
    for next_v in g[v]:
        # # next_v が探索済だったらスルー
        if next_v in path_list:
            continue
        # 距離３なら追加可能か確認して次へ
        if len(path_list) == 3:
            if path_list[0] not in g[next_v]:
                dic_a = added.setdefault(path_list[0], set())
                dic_a.add(next_v)
                dic_b = added.setdefault(next_v, set())
                dic_b.add(path_list[0])
        # 距離1なら複製して次へ
        elif len(path_list) == 1:
            copied = [v]
            dfs(g, next_v, copied, added)
        # 距離2なら複製して次へ
        elif len(path_list) == 2:
            copied = path_list.copy()
            dfs(g, next_v, copied, added)


def main():
    n, k = map(int, input().split())
    if k == 1:
        print(0)
        return

    y = n // k
    x = n - k*y

    x1 = x
    x2 = abs(x - k)
    print(min(x1, x2))



main()


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

using namespace std;
int main()
{
    long long int n,a,b,p,sum;
    cin>>n>>a>>b;
    p=a+b;
    if(a-n%p<=0)
        sum=((long long int)n/p)*a+a;
    else
        sum=((long long int)n/p)*a+n%p;
    cout<<sum<<endl;
    return 0;
}

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

int main(){
  vector<int> s(4);
  for(int i=0;i<4;i++) cin>>s[i];
  sort(s.begin(),s.end());
  bool x=s[0]==1&&s[1]==4&&s[2]==7&&s[3]==9;
  if(x) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
function Main(input) {
	input = input.trim().split(" ");
  var mae = parseInt(input[0]);
  var ato = parseInt(input[2]);
  if(input[1] == "+"){
     console.log(mae + ato);
     }else{
     console.log(mae - ato);
     }
  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import heapq

N = int(input())
A = list(map(int,input().split()))
ans = max(A)
A = [-1*item for item in A]
heapq.heapify(A)
heapq.heappop(A)
flag = 1
for i in range(N-2):
    if flag == 1:
        a = heapq.heappop(A)
        ans += -1*a
        flag = 0
    else:
        ans += -1*a
        flag = 1
print(ans)

Measured memory_bytes: 31528
#include<bits/stdc++.h>
using namespace std;
int main(){
	
		double h,b,sum=0,c;
		cin>>h>>b;
		for(int i=0;i<b;i++){
		    cin>>c;
		    sum+=c;
		}
		if(sum>=h){
		    cout<<"Yes";
		}
		else{
		    cout<<"No";
		}
	return 0;
}

Measured memory_bytes: 3692
import java.util.Scanner;

/**
 * B - Golden Coins
 * 高橋君は金色の硬貨が好きです。
 * 自分が持っている 500 円硬貨 1 枚につき 1000、5 円硬貨 1 枚につき 5 の 嬉しさ を得ます。
 * 高橋君は X 円を持っています。
 * これを高橋君の嬉しさが最大になるように両替したとき、高橋君の嬉しさはいくらになりますか？
 * (なお、利用できる硬貨は 500 円玉、100 円玉、50 円玉、10 円玉、5 円玉、1 円玉の 6 種類とします。)
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 高橋くんの所持金
        int x = sc.nextInt();
        // 嬉しさ
        int happiness = 0;
        happiness  = ( x / 500 ) * 1000;
        happiness += ( ( x % 500 ) / 5 ) * 5;

        System.out.println( happiness );

        sc.close();
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <queue>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

int main(){

    ll H, W, N;
    cin >> H >> W >> N;

    cout << (N + (max(H, W)) - 1) / max(H, W) << endl;


}

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

const static double eps = 1e-9;

bool equal(const double& a, const double& b) {
  return abs(a - b) < eps;
}

struct tensor {
  vector<double> v;
  size_t n;
  
  tensor(){}
  
  tensor(const vector<double>& vec) {
    v = vec;
    n = vec.size();
  }
  
  tensor(const tensor& t) {
    v = t.v;
    n = t.n;
  }
  
  tensor operator+(const tensor& t) const {
    assert(n == t.n);
    vector<double> nv(v);
    for (int i = 0; i < n; ++i) nv[i] += t.v[i];
    return tensor(nv);
  }
  
  tensor operator-(const tensor& t) const {
    assert(n == t.n);
    vector<double> nv(v);
    for (int i = 0; i < n; ++i) nv[i] -= t.v[i];
    return tensor(nv);
  }
  
  tensor operator*(const double& a) const {
    vector<double> nv(v);
    for (int i = 0; i < n; ++i) nv[i] *= a;
    return tensor(nv);
  }
  
  double norm() const {
    double s(0.0);
    for (int i = 0; i < n; ++i) s += v[i] * v[i];
    return sqrt(s);
  }
  
  void rect_rotate_2d() {
    assert(n == 2);
    swap(v[0], v[1]);
    v[0] *= -1;
  }
};

struct circle {
  tensor o;
  double r;
  
  circle(){
    o.v.resize(2);
    o.n = 2;
  }
  
  circle(const tensor& center, const double& radius) {
    o = center;
    r = radius;
  }
  
  circle(const circle& c) {
    o = c.o;
    r = c.r;
  }
  
  vector<tensor> intersect(const circle& c) const {
    tensor v(c.o - o);
    double d(v.norm());
    if (equal(d, 0)) return {};
    double d1(d + r + c.r), d2(max(d, max(r, c.r)));
    if (equal(d1, d2)) return {o + v * (r / d)};
    if (d1 < d2 + eps) return {};
    double x((r * r + d * d - c.r * c.r) / (2 * d)), y(sqrt(r * r - x * x));
    tensor mid(o + v * (x / d));
    v.rect_rotate_2d();
    return {mid + v * (y / d), mid - v * (y / d)};
  }
  
  bool inside(const tensor& v) const {
    return (v - o).norm() < r + eps;
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  
  vector<circle> cs(n);
  for (int i = 0; i < n; ++i)
    cin >> cs[i].o.v[0] >> cs[i].o.v[1] >> cs[i].r;
  
  double min_t(0), max_t(400000);
  while (!equal(min_t, max_t)) {
    double mid_t((min_t + max_t) / 2);
    
    vector<circle> tcs(cs);
    for (circle& c: tcs) c.r = mid_t / c.r;
    
    vector<tensor> points;
    for (int i = 0; i < n; ++i) {
      points.push_back(cs[i].o);
      for (int j = 0; j < i; ++j) {
        vector<tensor> temp = tcs[i].intersect(tcs[j]);
        points.insert(points.end(), temp.begin(), temp.end());
      }
    }
    
    bool found(false);
    for (const tensor& p: points) {
      int cnt(0);
      for (int i = 0; i < n; ++i) cnt += tcs[i].inside(p);
      if (cnt >= k) {
        found = true;
        break;
      }
    }
    found ? max_t = mid_t : min_t = mid_t;
  }
  printf("%.10f\n", min_t);
  return 0;
}

Measured memory_bytes: 760
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($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 :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      _a: [i64; n]
   }
   let mut a: Vec<_> = _a
      .iter()
      .enumerate()
      .map(|(i, a)| a - 1 - i as i64)
      .collect();
   a.sort();
   let s: Vec<_> = a
      .iter()
      .scan(0, |state, a| {
         *state += *a;
         Some(*state)
      })
      .collect();
   let mut ans = s[n - 1] - (n as i64) * a[0];
   for i in 1..n {
      let score = (s[n - 1] - s[i - 1]) - ((n - i) as i64) * a[i] + a[i] * (i as i64) - s[i - 1];
      if score < ans {
         ans = score;
      }
   }
   println!("{}", ans);
}


Measured memory_bytes: 12540
#include<bits/stdc++.h>
using std::cout;
using std::cin;
using std::endl;

int main()
{
    char ring[201], x[100], tmp[101];

    cin >> tmp;
    std::strcpy(ring, tmp);
    std::strcat(ring, tmp);
    //cout << ring << endl;
    cin >> x;
    //cout << x << endl;

    if (std::strstr(ring, x) != NULL)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    

    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<ll, ll> P;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa; cin>>nyaa;

ll sum[100001][300];
ll truesum[100000][300];
int sz = 300;
ll t10[19];


int lenq(ll a, ll b) {
	return upper_bound(t10, t10 + 19, a*b)-t10;
}
void solve() {
	t10[0] = 1;
	rep(i, 18) {
		t10[i + 1] = t10[i] * 10;
	}
	int n, m; cin >> n >> m;
	vector<ll> a(n);
	vector<ll> b(m);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, m) {
		cin >> b[i];
	}
	vector<int> x;
	rep(i, n)x.push_back(a[i]);
	sort(x.begin(), x.end());
	x.erase(unique(x.begin(), x.end()), x.end());
	int di = (m + sz - 1) / sz;
	rep(i, m) {
		ll s = b[i];
		int le = 0;
		int loc = i / di;
		rep1(j, 18) {
			int id = lower_bound(x.begin(), x.end(), (t10[j]+s-1) / s) - x.begin();
			sum[le][loc] += j;
			sum[id][loc] -= j;
			le = id;
		}
			sum[le][loc] += 19;
			sum[x.size()][loc] -= 19;
	}
	rep(i, x.size()) {
		rep(j, sz) {
			sum[i + 1][j] += sum[i][j];
		}
	}
	vector<ll> alsum(n, 0);
	rep(i, n) {
		int id = lower_bound(x.begin(), x.end(), a[i]) - x.begin();
		rep(j, sz) {
			truesum[i][j] = sum[id][j];
			alsum[i] += truesum[i][j];
		}
	}
	vector<ll> allsum(n + 1, 0);
	rep(i, n) {
		allsum[i + 1] = allsum[i] + alsum[i];
	}
	/*rep(i, n + 1) {
		cout << "! " << allsum[i] << endl;
	}*/
	string ans;
	int q; cin >> q;
	//cout << allsum[n] << endl;
	rep(aa, q) {
		ll x; cin >> x; x--;
		if (x >= allsum[n]) {
			//cout << 'x'; 
			ans.push_back('x');
			continue;
		}
		int rw = upper_bound(allsum.begin(), allsum.end(), x) - allsum.begin();
		rw--;
		ll rest = x - allsum[rw];
		int loc = rw;
		int chk = sz - 1;
		rep(j, sz) {
			if (truesum[loc][j] <= rest) {
				rest -= truesum[loc][j];
			}
			else {
				chk = j; break;
			}
		}
		int sta = di * chk;
		while (true) {
			//cout << loc << " " << sta << " "<<rest<<endl;
			int len = lenq(a[loc], b[sta]);
			if (len > rest) {
				string st = to_string(a[loc] * b[sta]);
				//cout << st[rest];
				ans.push_back(st[rest]);
				break;
			}
			else {
				rest -= len;
				sta++;
			}
		}

	}
	cout << ans<<endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//find_prime();
	solve();
	//stop
		return 0;
}


Measured memory_bytes: 387764
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


void solve(long long H, long long W, long long N){
	LL v=max(H,W);
	cout << (N+v-1)/v << endl;

}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long N;
    scanf("%lld",&N);
    solve(H, W, N);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
using namespace std;
int main(){
    int a[10],temp[10];
    char c[100];
    vector<int>ans;
    bool f;
    while(scanf("%s",c)!=EOF){
        for(int i=1;i<=9;i++)a[i]=0;
        for(int i=0;i<13;i++)a[c[i]-'0']++;
        ans.clear();
        for(int i=1;i<=9;i++)if(a[i]<=3){
            a[i]++;
            for(int j=1;j<=9;j++)if(a[j]>=2){
                for(int k=1;k<=9;k++)temp[k]=a[k];
                temp[j]-=2;
                f=true;
                for(int k=1;k<=9&&f;k++){
                    if(temp[k]<0)f=false;
                    if(temp[k]>=3)temp[k]-=3;
                    if(temp[k]>0){
                        if(k>7)f=false;
                        else{
                            temp[k+1]-=temp[k];
                            temp[k+2]-=temp[k];
                        }
                    }
                }
                if(f){
                    ans.push_back(i);
                    break;
                }
            }
            a[i]--;
        }
        if(ans.empty())printf("0\n");
        else{
            printf("%d",ans[0]);
            for(int i=1;i<ans.size();i++)printf(" %d",ans[i]);
            printf("\n");
        }
    }
}

Measured memory_bytes: 2716
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;

int main(){
    int n,m;cin>>n>>m;
    vvin a(m,vin(2));
    if(m%2){
        int s=1;
        int l=(m/2)*2+1;
        rep(i,m/2){
            cout<<s<<" "<<l<<endl;
            s++;
            l--;
        }
        s=(m/2)*2+2;
        l=s+2*(m/2+1)-1;
        rep(i,m/2+1){
            cout<<s<<" "<<l<<endl;
            s++;
            l--;
        }
    }
    else{
        int s=1;
        int l=m+1;
        rep(i,m/2){
            cout<<s<<" "<<l<<endl;
            s++;
            l--;
        }
        s=m+2;
        l=s+m-1;
        rep(i,m/2){
            cout<<s<<" "<<l<<endl;
            s++;
            l--;
        }
    }
}

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

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  cin >> N;
  vector<ll> A(N);
  ll sum = 0;
  rep(i, N) {
    cin >> A[i];
    sum += A[i];
  }
  sum /= 2;
  ll sum1 = 0;
  ll sum2 = 0;
  for (int i = 1; i < N-1; i+=2) {
    sum1 += A[i];
    sum2 += A[i+1];
  }
  int s1 = 1;
  int s2 = 2;
  rep(i, N) {
    if (i % 2 == 0) {
      cout << 2*(sum-sum1) << ' ';
      sum1 = sum1 + A[(s1+N-1)%N] - A[s1%N];
      // cout << A[(s1+N-3)%N] << ' ' << A[s1%N] << endl;
      // cout << sum1 << endl;
      s1 += 2;
    }
    else {
      cout << 2*(sum-sum2) << ' ';
      sum2 = sum2 + A[(s2+N-1)%N] - A[s2%N];
      s2 += 2;
    }
  }
  cout << endl;
  // cout << sum << ' ' << sum1 << ' ' << sum2 << endl;
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
	int x;
	cin >> x;
	if (x == 7 || x == 5 || x == 3) {
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;
using static ConsoleReader;

class Program
{
    static void Main(string[] args)
    {
        var n = Read<int>();
        var a = ReadArray<string>(n);
        var results = a
            .GroupBy(el => el)
            .ToDictionary(gr => gr.Key, gr => gr.Count());

        foreach (var code in new[] { "AC", "WA", "TLE", "RE" })
        {
            Console.Write($"{code} x ");
            if (results.ContainsKey(code))
                Console.WriteLine(results[code]);
            else
                Console.WriteLine(0);
        }
    }
}

public static class IntExtentions
{
    public static void Times(this int n, Action<int> action)
    {
        for (var i = 0; i < n; i++)
        {
            action(i);
        }
    }

    public static void Times(this (int n, int m) dimensions, Action<int, int> action)
    {
        var (n, m) = dimensions;
        n.Times(i => m.Times(j => action(i, j)));
    }
}

public static class ConsoleReader
{
    public static T Read<T>()
        where T : IConvertible
    {
        var inputBuffer = new StringBuilder();
        int currChar;

        while ((currChar = Console.Read()) != -1)
        {
            if (!char.IsWhiteSpace((char)currChar))
            {
                inputBuffer.Append((char)currChar);
            }
            else if (inputBuffer.Length != 0)
            {
                break;
            }
        }

        return (T)Convert.ChangeType(inputBuffer.ToString(), typeof(T));
    }

    public static T[] ReadArray<T>(int count)
        where T : IConvertible
    {
        if (count < 0)
        {
            throw new ArgumentOutOfRangeException(nameof(count), $"'{nameof(count)}' must be >= 0");
        }

        var result = new T[count];

        for (var i = 0; i < count; i++)
        {
            result[i] = Read<T>();
        }

        return result;
    }
}

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

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

    int res = 1;

    for(int i=0;i<n;i++){
        if(res*2 <= res+k){
            res *= 2;
        }else{
            res += k;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		//半径と円周
		double dbradius = scan.nextDouble();
		double dbpai = Math.PI;

		//面積と円周
		double dbArea = (double)dbpai * dbradius * dbradius;
		double dbCirL = (double)2 * dbpai * dbradius;

		//formatメソッドで小数点の桁数を指定
		System.out.println(String.format("%.6f",dbArea)
								+ " " + String.format("%.6f", dbCirL));

		scan.close();
	}
}


Measured memory_bytes: 28348
from itertools import combinations_with_replacement as combination

N=int(input())
lst=[[0]*10 for i in range(10)]
for i in range(1,N+1):
	s=str(i)
	l=int(s[0])
	r=int(s[-1])
	lst[l][r]+=1
cmb=list(combination([i for i in range(1,10)],2))

ans=0

for i in range(len(cmb)):
	if cmb[i][0]!=cmb[i][1]:
		ans+=lst[cmb[i][0]][cmb[i][1]]*lst[cmb[i][1]][cmb[i][0]]
	ans+=lst[cmb[i][0]][cmb[i][1]]*lst[cmb[i][1]][cmb[i][0]]
    
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iterator>
#include <cstdio>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <chrono>
#include <functional>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No")
	{
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right)
	{
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;
int main()
{
	int a, b;
	int ans;
	cin >> a >> b;
	if (a%b == 0) {
		ans = 0;
	}
	else {
		ans = 1;
	}
	cout << ans << endl;
}



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

int main(int argc, char *argv[])
{
    int N, A, B;
    std::cin >> N >> A >> B;

    /*
    int ans = 0;
    for (int i = 0; i <= N; i++) {
        std::string str = std::to_string(i);

        int sum = 0;
        for (int j = 0; j < str.size(); j++) {
            sum += (int)(str[j] - '0'); 
        }
        if ((A <= sum) && (sum <= B)) {
            ans += i;
        }
    }

    std::cout << ans;
    */

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int sum = 0;
        int num = i;
        while (num > 0) {
            sum += (num % 10);
            num /= 10;
        }

        if ((A <= sum) && (sum <= B)) {
            ans += i;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};



int main() {
	int x,y;
	string s;
	cin>>s;int sl=s.length();
	cin>>x>>y;
	vi x_s,y_s;
	int syoki=0;
	rep(i,0,sl){
		if(s[i]=='F')syoki++;
		else break;
	}
	x-=syoki;
	//最初だけx軸正の方向に行くので補正.
	bool r=false;//x軸方向に向いているならtrue;
	int xstep=0,ystep=0;
	rep(i,syoki+1,sl){
		if(r){
			if(s[i]=='F')xstep++;
			if(s[i]=='T'||i==sl-1){
				x_s.push_back(xstep);
				xstep=0;
				r=false;
			}
		}else{
			if(s[i]=='F')ystep++;
			if(s[i]=='T'||i==sl-1){
				y_s.push_back(ystep);
				ystep=0;
				r=true;
			}
		}
	}
	sort(ALL(x_s),greater<>());
	sort(ALL(y_s),greater<>());
	int distx=0,disty=0;
	rep(i,0,x_s.size()){
		if(distx>=x)distx-=x_s[i];
		else distx+=x_s[i];
	}
	rep(i,0,y_s.size()){
		if(disty>=y)disty-=y_s[i];
		else disty+=y_s[i];
	}
	if(distx==x&&disty==y)print("Yes");
	else print("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  int S;
  cin>>S;
  int T=S;
  long long answer=0;
  long long convi[2001][2001];
  for(int i=0;i<=T;i++){
    for(int j=0;j<=i;j++){
      if(i==0||j==0||j==i) convi[i][j]=1;
      else convi[i][j]=(convi[i-1][j]+convi[i-1][j-1])%1000000007;
    }
  }
  for(int i=0;T-3>=0;i++){
    T-=3;
    answer=(answer+convi[T+i][i])%1000000007;
  }
  if(S<=2) cout<<0<<endl;
  else cout<<answer<<endl;
  
  return 0;
}

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

#define fi first
#define se second
#define allV(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back

typedef long long LL;
typedef pair< int, int > pii;
typedef pair< LL, LL > pLL;
typedef vector< pLL > vpLL;
typedef vector< int > vi;
typedef vector< pii > vpii;
typedef vector< LL > vL;

// GLOBAL
const int inf = 1e9+3;
const LL linf = (LL)inf*inf+2;

const LL MOD = 1e9+7;

int N;
LL S, dp[5002][5002];
// --

LL foo(int steps, int wordLen) {
	if (wordLen > steps) return 0;
	if (wordLen < 0) return 0;
	if (steps == 0) {
		if (wordLen == 0) return 1;
		return 0;
	}
	LL &DP = dp[steps][wordLen];
	if (DP == -1)
		DP = (foo(steps-1, max(0, wordLen-1)) + (foo(steps-1, wordLen+1)*2) % MOD) % MOD;
	// cout << steps << ' ' << wordLen << " -> " << DP << endl;
	return DP;
}

int main()
{
	ios_base::sync_with_stdio(false);

	memset(dp, -1, sizeof(dp));
	string str;
	cin >> N >> str;
	S = str.length();

	cout << foo(N, S) << '\n';

	return 0;
}


Measured memory_bytes: 195968
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

//完コピ。DFS要勉強

using namespace std;

typedef long long LL;

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}


bool graph[8][8];

int dfs(int v, int n, bool visited[8]) {
	bool all_visited = true;
	for (int i = 0; i < n; i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited) {
		return 1;
	}
	int ret = 0;
	for (int i = 0; i < n; i++) {
		if (graph[v][i] == false)
		{
			continue;
		}
		if (visited[i]) {
			continue;
		}
		visited[i] = true;
		ret += dfs(i, n, visited);
		visited[i] = false;
	}
	return ret;
}

int main(void) {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		graph[a - 1][b - 1] = graph[b - 1][a - 1] = true;
	}
	bool visited[8];
	for (int i = 0; i < n; i++) {
		visited[i] = false;
	}
	visited[0] = true;
	cout << dfs(0, n, visited) << endl;
	return 0;
}

Measured memory_bytes: 256