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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ll a,b,k,cnt;
  cin >> a >> b >> k;
  cnt = 0;
  VI ans;
  FOR(i,1,max(a,b)+1){
    if(a%i == 0 && b%i == 0){
      ans.push_back(i);
    }
  }
  cout << ans[ans.size()-k] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  int n,x;
  cin >> n >> x;
  ll ans=0;
  vector<ll> a(n);
  rep(i,n){ cin >> a[i]; }
  rep(i,n-1){
    if(a[i]+a[i+1]>x){
      ll tmp = a[i]+a[i+1]-x;
      a[i+1] = max(0LL,a[i+1]-tmp);
      ans += tmp;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/python3
# -*- coding: utf-8 -*-



N = int(input())
Pn = list(map(int, input().split()))

In = [0] * (N+1)
for i in range(N):
  In[Pn[i]] = i+1

cnt = 0
l = [0] + [i for i in range(N+1)]
r = [i+1 for i in range((N+1))] + [N+1]

for v in range(1, N+1):
  i = In[v]
  
  l1 = l[i]
  l2 = l[l1]
  r1 = r[i]
  r2 = r[r1]
  cnt += ((l1-l2) * (r1-i) + (i-l1) * (r2-r1)) * v
  
  l[r1] = l1
  r[l1] = r1
    
print(cnt)


Measured memory_bytes: 60268
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define PB push_back
#define MP make_pair
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
const int MOD = 1000000007;
const int INF = 1000000000;


int main(){
    int n; cin >> n;
    VD v(n);
    REP(i, n) cin >> v[i];
    SORT(v);
    double ans = 0;
    REP(i, n){
        ans += v[i];
        if(i) ans /= 2;
    }
    cout << fixed << setprecision(10) << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)
g = [0] * (N + 1)
g[1] = 1
if S[1] == S[0]:
    g[2] = 1
else:
    g[2] = 2

for i in range(2, N):
    if S[i] != S[i-1]:
        g[i+1] = g[i] + 1
    else:
        g[i+1] = g[i-2] + 2

print(g[N])

Measured memory_bytes: 11144
s = int(input())

a = s // 10**9 + 1
b = 10**9 - s % 10**9
if a > 10**9:
  a -= 1
  b -= 10**9

assert abs(a * 10**9 - b) == s

print(" ".join(map(str, [0, 0, a, 1, b, 10**9])))

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static int sum(ArrayList<Integer> a){
        int total = 0;
        for(int number : a){
            total += number;
        }
        return total;
    }

    public static int min(ArrayList<Integer> a){
        int min_num = 1000000000;
        for(int number : a){
            if(min_num > number){
                min_num = number;
            }
        }
        return min_num;
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int total_distance = sc.nextInt();
        int number_of_points = sc.nextInt();
        ArrayList<Integer> points = new ArrayList<>();
        ArrayList<Integer> point_distance = new ArrayList<>();
        for(int i=0;i < number_of_points;i++){
            int number = sc.nextInt();
            points.add(number);
        }
        for(int i=0;i < number_of_points;i++){
            if(i == 0){
                point_distance.add(points.get(number_of_points-1) - points.get(0));
            }else{
                point_distance.add(total_distance - points.get(i) + points.get(i-1));
            }
        }
        System.out.println(min(point_distance));
    }
}

Measured memory_bytes: 90556
N,M,K=map(int,input().split())
A=[];B=[]
for i in range(M):
    a,b=map(int,input().split())
    A.append(a);B.append(b)
C=[];D=[]
for i in range(K):
    c,d=map(int,input().split())
    C.append(c);D.append(d)
f=[set() for i in range(N)]
b=[set() for i in range(N)]
for i in range(M):
    f[A[i]-1].add(B[i]-1)
    f[B[i]-1].add(A[i]-1)
for i in range(K):
    b[C[i]-1].add(D[i]-1)
    b[D[i]-1].add(C[i]-1)
checked=[False for i in range(N)]
class UnionFind:
    def __init__(self,n):
        self.n=n
        self.parents=[-1]*n
    def root(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.root(self.parents[x])
            return self.parents[x]
    def union(self,x,y):
        x=self.root(x)
        y=self.root(y)
        if x==y:
            return
        if self.parents[x]>self.parents[y]:
            x,y=y,x
        self.parents[x]+=self.parents[y]
        self.parents[y]=x
    def same(self,x,y):
        return self.root(x)==self.root(y)
    def size(self,x):
        return -self.parents[self.root(x)]
    def roots(self):
        return [i for i,x in enumerate(self.parents) if x<0]
    def group_count(self):
        return len(self.roots())
uf=UnionFind(N)
for i in range(N):
    for people in f[i]:
        uf.union(i,people)
ans=[]
for i in range(N):
    c=uf.size(i)
    bl=0
    for x in b[i]:
        if uf.same(i,x):
            bl+=1
    ans.append(c-bl-1-len(f[i]))
print(*ans)

Measured memory_bytes: 93344
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = [ni() for _ in range(n)]

suma = sum(a)
MOD = 998244353

dp_rgb = [[0]*(suma+1) for _ in range(n+1)]
dp_gb = [[0]*(suma+1) for _ in range(n+1)]

dp_rgb[0][0] = 1
dp_gb[0][0] = 1

for i, ai in enumerate(a):
    for sm in range(suma+1):
        if sm + ai <= suma:
            dp_rgb[i+1][sm+ai] += dp_rgb[i][sm] % MOD
            dp_gb[i+1][sm+ai] += dp_gb[i][sm] % MOD
            
        dp_rgb[i+1][sm] += 2 * dp_rgb[i][sm] % MOD
        dp_gb[i+1][sm] += dp_gb[i][sm] % MOD
        
ng = 3 * sum(dp_rgb[n][-(-suma//2):]) % MOD
ok = 0 if suma%2 else 3*dp_gb[n][suma//2] % MOD

print((pow(3,n,MOD) - ng + ok) % MOD)

Measured memory_bytes: 458648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int N=1e5+5;
ll dp[N];
ll power(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b&1)
            res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res%mod;
}
int main()
{
    int n,k;
    ll ans=0;
    scanf("%d%d",&n,&k);
    for(int i=k;i>=1;i--)//以i为gcd
    {
        int tk=k/i;
        dp[i]=power(1LL*tk,1LL*n);
        for(int j=i*2;j<=k;j+=i)
            dp[i]-=dp[j];
        //ll t=power(1LL*tk,1LL*n)-power(1LL*(tk-1),1LL*n);cout<<i<<"="<<t<<endl;
        ans=(ans+dp[i]*i%mod+mod)%mod;//cout<<ans<<endl;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4500
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int X, A, B; cin >> X >> A >> B;

    int x = X - A;
    //while (x >= B) x -= B;
    x %= B;

    int ans = x;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
h_list = list(map(int,input().split()))
count = 0
for i in range(1,max(h_list) + 1):
  p = 0
  check = False
  for j in range(n):
    if i > h_list[j]:
      if check == True:
        p += 1
      check = False
      
    else:
      if j == n-1:
        p += 1
      check = True
  count += p
  
print(count)
      
  
              

Measured memory_bytes: 38896
#include<iostream>
#include<algorithm>
#include<deque>
#include<string>
#include<map>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>

using namespace std;

int main(void) {
	int n, h, w; cin >> n >> h >> w;
	int i, sum = 0;
	int a[n], b[n];
  

	for (i = 0; i < n; i++) {
      cin>>a[i]>>b[i];
		int x = a[i] - h;
		int y = b[i] - w;
		if (x >= 0 && y >= 0) {
			sum++;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a=sc.nextLong();
    long b=sc.nextLong();
    long c=sc.nextLong();
    long d=sc.nextLong();
    
    long x=a*c;
    long y=a*d;
    long z=b*c;
    long w=b*d;
    
    if(x>=y&&x>=z&&x>=w)
    {
    	System.out.println(x); 
    }else {
    	if(y>=z&&y>=w&&y>=x) {
    		System.out.println(y);
    	}else {
    		if(z>=w&&z>=y&&z>=x) {
    			System.out.println(z);
    		}else {
    			System.out.println(w);
    		}
    	}
    }
  }
}
 

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

int main(){
  int n;
  cin >> n;
  long long int ans = 0;
  for(int i=1; i<n; i++){
    int j=1;
    while(i*j < n){
      ans++;
      j++;
    }
  }
  cout << ans << endl;
}


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

int main(){
  int n;
  cin >> n;
  
  if(n<100){
    cout << "0";
    return 0;
  }else{
    int x=n%100;
    int count=0;
    for(int i=5;i>0;i--){
      count+=x/i;
      x-=(x/i)*i;
    }
    if(n/100>=count){
      cout << "1";
    }else{
      cout << "0";
    }
  }
}

Measured memory_bytes: 3616
#include <iostream>
#include <map>

using namespace std;

int main(){
  long long N,K,Q;
  cin >> N >> K >> Q;
  map< int, int > table;
  for(int i=0; i<N; i++){
    table[i] = 0;
  }
  for(int i=0; i<Q; i++){
    int a;
    cin >> a;
    a--;
    table[a]++;
  }
  for(int i=0; i<N; i++){
    if(table[i] >= Q-K+1){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 5376
N,M = map(int,input().split())
shop_dict ={}
for i in range(N):
    price,num = map(int, input().split())
    if  price not in shop_dict:
        shop_dict[price] = num
    else:
        shop_dict[price] += num

shop_dict = sorted(shop_dict.items(), key = lambda x:x[0])

#print(shop_dict)
num_count = 0
money_count = 0
for i in range(N):
    #print(shop_dict[i][1] + num_count)
    if num_count + shop_dict[i][1] >= M:
        print(money_count + (M-num_count) * shop_dict[i][0])
     #   print("OK")
        exit()
    num_count += shop_dict[i][1]
    money_count += shop_dict[i][0] * shop_dict[i][1]






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

int main()
{

  int K;
  cin >> K;
  int A, B;
  cin >> A >> B;
  int flag = 0;
  for (int i = 0; i <= B - A; i++)
  {
    if ((A + i) % K == 0)
    {
      flag = 1;
      break;
    }
  }

  if (flag)
    cout << "OK";
  else
    cout << "NG";
  return 0;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		var A = GetInts(N);

		var cnt = new long[N + 1];
		for(int i = 0; i < N; i++)
			cnt[A[i]]++;

		long sum = 0;
		for(int i = 1; i <= N; i++)
			sum += cnt[i] * (cnt[i] - 1) / 2;

		var ans = new long[N];
		for(int i = 0; i < N; i++)
		{
			long tmp = sum - cnt[A[i]] * (cnt[A[i]] - 1) / 2;
			ans[i] = tmp + (cnt[A[i]] - 1) * (cnt[A[i]] - 2) / 2;
		}
		WriteLine(string.Join("\n", ans));
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 43788
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

AB = []
for a in A:
  for b in B:
    AB.append(a + b)
AB.sort(reverse = True)
AB = AB[:3000]

ABC = []
for ab in AB:
  for c in C:
    ABC.append(ab + c)
ABC.sort(reverse = True)

for i in range(K):
  print(ABC[i])

Measured memory_bytes: 148200
#include <bits/stdc++.h>
#define int long long

using namespace std;

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

    map<int, int> cnt;
    cnt[0] = 1;
    int s = 0, ans = 0;
    for (int i = 0; i < n; ++i) {
        int x; cin >> x;
        s += x;
        ans += cnt[s];
        cnt[s] += 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bs binary_search
#define pb push_back
#define pp pair<ll,ll>
#define F first 
#define S second 
#define lc "\n"
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
ll MAX=1e18 , MIN=-1e18 , MOD=1000000007;
int main() 
{
    fastio
    ll n=100,x,ans=0; cin>>x;
    while(n<x)
    {
        n+=(n/100);
        ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int R;
  cin >> R;
  cout << setprecision(16) << 2*M_PI*R << endl;
  return 0;
}

Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int T = sc.nextInt();
		final int X = sc.nextInt();
		
		final double A = (double) T / X;
		
		System.out.println(A);
	}

}

Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include<utility>
#include<map>
#include <queue>
#include <set>

using namespace std;

int main(){
	int n, a, b, ans=0;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		int sum=0,num=i;
		while (num > 0) {
			sum += num % 10;
			num /= 10;
		}
		if (sum >= a && sum <= b)ans += i;
	}
	cout << ans << endl;
 	return 0;
}



Measured memory_bytes: 256
#include <utility>
#include <algorithm>
#include <iostream>
#include <stdio.h>
using namespace std;

int main( void ) {

	int n, m, d, p, i, ans, guarded;
	pair<int,int> pd[10000];
	
	while ( scanf( "%d %d", &n, &m ) && ( n != 0 || m != 0 ) ) {
	
		ans = 0;
	
		for ( i = 0; i < n; i++ ) {
		
			scanf( "%d %d", &d, &p );
			pd[i] = make_pair( p, d );
		
		}
		
		sort( pd, pd + n );
		reverse( pd, pd + n );
	
		for ( i = 0; i < n; i++ ) { ans += pd[i].first * pd[i].second; }
		
		for ( i = 0; i < n && m > 0; i++ ) {
		
			guarded = min( m, pd[i].second );
			ans -= pd[i].first * guarded;
			m -= guarded;
			
		}
		
		printf( "%d\n", ans );
	
	}

	return 0;

}

Measured memory_bytes: 1264
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
using ll = long long;

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



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) c.begin(), c.end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int MAX_N = 200010;

int n, width;
int dat[MAX_N*4];

void init(){
    width = 1;
    while(width<n) width*=2;
    REP(i,2*width-1) dat[i] = 0;
}

void update(int i, int x){
    i += width-1;
    dat[i] = x;
    while (i>0){
        i = (i-1)/2;
        dat[i] = dat[i*2+1] + dat[i*2+2];
    }
}

int query(int a, int b, int k, int l, int r){
    if (r<=a || b<=l) return 0;
    if (a<=l && r<=b) return dat[k];
    int vl = query(a,b,k*2+1,l,(l+r)/2);
    int vr = query(a,b,k*2+2,(l+r)/2,r);
    return vl + vr;
}

int main(){
    ll m, k;
    cin >> m >> k;
    VL a(m);
    REP(i,m){
        scanf("%lld", &a[i]);
        a[i] -= k;
    }

    VL s(m+1);
    REP(i,m){
        s[i+1] = s[i] + a[i];
    }

    vector<pair<ll, ll> > b(m+1);
    REP(i,m+1){
        b[i].first = s[i];
        b[i].second = i;
    }
    sort(ALL(b));

    REP(i,m+1){
        s[b[i].second] = i;
    }

    n = m + 1;
    init();

    ll ans = 0;
    REP(i,m){
        update(s[i], 1);
        ans += query(0, s[i+1], 0, 0, width);
    }
    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)
  
  ll N;
  IN(N);
  vll mp(N);
  REP(i,N){
    ll a;
    IN(a);
    mp[i] = a-1;
  }
  ll ans = 0;
  REP(i,N){
    if(mp[i]>i && mp[mp[i]]==i) ans++;
  }

  OUT(ans);

  return 0;
}

Measured memory_bytes: 1024
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	int n, len;
multitest_loop:
	while (readf (" %s %s", &n, &len) > 0)
	{
		readln;
		auto a = readln.split.map !(to !(int)).array;
		foreach (i; 0..n - 1)
		{
			if (a[i] + a[i + 1] >= len)
			{
				writeln ("Possible");
				auto d = iota (1, n).array;
				reverse (d[i..$]);
				writefln ("%(%s\n%)", d);
				continue multitest_loop;
			}
		}
		writeln ("Impossible");
	}
}


Measured memory_bytes: 4424
#include<iostream>
#include<cstdio>
using namespace std;
using ll = long long;

int main(){
    ll w,h,x,y;
    cin>>w>>h>>x>>y;
    printf("%.10f %d\n",w*h/2.0,(x==w/2.0&&y==h/2.0)?1:0);
}

Measured memory_bytes: 3724
#include <cstdio>

int main()
{
  int x1, y1, x2, y2;
  scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
  
  int vecx = x1 - x2;
  int vecy = y1 - y2;
  
  printf("%d %d %d %d", x2 + vecy, y2 - vecx, x1 + vecy, y1 - vecx);
  return 0;
}

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

using namespace std;

long long factorial(int x) {
    long long res = 1;
    for(int i = 1; i <= x; i++) {
        res *= i;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    int x[n], y[n];
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }

    double result = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            result += hypot(x[i]-x[j], y[i]-y[j]);
        }
    }
    long long coeff = factorial(n-2) * (n-1) * 2;
    result = result * coeff / factorial(n);

    cout << fixed << result << endl;
}

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

int main(){
	int a, b;
	vector<int> output;
	while(cin >> a >> b){
		int sum = a + b;
		int digit = 0;
		while(sum){
			sum /= 10;
			digit++;
		}
		output.push_back(digit);
	}
	for(vector<int>::iterator itr = output.begin(); itr != output.end(); ++itr){
		cout << *itr << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define num(a) a-'0'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define vl vector<long long int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

void solve(){
	int n;
	cin>>n;
	v<p<int,int>> a(n);
	rep(i,0,n){
		cin>>a[i].f;
		a[i].s=i+1;
	}
	sort(all(a));
	rep(i,0,n){
		cout<<a[i].s<<" ";
	}
}

int main(){
	boost_io;
	cout<<setprecision(10);
	solve();
	return 0;
}


Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(aa) (aa).begin(), (aa).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<pill,int> PA;
//ll MOD;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	ll weight;
};
int M,N;
vi gr[214514];
int num[214514];
void dfs(int now, int from){
	for(int i=0;i<gr[now].size();i++){
		int nex=gr[now][i];
		if(nex!=from){
			num[nex]=1-num[now];
			dfs(nex,now);
		}
	}
}
int ans[214514]={0};
int main(){
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	cin>>N;
	rep(i,N-1){
		int a,b;
		cin>>a>>b;a--;b--;
		gr[a].pb(b);
		gr[b].pb(a);
	}

	num[0]=0;
	dfs(0,-1);
	int cnt0=0;
	rep(i,N){
		//cout<<num[i]<<" ";
		if(num[i]==0)cnt0++;
	}
	//cout<<endl;
	int tw=(N+1)/3;
	int an;
	if(tw>cnt0){//1に全部押し込む
		an=1;
		rep(i,N){
			if(an>N)continue;
			if(num[i]==1&&ans[i]==0){
				ans[i]=an;
				an+=3;
			}
		}
		an=2;
		rep(i,N){
			if(an>N)continue;
			if(num[i]==1&&ans[i]==0){
				ans[i]=an;
				an+=3;
			}
		}
		an=3;
		rep(i,N){
			//if(an>N)continue;
			if(ans[i]==0){
				ans[i]=an;
				an+=3;
			}
		}
	}else if(tw>(N-cnt0)){//0に全部押し込む
		an=1;
		rep(i,N){
			if(an>N)continue;
			if(num[i]==0&&ans[i]==0){
				ans[i]=an;
				an+=3;
			}
		}
		an=2;
		rep(i,N){
			if(an>N)continue;
			if(num[i]==0&&ans[i]==0){
				ans[i]=an;
				an+=3;
			}
		}
		an=3;
		rep(i,N){
			//if(an>N)continue;
			if(ans[i]==0){
				ans[i]=an;
				an+=3;
			}
		}
	}else{//0に1,1に2を押し込む
		an=1;
		rep(i,N){
			if(an>N)continue;
			if(num[i]==0&&ans[i]==0){
				ans[i]=an;
				an+=3;
			}
		}
		an=2;
		rep(i,N){
			if(an>N)continue;
			if(num[i]==1&&ans[i]==0){
				ans[i]=an;
				an+=3;
			}
		}
		an=3;
		rep(i,N){
			//if(an>N)continue;
			if(ans[i]==0){
				ans[i]=an;
				an+=3;
			}
		}
	}

	rep(i,N){
		cout<<ans[i]<<" ";
	}
	cout<<endl;
}

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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    int n;
    cin >> n;
    vl a(n);
    ll sum = 0;
    rep (i, n) {
        cin >> a[i];
        sum += a[i];
    }

    ll one = (ll)n * (n + 1) / 2;
    if (sum % one != 0) {
        cout << "NO" << endl;
        return 0;
    }

    ll op = sum / one;
    vl b(n);
    rep (i, n) {
        b[i] = a[(i + 1) % n] - a[i];
    }
    rep (i, n) {
        b[i] -= op;
    }

    ll num = 0;
    rep (i, n) {
        if (b[i] > 0) {
            cout << "NO" << endl;
            return 0;
        }
        if (-b[i] % n != 0) {
            cout << "NO" << endl;
            return 0;
        }
        num += -b[i] / n;
    }

    if (num == op) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }

}

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

int main() {
  string S;
  cin >> S;
  int a=S.size(),c=0;
  vector<char> b(a);
  for (int i=0;i<a;i++){
  b.at(i)=S.at(i);
  }
  sort(b.begin(),b.end());
  for (int i=0;i<a-1;i++){
  if (b.at(i)==b.at(i+1)){
  c++;
  }
  }
  
  if(c>0){
  cout << "no" << endl;
  }
  else {
  cout << "yes" << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define P pair<ll, ll>
#define V vector<ll>
#define C vector<char>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mod 1000000007
#define rep(i, s, n) for (ll i = (ll)(s); i < (ll)(n); i++)


int power(ll x, unsigned int y)  
{  
	ll p=mod;
    ll res = 1;      
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    { 
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}  
ll gcdExtended(ll a, ll b, ll *x, ll *y)  
{  
    // Base Case  
    if (a == 0)  
    {  
        *x = 0;  
        *y = 1;  
        return b;  
    }  
  
    ll x1, y1; // Tor store results of recursive call  
    ll gcd = gcdExtended(b%a, a, &x1, &y1);  
  
    // Update x and y using results of  
    // recursive call  
    *x = y1 - (b/a) * x1;  
    *y = x1;  
  
    return gcd;  
}  

int main()
{
	string s;
	cin>>s;
	ll i=0;
	ll ans[s.length()];
	while (i<s.length())
	{
		ll cur=i;
		ll cnt=0;
		while (s[i]=='R')
		{
			cnt++;
			i++;
		}
		for (ll k=cur;k<i-1;k++)
			ans[k]=0;
		ans[i-1]=cnt;
		cur=i;
		cnt=0;
		while (s[i]=='L')
		{
			cnt++;
			i++;
		}
		ans[cur]=cnt;
		for (ll k=cur+1;k<=i-1;k++)
			ans[k]=0;
	}
	for (ll i=0;i<s.length()-1;i++)
	{
		if (s[i]=='R'&&s[i+1]=='L')
		{
			ll ti,ti1;
			ti=1+ans[i+1]/2+(ans[i]-1)/2;
			ti1=1+ans[i]/2+(ans[i+1]-1)/2;
			ans[i]=ti;
			ans[i+1]=ti1;
		}
	}
	for (ll i=0;i<s.length();i++)
		cout<<ans[i]<<" ";
 


}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    int K;
    string S;
    cin >> K >> S;
    if (S.length() <= K) { cout << S << endl; }
    else { cout << S.substr(0, K) + "..." << endl; }
}

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

int main() {
  int64_t A, B, C, D;
  cin >> A >> B >> C >> D;
  A--;
  int64_t a = A - (A / C + A / D - A / lcm(C, D));
  int64_t b = B - (B / C + B / D - B / lcm(C, D)); 
  cout << b - a << endl;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<iostream>
using namespace std;
#define MAX 100000

int A[MAX], n;

int partition(int p, int r)
{
	int x, i, j, t;
	x = A[r];
	i = p-1;
	for ( j = p; j < r; ++j )
	{
		if ( A[j] <= x )
		{
			i++;
			t = A[i]; A[i] = A[j]; A[j] = t;
		}
	}
	t = A[i+1]; A[i+1] = A[r]; A[r] = t;
	return i+1;
}

int main(int argc, char const *argv[])
{
	int i, q;
	scanf("%d",&n);
	for ( i = 0; i < n; ++i)
	{
		scanf("%d",&A[i]);
	}
	q = partition(0, n-1);
	for ( i = 0; i < n; ++i)
	{
		if(i) printf(" ");
		if(i == q) printf("[");
		printf("%d", A[i]);
		if(i == q) printf("]");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 3520
// ------------------------------------
// Date:2018/ 3/11
// Problem:ABC 074 SugarWater c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#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 ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

int A, B, C, D, E, F;

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

  cin >> A >> B >> C >> D >> E >> F;

  int ansW, ansS;
  double rate = 0.0;
  
  // water
  REP(a, F / A * 100) {
    REP(b, F / B * 100) {
      double water = (a * A + b * B) * 100;
      if (water > F) break;
      // sugar
      REP(c, F / C) {
	REP(d, F / D) {
	  double sugar = c * C + d * D;

	  // 例外の処理
	  if (sugar + water == 0) continue;
	  if (sugar + water > F) break;
	  if (water * E < sugar * 100) break;
	  
	  double tmp = (100 * sugar) / (sugar + water);

	  if (tmp >= rate) {
	    ansW = water;
	    ansS = sugar;
	    rate = tmp;
	  }
	}
      }
    }
  }

  cout << ansW + ansS << " " << ansS << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    cout << (in() + in() >= in() ? "Yes" : "No") << "\n";
}

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

ll f (ll n)
{
    return n*(n+1)/2;
}

int main(void) 
{
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <=n; i++)
    {
        ll r = n/i;
        ans += i * f(r);
       // cout <<  i * f(r) << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>

using namespace std;

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main () {
  int n;
  vector<int> cnt(1000000);
  cin >> n;
  for (int x = 1; x < 100; x++){
    for (int y = 1; y < 100; y++){
      for (int z = 1; z < 100; z++){
        cnt[x * x + y * y + z * z + x * y + y * z + z * x]++;
      }
    }
  }
  for (int i = 1; i <= n; i++){
    cout << cnt[i] << '\n';
  }  
  return 0;
}

Measured memory_bytes: 6992
#include <bits/stdc++.h>
#define INF 1e9
#define Rep(i, n, a) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, n, 0)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n + 1);
    rep(i, n) cin >> a[i];
    a[n] = 0;
    ll ans = 0;
    rep(i, n)
    {
        ans += a[i] / 2;
        a[i] %= 2;
        if (a[i] == 1 && a[i + 1] > 0)
        {
            ans++;
            a[i + 1]--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.io.IOException;

class Main 
{
	private static int[][] field;
	private static int W, H;
	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws IOException
	{
		int[] s;

		while(init())
		{
			s = find_start();
			dfs(s[0], s[1]);

			System.out.println(calc());
		}
	}

	private static boolean init() throws IOException
	{
		String str;
		
		W = sc.nextInt();
		H = sc.nextInt();

		if(W == 0 && H == 0)
		{
			return false;
		}

		field = new int[H][W];

		for(int i = 0; i < H; i++)
		{
			str = sc.next();

			for(int j = 0; j < W; j++)
			{
				switch(str.charAt(j))
				{
					case '.':
						field[i][j] = 0;
						break;

					case '#':
						field[i][j] = -1;
						break;

					case '@':
						field[i][j] = 1;
						break;
				}
			}
		}

		return true;
	}

	private static int[] find_start()
	{
		int[] s = new int[2];

		for(int i = 0; i < H; i++)
		{
			for(int j = 0; j < W; j++)
			{
				if(field[i][j] == 1)
				{
					s[0] = i;
					s[1] = j;
				}
			}
		}

		return s;
	}

	private static void dfs(int i, int j)
	{
		// System.out.println("("+i+","+j+")");

		if(0 < i && i < H - 1)
		{
			// up
			if(field[i - 1][j] == 0)
			{
				field[i - 1][j] = 1;
				dfs(i - 1, j);
			}

			// down
			if(field[i + 1][j] == 0)
			{
				field[i + 1][j] = 1;
				dfs(i + 1, j);
			}
		}
		else if(i == 0 && H != 1)
		{
			// down
			if(field[i + 1][j] == 0)
			{
				field[i + 1][j] = 1;
				dfs(i + 1, j);
			}
		}
		else if(i == H - 1 && H != 1)
		{
			// up
			if(field[i - 1][j] == 0)
			{
				field[i - 1][j] = 1;
				dfs(i - 1, j);
			}
		}

		if(0 < j && j < W - 1)
		{
			// left
			if(field[i][j - 1] == 0)
			{
				field[i][j - 1] = 1;
				dfs(i, j - 1);
			}

			// right
			if(field[i][j + 1] == 0)
			{
				field[i][j + 1] = 1;
				dfs(i, j + 1);
			}
		}
		else if(j == 0 && W != 1)
		{
			// right
			if(field[i][j + 1] == 0)
			{
				field[i][j + 1] = 1;
				dfs(i, j + 1);
			}
		}
		else if(j == W - 1 && W != 1)
		{
			// left
			if(field[i][j - 1] == 0)
			{
				field[i][j - 1] = 1;
				dfs(i, j - 1);
			}
		}
	}

	private static int calc()
	{
		int cnt = 0;

		for(int i = 0; i < H; i++)
		{
			for(int j = 0; j < W; j++)
			{
				if(field[i][j] == 1)
				{
					cnt++;
				}
			}
		}

		return cnt;
	}
}

Measured memory_bytes: 27172
#include <bits/stdc++.h>
#include <string>
#define rep(i, k) for(int i = 0; i < (k); i++)

using namespace std;

void dfs(vector<vector<int>> &tree, vector<int> &flow, int pool, int n, int par)
{
    pool += flow[n];
    flow[n] = pool;
    if(tree[n].size() == 0){
        return;
    }
    for(int i = 0; i < tree[n].size(); i++){
        int node = tree[n][i];
        if(node == par) continue;
        dfs(tree, flow, pool, node, n);
    }
    return;
}

int main(void)
{
    int N, Q;
    cin >> N >> Q;
    vector<vector<int> > tree(N, vector<int>());
    vector<int> flow(N);

    rep(i, N-1){
        int a, b;
        cin >> a >> b;
        tree[a-1].push_back(b-1);
        tree[b-1].push_back(a-1);
    }
    rep(i, Q){
        int p, x;
        cin >> p >> x;
        flow[p-1] += x;
    }
    dfs(tree, flow, 0, 0, 0);
    for(int i = 0; i < N-1; i++){
        cout << flow[i] << " ";
    }
    cout << flow[N-1] << endl;
    
    return 0;
}

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

int main() {
  int i, j, k, n, q, b, m, e, index, dest_index;
  int A[2][1010];

  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> A[0][i];
  }

  cin >> q;
  for (i = 0; i < q; ++i) {
    cin >> b >> m >> e;
    index = i % 2;
    for (j = 0; j < n; ++j) {
      A[!index][j] = A[index][j];
    }
    for (k = 0; k < (e - b); ++k) {
      dest_index = b + ((k + e - m) % (e - b));
      A[!index][dest_index] = A[index][b + k];
    }
  }

  for (i = 0; i < n; ++i) {
    if (i != 0) cout << ' ';
    cout << A[!index][i];
  }
  cout << endl;
  
  return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
char m[55][55];
int h,w;
int main(){
    cin>>h>>w;
    lol(i,h)lol(j,w)cin>>m[i][j];
    bool ok=true;
    lol(i,h){
	lol(j,w){
	    if(m[i][j]=='.')continue;
	    bool t=false;
	    int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
	    lol(r,4){
		int xx=j+dx[r],yy=i+dy[r];
		if(xx>=0&&xx<w&&yy>=0&&yy<h){
		    if(m[yy][xx]=='#')t=true;
		}
	    }
	    if(t==false)ok=false;
	}
    }
    cout<<(ok?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string.h>
#include<algorithm>
using namespace std;

int main() {
	int a,b,c,x;
	cin >> a>>b;
	x = 0;
	if (a * b * 1 % 2 == 0)x = x + 1;
	if (a * b * 2 % 2 == 0)x = x + 1;
	if (a * b * 3 % 2 == 0)x = x + 1;
	
	if (x == 3) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
class Dice {
    int *d;
public:
    Dice(int *pd);
    void roll(char dir);
    int me(int n);
};
Dice::Dice(int *pd) {
    d = pd;
}
void Dice::roll(char dir) {
    int tmp;
    if(dir=='E') {
        tmp = d[0];
        d[0] = d[3];
        d[3] = d[5];
        d[5] = d[2];
        d[2] = tmp;
        }
    else if(dir=='W') {
        tmp = d[0];
        d[0] = d[2];
        d[2] = d[5];
        d[5] = d[3];
        d[3] = tmp;
    }
    else if(dir=='S') {
        tmp = d[0];
        d[0] = d[4];
        d[4] = d[5];
        d[5] = d[1];
        d[1] = tmp;
    }
    else {
        tmp = d[0];
        d[0] = d[1];
        d[1] = d[5];
        d[5] = d[4];
        d[4] = tmp;
    }
}
int Dice::me(int n) {
    return d[n-1];
}
 
int main()
{
    int d[6];
    string dir;
    for (int i=0; i < 6; i++)
        cin >> d[i];
    cin >> dir;
    Dice dice(d);
    for (int i = 0; i < (dir.size()); i++)
        dice.roll(dir[i]);
    cout << dice.me(1) << endl;   
    return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <array>

using namespace std;

//デバッグ時はTESTを定義する。本番時はこの行をコメントアウトする
#define TEST //*******************************************************************************************************************************************

//そうすることで、以下に定義する、デバッグ時にのみ標準出力する、doutコマンドが実現できる。本番時はダミーストリームに出力
#ifdef TEST
    #define dout cout
#else
    stringstream dummy; //デバッグ時のdoutコマンドのダミー出力先
    #define dout dummy
#endif

int main(void) {
    int N;
    cin >> N;
    
    int p[N];
    
    int i;
    
    //input data
    for(i=0; i<N; i++) {
        cin >> p[i];
    }

    
//    //display p[]
//    for(i=0; i<N; i++) {
//        dout << p[i] << " ";
//    }
//    dout << endl;
    
    
    //indexとdataが等しいものを1、等しくないものを0にデータ変換する
    for(i=0; i<N; i++) {
        if( p[i] == i+1 )
            p[i] = 1;
        else
            p[i] = 0;
    }
    
    
//    //display p[]
//    for(i=0; i<N; i++) {
//        dout << p[i] << " ";
//    }
//    dout << endl;
    
    
    
    // 1 1 の並びを 1 0 に変換する
    for(i=0; i<N; i++) {
        if( p[i] == 1 && p[i+1] == 1 )
            p[i+1] = 0;
    }
    
    
//    //display p[]
//    for(i=0; i<N; i++) {
//        dout << p[i] << " ";
//    }
//    dout << endl;
    
    
    // 1の数を数える
    int cnt=0;
    for(i=0; i<N; i++) {
        if( p[i] == 1)
            cnt++;
    }

    cout << cnt << endl;
    

}

Measured memory_bytes: 640