akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = long long;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int dx2[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy2[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct edge {int from, to, cost; };

void solve(){
    int n;
    scanf("%d", &n);
    printf("%d\n", n/3);
}

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


Measured memory_bytes: 128
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (ll i = (ll)(a); i<(ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL <class T = ll> inline T IN() { T x; cin >> x; return x; }
TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void bOUT(bool c, string s, string t) { OUT(c ? s : t); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }
TPL<TNM T> vector<T> make_v(size_t a) { return vector<T>(a); }
TPL<TNM T, TNM... Ts> auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }


int next_combination(int sub) {
	int x = sub & -sub, y = sub + x;
	return (((sub & ~y) / x) >> 1) | y;
}

int main(void) {
	vec<ll> A(5);
	int N;
	cin >> N;
	REP(i, N) {
		string S;
		cin >> S;
		switch (S[0])
		{
		case 'M':
			A[0]++;
			break;
		case 'A':
			A[1]++;
			break;
		case 'R':
			A[2]++;
			break;
		case 'C':
			A[3]++;
			break;
		case 'H':
			A[4]++;
			break;
		default:
			break;
		}
	}
	ll ans = 0;
	int k = 3;
	int bit = (1 << k) - 1;
	for (; bit < (1 << 5); bit = next_combination(bit)) {
		ll x = 1;
		for (int i = 0; i < 5; ++i) {
			if (bit & (1 << i)) {
				x *= A[i];
			}
		}
		ans += x;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////
    int year, month, day;
    char tmp1, tmp2;
    cin >> year >> tmp1 >> month >> tmp2 >> day;
    if ( month <= 4 ) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var values = cin.ReadIntArray(2);
            var K = values[0];
            var S = values[1];
            var ans = 0;
            
            for (int i = 0; i <= K; ++i)
                for (int j = 0; j <= K; ++j)
                   if (0 <= S - i - j && S - i - j <= K) 
                        ans++;
            WriteLine(ans);
            
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 11220
import java.util.Scanner;

public class Main {
    public static void main (String[] args){
        solve1159();
    }

    public static void solve1159() {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int n = sc.nextInt();
            int p = sc.nextInt();
            if (n == 0 && p == 0) {
                break;
            }
            int[] kouhosya = new int[n];
            for(int i = 0; i < n; i++){
                kouhosya[i] = 0;
            }
            int wan = p;
            int index = 0;

            while(true){
                if(wan > 0){
                    kouhosya[index % n]++;
                    wan--;
                    if(kouhosya[index % n] == p){
                        break;
                    }
                } else {
                    wan += kouhosya[index % n];
                    kouhosya[index % n] = 0;
                }
                index++;
            }
            System.out.println(index % n);
        }
    }
}

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

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    for(int i=0; i<N; ++i) {
        cin >> v[i] >> w[i];
    }
    vector<int> dp(W+1);
    for(int i=0; i<N; ++i) {
        for(int j=W-w[i]; j>=0; --j) {
            dp[j+w[i]] = max(dp[j+w[i]], dp[j]+v[i]);
        }
    }
    cout << dp[W] << endl;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, ans = 0;
  cin >> n;
  vector<int> x(n);
  arep(i, x) cin >> i, ans ^= i;

  rep(i, 0, n) { cout << (ans ^ x[i]) << '\n'; }

  return 0;
}

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

int main() {
    int a,b,c,i,cnt;
	cin>>a>>b>>c;
	
	for(i = a; i <=b;i++){
	    if(c%i == 0){
	        cnt++;
	    }
	}
	
	cout<<cnt<<endl;
	return 0;
}



Measured memory_bytes: 3112
from math import gcd


def main():
    input()  # N
    array = [int(x) for x in input().split()]
    MAX_A = 10 ** 6 + 1
    histogram = [0] * MAX_A
    for x in array:
        histogram[int(x)] += 1
    for divider in range(2, MAX_A):
        count = 0
        for counted in histogram[divider::divider]:
            count += counted
        if count > 1:
            break
    else:
        return 'pairwise coprime'
    gcd_now = 0
    for x in array:
        gcd_now = gcd(x, gcd_now)
    if gcd_now == 1:
        return 'setwise coprime'
    else:
        return 'not coprime'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 133200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	vector<int> d(3);
  	cin>>d.at(0)>>d.at(1)>>d.at(2);
  	sort(d.begin(),d.end());
  	cout<<d.at(2)*10+d.at(1)+d.at(0)<<endl;
}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main(){
    int a,b,c,d,i,flag = 0;
    cin >> a >> b >> c >> d;
    for(i = 0;i < d;i++){
        if(a >= b){
            b *= 2;
        }
        else if(b >= c){
            c *= 2;
        }
        if(a < b && b < c){
            cout << "Yes" << endl;
            flag += 1;
            break;
        }
    }
    if(flag == 0)
        cout << "No" << endl;
    
    
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

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

  int n; cin >> n;
  rep(i,n){
    int a; cin >> a;
    if(a%2!=0) continue;
    else{
      if(a%3!=0 && a%5!=0){
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }

  cout << "APPROVED" << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define mx 100009
ll ar[mx+10];
ll mem[mx+10];
ll n,k;

ll dp(ll ind){
    if(ind>n)  return INT_MAX;
    else if(ind==n) return 0;
    else if(mem[ind]!=-1) return mem[ind];

    ll ans=INT_MAX;
    for(ll i=1;i<=k;i++){
        if(i+ind<=n){
            ll x=abs(ar[ind]-ar[ind+i])+dp(ind+i);
            ans=min(ans,x);
        }
    }
    mem[ind]=ans;
    return mem[ind];
}

int main()
{

    memset(mem,-1,sizeof(mem));
    cin>>n>>k;
    for(ll i=1;i<=n;i++){
        cin>>ar[i];
    }
    cout<<dp(1)<<endl;
    return 0;
}



Measured memory_bytes: 13000
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    getchar();
    int a=0,t=0,w=0,r=0;
    for(int i=0; i<n; i++)
    {
        char s[5];
        scanf("%s",s);
        if(s[0]=='A')
            a++;
        if(s[0]=='T')
            t++;
        if(s[0]=='W')
            w++;
        if(s[0]=='R')
            r++;
    }
    printf("AC x %d\n",a);
    printf("WA x %d\n",w);
    printf("TLE x %d\n",t);
    printf("RE x %d\n",r);
    return 0;
}


Measured memory_bytes: 3824
n = int(input())

ans = []
for odd in range(1, n+1):
    if odd % 2 == 0: continue
    cnt = 0
    for j in range(1, odd+1):
        if odd % j == 0:
            cnt += 1
    if cnt == 8:
        ans.append(odd)
print(len(ans))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
 
int N, L[100001], R[100001];
 
int main() {
    cin >> N;
    REP(i, N) cin >> L[i] >> R[i];
    
    N++;
    sort(L, L + N, greater<int>());
    sort(R, R + N);
 
    ll ans = 0;
    for (int i = 0; i < N && L[i] > R[i]; i++) {
        ans += 2LL * (L[i] - R[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   int odd = (n + 1) / 2;
   printf("%0.6f\n", 1.0 * odd / n);
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
 
template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int a;
	set<int> st;
	
	REP(i,3){
		cin>>a;
		st.insert(a);
	}
	cout<<st.size()<<endl;
	return 0; 
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int P=Integer.parseInt(sc.next());
		int Q=Integer.parseInt(sc.next());
		int R=Integer.parseInt(sc.next());

		int a = P+Q;
		int b = Q+R;
		int c = R+P;
		System.out.println(Math.min(a, Math.min(b, c)));

	}
}


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

int main() {
  int N,X;
  cin>>N>>X;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin>>L.at(i);
  }
  int D=0;
  int ans=1;
  while(ans<=N){
    D+=L.at(ans-1);
    if(D>X)break;
    ans++;
  }
  cout<<ans<<endl;
}


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

vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int n,m;
	cin >> n >> m;
	if(n > m){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
}

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

using namespace std;

int main(){
	long long int n;
	cin>>n;
	long long int j=1;
	long long int a[n];
	for(long long int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==j)
			j++;
	}
	if(j==1)
		cout<<-1;
	else
		cout<<n-j+1;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
	long long N = 0;
    long long K = 0;
	scanf("%lld %lld", &N, &K);

    N %= K;
    
    if(K-N < N){
        N = K-N;
    }else{
        
    }

    printf("%lld", N);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
const int MAX_N=1e5;
struct BIT{
    //1-indexed
    int bit[MAX_N+1], n;
    
    int sum(int i){
        int s=0;
        while(i>0){
            s+=bit[i];
            i-=i&-i;
        }
        return s;
    }
    
    void add(int i, int x){
        while(i<=n){
            bit[i]+=x;
            i+=i&-i;
        }
    }
};
BIT b;
int q;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>b.n>>q;
    rep(i,0,q){
        int c,x,y;
        cin>>c>>x>>y;
        if(c) cout <<b.sum(y)-b.sum(x-1)<<"\n";
        else b.add(x,y);
    }
}


Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
    long double a, b, c;
    cin >> a >> b >> c;
    long double A = sqrt(a)*sqrt(b);
    long double m = a + 2*A + b;
    if(m < c){
        puts("Yes");
    }
    else puts("No");
}




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

int main(){
  int a,b;
  int an[1000];
  int con[1000];
  int i=0,j,k;

  while(cin>>a>>b){
    an[i] =a + b;
    con[i] = 1;
    while(an[i]>=10){
      an[i] /= 10;
      con[i]++;
    }
    i++;
      }
  for(j=0;j<i;j++){
    cout<<con[j]<<endl;
  }

  return 0;

}
    

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int arr[n];
  for(int i= 0;i<n;++i)
  cin >> arr[i];
  sort(arr, arr+n);
  int sum = 0;
  for(int i = 0;i<n-1;i++)
    sum += arr[i];
  if(sum > arr[n-1])
  cout << "Yes" ;
  else
    cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

int main() {
  int n, k, d;
  bool is_safe[10] = {};
  std::cin >> n >> k;
  std::fill(is_safe, is_safe + 10, true);
  for (int ki = 0 ; ki < k; ++ki) {
    std::cin >> d;
    is_safe[d] = false;
  }
  while (true) {
    int r = n;
    while (r > 0) {
      if (not is_safe[r % 10]) {
        goto fail;
      }
      r /= 10;
    }
    std::cout << n << std::endl;
    return 0;
fail:
    ++n;
  }
}

Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
long long ans[100010];
int a[100010];

int main(int argc, char const *argv[])
{
	int n;
	scanf("%d", &n);
	
	map <int, int> cnt, least;
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		cnt[a[i]] += 1;
		if(least.find(a[i]) == least.end()) least[a[i]] = i;
		else least[a[i]] = min(least[a[i]], i);
	}
	vector <int> v;
	for(auto i : cnt) {
		v.push_back(i.first);
	}
	reverse(v.begin(), v.end());
	v.push_back(0);
	for(int i = 0; i + 1 < v.size(); i++) {
		ans[least[v[i]]] += 1LL * cnt[v[i]] * abs(v[i] - v[i + 1]);
		cnt[v[i + 1]] += cnt[v[i]];
		least[v[i + 1]] = min(least[v[i + 1]], least[v[i]]);
	}
	for(int i = 1; i <= n; i++) {
		printf("%lld\n", ans[i]);
	}
	return 0;
}

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

using namespace std;

int main(void){

    int n;
    cin >> n;
    vector<int> a(n);
    int alice = 0, bob = 0;
    for(int i = 0;i < n;i++) cin >> a[i];

    sort(a.begin(), a.end(), greater<int>());

    for(int i = 0;i < n;i++){
        if(i % 2 == 0) alice += a[i];
        else bob += a[i];
    }

    cout << abs(alice-bob) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    int a;
    long double b, n;
    cin >> a >> b >> n;
    long double a_b = a/b;
    ll x = min(n, b-1);
    ll f_a = floor(a_b*(x)) - a*floor((x)/b);
        
    out(f_a);
}

Measured memory_bytes: 3724
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(d, e);
    if(d == 0 && e == 0)break;
    double res = 1010101.0;
    rep(i, d + 1){  //(i, d - i)
      double tmp = sqrt((double)(i * i) + (double)((d - i) * (d - i)));
      res = min(res, abs((double)e - tmp));
    }
    prid(res);

  }
  return 0;
}

Measured memory_bytes: 1224
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using ll = long long;
using namespace std;

const long long MOD = 1000000007;
const ll LINF = 1LL << 50;

ll N;
int ketamax = 10;
ll ans = 0;


bool thisIs753num(string S){
  int s = S.size();
  bool f7 = false;
  bool f5 = false;
  bool f3 = false;

  REP(n,s){
    if (S[n] == '3') f3 = true;
    if (S[n] == '5') f5 = true;
    if (S[n] == '7') f7 = true;
  }

  if (f3 && f5 && f7){
    return true;
  } else{
    return false;
  }
}

void solve(int n, string S){
  if (thisIs753num(S)){
    ll num = stol(S);
    if (N >= num){
      //cout << num << endl;
      ans += 1;
    }
  }

  if (n <= ketamax){
    solve(n+1, "3"+S);
    solve(n+1, "5"+S);
    solve(n+1, "7"+S);
  }
}

int main() {
  cin >> N;
  solve(1,"3");
  solve(1,"5");
  solve(1,"7");

  cout << ans << endl;
}


Measured memory_bytes: 3608
S=input()
T=input()
string="abcdefghijklmnopqrstuvwxyz"
s=[0 for i in range(26)]
t=[0 for i in range(26)]
for i in range(26):
    s[i]+=S.count(string[i])
    t[i]+=T.count(string[i])
print("Yes" if sorted(s)==sorted(t) else "No")

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

int main()
{
        int x,y;
        cin >> x>> y;

        if(x>y)
            swap(x,y);
        int d = y-x+1;
        if(d>=2019){
            cout << "0" << endl;
            return 0;
        }

        int mn = 1000000010;
        for(int i=x;i<=y;i++){
            for(int j=i+1;j<=y;j++){
                int t = ((i%2019)*(j%2019))%2019;
                mn = min(mn,t);
            }
        }
        cout << mn << endl;




return 0;

}

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;

public class Main {
    int[] ans;
    boolean[] visited;
    List<Integer>[] tree;

    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int q = sc.nextInt();

        ans = new int[n];
        tree = new List[n];
        visited = new boolean[n];
        for (int i = 0; i < n; i++) {
            tree[i] = new ArrayList<>();
        }

        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            tree[a].add(b);
            tree[b].add(a);
        }

        for (int i = 0; i < q; i++) {
            int p = sc.nextInt() - 1;
            int x = sc.nextInt();
            ans[p] += x;
        }

        dfs(0);

        PrintWriter pw = new PrintWriter(System.out);

        pw.print(ans[0]);
        for (int i = 1; i < n; i++) {
            pw.print(" ");
            pw.print(ans[i]);
        }
        pw.println();
        pw.flush();
    }

    void dfs(int parent) {
        visited[parent] = true;
        List<Integer> nextNodes = tree[parent];
        for (int nodeIdx : nextNodes) {
            if (!visited[nodeIdx]) {
                ans[nodeIdx] += ans[parent];
                dfs(nodeIdx);
            }
        }
    }

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

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


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

int main(){
	long N;
	cin >> N;
	int ans = 1e9;
	for(long i = 1; i * i <= N; i++){
		if(N % i == 0){
			ans = min(ans, max(int(to_string(i).size()), int(to_string(N / i).size())));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define ko 100
int main(){
  int i,j,N,A[ko],flag=1,im,cou=0;

  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  i=0;
  while(flag){
    flag=0;
    for(j=N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	im=A[j];
	A[j]=A[j-1];
	A[j-1]=im;
	flag=1;
	cou++;
      }
    
    }
    i++;
  }
  for(i=0;i<N;i++){
  printf("%d",A[i]);
  if(i!=N-1)printf(" ");
  }
  printf("\n%d\n",cou);
  return 0;
}

Measured memory_bytes: 604
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    n, k = map(int, input().split())
    val = (n-1)*(n-2)//2
    if k > val:
        print(-1)
    else:
        rem = val-k
        print(n-1+rem)
        for i in range(2,n+1):
            print(1,i)
        a, b = 2, 3
        cnt = 0
        for i in range(rem):
            print(a,b)
            if b < n:
                b+=1
            else:
                a += 1
                b = a+1



resolve()


Measured memory_bytes: 73504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  int a,b;
  cin >> a >> b;
  int ans = max(a+b,a-b);
  ans = max(ans,a*b);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long S){
    ll M = (ll) ceil(sqrt(S));
    M = max(M-2, 1LL);
    for(; M*M <=S; M++){}
    if(M*M>S) M--;
    if(M*M<S) M++;
    if(M*M==S){
        cout << 0 <<" "<< M <<" " << M << " " << 0 << " " << 0 << " "<< 0<<endl;
        return;
    }
    cout << 0 <<" "<< M-S%M <<" " << (S/M)+1 << " " << 0 << " " << S/M << " "<< M<<endl;
}

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


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <stdio.h>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};
char ch[10];

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 8, stdin);
    if (ch[7] == '\n') {
        if (ch[0] == '3') {
            puti('4' - ch[2]);
        }
        else if (ch[0] == '2' && ch[1] == ' ') {
            puti(ch[2] - '0');
        }
        else
            puti(arr1[ch[0] - '0'][ch[6] - '0']);
    }
    else if (ch[6] == '9') {
        if (ch[0] == '6') {
            puti(22888);
        }
        else if (ch[0] == '9') {
            puti(25436);
        }
        else
            puti(arr1[ch[0] - '0'][ch[7] - '0']);
    }
    else
        puti(arr1[ch[0] - '0'][ch[7] - '0']);
    fputc('\n', stdout);
    return 0;
}

Measured memory_bytes: 1512
#include <iostream>
#include <vector>
#include <string>

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
using namespace std; 

#define MAX 10

int N;
int in[MAX];
vector<string> vs;
string s;

void dfs(int l, int r, int cnt) {
	if(cnt == MAX) s = "YES";
	if(in[cnt] > l) dfs(in[cnt],r,cnt+1);
	if(in[cnt] > r) dfs(l,in[cnt],cnt+1);
}

void solve()
{
	s = "NO";
	dfs(0,0,0);
	vs.pb(s);
}

void input()
{
	cin >> N;
	rep(i,0,N) {
		rep(j,0,MAX) cin >> in[j];
		solve();
	}
}

int main(void)
{
	input();
	rep(i,0,vs.size()) cout << vs[i] << endl;
	return 0;
}

Measured memory_bytes: 1200
///spaesk

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define pi acos(-1)
#define int long long int
#define ld long double
#define ar array
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<int> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const int ths = 1LL << 40;
const int NN = 5e3 + 6;

const int maxN = 1e5 + 7;

///
///

void solve()
{

    int a;
    cin>>a;
    int ans = a + a * a + a * a * a;
    cout<<ans;
    cout<<"\n";
    return ;
}

/*
*/

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3636
using System;

class Program
{
	static void Main()
	{
		var xy = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => long.Parse(number));
		var x = xy[0];
		var y = xy[1];

		var count = 0;
		for (var i = x; i <= y; i *= 2) {
			++count;
		}

		Console.WriteLine(count);
	}
}


Measured memory_bytes: 27564
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define DUMP(v) for(auto& x : v) cerr << x << " "; cerr << endl;
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1e9;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> l(n);
  vector<ll> r(n);

  l[0] = a[0];
  for (int i = 1; i < n; i++) {
    l[i] = gcd(l[i-1], a[i]);
  }

  r[n-1] = a[n-1];
  for (int i = n-2; i >= 0; i--) {
    r[i] = gcd(r[i+1], a[i]);
  }

  // DUMP(l);
  // DUMP(r);

  ll ans = 1;
  for (int i = 0; i < n; i++) {
    if (i == 0) chmax(ans, r[i+1]);
    else if (i == n-1) chmax(ans, l[i-1]);
    else chmax(ans, gcd(l[i-1], r[i+1]));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,M = map(int,read().split())

def solve(N,M):
    if N > M:
        return solve(M,N).T
    H = np.array([[0]], np.int8)
    for i in range(M):
        H = np.tile(H, (2,2))
        H[1<<i:,1<<i:] ^= 1
    H = np.diff(H, axis=0)
    H = np.diff(H, axis=1)
    return (H % 2)[:(1<<N) - 1]

H = solve(N,M)
size = 0
for row in H:
    word = ''.join(row.astype(str))
    print(word)
    

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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

int main()
{
	int n;
	int64_t t, ans = 1;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> t;
		ans = lcm(ans, t);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3680
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  result = ceill(n / 11.0);
  result *= 2;
  tmp = n % 11;
  if(tmp>=1 &&tmp<=6) result--;
  printf("%lld",result);
  
  return 0;
}



Measured memory_bytes: 128
from itertools import combinations
n = int(input())
lst = list(map(int, input().split()))
comb = combinations(lst, 3)
count = 0
for i in comb:
  if i[0] != i[1] and i[1] != i[2] and i[0] != i[2]:
    if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
      count += 1
print(count)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
#define MAX_V 1000
struct edge {
    int to, cap, rev;
};
vector<edge> G[MAX_V];
bool used[MAX_V];
void add_edge(int from, int to, int cap) {
    // G[to].size()をrevに保持することでG[edge.to][edge.rev]で逆辺の構造体にアクセスできる
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}
int dfs(int v, int t, int f) {
    if(v == t) {
        return f;
    }
    used[v] = true;
    for(int i = 0; i < (int)G[v].size(); i++) {
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            // d==0ならtにたどり着かない
            if(d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s, int t) {
    int flow = 0;
    for(;;) {
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, MOD);
        if(f == 0) {
            return flow;
        }
        flow += f;
    }
}
int main() {
    int v, e;
    cin >> v >> e;
    for(int i = 0; i < e; i++) {
        int u, v, c;
        cin >> u >> v >> c;
        add_edge(u, v, c);
    }
    cout << max_flow(0, v - 1) << endl;
}


Measured memory_bytes: 3220
#include <stdio.h>

int main() {
    char a, b, c, d;

    scanf("%c", &a);
    scanf("%c", &b);
    scanf("%c", &c);
    scanf("%c", &d);

    if ((a == b && c == d && a != c) ||
        (a == c && b == d && a != b) ||
        (a == d && b == c && a != b)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m1 = sc.nextInt();
		int d1 = sc.nextInt();
		int m2 = sc.nextInt();
		int d2 = sc.nextInt();
		if(m2 - m1 != 0) {
			System.out.println(1);
		}else {
			System.out.println(0);
		}
		sc.close();
	}
}


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

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(400).
01 maxlen     PIC 9(10) VALUE 100 COMP.
01 cur        PIC 9(10) VALUE 1 COMP.
01 i          PIC 9(10) VALUE 1 COMP.
01 j          PIC 9(10) COMP.
01 len        PIC 9(10) COMP.
01 cnt        PIC 9(10) VALUE ZERO.
01 zs         PIC Z(9)9.
01 N          PIC 9(10).
01 p          PIC 9(10).

PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT ln.
  MOVE N TO maxlen.
  PERFORM maxlen TIMES
    PERFORM VARYING j FROM cur BY 1 UNTIL ln(j:1) = SPACE
    END-PERFORM
    COMPUTE len = j - cur
    MOVE ln(cur:len) TO p
    IF p <> i
      ADD 1 TO cnt
    END-IF
    COMPUTE cur = j + 1
    ADD 1 TO i
  END-PERFORM.
  IF cnt <= 2
    DISPLAY "YES"
  ELSE
    DISPLAY "NO"
  END-IF.
  STOP RUN.


Measured memory_bytes: 3932
#include<stdio.h>
#include<stdbool.h>
#define N 8
#define F -1
#define NF 1

int r[N],c[N],s[2*N-1],g[2*N-1];
bool x[N][N];

void initialize(){
  int i;
  for(i=0;i<N;i++){
    r[i]=F;
    c[i]=F;
  }
  for(i=0;i<2*N-1;i++){
    s[i]=F;
    g[i]=F;
  }
}

void print(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(x[i][j]){
        if(r[i]!=j)return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(r[i]==j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void recu(int i){
  int j;
  if(i==N){
    print();
    return;
  }
  for(j=0;j<N;j++){
    if(c[j]==NF || s[i+j]==NF || g[i-j+N-1]==NF)continue;
    r[i]=j;
    c[j]=s[i+j]=g[i-j+N-1]=NF;
    recu(i+1);
    r[i]=c[j]=s[i+j]=g[i-j+N-1]=F;
  }
}

int main(){
  initialize();
  int i,j,k,r,c;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      x[i][j]=false;
    }
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    x[r][c]=true;
  }
  recu(0);
  return 0;
}


Measured memory_bytes: 2112
#ABC 152 C - Low Elements

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

count = 0

tmp_min = Ps[0]
for i in range(N):
    
    if(tmp_min >= Ps[i]):
        count += 1
        tmp_min = Ps[i]
    else:
        pass
    
    
print(count)

Measured memory_bytes: 24744
#include <bits/stdc++.h>
using namespace std;
char a[1001][1001];
long long f[1001][1001];
int main()
{
        long long i,j,n,m;
        scanf("%lld %lld",&n,&m);
        for(i=1;i<=n;i++)
        {
                getchar();
                for(j=1;j<=m;j++)
                {
                        scanf("%c",&a[i][j]);
                }
        }
        for(i=1;i<=n;i++)
        {
                for(j=1;j<=m;j++)
                {
                        if(i==1&&j==1)
                                f[i][j]=1;
                        else if(a[i][j]=='.')
                                f[i][j]=(f[i-1][j]+f[i][j-1])%1000000007;
                        else if(a[i][j]=='#')
                                f[i][j]=0;      
                }
        }
        printf("%lld",f[n][m]);
        return 0;
} 

Measured memory_bytes: 9088
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
g=[["#"]*(w+1)]+[["#"]+list(input())+["#"]for _ in range(h)]+[["#"]*(w+1)]
gg=[[0]*w for _ in range(h)]
for i in range(1,h+1):
  k=1
  for j in range(1,w+1):
    if g[i][j]==".":
      gg[i-1][j-1]=k;k+=1
    else:k=1
  d=gg[i-1][-1]
  for j in range(1,w+1):
    if gg[i-1][-j]!=0:gg[i-1][-j]=d
    elif j!=w:d=gg[i-1][-j-1]
ggg=[[0]*w for _ in range(h)]
for j in range(1,w+1):
  k=1
  for i in range(1,h+1):
    if g[i][j]==".":
      ggg[i-1][j-1]=k;k+=1
    else:k=1
  d=ggg[-1][j-1]
  for i in range(1,h+1):
    if ggg[-i][j-1]!=0:ggg[-i][j-1]=d
    elif i!=h:d=ggg[-i-1][j-1]
ans=0
for i in range(h):
  for j in range(w):ans=max(ans,gg[i][j]+ggg[i][j])
print(ans-1)

Measured memory_bytes: 247688
# -*- coding: utf-8 -*-


def f(n):
    C = [[1 for i in range(10)]]
    while sum(d for c in C for d in c[1:]) < n:
        C.append([sum(C[-1][max(0,i-1):min(i+2,10)]) for i in range(10)])
    return C

def solve():
    n = int(input())
    C = f(n)
    X = []
    m = sum(d for c in C[:-1] for d in c[1:])
    x = 1
    for x in range(1,10):
        if m + C[-1][x] < n:
            m += C[-1][x]
        else:
            break
    X.append(x)
    C = C[:-1]
    for c in C[::-1]:
        for x in range(max(0,X[-1]-1), min(10,X[-1]+2)):
            if m + c[x] < n:
                m += c[x]
            else:
                break
        X.append(x)
    return ''.join(map(str,X))


if __name__ == '__main__':
    print(solve())



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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

ll a[MAXN];

void solve(){
	int n;
	ll sum = 0;
	scanf("%d", &n);
	REP(i, 0, n){
		scanf("%lld", &a[i]);
		sum += a[i];
	}
	if (n == 1){
		printf("YES\n");
		return;
	}
	ll mul = (ll)n * (ll)(n + 1) / 2ll;
	if (sum % mul){
		printf("NO\n");
		return;
	}
	ll sumx = sum / mul;
	REP(i, 0, n){
		ll cur = sumx - (a[i] - a[(i + n - 1) % n]);
		if (cur < 0 || cur % n){
			printf("NO\n");
			return;
		}
	}
	printf("YES\n");
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

using namespace std;

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

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

  vector<int> dp(n);
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < n; ++i) {
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
  }
  cout << dp[n-1] << '\n';

  return 0;
}


Measured memory_bytes: 1024
N, P = [int(i) for i in input().strip().split()]
dic={}
ans = 1

if N == 1:
    print(P)
    quit()
elif P == 1:
    print(1)
    quit()
    
for i in range(2,int(P**(1/2))+1):
    num = 0
    while P%i == 0:
        num = num +1
        P = int(P/i)
    dic[i] = num//N
    ans = ans*(i**(dic[i]))

print(ans)

Measured memory_bytes: 99040
// Aizu Vol-1 0010: Circumscribed Circle of a Triangle
// 2017.8.11

#include <stdio.h>
#include <string.h>
#include <math.h>

#define EPS 1.0e-8

double x[3], y[3];
double px, py, r;

int crossPoint(double *x, double *y, double *A, double *B, double *C)
{
	double a, b, c, d, e;

	e = A[0] * B[1] - B[0] * A[1];
	if (fabs(e) <= EPS) return 0;
	a = B[1] / e, b = -B[0] / e, c = -A[1] / e, d = A[0] / e;
	*x = -a * C[0] - b * C[1];
	*y = -c * C[0] - d * C[1];
	return 1;
}

int main()
{
	int n, i;
	double a[2], b[2], c[2];
	char xs[30], ys[30], *xp, *yp;

	scanf("%d", &n);
	while (n-- > 0) {
		for (i = 0; i < 3; i++) scanf("%lf%lf", x + i, y + i);
		for (i = 0; i < 2; i++) {
			a[i] = x[i] - x[i + 1];
			b[i] = y[i] - y[i + 1];
			c[i] = -a[i] * (x[i] + x[i + 1]) / 2.0 - b[i] * (y[i] + y[i + 1]) / 2.0;
		}
		crossPoint(&px, &py, a, b, c);
		r = sqrt((px - x[0])*(px - x[0]) + (py - y[0])*(py - y[0]));
		xp = xs, yp = ys;
		sprintf(xs, "%.3lf", px); if (!strcmp(xp, "-0.000")) xp++;
		sprintf(ys, "%.3lf", py); if (!strcmp(yp, "-0.000")) yp++;
		printf("%s %s %.3lf\n", xp, yp, r);
	}
	return 0;
}

Measured memory_bytes: 676