akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
 
public class Main {
  public static void main(String[] args) throws Exception{
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    new Solution(n);
  }
}

class Solution {
  public Solution(int n) {
    long res = 0;
    for(int a = 1; a <= n; ++a) {
      for(int b = 1; b <= n; ++b) {
        for(int c = 1; c <= n; ++c) {
          res += dgcd(a, b, c);
        }
      }
    }
    System.out.println(res);
  }

  public int dgcd (int a, int b, int c) {
    return GCD(GCD(a, b), c);
  }

  public int GCD (int a, int b) {
    if(a == b) return a;
    if((a & 1) == 0 && (b & 1) == 0) return GCD(a>>1, b>>1)<<1;
    if((a & 1) == 0) return GCD(a>>1, b);
    if((b & 1) == 0) return GCD(a, b>>1);
    if(a > b) return GCD(b, a - b);
    return GCD(b - a, a);
  }
}

class FastScanner {
  private final InputStream in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  public FastScanner(InputStream source) {
    in = source;
  }

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) return buffer[ptr++];
    else return -1;
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  public boolean hasNext() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) throw new NoSuchElementException();
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public long nextLong() {
    if (!hasNext()) throw new NoSuchElementException();
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public int nextInt() {
    long nl = nextLong();
    if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
      throw new NumberFormatException();
    return (int) nl;
  }

  public double nextDouble() {
    return Double.parseDouble(next());
  }
}

Measured memory_bytes: 27156
n = int(input())
a = list(map(int, input().split()))

count=0
while True:
    exist_odd = False
    for i in range(n):
        if a[i] % 2 != 0:
            exist_odd = True
    if exist_odd:
        break
    for i in range(n):
        a[i] /= 2
    count += 1

print(count)

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

const int N = 2e6;

int a[N];

main() {
	clog << "Ready\n";
	
	int n;
	cin >> n;
	
	int cnt = 0;

	for (int i = 1; i <= n; ++ i)
		cin >> a[i];
	
	for (int i = 1; i <= n; ++ i) {
		bool ok = false;
		for (int j = 1; j < i; ++ j)
			if (a[j] > a[i])
				ok = true;
		cnt += !ok;
	}

	cout << cnt;
	
	cerr << '\n';

	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author RiaD
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <algorithm>
//#define PROBLEM "problem_name.h"
//#include PROBLEM
//#include <message.h>
//#include <spcppl/dgcj.h>

using namespace std;

class TaskA {
public:
	void solve(std::istream& in, std::ostream& out) {
		string s;
		in >> s;
		if (s.substr(0, min<int>(s.size(), 4)) == "YAKI") {
			out << "Yes\n";
		} else {
			out << "No\n";
		}
	}
};


int main() {
	std::ios_base::sync_with_stdio(false);
	TaskA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(nullptr);
	out << std::fixed;
	out.precision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN,"%d %d",$a,$b);

$sum=$a+$b; 
$sub=$a-$b; 
$product=$a*$b;  

if($sum>$sub){
  $max=$sum;
}else{
  $max=$sub; 
}

if($product>$max){
  $max=$product;
}

echo $max;



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

struct dat {
  long long a, b;
};
bool operator<(const dat &l, const dat &r) {
  if(l.a != r.a) return l.a < r.a;
  return l.b > r.b;
}

long long n, t;
vector<dat> v;
vector<vector<long long>> dp;

long long solve();

int main() {
  cin >> n >> t;
  v.resize(n);
  for(int i = 0; i < n; ++i) cin >> v[i].a >> v[i].b;
  sort(v.begin(), v.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  dp.assign(n + 1, vector<long long>(t + 1, 0));
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < t; ++j) {
      dp[i + 1][j] = dp[i][j];
      ans = max(ans, dp[i][j] + v[i].b);
      if(j + v[i].a < t)
        dp[i + 1][j] =
            max(dp[i + 1][j], dp[i][j + v[i].a] + v[i].b);
      ans = max(ans, dp[i + 1][j]);
    }
  }
  return ans;
}


Measured memory_bytes: 73720
#include <bits/stdc++.h>
using namespace std;
struct dat{int h,f;};

vector<dat> compless(vector<dat> A,int h){
  int n=A.size();
  for(int i=0;i<n-1;i++){
    if(A[i].f&&A[i+1].f)A[i+1].h=max(A[i+1].h,A[i].h),A[i]=(dat){0,0};
    if(A[i].f||A[i].h<=h)continue;
    int mn=A[i].h,idx=i;
    A[i]=(dat){0,0};
    while((A[++i].f&&h>=A[i].h)||!A[i].f){
      if(!A[i].f&&h>=A[i].h)continue;
      if(!A[i].f)mn=min(mn,A[i].h),idx=i;
      A[i]=(dat){0,0};
    }
    A[idx] = (dat){mn,0}; 
    i = idx;
  }
  vector<dat> res;
  for(int i=0;i<n;i++)if(A[i].h) res.push_back(A[i]);
  return res;
}
typedef pair<int,int>P;

int solve(vector<dat> A){
  vector<int> H;
  A=compless(A,0);
  for(int i=0;i<A.size();i++)if(A[i].f)H.push_back(A[i].h);
  sort(H.begin(),H.end());
  vector<dat> B[2]={A};
  for(int i=0;i<H.size();i++)B[(i+1)%2] = compless(B[i%2],H[i]);
  A = B[H.size()%2];
  int res=0;
  for(int i=0;i<A.size();i++)res+=!A[i].f;
  return res;
}

int main(){
  int n;
  cin>>n;
  vector<dat> A;
  A.resize(n+2);
  A[n]=(dat){10000,1};
  char ch;
  for(int i=0;i<n;i++)cin>>ch>>A[i].h,A[i].f = ch=='n';
  cout<<solve(A)<<endl;
  return 0;
}

Measured memory_bytes: 3204
#include <stdio.h>
#include <string.h>

int main(){
int x,b,a;
scanf("%d%d%d",&x,&a,&b);
if(b-a<x+1&&b-a>0){
	
	printf("safe\n");
	
}else if(b<=a){
	
	printf("delicious\n");
	
}else if(b-a>=x+1){
	
	printf("dangerous\n");
}

	return 0;
}

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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
  int N;
  cin >> N;
  vector<int>a(3, 0);
  ll ans = 1;
  REP(i, N){
    int x, cnt = 0;
    cin >> x;
    bool flag = true;
    REP(j, 3){
      if(a[j] == x){
        if(flag) a[j]++, flag = false;
        cnt++;
      }
    }
    ans = (ans * cnt) % MOD;
  }
 print(ans);
 return 0;
}


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

using namespace std;

pair<int, int> a[111111];
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
		scanf("%d%d", &a[i].first, &a[i].second);
	sort(a, a + m);
	int l = 0, r = 0, c = 0;
	for (int i = 0; i < m; i++) {
		if (r <= a[i].first) {
			l = a[i].first, r = a[i].second;
			c++;
			continue;
		}
		l = a[i].first;
		r = min(r, a[i].second);
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).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 (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


class UnionFind
{
public:
  UnionFind(ll n)//0~n-1までitemを初期化
  {
    parent=vector<ll>(n,-1);//親なら-size
    weight=vector<ll>(n,0);
  }
  ll root(ll a)
  {
    if(parent[a]<0)return a;
    root(parent[a]);
    weight[a]+=weight[parent[a]];
    return parent[a]=root(parent[a]);
  }
  ll size(ll a)
  {
    return -parent[root(a)];
  }
  bool connect(ll a,ll b,ll cost)
  {
    ll A=root(a);
    ll B=root(b);
    cost+=weight[a];
    cost-=weight[b];
    if(A==B && cost!=0)return false;
    if(A==B)return true;
    if(size(A)>size(B))
    {
      swap(A,B);
    }
    else cost=-cost;
    weight[A]=cost;
    parent[B]+=parent[A];
    parent[A]=B;
    return true;

  }
private:
  vector<ll> parent;
  vector<ll> weight;

};


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  ll n,m;
  cin>>n>>m;
  vector<ll>x(n+1,-1);
  x[1]=0;
  UnionFind uni(n+1);
  rep(i,m)
  {
    ll l,r,d;
    cin>>l>>r>>d;
    if(!uni.connect(l,r,d))
    {
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;

}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define fname "C"
#define cerr if(false)cerr
#define bug(x) cerr << (#x) << " = " << (x) << endl
#define ll long long
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define ARR0(a, n) {cerr <<(#a)<< ": ["; REP0(i, n) cerr<< ' ' << a[i] <<','; cerr<<']'<<endl;}
#define ARR1(a, n) {cerr <<(#a)<< ": ["; REP1(i, n) cerr<< ' ' << a[i] <<','; cerr<<']'<<endl;}
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define LB lower_bound
#define UB upper_bound
#define X first
#define Y second

using namespace std;
template<typename T, typename V>
inline void bugp(const pair<T, V> &x) {cerr << '{' << x.X << ", " << x.Y << '}' << endl;}
template<typename T, typename U, typename V>
inline void bugpp(const pair<T, pair<U, V> > &x) {cerr << '{' << x.X << ", {" << x.Y.X << ", " << x.Y.Y << "}}" << endl;}
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ll, int> li;
typedef pair<ll, ii> lii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
    ll x, k, d;
    cin >> x >> k >> d;
    ll m = min(abs(x/d), k);
    ll n = min(abs(x/d) + 1, k);
    bug(m); bug(n);
    if(abs(k - m) & 1) {
        if(x > 0) x -= n*d;
        else x += n*d;
        cerr << "use n\n";
        bug(x);
    }
    else {
        if(x > 0) x -= m*d;
        else x += m*d;
        cerr << "use m\n";
        bug(x);
    }
    cout << abs(x);
	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int main(){
  cout << fixed << setprecision(20);
  double a, b, C;
  cin >> a >> b >> C;
  C = C * M_PI / 180;
  cout << a * b * sin(C) / 2 << endl;
  cout << a + b + sqrt(a * a + b * b - 2 * a * b * cos(C)) << endl;
  cout << b * sin(C) << endl;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int tac = a/d + (a%d ? 1 : 0);
  int aoc = c/b + (c%b ? 1 : 0);
  cout << (tac >= aoc ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3532
#include<iostream>
#include<cmath>
using namespace std;
int a, b[20], ok;
int main() {
	while (true) {
		ok = 0;
		cin >> a;
		if (a == -1) { break; }
		for (int i = 0; i < 15; i++) {
			b[i] = (a / (int)pow(4, i)) % 4;
		}
		for (int i = 14; i >= 0; i--) {
			if (b[i] >= 1) { ok = 1; }
			if (ok == 1 || i == 0) {
				cout << b[i];
			}
		}
		cout << endl;
	}
}

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

using namespace std;

int n,a[100010],mx,cmx;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=1;i<=n;i++) {
        cin>>a[i];
        mx=max(mx,a[i]);
    }
    for (int i=1;i<=n;i++) {
        if (a[i]<mx-1) {
            cout<<"No"<<endl;
            return 0;
        }
        cmx+=(a[i]==mx);
    }
    if (cmx==1) {
        cout<<"No"<<endl;
        return 0;
    }
    if (cmx==n && mx==n-1) {
        cout<<"Yes"<<endl;
        return 0;
    }
    if (n-cmx+1<=mx && mx<=n-cmx+cmx/2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 640
r,c=[int(x) for x in input().split()]
rows=[]
for i in range(r):
	inp=[int(x) for x in input().split()]
	rows.append(inp)


for i,x in enumerate(rows):
	_sum_=sum(x)
	rows[i].append(_sum_)



sums=[]
for i in range(len(rows[0])):
	_sum_=0
	for x in rows:
		_sum_+=x[i]
	sums.append(_sum_)

rows.append(sums)

for i in rows:
	for s,j in enumerate(i):
		print(f"{j}",end="")
		if s!=len(i)-1:
			print(" ",end="")

	print()


Measured memory_bytes: 6668
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)


def solve(string):
    n, m, *a = map(int, string.split())
    c = 0
    for _a in a:
        if not c:
            while _a % 2 == 0:
                _a //= 2
                c += 1
        else:
            t = 0
            while _a % 2 == 0:
                _a //= 2
                t += 1
            if c != t:
                return "0"
    l = reduce(lcm, a)
    return str(max((m - l // 2) // l + 1, 0))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 17168
//
//AtCoder Beginner Contest 179
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    int ans=0;
    FOR(a, 1, n-1){
        FOR(b, 1, n-1){
            int c = n - (a*b);
            if (c<=0) break;
            ans++;

            //cout << a << " "<<  b  << " " << c << endl;
        }
    }
    cout << ans << endl;
    return 0;
}


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

/*
一本の道を通ってたどり着けるどの展望台よりも高いとき+1
それぞれの頂点から全部見るとO(2 * M)ぐらいになりそう
*/

int	main(void)
{
	int n, m;
    cin >> n >> m;
	vector<int> h(n);
	for (int i = 0; i < n; i++) cin >> h[i];
	vector<vector<int>> edge(n);
	int a, b;
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b; a--; b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (edge[i].size() == 0) ans++;
		else
		{
			bool flag = true;
			for (int j = 0; j < edge[i].size(); j++)
			{
				if (h[i] <= h[edge[i][j]]) flag = false;
			}
			ans += flag;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 8800
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>

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

using namespace std;

class pred {
	string str;
public:
	pred(const string& _str) : str(_str) {}
	bool operator()( const pair< string , int > pr ) { return pr.first == str; }
};

int main(){
	
	int n;
	string s_ans;
	
	cin >> n;
	while(n)
	{
		vector< pair<string , int> > item;
		vector< pair<string , int> > :: iterator ite;
		
		rep(i,n) 
		{
			string a;
			int	b;
			cin >> a >> b;
			item.push_back( mp( a , b ) );
		}
		
		cin>>n;
		
		rep(i,n)
		{
			string s;
			int m , goukei=0;
			cin >> s >>m;
			rep(i,m)
			{
				string dummy;
				cin >> dummy;
				ite = find_if( item.begin() , item.end() , pred( dummy ) );
				goukei += (*ite).second;
			}
			ite = find_if( item.begin() , item.end() , pred( s ) );
			if( (*ite).second > goukei )
			{
				ite = remove_if( item.begin() , item.end(), pred( s ) );
				item.erase( ite );
				item.push_back( mp( s , goukei )  );
			}
		}
		
		cin>>s_ans;
		ite = find_if( item.begin() , item.end() , pred( s_ans ) );
		cout << (*ite).second << endl;
		cin>>n;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<stdio.h>
#include<stdlib.h>

int main()
{
    int A,B,C,K;
    int s,max;
    char m;
    int i;

    scanf("%d %d %d\n",&A,&B,&C);
    scanf("%d\n",&K);

    s=0;
    max=A;
    m='A';

    if(max<B){
        max=B;
        if(max<C){
            max=C;
            m='C';
        }
        m='B';
    }
    else{
        if(max<C){
            max=C;
            m='C';
        }
    }

    for(i=0;i<K;i++){
        max=max*2;
    }

    if(m=='A'){
        s=max+B+C;
    }
    else if(m=='B'){
        s=A+max+C;
    }
    else{
        s=A+B+max;
    }

    printf("%d\n",s);

    return 0;
}

Measured memory_bytes: 128
N = int(input())
if N % 4 == 0 or N % 7 == 0:
    print("Yes")
else:
    d = N // 7
    while d > 0 and (N - d * 7) % 4 != 0:
        d -= 1
    if d == 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define mkp make_pair
#define pii pair<int,int>
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=5e5+5;
int main(){
	long long x;
	cin>>x;
	long long ans=(x/500)*1000;
	x=x-(x/500)*500;;
	ans+=(x/5)*5;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n, k = [int(_) for _ in input().split()]
h = []
for i in range(n):
    hi = int(input())
    h.append(hi)

h_sort = sorted(h, reverse=True)

max_res = 10000000000
for i in range(n-k+1):
    if h_sort[i] - h_sort[i+k-1] < max_res:
        max_res = h_sort[i] - h_sort[i+k-1]

print(max_res)

Measured memory_bytes: 8280
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    long long x[100001],y[100001];
    for(int i=1;i<=n;i++){
        cin>>x[i];
    }
    for(int i=1;i<=m;i++){
        cin>>y[i];
    }
    unsigned long long s=x[1],s1=0;
    for(int i=2;i<=n;i++){
        s1+=((i-1)*x[i]-s)%1000000007;
        s+=x[i];
    }
    s1=s1%1000000007;
    s=y[1];
    unsigned long long s2=0;
    for(int i=2;i<=m;i++){
        s2+=((i-1)*y[i]-s)%1000000007;
        s+=y[i];
    }
    s2=s2%1000000007;
    cout<<(s1*s2)%1000000007;
    
}

Measured memory_bytes: 1792
<?php
list($n) = ints();
for ($i = 0; $i < $n; ++$i) {
    list($s) = strs();
    $l = strlen($s);
    for ($j = 0; $j < $l; ++$j) {
        if (isset($cnt[$s[$j]][$i])) $cnt[$s[$j]][$i]++;
        else $cnt[$s[$j]][$i] = 1;
    }
}
ksort($cnt);
$ans = '';
foreach ($cnt as $c => $v) {
    if (count($v) < $n) continue;
    $ans .= str_repeat($c, min($v));
}
echo $ans;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4728
S = input()

check_a = True
N = len(S)
for i in range(int((N-1)/2)):
    if not S[i] == S[N-1-i]:
        check_a = False

check_b = True
for i in range(int((N-1)/4)):
    if not S[i] == S[int((N-1)/2)-1-i]:
        check_b = False

if check_a and check_b:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include <math.h>
#include <set>
#include <map>
#include <stdio.h>
#include <queue>
#include <iomanip>
#include <cstring>
#include <stack>
#include <chrono>
#include <unordered_map>
#include <stdlib.h>
#include <ctime>
using namespace std;
typedef long long ll;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define fi first
#define se second
#define pll pair<ll,ll>
#define forn(i,e) for(ll i = 1; i<=e; i++)
#define forsn(i,s,e) for(ll i = s; i<=e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
// freopen("input.txt","r", stdin);
// freopen("out.txt","w", stdout);
// auto start = chrono::high_resolution_clock::now();
// auto end = chrono::high_resolution_clock::now();
// double time_taken =chrono::duration_cast<chrono::nanoseconds>(end - start).count();
// time_taken *= 1e-9;
// cout << "Time taken by program is : " << fixed << time_taken << setprecision(9);
// cout << " sec" << endl;
int main()
{
    ll n;
    string s;
    cin>>n>>s;
    ll l=0,r=n-1;
    ll cnt=0;
    while(l<r){
        if(s[l]=='W' && s[r]=='R'){
            l++; r--;
            cnt++;
            continue;
        }
        if(s[l]=='R'){
            l++;
            continue;
        }
        if(s[r]=='W'){
            r--;
            continue;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(true){
    c -= b;
    if(c <= 0){
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if(a <= 0){
      cout << "No" << endl;
      break;
    }
  }

}


Measured memory_bytes: 3604
#include <stdio.h>
#include <algorithm>

using namespace std;
using ll = long long;

ll num;
char str[123456];

ll smallans;
ll jans, ians;
ll omax;

int main()
{
	scanf("%lld", &num);
	scanf("%s", str);
	ll inum = 0;
	for (char* c = str; *c != '\0'; ++c)
	{
		if (*c == 'I')++inum;
	}
	ll jnum = 0;
	for (char* c = str; *c != '\0'; ++c)
	{
		omax = max(omax,jnum * inum);
		if (*c == 'O')
		{
			smallans += (jnum * inum);
			jans += ((jnum + 1) * inum);
			ians += (jnum * (inum + 1));
		}
		if (*c == 'J')++jnum;
		if (*c == 'I')--inum;
	}
	printf("%lld\n", max({ jans,ians,smallans + omax }));
	return 0;
}

Measured memory_bytes: 2792
#include <bits/stdc++.h>
 
#define A_MAX 1000000
#define A_MAX_HALF 500000
 
using namespace std;
 
int min_factor[A_MAX + 1];
int q[A_MAX + 1];
int a[A_MAX + 1];
 
int main() {
    vector<int> primes;
    primes.reserve(A_MAX_HALF);
    for (int i = 2; i <= A_MAX_HALF; ++i) {
        if (!min_factor[i]) {
            min_factor[i] = i;
            primes.push_back(i);
        }
        int min_factor_i = min_factor[i];
        for (int p : primes) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor_i) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }
 
    int N = 0;
    char c = getchar_unlocked();
    do {
        N = 10 * N + c - '0';
    } while ((c = getchar_unlocked()) >= '0');
    for (int i = 0; i < N; ++i) {
        int A = 0;
        c = getchar_unlocked();
        do {
            A = 10 * A + c - '0';
    	} while ((c = getchar_unlocked()) >= '0');
        ++a[A];
    }
 
    int is_pairwise_coprime = 1;
    for (int n = A_MAX; n > 1; --n) {
        int an = a[n];
        if (an) {
            if (an > 1) {
                if (an == N) {
                    printf("not coprime\n");
                    return 0;
                }
                is_pairwise_coprime = 0;
            }
            a[min_factor[n]] += an;
            a[q[n]] += an;
        }
    }
    if (is_pairwise_coprime) {
        printf("pairwise coprime\n");
    } else {
        printf("setwise coprime\n");
    }
 
    return 0;
}

Measured memory_bytes: 15236
function main(input){
  const lines = input.split('\n');
  const NK = lines.shift().split(' ').map(x => parseInt(x));
  const N = NK[0];
  const K = NK[1];  
  const H = lines.shift().split(' ').map(x => parseInt(x));

  const DP = Array(N).fill(Infinity);
  for(var i=0;i<=K && i<N;i++){
    DP[i]=Math.abs(H[0]-H[i]);
  }

//console.log(DP);
//console.log('==');

  for(var i=1;i<N;i++){
    var hops = [];
    for(var j=1;j<=K && i-j>=0;j++){
      //hops.push( DP[i-j] + Math.abs(H[i-j] - H[i]) )
      var current = DP[i-j] + Math.abs(H[i-j] - H[i]);
      if(current<DP[i]){
        DP[i]=current;
      }
    }
    //DP[i]=Math.min(...hops);

//console.log(hops);
//console.log(DP);
//console.log('---');

  }
//  console.log(DP);
  console.log(DP[N-1]);

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 27804
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int p,q,r;
  scanf("%d%d%d",&p,&q,&r);
  cout << min(min(p+q,q+r),r+p) << endl;
  
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	aa := [32]int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	k := getNextInt(scanner) - 1
	fmt.Fprintln(writer, aa[k])
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
using namespace std;
int a;
double b,c,d;
template<typename T>
inline void read(T &c){
    ios::sync_with_stdio(false);
    cin>>c;
    return;
}
void Read(){
    read(a);
    read(b);
    read(c);
    return;
}
int main(){
    Read();
    for(int i=1;a;a--){
        d+=b+(a-0.5)*c;
        b=((2*a+2)*b+5*c)/(2*a);
        c=(2*a+4)*c/(2*a);
    }
    return printf("%.9lf\n",d),0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int a[5];
int main()
{
    for(int i=1;i<=3;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+4);
    cout<<a[1]+a[2]<<endl;
    return 0;
}


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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a <= c && c <= b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
///////

int const N = 3e3 + 41;
int const MOD = 1e9 + 7;

void add(int &a, int b){
	a += b;
	if(a >= MOD) a -= MOD;
}

int n, m;
int d[N][N][2];
int dx[2][2] = {{-1, 0}, {0, -1}};

void solve(){
	cin >> n >> m;
	fi(0, n+1) d[0][i][0] = 1;
	fi(0, m){
		fj(0, n+1){
			fk(0, 2){
				if(!d[i][j][k]) continue;
				for(int i1=0;i1<2;++i1){
					for(int j1=0;j1<2;++j1){
						int f = j;
						int s = n - j;
						int mask = k;
						f += dx[0][i1];
						s += dx[1][i1];
						if(f < 0 || s < 0) continue;
						if(f == 0) mask = 1;
						++f;++s;
						f += dx[0][j1];
						s += dx[1][j1];

						if(f < 0 || s < 0) continue;
						if(f == 0) mask = 1;
						add(d[i+1][f][mask], d[i][j][k]);
					}
				}
			}
		}
	}

	int ans = 0;
	fi(0, n+1) add(ans, d[m][i][1]);
	cout << ans << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();


	return 0;
}

Measured memory_bytes: 71936
//TEMPLATE FOR CSES PROBLEMSET
//PROBLEM LINK:
//PROBLEM PATH: 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
constexpr int MAXN = 1e6;
constexpr int inf = 2e9;

int main()
{	
	ios::sync_with_stdio(false); 
	cin.tie(0);
	int x;
	cin>>x;
	cout<<(x?0:1);
	
}


Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main()
{
    int n,c=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')c++;
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20); cout.tie(nullptr); cin.tie(nullptr);
    ll n;
    cin >> n;
    ++n;
    ll ans = 0;
    ll p10 = 1;
    ll cn = 0;
    while (p10 * 10 <= n) {
        p10 *= 10;
        ++cn;
    }

    cout << n / p10 + cn * 9 - 1 << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();

		if (a == 1) {
			System.out.println("Hello World");
		} else {
			int b = sc.nextInt();
			int c = sc.nextInt();
			System.out.println(b + c);
		}
		sc.close();
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int sum_digit(const int n) {
	return (n == 0) ? 0 : n % 10 + sum_digit(n / 10);
}
int main() {
	long long int x, y; std::cin >> x >> y;
	int count = 0;
	while (x <= y) {
		++count; 
		x <<= 1;
	}
	std::cout << count << std::endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=100005;
int n,m; 
vector <int> g[MAX_N];
int in[MAX_N];
int dp[MAX_N];
int dfs(int v)
{
	if(dp[v])return dp[v];
	for(int i=0;i<g[v].size();i++)
	{
		dp[v]=max(dp[v],dfs(g[v][i])+1);
	}
	return dp[v];
}
int main()
{
	cin>>n>>m;
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		in[y]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(!in[i])dfs(i);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 11136
/*
author: madhav_1999 aka orthodoxparadox
31 May 2020 at 5:33 PM
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define dbl long double
#define int ll
#define ll long long
#define pii pair<int, int>
#define len(x) (int) x.size()
#define rev(a) reverse(all(a))
#define oiint ostream_iterator<int>(cout, " ") 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
#define inf 2e18
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef MADHAV
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define dbg(...) 42
#endif
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(int i=0;i<(int)v.size();++i) x<<v[i]<<" ";return x;} 
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;} 
template <typename X> ostream& operator << (ostream& x,const multiset<X>& v){for(auto it:v) x<<it<<" ";return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
struct pair_hash {inline std::size_t operator()(const std::pair<int, int> & v) const {return v.first*31+v.second;}};
const int MOD = 1e9 + 7;

int takemod(int a, int mod = MOD){a%=mod;if(a<0)a+=mod;return a;}

int fast_exp(int base, int expo, int mod = MOD) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;}
	return res;}

int modinv(int a, int mod = MOD){return takemod(fast_exp(takemod(a, mod), mod-2, mod), mod);}


void solve()
{
	dbl a, b;
	cin >> a >> b;
	cout << (int)(a * b);
}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	#ifdef MADHAV
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
	clock_t t1, t2;
	t1 = clock();

	int tt = 1;
	// cin >> tt;
	while(tt--)
	{
		solve();
	}
	#ifdef MADHAV
	t2 = clock(); cout << "\n\ntime taken: " << (t2-t1)/(dbl)CLOCKS_PER_SEC;
	#endif
	return 0;
}

Measured memory_bytes: 3764
n = int(input())
b = list(map(int,input().split()))

a = [b[0],b[0]]
for i in range(1, n-1):
    now_b = b[i]
    a[i] = min(b[i-1], now_b)
    a.append(now_b)
# print(a)
print(sum(a))


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
 
int main(){
    long long int N;
    cin >> N;
    int ans = 0;
    for(long long int i=2;i*i<=N;i++){
        int cur = 0;
        while (N % i == 0) {
            cur++;
            N /= i;
        }
        for(long long int j=1;j<=cur;j++) {
            ans++; cur -= j;
        }
    }
    if(N>1) ans++;
    cout << ans << endl;
 
	return 0;
 
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int MAX_N = 2e5+10;
int N;
ll K;
int A[MAX_N];
map<int,int> vis;

void solve()
{
	int at = 1, step = 0;
    vis[at]=0;
    int st=-1, ed=1,ns=-1;
    while(true){
        step++;
        int nxt = A[at];
        if(step == K){
            cout << nxt << '\n';
            return;
        }
        if(vis.count(nxt)){
            ns=nxt;
            st = vis[nxt];
            ed = step;
            break;
        }
        vis[nxt]=step;
        at=nxt;
    }
    //cout << st << ' ' << ed << '\n';
    K-=st;
    const int len=ed-st;
    K%=len;
    at = ns;
    //cout << at << ' ' << K << '\n';
    for(int i=0;i<K;++i) at=A[at];
    cout << at << '\n';
}

int main()
{
	cin >> N >> K;
	for(int i=1;i<=N;++i) cin >> A[i];
	solve();
	return 0;
}

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

    int a[100];
    rep(i, m){
        cin >> a[i];
    }

    int cost1 = 0, cost2 = 0;
    rep(i, m){
        if(a[i] > x && a[i] < n){
            cost1++;
        }
        if(a[i] > 0 && a[i] < x){
            cost2++;
        }
    }
    cout << min(cost1, cost2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef pair<int,int> P;

int main(){
    
    char str[101];
    int K;
    int achain=0;
    cin >> str>>K;
    
    for(int i=0;str[i]!='/0';i++){
        if(str[i]=='1'){
            achain+=1;
        }else{
            break;
        }
    }
    
    if(K<=achain){
        cout<<1<<endl;
    }else{
        cout<<str[achain]<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  int ans=0;
  rep(i,n){
    cin>>a[i];
    if(i%2==0 && a[i]%2==1) ans++;
  }
  cout<<ans<<endl;

  return 0;
}

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

int bubbleSort(int a[],int n){
	bool reverse = true;
	int count = 0;
	while(reverse){
		reverse = false;
		for(int i=n-1;i>0;i--){
			if(a[i]<a[i-1]) {
				swap(a[i],a[i-1]);
				reverse = true;
				count ++;
			}
		}
	}
	return count;
}

int main(){
	int n, count;
	cin >> n;
	
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	count = bubbleSort(a,n);
	
	for(int i=0;i<n-1;i++) cout << a[i] << " ";
	cout << a[n-1] << endl;
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void solve();

int main()
{
	solve();
	fflush(stdout);
	return 0;
}

static void solve()
{
	int N;
	getint(N);

	std::vector<LLONG> ai(N), bi(N), ci(N);
	for (int i = 0; i < N; i++) {
		getint(ai[i]);
	}
	std::sort(ai.begin(), ai.end());

	int start = 0;
	int end = N - 1;
	int bidx = 1, cidx = 1;
	while ((start <= end) && (bidx < N)) {
		bi[bidx++] = ai[start];
		if (bidx < N) {
			bi[bidx++] = ai[end];
		}
		ci[cidx++] = ai[end];
		if (cidx < N) {
			ci[cidx++] = ai[start];
		}
		end--;
		start++;
	}
	bi[0] = ai[start];
	ci[0] = ai[start];
	LLONG bsum = 0, csum = 0;
	for (int i = 1; i < N; i++) {
		bsum += tp_abs(bi[i] - bi[i - 1]);
		csum += tp_abs(ci[i] - ci[i - 1]);
	}
	printf("%lld\n", std::max(bsum, csum));
}


Measured memory_bytes: 5564
object Main extends App{
  import scala.io.StdIn.readLine
  val n = readLine().toInt
  val nodes = Array.tabulate(n){_ ⇒ Node(readLine().trim())}
  for (_ ← 1 until n){
    val Array(s, t) = readLine().split(' ').map(_.toInt)
    nodes(s - 1).addChile(nodes(t - 1))
  }
  println(nodes(0).pattern())
}
object Node {
  def apply(str:String):Node = {
    str match{
      case "E" ⇒ new MaterialNode
      case "E?" ⇒ new OptMaterialNode
      case "A" ⇒ new AltNode
      case "A?" ⇒ new OptAltNode
      case "R" ⇒ new OrNode
      case "R?" ⇒ new OptOrNode
      case _ ⇒ ???
    }
  }
}
sealed trait Node{
  protected var mChildren:List[Node] = Nil
  def addChile(node:Node):Unit = mChildren ::= node
  def pattern():Long = rawPattern() % mod
  protected def mod = 1000000007l
  protected def rawPattern():Long
}
sealed trait OptNode extends Node{
  override def pattern() = (super.pattern() + 1) % mod
}
class MaterialNode extends Node {
  override def rawPattern():Long = mChildren.foldLeft(1l){case (prev, node) ⇒ prev * node.pattern() % mod}
}
class OptMaterialNode extends MaterialNode with OptNode
class AltNode extends Node {
  override def rawPattern():Long = mChildren.map{node ⇒ node.pattern()}.sum
}
class OptAltNode extends AltNode with OptNode
class OrNode extends Node{
  override def rawPattern(): Long = mChildren.foldLeft(1l){case (prev, node) ⇒ prev * (node.pattern() + 1) % mod} + mod - 1
}
class OptOrNode extends OrNode with OptNode



Measured memory_bytes: 45656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(long long)N;i++)
typedef int64_t LL;
int main()
{
  int NG,OK,BASE;
  LL N,K,L=-pow(16,16)/16,M,R=LLONG_MAX/3,count;
  bool minus;
  cin>>N>>K;
  vector<LL> A(N,0);
  rep(i,N)cin>>A.at(i);
  sort(A.begin(),A.end());
  while(R-L>1)
  {
    M=(L+R)/2,count=0;
    rep(i,N)
    {
      NG=i,OK=N;
      minus=(A.at(i)<0)?true:false;
      while(OK-NG>1)
      {
        BASE=(NG+OK)/2;
        if(A.at(i)*A.at(BASE)<=M)(minus)?OK=BASE:NG=BASE;
        else(minus)?NG=BASE:OK=BASE;
      }
      count+=(minus)?N-OK:NG-i;
    }
    (count<K)?L=M:R=M;
  }
  cout<<R<<endl;
}

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

const long MOD=1000000007;
const long INF=100000000000000000;
int main(){
    long S;
    cin>>S;
    
    long X2=1000000000,Y2=1;
    long Y3=S/X2+(S%X2!=0);
    long X3=X2*Y3-S;
    
    cout<<0<<" "<<0<<" "<<X2<<" "<<Y2<<" "<<X3<<" "<<Y3<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
#define Yfin {cout<<"Yes"<<endl;return 0;}
#define Nfin {cout<<"No"<<endl;return 0;}
//template
//main
signed main(){
  int N,X;cin>>N>>X;
  int a=LINF;
  for(int i=0;i<N;i++){
    int m;cin>>m;
    X-=m;a=min(a,m);
  }
  cout<<N+X/a<<endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

ll rui(ll a,ll n){
  if(n==0) return 1;
  ll aa=a;
  while(n!=1){
    a*=aa;
    a%=MOD;
    n--;
  }
  return a;
}

int main(){
  int N; cin >> N;
  vector<ll> c(N);
  rep(i,N) cin >> c[i];
  sort(all(c));
  ll A=rui(4,N-1);
  //cout << A.x << endl;
  ll B=0;
  for(int i=0;i<N;i++){
    B+=c[i]*(N+1-i);
    B%=MOD;
  }
  ll ans=A*B%MOD;
  cout << ans << endl;
}

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

int n;
int a[100000001];

int main() {

  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  
  sort(a, a+n);
  int b[5];
  int m;
  for(int i=0; i<min(4, n); i++) {
    b[i] = a[i]; 
    m = i;
  }

  vector<int> v;
  for(int i=0; i<=m; i++) {
    for(int j=0; j<=m; j++) {
      if( i == j ) continue;
      int c = b[j], e = 1;
      while( c ) {
	c /= 10;
	e *= 10;
      }

      v.push_back(b[i] * e + b[j]);
    }
  }
  sort(v.begin(), v.end());

  cout << v[2] << endl;
} 

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

int n, a[100010];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int count = 0;
	int same = a[0];
	int ans = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] == same) {
			count++;
		}
		else {
			same = a[i];
			if (count % 2 == 0) {
				ans++;
			}
			count = 0;
		}
		if (i == n - 1) {
			if (count % 2 == 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640