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

int main(){
  string S;
  cin>> S;
  if(S[0]==S[1]&&S[1]==S[3]){
    cout<< "No"<< endl;
  }
  else if(S[0]==S[1]&&S[2]==S[3]){
    cout<< "Yes"<< endl;
  }
  else if(S[0]==S[2]&&S[1]==S[3]){
    cout<< "Yes"<< endl;
  }
  else if(S[0]==S[3]&&S[1]==S[2]){
    cout<< "Yes"<< endl;
  }
  else{
    cout<< "No"<< endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

//ll a[10010][3];
ll dp[10010][3];

int main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    ll a;
    ll sum,sum2;
    sum = 0;
    sum2 = 0;
    rep(i, n)
    {
        cin >> a;
        v[i] = a;
        sum += a;
    }
    for (int i = 1; i <n-1;i+=2)
    {
        sum2 += v[i];
    }
    vector <ll> ans(n);
    ans[0] = sum - 2*sum2;
    rep2(i, 1, n)
    {
        ans[i] = 2 * v[i - 1] - ans[i - 1];
    }
    rep(i,n){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 2944
k = gets.to_i
a = gets.split.map(&:to_i).reverse

l = r = 2
a.each do |e|
    x = l.fdiv(e).ceil * e
    y = r.fdiv(e).floor * e + e - 1

    if !x.between?(l, r)
        p -1
        exit
    end
    
    l = x
    r = y
end

puts "#{l} #{r}"

Measured memory_bytes: 21692
#include <iostream>
#include <cmath>
using namespace std;
typedef long long  ll;
int main ()
{
    ll t1, t2;
    ll a1, a2, b1, b2;
    cin >> t1 >> t2;
    cin >> a1 >> a2;
    cin >> b1 >> b2;
    ll sa1 = a1 * t1, sa2 = a2 * t2;
    ll sb1 = b1 * t1, sb2 = b2 * t2;
    ll suma =sa1 + sa2 , sumb = sb1 + sb2;
    if(suma == sumb)
        cout << "infinity" << endl;
    else
    {
        if(sa1 < sb1 && suma < sumb || sa1 > sb1 && suma > sumb)
            cout << 0 <<endl;
        else if(sa1 < sb1 && suma > sumb || sa1 > sb1 && suma < sumb)
        {
            ll k1 = abs(suma - sumb);
            ll k2 = abs(sa1 - sb1);
            ll k3 = k2 / k1;
            if(k3 * k1 == k2)
                cout << 2 * k3 << endl;
            else
                cout << 2 * k3 + 1 << endl;
        }

    }
    return 0;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> data(M);
  int a=0;
  for(int i=0;i<M;i++){
    cin>>data.at(i);
    a+=data.at(i);
  }
  if(a<=N){
    cout<<N-a<<endl;
  }
  else{
    cout<<"-1"<<endl;
  }
}


Measured memory_bytes: 3640
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const long long MAX_N = 100000;
long long N;
vector<long long> Counter(MAX_N + 1, 0);

int main() {
  scanf("%lld", &N);
  long long ai;
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &ai);
    if (ai == 0) {
      ++Counter[0];
      ++Counter[1];
    } else {
      for (int j = -1; j < 2; ++j) {
        ++Counter[ai + j];
      }
    }
  }
  vector<long long>::iterator iter = max_element(Counter.begin(),
                                                 Counter.end());
  long long answer = distance(Counter.begin(), iter);
  printf("%lld\n", Counter[answer]);
}


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

using namespace std;

void solve2() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
}

void solve1() {
	int N;
	cin >> N;
	if (N / 10 == 9 || N % 10 == 9) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

int main() {
	//solve1();
	solve2();
	return 0;
}

Measured memory_bytes: 256
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

for bit in range(1 << d):
    count = 0
    sum = 0
    nokori = set(range(1, d + 1))

    for i in range(d):
        if bit & (1 << i):
            sum += pc[i][0] * (i + 1) * 100 + pc[i][1]
            count += pc[i][0]
            nokori.discard(i + 1)

    # G 点に満たなければ nokori のうち一番大きいものを解く
    if sum < g:
        use = max(nokori)
        n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
        count += n
        sum += n * use * 100

    if sum >= g:
        ans = min(ans, count)

print(ans)

Measured memory_bytes: 9248
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	long a=scan.nextInt();
	long b=scan.nextInt();
	long c=scan.nextInt();
	long st=1;
		if(b>c) {
			st=0;
		}
		else if(a==1&&b==c) {
			st=1;
		}
		else if(a==1) {
			st=0;
		}
		else {
			st=(c-b)*(a-2)+1;
		}
	System.out.println(st);
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;
 
int main(){
    int a,b;
    int c=0;
    cin>>a>>b;
    for (int i=a; i<=b; i++) {
        if (i%10==i/10000 && (i/1000)%10==(i/10)%10) c++;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int;  // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;

/*
 * データ変換 
 */
/* char -> int */
int ctoi(char c) { return (int)(c - '0'); }

/*
 * 数学的な計算
 */
/* 階乗 */
int factorial(int n) {
  int ret = 1;
  for (int i = 1; i < n + 1; ++i) {
    ret = ret * i;
  }
  return ret;
}

/* 最大公約数 */
template <typename T>
T gcd(T x, T y) { return x % y == 0 ? y : gcd(y, x % y); }

/* 最小公倍数 */
template <typename T>
T lcm(T a, T b) { return a * b / gcd(a, b); }

/* n個の整数の最小公倍数 */
template <typename T>
T lcm_n(vector<T> &numbers) {
  T l;
  l = numbers[0];
  for (int i = 1; i < numbers.size(); ++i) {
    l = lcm(l, numbers[i]);
  }
  return l;
}

/*
 * DP向け
 */
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;
}

/**
 * @param N 素因数分解する整数
 * @param result N = 2^3 * 3^2の場合、{{2, 3}, {3, 2}}のような形式のvectorが生成される
 * @brief 2, 3,..., √Nまでの整数をNで割っていき、割り切れる数と割った回数を保存することで、素因数分解を行う。
 *        O(√N)
*/
void prime_factorize(ll N, vector<pair<ll, ll>> &result) {
  for (ll a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    ll ex = 0;  // 指数

    // 割れる限り割り続ける
    while (N % a == 0) {
      ++ex;
      N /= a;
    }

    result.emplace_back(pair<ll, ll>{a, ex});
  }

  // 最後に残った数
  if (N != 1) result.emplace_back(pair<ll, ll>{N, 1});
}


int main() {
  long double a;
  long double b;
  cin >> a >> b;

  mpint ans = mpint(a * b);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3880
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define read(x) scanf("%d",&x)
const ll MOD=1e9+7;
int n;
int H[105];
inline ll pow2(int exp){
	ll ret=1,tmp=2;
	while(exp){
		if (exp&1) ret=ret*tmp%MOD;
		tmp=tmp*tmp%MOD;
		exp>>=1;
	}
	return ret;
}
inline pair<ll,ll> dp(int l,int r,int h){
	int low=2e9,cnt=0;
	for (int i=l;i<=r;++i){
		if (low==H[i]) ++cnt;
		else if (H[i]<low) low=H[i],cnt=1;
	}
	if (cnt==r-l+1){
		return mp(pow2(low-h)%MOD,(pow2(cnt)+pow2(low-h)-2)%MOD);
	}
	else{
		pair<ll,ll> data[105];int cntseg=0;
		for (int i=l;i<=r;){
			while(i<=r&&H[i]==low) ++i;
			int nl=i;
			while(i<=r&&H[i]>low) ++i;
			int nr=i-1;
			if (nr<nl) continue;
			data[++cntseg]=dp(nl,nr,low);
		}
		pair<ll,ll> ret=mp(1,1);
		for (int i=1;i<=cntseg;++i) ret.F=ret.F*data[i].F%MOD;
		ret.F=ret.F*pow2(low-h)%MOD;
		ll part1=1,part2=1;
		for (int i=1;i<=cntseg;++i) part1=part1*(data[i].F+data[i].S)%MOD;
		part1=part1*pow2(cnt)%MOD;
		for (int i=1;i<=cntseg;++i) part2=part2*data[i].F%MOD;
		part2=part2*(pow2(low-h)-2)%MOD;
		ret.S=(part1+part2)%MOD;
		return ret;
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for (int i=1;i<=n;++i) cin>>H[i];
	pair<ll,ll> ret=dp(1,n,0);
	cout<<ret.S<<endl;
	return 0;
}

Measured memory_bytes: 384
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
a = lines.shift() * 1
b = lines.shift() * 1
c = lines.shift() * 1
d = lines.shift() * 1
e = lines.shift() * 1
k = lines.shift() * 1
console.log(e - a <= k ? 'Yay!' : ':(' )

Measured memory_bytes: 7496
#include<iostream>
#include<vector>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    vector<int> ans;
    cin>>n;
    while(n)
    {
        int a=n%26;
        if(a==0)
        {
            ans.push_back(26);
            n=n/26-1;
        }
        else
        {
            ans.push_back(a);
            n=n/26;
        }
    }
    int k=ans.size();
    for(int i=k-1;i>=0;i--)
    {
        char c= ans[i] + 96;
        cout<<c;
    }
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = 0;
        for (int i = 0; i < 4; i++) {
            s += sc.nextInt();
        }
        System.out.println(s/60+"\n"+s%60);
    }
}


Measured memory_bytes: 26224
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int a, b, c, k, ans = 0,m;
	cin >> a >> b >> c >> k;
	m = max({ a,b,c });
	cout << m * pow(2, k) + a + b + c - m << endl;
}

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

int L[200000];
int R[200000];
int p[200000];
char s[200000];
int main() {
    int n,q;
    scanf("%d%d",&n,&q);
    memset(p,0,sizeof(p));
    scanf("%s",s+1);
    for(int i=2;i<=n;i++) {
        if(s[i]=='C' && s[i-1]=='A') {
            p[i]=1;
        }
    }
    for(int i=1;i<=n;i++) {
        p[i]+=p[i-1];
    }
    for(int i=1;i<=q;i++) {
        int l,r; scanf("%d%d",&l,&r);
        printf("%d\n",p[r]-p[l]);
    }
    return 0;
}


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

int main(){
	int length, count, res=0;
	string input;
	cin >> length >> input;
	for(int i=0;i<length;i++){
		string temp = input;
		temp.resize(i);
		string temp2 = input.substr(i);
		count = 0;
		for(int j='a';j<='z';j++){
			if(temp.find(j)!=string::npos && temp2.find(j)!=string::npos){
				count++;
			}
		}
		res = (count>res?count:res);
	}
	cout << res << endl;
	return 0;
}

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

using namespace std;

const int N=2e5+5,MOD=1e9+7;

int plu(int u,int v){
	return (u+v)%MOD;
}

int mul(int u,int v){
	return (int)(1LL*u*v%MOD);
}

int qpow(int u,int v=MOD-2){
	int rep=1;
	while(v>0){
		if(v&1){
			rep=mul(rep,u);
		}
		u=mul(u,u);
		v>>=1;
	}
	return rep;
}

int n,x,y,cnt[N],fac[N],invfac[N],ans;

int mi=0x3f3f3f3f,mii=0x3f3f3f3f,pos,ppos;

vector<int>G[N];

int main(){
	fac[0]=1;
	for(int i=1;i<=2e5;i++){
		fac[i]=mul(fac[i-1],i);
	}
	invfac[(int)2e5]=qpow(fac[(int)2e5]);
	for(int i=(int)2e5-1;~i;i--){
		invfac[i]=mul(invfac[i+1],i+1);
	}
//	for(int i=0;i<=10;i++){
//		printf("[%d]fac=%d inv=%d\n",i,fac[i],invfac[i]);
//	}
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1,u,v;i<=n;i++){
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
	}
	for(int i=1;i<=n;i++){
		if(!(int)G[i].size()){
			continue;
		}
		sort(G[i].begin(),G[i].end());
		if(G[i][0]<mi){
			mii=mi;ppos=pos;
			mi=G[i][0];pos=i;
		}
		else if(G[i][0]<mii){
			mii=G[i][0];ppos=i;
		}
	}
	for(int i=1;i<=n;i++){
		if(!(int)G[i].size()){
			continue;
		}
		if(G[i][0]+(i==pos?mii:mi)>y){
			continue;
		}
		cnt[i]=(int)(upper_bound(G[i].begin(),G[i].end(),i==pos?max(y-mii,x-G[i][0]):max(y-mi,x-G[i][0]))-G[i].begin());
		cnt[0]+=cnt[i];
	}
	ans=fac[cnt[0]];
	for(int i=1;i<=n;i++){
		ans=mul(ans,invfac[cnt[i]]);
	}
	printf("%d\n",ans);
//	for(int i=1;i<=n;i++){
//		printf("[%d]cnt=%d\n",i,cnt[i]);
//	}
	return 0;
}

Measured memory_bytes: 11648
def main():
    N = int(input())
    L = list(map(int, input().split()))
    sum = 0
    L.sort()
    for i in range(N - 1):
        sum += L[i]
    if sum > L[-1]:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()

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

int main() {
  int64_t N,A,B;
  cin >> N >> A >> B;
  
  int64_t r = N % (A + B);
  if (r <= A) {
    cout << N / (A + B) * A + r << endl;
  }
  else {
    cout << (N / (A + B) + 1) * A << endl;
  }
}


Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  case class Edge(to: Int, fee: Int, time: Long)

  case class Node(num: Int, time: Long)

  val N, M, _S = in.next().toInt
  val graph = Array.fill[List[Edge]](N+1)(Nil)
  val nodes = new Array[Node](N+1)
  for (i <- 1 to M) {
    val u, v, a, b = in.next().toInt
    val edge = 
    graph(u) = Edge(v, a, b) :: graph(u)
    graph(v) = Edge(u, a, b) :: graph(v)
  }
  for (i <- 1 to N) {
    val c, d = in.next().toInt
    nodes(i) = Node(c, d)
  }

  val sMax = 2500
  val S = Math.min(_S, sMax)


  //
  val MAX = Long.MaxValue

  val dist = Array.ofDim[Long](N+1, sMax+1) // from からの距離を格納する
  for (i <- 1 to N; j <- 0 to sMax)
    dist(i)(j) = MAX

  val check = Array.ofDim[Boolean](N+1, sMax+1)  // すでにその頂点からを調べたかのフラグ

  dist(1)(S) = 0

  val pq = new PriorityQueue[(Long, (Int, Int))]  // (-cost, node) queue
  pq.enqueue((-0, (S, 1)))

  // 頂点は v 個あるので、v 周する
  for(_ <- 0 until N * 2500) {
    // 調べ済みでない頂点のうち、最も近い頂点を now に入れる
    var nowNode = -1       // このターンにフォーカスするノード
    var ginka = -1
    var nowTime = -1L

    breakable {
      while(!pq.isEmpty) {
        val (_time, (_ginka, nodeNum)) = pq.dequeue
        nowNode = nodeNum
        ginka = _ginka
        nowTime = -_time
        if(!check(nowNode)(ginka)){  // まだチェックされていないノードだったら決定
          check(nowNode)(ginka) = true
          break
        }
      }
    }

    if (nowNode != -1) {
      val node = nodes(nowNode)
      if (ginka < sMax) {
        val nextTime = nowTime + node.time
        val nextGinka = (ginka + node.num) min sMax
        dist(nowNode)(nextGinka) = dist(nowNode)(nextGinka) min nextTime

        pq.enqueue((-nextTime, (nextGinka, nowNode)))
      }

      // その頂点からたどり着ける頂点の情報を更新する
      for(Edge(nextNode, fee, time) <- graph(nowNode)) {
        val nextTime = nowTime + time
        val nextGinka = ginka - fee

        if(nextGinka >= 0 && nextTime < dist(nextNode)(nextGinka)){  // 既存の通路より近いなら更新
          dist(nextNode)(nextGinka) = nextTime
          pq.enqueue((-nextTime, (nextGinka, nextNode)))
        }
      }
    }
  }

  for (i <- 2 to N) {
    pw.println(dist(i).min)
  }
  pw.flush()
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 77200
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
ll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}
ll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n,h,w;
    // ll ans=0;
    scanf("%lld%lld%lld",&h,&w,&n);
    ll a[n];
    rep(i,0,n){
        scanf("%lld",&a[i]);
    }
    ll csum[n];
    csum[0]=a[0];
    rep(i,1,n){
        csum[i]=csum[i-1] + a[i];
    }
    ll mark=0,color[h][w];
    rep(i,0,h){
        rep(j,0,w){
            ll b;
            if(i%2) b= (w-1) -j;
            else b=j;
            // printf("%lld %lld %lld\n",i,b,i*w+b);
            if((i*w+j)<csum[mark] ) color[i][b] = mark+1;
            else{
                mark++;
                color[i][b] = mark+1;
            }
        }
    }

    rep(i,0,h){
        rep(j,0,w){
            printf("%lld",color[i][j]);
            if(j!=w-1) printf(" ");
        }
        PN;
    }

    
    // printf("%lld\n");
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int modinv(Int a, Int m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

Int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int root_sum(int target, vi &parents, vi &nodes_value, vi &memo, int sum){
    if(memo[target] != -1){
        sum += memo[target];
        return sum;
    }
    if (parents[target] == target){
        sum+=nodes_value[target];
        return sum;
    }else{
        sum+=nodes_value[target];
        return root_sum(parents[target],parents, nodes_value, memo, sum);
    }
}


int main() {
    Int N,Q;

    cin >> N >> Q;

    vi parents = vi(N+1,0);
    vi nodes_value = vi(N+1,0);

    parents[1]=1;

    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        parents[b]=a;
    }


    rep(i,Q){
        int a,b;
        cin >> a >> b;
        nodes_value[a]+=b;
    }

    vi memo = vi(N+1,-1);
    REP(i,1,N+1){
        Int ans=0;
        ans = root_sum(i,parents,nodes_value,memo,0);
        memo[i]=ans;
        cout << ans << " ";
    }
    cout << endl;


    return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int h, w;
    cin >> h >> w;
    char f[10][10] = {};
    for (Int i = 0; i < h; i++) {
        for (Int j = 0; j < w; j++) {
            cin >> f[i][j];
        }
    }
    queue<pair<Int, Int>> q;
    q.push({0, 0});
    while (not q.empty()) {
        pair<Int, Int> p = q.front();
        q.pop();
        f[p.fi][p.se] = '.';
        Int dx[] = {1, 0};
        Int dy[] = {0, 1};
        for (Int i = 0; i < 2; i++) {
            Int ny = dy[i] + p.fi;
            Int nx = dx[i] + p.se;
            if (ny < 0 or ny == h or nx < 0 or nx == w) continue;
            if (f[ny][nx] == '.') continue;
            q.push({ny, nx});
            break;
        }
    }
    bool check = true;
    for (Int i = 0; i < h; i++) {
        for (Int j = 0; j < w; j++) {
            if (f[i][j] == '#') check = false;
        }
    }
    dump(not check ? "Impossible" : "Possible");
    return 0;
}


Measured memory_bytes: 256
const fs = require('fs')
const inputs = fs.readFileSync('/dev/stdin', 'utf8').trim().split(/\s+/).map(s => parseInt(s))

const n = inputs[0]
const arr = inputs.slice(1, n + 1).sort((a, b) => a - b)
const aMax = arr[arr.length - 1]

let count = 0
const dp = new Array(aMax + 1).fill(true)
arr.forEach((a, index) => {
  if (dp[a]) {
    for (let i = 1; i * a <= aMax; i++) {
      dp[i * a] = false
    }
    if (a !== arr[index + 1]) {
      count += 1
    }
  }
})
console.log(count)


Measured memory_bytes: 57328
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

H,W,A,B = map(int,input().split())

for i in range(B):
    print('1'*A + '0'*(W-A))
for i in range(H-B):
    print('0'*A + '1'*(W-A))

Measured memory_bytes: 3956
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
using namespace std;

int main()
{
   long long int r;cin>>r;
    long double ans;
    ans=2*3.1415926*r;
    cout<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 3788
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<unordered_map>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 100010;
const int INF = 2147483600;

#define fr first
#define sc second
int N; int Node[MAXN<<1],Next[MAXN<<1],Root[MAXN+1],cnt;
multiset<int> S[MAXN+1]; int fa[MAXN+1];
queue<pair<int,int> > que;
inline int find(int x){
	return (x==fa[x]?x:(fa[x]=find(fa[x])));
}
pair<int,int> sta[MAXN+1];int top;
unordered_map<int,int> mp[MAXN+1];

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(); 
	for(int i=1;i<=N;i++) fa[i]=i;
	for(int i=1;i<=2*N-2;i++){
		int u=read(),v=read();
		S[u].insert(v);
		S[v].insert(u);
		mp[u][v]++; mp[v][u]++;
		if(mp[u][v]==2) que.push(make_pair(u,v)),sta[++top]=make_pair(u,v);
		if(mp[u][v]>2){
			puts("NO"); return 0;
		} 
	} int d=0;
	for(int i=1;i<=top;i++){
			mp[sta[i].fr][sta[i].sc]=mp[sta[i].sc][sta[i].fr]=0;
			S[sta[i].fr].erase(S[sta[i].fr].find(sta[i].sc));
			S[sta[i].sc].erase(S[sta[i].sc].find(sta[i].fr));
		}
	while(!que.empty()){
		pair<int,int> k=que.front(); ++d; que.pop();
		int u=find(k.fr),v=find(k.sc);
		if(S[u].size()<S[v].size()) swap(u,v); int last=find(v);
		fa[find(v)]=find(u); top=0;
		multiset<int>::iterator it=S[v].begin();
		while(it!=S[v].end()){
			if(find(*it)==find(u)) {++it;continue;}
			S[u].insert(*it);
			mp[last][*it]=mp[*it][last]=0;
			mp[*it][find(u)]++;
			mp[find(u)][*it]++;
			S[*it].erase(S[*it].find(last));
			S[*it].insert(find(u));
			if(mp[find(u)][*it]==2) que.push(make_pair(find(u),(*it))),sta[++top]=make_pair(find(u),(*it));
			if(mp[find(u)][*it]>2) {
				puts("NO"); return 0;
			}
			++it;
		} 
		for(int i=1;i<=top;i++){
			mp[sta[i].fr][sta[i].sc]=mp[sta[i].sc][sta[i].fr]=0;
			S[sta[i].fr].erase(S[sta[i].fr].find(sta[i].sc));
			S[sta[i].sc].erase(S[sta[i].sc].find(sta[i].fr));
		}
		S[v].clear();
	} if(d==N-1) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 54028
//
// Created by Akifumi Ohata on 2017/09/30.
//

//
// Created by Akifumi Ohata on 2017/09/29.
//

#include<iostream>
#include <vector>
#include <numeric>
#include <math.h>
#include <cmath>

using namespace std;

using ll =  long long int;

int main() {

    int N, M;


    cin >> N >> M;

    ll ans = 1;

    ll MOD=1000000007;
   // cout << dev << endl;

    if (abs(N - M) >= 2) {

        ans = 0;
        cout << ans % MOD << endl;
        return 0;
    }


    // ans = 1;

    for (int a = 1; a <= N; a++) {
        //ans = a * ans;
        ans = (ans * a) % MOD;
       // cout << ans << endl;

    }

    for (int b = 1; b <= M; b++) {

        ans = (ans * b) % MOD;
       // cout << ans << endl;

    }

    //
    // cout << ans;

    if (N == M) {
        //cout << ans << endl;

        ans = (2 * ans) % MOD;
    }

    cout << ans << endl;

    return 0;


}


Measured memory_bytes: 256
n, a, b = list(map(int, input().split()))
x = list(map(int, input().split()))

d = [x[i+1] - x[i] for i in range(n-1)]

s = 0

for i in d:
    if a*i < b:
        s += a*i
    else:
        s += b

print(s)

Measured memory_bytes: 15020
#include <iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main(void){
   string s[2];
   int num[2][200000][2]={{{0}}};
   int i,j,q,a,b,c,d,s1,t1;
   
   cin>>s[0]>>s[1];
   for(i=0;i<2;i++){
        for(j=0;s[i][j]!=NULL;j++){
            if(s[i][j]=='A'){
                num[i][j+1][0]=num[i][j][0]+1;
                num[i][j+1][1]=num[i][j][1];
            }
            if(s[i][j]=='B'){
                num[i][j+1][0]=num[i][j][0];
                num[i][j+1][1]=num[i][j][1]+1;
            }
        }
   }
   
   cin>>q;
   
   for(i=0;i<q;i++){
       cin>>a>>b>>c>>d;
       s1=(num[0][b][0]-num[0][a-1][0])+(num[0][b][1]-num[0][a-1][1])*2;
       t1=(num[1][d][0]-num[1][c-1][0])+(num[1][d][1]-num[1][c-1][1])*2;
       
       if((s1-t1)%3){
           cout<<"NO"<<endl;
       }
       else{
           cout<<"YES"<<endl;
       }
   }
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
#define fori(a,b) for(int i=a;i<b;i++)
#define forj(a,b) for(int j=a;j<b;j++)
#define fork(a,b) for(int k=a;k<b;k++)
#define ford(i,a,b) for(int i=a;i>=b;i--)
#define seto(x,i) memset(x,i,sizeof x)
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define pf first
#define ps second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int n,len[2001],x,t;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("", "r", stdin);
    cin>>n;
    fori(0,n)
        cin>>len[i];
    sort(len,len+n);
    fori(0,n)
    {
        x=0;
        forj(0,i)
        {
            for(;x<n&&len[x]<len[i]+len[j];x++);
            t+=x-i-1;
        }
    }
    cout<<t;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a,b,sum = 0;
    scanf("%d %d", &a, &b);
    for(int i=0;i<2;i++){
        if(a>=b){
            sum += a;
            a--;
        }else{
            sum += b;
            b--;
        }
    }
    printf("%d", sum);

    return 0;
}

Measured memory_bytes: 128
Option Strict On
Imports System.Console
Imports System.Collections.Generic
Imports System.Math

Module Program

    Sub Main()
        Dim w As Integer = NextInt()
        Dim h As Integer = NextInt()
        Dim n As Integer = NextInt()

        Dim x As Integer = 0
        Dim y As Integer = 0

        For i As Integer = 1 To n
            Dim xi As Integer = NextInt()
            Dim yi As Integer = NextInt()
            Dim a As Integer = NextInt()

            Select Case a
                Case 1
                    x = Max(x, xi)
                Case 2
                    w = Min(w, xi)
                Case 3
                    y = Max(y, yi)
                Case 4
                    h = Min(h, yi)
            End Select
        Next

        WriteLine(Max(0, w - x) * Max(0, h - y))
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of String)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return String.Join("", result)
    End Function

End Module


Measured memory_bytes: 19920
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long w = sc.nextLong();
		
		if (h == 1 || w == 1)
			System.out.println(1);
		else
			System.out.println((h * w + 1) / 2);
		
		sc.close();
	}
}


Measured memory_bytes: 22100
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(i64, X);
    i64 cur = 100;

    i64 cnt = 0;
    while (cur < X) {
        cur += i64(cur * 0.01);
        ++cnt;
    }

    print(cnt);

    return 0;
}


Measured memory_bytes: 3664
def main():
    N = int(input())
    A = list(map(int,input().split()))

    if 0 in A:
        print(0)
        return

    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main()

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

int main(){
  string S, T;
  cin >> S >> T;
  int count = 0;
  for(int i = 0; i < S.size(); i++){
    if(S.at(i) != T.at(i)){
      count++;
    }
}
  cout << count << endl;
}


Measured memory_bytes: 3912
#include<stdio.h>
int main(){
    int n,m,i;
    scanf("%d%d",&n,&m);
    int s[m],c[m];
    for(i=0;i<m;i++)
        scanf("%d%d",&s[i],&c[i]);
    for(i=0;i<m;i++){
        if(s[i]==1&&c[i]==0&&n!=1){
            printf("-1\n");
            return 0;
        }
    }
    for(i=0;i<m;i++){
        for(int j=i+1;j<m;j++){
            if(s[i]==s[j]){
                if(c[i]!=c[j]){
                    printf("-1\n");
                    return 0;
                }
            }
        }
    }
    if(n==1&&m!=0){
        printf("%d\n",c[0]);
        return 0;
    }
    else if(n==2&&m!=0){
        int ans=0,count=0,count1=0;
        for(i=0;i<m;i++){
            if(s[i]==1&&count==0){
                ans+=10*c[i];
                count++;
            }
            else if(s[i]==2&&count1==0){
                ans+=c[i];
                count1++;
            }
        }
        if(count==0){
            ans+=10;
        }
        printf("%d\n",ans);
        return 0;
    }
    else if(m!=0){
        int ans=0,count=0,count1=0,count2=0;
        for(i=0;i<m;i++){
            if(s[i]==1&&count==0){
                ans+=100*c[i];
                count++;
            }
            else if(s[i]==2&&count1==0){
                ans+=10*c[i];
                count1++;
            }
            else if(s[i]==3&&count2==0){
                ans+=c[i];
                count2++;
            }
        }
        if(count==0) ans+=100;
        printf("%d\n",ans);
        return 0;
    }
    if(m==0&&n==1) printf("0\n");
    if(m==0&&n==2) printf("10\n");
    if(m==0&&n==3) printf("100\n");
    return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a;
    cin >> n >> a;
    cout << (n % 500 <= a ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 256
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def dfs(N, L, s):
    depth = [-1] * N

    stack = [(0, s)]
    while stack:
        d, p = stack.pop()
        depth[p] = d

        for q in L[p]:
            if depth[q] != -1:
                continue
            stack.append((d + 1, q))
    return depth

    
def main():
    S, T = input().split()

    print(T + S)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  if (a[0] != 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1; i < n; i++) {
    if (a[i] > a[i - 1] + 1) {
      cout << -1 << endl;
      return 0;
    }
  }
  long long ans = 0;
  int cur = -100;
  for (int i = n - 1; i >= 0; i--) {
    cur--;
    if (cur < a[i]) {
      ans += a[i];
      cur = a[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1152
h, w = map(int, input().split())
s = [input() for _ in range(h)]

def f(i, j):
   t = [[-1] * w for _ in range(h)]
   t[i][j] = 0

   q = [(i, j)]
   while q:
      y, x = q.pop(0)
      if (y-1 >= 0 and s[y-1][x] != '#' and t[y-1][x] == -1):
         t[y-1][x] = t[y][x] + 1
         q.append((y-1, x))
      if (y+1 < h and s[y+1][x] != '#' and t[y+1][x] == -1):
         t[y+1][x] = t[y][x] + 1
         q.append((y+1, x))
      if (x-1 >= 0 and s[y][x-1] != '#' and t[y][x-1] == -1):
         t[y][x-1] = t[y][x] + 1
         q.append((y, x-1))
      if (x+1 < w and s[y][x+1] != '#' and t[y][x+1] == -1):
         t[y][x+1] = t[y][x] + 1
         q.append((y, x+1))

   return max(max(tt) for tt in t)

result = 0
for i in range(h):
   for j in range(w):
      if s[i][j] != '#':
         result = max(result, f(i, j))
print(result)
  

Measured memory_bytes: 3188
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
ab = [0] * m
for i in range(m):
    aa, bb = map(int, input().split())
    ab[i] = (aa, bb)

ab.sort()
ans = 1
prev_left, border = ab[0][0], ab[0][1]
for i in range(1, m):
    if prev_left == ab[i][0]:
        border = min(border, ab[i][1])
    else:
        if border <= ab[i][0]:
            ans += 1
            border = ab[i][1]
        prev_left = ab[i][0]
        border = min(border, ab[i][1])
print(ans)

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

int main(){
    int N;
    int d[50];
    cin >> N;
    for(int i = 0; i < N; i++) cin >> d[i];
    int sum = 0;
    for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j < N; j++){
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int N;
    int card[4][14] = {};
    
    cin >> N;
    for(int i = 0; i < N; i++){
        char picture;
        int num;
        cin >> picture >> num;
        if(picture == 'S') card[0][num]++;
        if(picture == 'H') card[1][num]++;
        if(picture == 'C') card[2][num]++;
        if(picture == 'D') card[3][num]++;
    }
    
    for(int i = 0; i < 4; i++){
        for(int j = 1; j <= 13; j++){
            if(card[i][j] == 0){
                if(i == 0) cout << "S " << j << endl;
                if(i == 1) cout << "H " << j << endl;
                if(i == 2) cout << "C " << j << endl;
                if(i == 3) cout << "D " << j << endl;
            }
        }
    }
    
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
int n, m;
int d[maxn][maxn];
char s[maxn][maxn];
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i) {
		scanf("%s", s[i] + 1);
	}
	int ans = 0;
	queue<int> q;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= m; ++j) {
			if(s[i][j] == '.') {
				memset(d, -1, sizeof(d));
				d[i][j] = 0;
				q.push(i);
				q.push(j);
				while(!q.empty()) {
					int x = q.front(); q.pop();
					int y = q.front(); q.pop();
					for(int k = 0; k < 4; ++k) {
						int xx = x + dx[k], yy = y + dy[k];
						if(s[xx][yy] == '.' && d[xx][yy] == -1) {
							q.push(xx);
							q.push(yy);
							d[xx][yy] = d[x][y] + 1;
						}
					}
				}
				for(int x = 1; x <= n; ++x) {
					for(int y = 1; y <= m; ++y) {
						ans = max(ans, d[x][y]);
					}
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  ll ans = 1;
  ll mx = 0;
  cin >> mx;
  for(ll i = 1; i < n; i++) {
    ll tp;
    cin >> tp;
    if(tp >= mx) ans++;
    mx = max(mx, tp);
  }
  cout << ans << endl;
  return 0;
} //good night.

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
//#define for(i, K, N)  for(int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
long double W, H, x, y;cin >> W >> H >> x >> y;

cout << fixed << setprecision(9) << (W*H)/2 << " ";

if(W - 2*x == 0 && H - 2*y == 0){cout << 1;exit(0);}
else cout << 0;
}

Measured memory_bytes: 3792
import java.util.Scanner;

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

    int a, b, d, r;
    a = sc.nextInt();
    b = sc.nextInt();

    double f;

    d = a/b ;
    r = a%b ;
    f = 1.00000 * a/b ;

    System.out.println( d + " " + r + " " + String.format("%.5f",f) );

    } 
}


Measured memory_bytes: 26436
#include <iostream>
 
using namespace std;
 
int main()
{
    int x;
    cin >> x;
 
    int h = x / 3600;
    int m = (x / 60) % 60;
    int s = x % 60;
    cout << h << ':' << m << ':' << s << endl;
 
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int func(ll n, vector<int> &a, int k){
	rep(i, k){
		n /= (ll)a.at(i);
		n *= (ll)a.at(i);
	}
	if(n > 2) return 1;
	else if(n == 2) return 0;
	else return -1;
}

ll b_serch(ll l, ll r, vector<int> &a, int k){
	while(abs(r - l) > 1){
		ll mid = (l+r)/2;
		if(func(mid, a, k) >= 0){
			r = mid;
		}else{
			l = mid;
		}
	}
	return r;
}

ll b_serch2(ll l, ll r, vector<int> &a, int k){
	while(abs(r - l) > 1){
		ll mid = (l+r)/2;
		if(func(mid, a, k) <= 0){
			l = mid;
		}else{
			r = mid;
		}
	}
	return l;
}

int main(){
	int k;
	cin >> k;
	vector<int> a(k);
	int mx = 0;
	rep(snip_i, k){
		cin >> a.at(snip_i);
		mx = max(mx, a.at(snip_i));
	}
	ll n_mn, n_mx;
	n_mn = b_serch(1, (ll)mx*k+3, a, k);
	n_mx = b_serch2(1, (ll)mx*k+3, a, k);
	if(n_mn > n_mx){
		cout << -1 << endl;
	}else{
		cout << n_mn << " " << n_mx << endl;
	}
	
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(x) for(int i=last[x];i;i=e[i].next)
using namespace std;
inline ll read(){
    ll f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//******head by yjjr******
ll a,b,c;
int main(){
    a=read(),b=read(),c=read();
    if(a==b&&a==c&&b==c)puts("Yes");else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 1e3 + 10;


void yes(){
   cout<<"Yes";
   // exit(0);
}

void no(){
   cout<<"No";
   // exit(0);
}


int n, m;

#define y1 decfce
int x1, y1, x2, y2;

char a[N][N];

int32_t main(){_
   
   cin >> n >> m;

   cin >> x1 >> y1;
   cin >> x2 >> y2;

   for (int i = 1; i <= n; ++i)
   {
      for (int j = 1; j <= m; ++j)
      {
         cin >> a[i][j];
      }
   }


   vector<vector<int>> ans(n+1, vector<int>(m + 1, inf));
   multiset<array<int, 3>> ms;
   ans[x1][y1] = 0;
   ms.insert({0, x1, y1});

   while(!ms.empty()){
      
      auto it = *ms.begin();
      ms.erase(ms.begin());

      int X = it[1], Y = it[2];

      if (X + 1 <= n and a[X+1][Y] == '.' and ans[X+1][Y] > ans[X][Y]){
         ans[X+1][Y] = ans[X][Y];
         ms.insert({ans[X][Y], X + 1, Y});
      }

      if (X - 1 >= 1 and a[X-1][Y] == '.' and ans[X-1][Y] > ans[X][Y]){
         ans[X-1][Y] = ans[X][Y];
         ms.insert({ans[X][Y], X - 1, Y});
      }

      if (Y + 1 <= m and a[X][Y+1] == '.' and ans[X][Y+1] > ans[X][Y]){
         ans[X][Y+1] = ans[X][Y];
         ms.insert({ans[X][Y], X, Y+1});
      }

      if (Y - 1 >= 1 and a[X][Y-1] == '.' and ans[X][Y-1] > ans[X][Y]){
         ans[X][Y-1] = ans[X][Y];
         ms.insert({ans[X][Y], X, Y-1});
      }

      for (int i = -2; i <= 2; ++i)
      {
         for (int j = -2; j <= 2; ++j)
         {
            int nx = X + i;
            int ny = Y + j;
            if (nx >= 1 and nx <= n and ny >= 1 and ny <= m and a[nx][ny] == '.' and ans[nx][ny] > ans[X][Y] + 1){
               ans[nx][ny] = ans[X][Y] + 1;
               ms.insert({ans[X][Y] + 1, nx, ny});
            }
         }
      }

   }

   tr(ans);
   if (ans[x2][y2] == inf){
      ans[x2][y2] = -1;
   }

   cout<<ans[x2][y2];

   return 0;
}


Measured memory_bytes: 13108
N=int(input())
list=[]
for i in range(0,N):
    list.append(0)
list2=input().split()
for i in range(0,N-1):
    list[int(list2[i])-1]=list[int(list2[i])-1]+1
for i in range(0,N):
    print(list[i])
    

Measured memory_bytes: 25824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(x/d-k>=0){
        cout<<x-k*d;
    }else{
        ll ans=(k%2==x/d%2)?(x%d):(abs(x%d-d));
        cout<<ans;
    }
   
}


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
from collections import defaultdict
N=input()
s=raw_input()

D={}
def check(m):
	for i in range(N):
		if i+m<=N:
			str=s[i:i+m]
			if str in D:
				if i-D[str]>=m:
					return True
			else:
				D[str]=i
	else:
		return False

l=0
h=N

while 1<(h-l):
	m=(l+h)/2
	if check(m):
		l=m
	else:
		h=m

print l

Measured memory_bytes: 99868