akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <tuple>
#include <queue>
#include <utility>
using namespace std;
 
typedef tuple<int,int,int> T3; //to,dist,transfer
vector<T3> E[200050];
map<tuple<int,int,string>,int> M;
 
int id(int line, int pos, string sta){
    auto t = make_tuple(line,pos,sta);
    if(M.find(t)==M.end()){
        int id = M.size();
        M[t]=id;
    }
    return M[t];
}
 
int main(){
    int N,T;
    cin>>N>>T;
    string A,B;
    cin>>A>>B;
    int start = id(0,0,A), goal = id(0,0,B);
    for(int n=1;n<=N;n++){
        int a;
        cin>>a;
        vector<string> S(a);
        vector<int> TT(a-1);
        for(auto &s:S){
            cin>>s;
        }
        for(auto &t:TT){
            cin>>t;
        }
        //graph build
        for(int i=0;i<a;i++){
            int ground = id(0,0,S[i]);
            int inside = id(n,i,S[i]);
            E[ground].emplace_back(inside,T,1);
            E[inside].emplace_back(ground,0,0);
        }
        for(int i=0;i<a-1;i++){
            int cs = id(n,i,S[i]);
            int ns = id(n,i+1,S[i+1]);
            E[cs].emplace_back(ns,TT[i],0);
            E[ns].emplace_back(cs,TT[i],0);
        }
    }
 
    priority_queue<T3,vector<T3>,greater<T3>> que; // T:=<time,transfer,id>
    que.emplace(0,0,start);
    typedef pair<int,int> P; // time, trasfer
    vector<P> memo(200000,P(1100000000,0));
    while(!que.empty()){
        int time, transfer, cs;
        tie(time,transfer,cs) = que.top(); que.pop();
        if(cs==goal){
            cout<<time-T<<' '<<transfer-1<<endl;
            return 0;
        }
        for(auto e:E[cs]){
            int to, dist, trans;
            tie(to,dist,trans) = e;
            if(P(dist+time,transfer+trans)<memo[to]){
                memo[to]=P(dist+time,transfer+trans);
                que.emplace(dist+time,transfer+trans,to);
            }
        }
    }
    cout<<-1<<endl;
 
    return 0;
}

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

int main() {
  int n, m, q;
  cin >> n >> m >> q;
  int a[q], b[q], c[q], d[q];
  rep(i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }
  
  int e[n];
  rep(i,n) e[i] = 1;
  
  int maxscore = 0;
  bool ok = true;
  while (ok) {
    int score = 0;
    rep(i,q) if (e[b[i]] - e[a[i]] == c[i]) score += d[i];
    maxscore = max (maxscore, score);
    
    int k = n-1;
    while (e[k] == m) k--;
    if (k == -1) ok = false;
    else {
      e[k]++;
      for (int p = k+1; p < n; p++) e[p] = e[k];
    }
  }
  
  cout << maxscore << endl; 
}

Measured memory_bytes: 3604
#include<stdio.h>

int main(void){
	int a11, a12, a13, a21, a22, a23, a31, a32, a33;
	int n11, n12, n13, n21, n22, n23, n31, n32, n33;
	int N;
	int b[100];
	int i;
	int j = 0;

	n11 = 0;
	n12 = 0;
	n13 = 0;
	n21 = 0;
	n22 = 0;
	n23 = 0;
	n31 = 0;
	n32 = 0;
	n33 = 0;

	scanf("%d %d %d", &a11, &a12, &a13);
	scanf("%d %d %d", &a21, &a22, &a23);
	scanf("%d %d %d", &a31, &a32, &a33);
	scanf("%d", &N);

	for (i = 0; i < N; i++){
		scanf("%d", &b[i]);
	}

	for (i = 0; i < N; i++){
		if (a11 == b[i]) n11 = 1;
		if (a12 == b[i]) n12 = 1;
		if (a13 == b[i]) n13 = 1;
		if (a21 == b[i]) n21 = 1;
		if (a22 == b[i]) n22 = 1;
		if (a23 == b[i]) n23 = 1;
		if (a31 == b[i]) n31 = 1;
		if (a32 == b[i]) n32 = 1;
		if (a33 == b[i]) n33 = 1;
	}

	if (n11 == n12 && n12 == n13 && n11 == 1)
		j = 1;

	if (n21 == n22 && n22 == n23 && n21 == 1)
		j = 1;

	if (n31 == n32 && n32 == n33 && n31 == 1)
		j = 1;

	if (n11 == n21 && n21 == n31 && n11 == 1)
		j = 1;

	if (n12 == n22 && n22 == n32 && n12 == 1)
		j = 1;

	if (n13 == n23 && n23 == n33 && n13 == 1)
		j = 1;

	if (n11 == n22 && n22 == n33 && n11 == 1)
		j = 1;

	if (n13 == n22 && n22 == n31 && n13 == 1)
		j = 1;

	if (j == 1){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
}

Measured memory_bytes: 128
# ABC052c
import sys
from math import factorial
from collections import Counter
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
MOD = 10**9+7


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


ans = 1
for i in Counter(prime_factorize(factorial(n))).values():
    ans = ans*(i+1) % MOD
print(ans)


Measured memory_bytes: 3316
from collections import Counter

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

c = Counter()

for ai in A:
    c[ai] += 1

more_than_2 = []
for k, v in c.items():
    if v >= 4:
        more_than_2.append(k)
    if v >= 2:
        more_than_2.append(k)

if len(more_than_2) < 2:
    print(0)
else:
    more_than_2.sort(reverse=True)
    ans = more_than_2[0] * more_than_2[1]
    print(ans)



Measured memory_bytes: 18600
#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;

ll power(ll x, ll k, ll p){
    if (k==0) return 1;
    else if (k==1) return x%p;
    else if (k%2==0) return (power(x,k/2,p) * power(x,k/2,p))%p;
    else return (power(x,k/2,p) * power(x,k/2+1,p))%p;
}

ll dp[2][1010];

int main() {
    ll N, M;
    cin >> N >>M;
    
    if (M==1){
        cout << 1<< endl;
    }
    else {
        int a=0;
        ll b=2;
        while (b<=1000){
            if (M%b==0){
                dp[0][a]=b;
                while (M%b==0){
                    M/=b;
                    dp[1][a]++;
                }
                a++;
            }
            b++;
        }
        if (M!=1){
            dp[0][a]=M;
            dp[1][a]=1;
            a++;
        }
        ll ans=1;
        if (a==0){
            cout << N << endl;
        }
        else {
            rep(i, 0, a){
                ll p=1;
                ll q=1;
                for (ll j=N ;j< dp[1][i]+N; j++){
                    p*=j;
                    p%=MOD;
                }
                for(ll j=1; j<dp[1][i]+1; j++){
                    q*=j;
                    q%=MOD;
                }
                ans*=(p*power(q, MOD-2, MOD)) % MOD;
                ans%=MOD;
            }
            cout << ans << endl;
        }
    }
}

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

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

Measured memory_bytes: 1408
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()) {
			System.out.println(solve(in.nextFloat()));
		};
	}
	static String solve(float w) {
		String ans = "";
		if(w <= 48.00f) ans = "light fly";
		else if(w <= 51.00f) ans = "fly";
		else if(w <= 54.00f) ans = "bantam";
		else if(w <= 57.00f) ans = "feather";
		else if(w <= 60.00f) ans = "light";
		else if(w <= 64.00f) ans = "light welter";
		else if(w <= 69.00f) ans = "welter";
		else if(w <= 75.00f) ans = "light middle";
		else if(w <= 81.00f) ans = "middle";
		else if(w <= 91.00f) ans = "light heavy";
		else ans = "heavy";
		return ans;
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
int a,b;
#define For(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) For(i,0,n)

#define F first
#define S second
typedef double db;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

int main(){
  int n,m,sum;
  sum=0;
  cin>>n>>m;
  vector<int> v(m);
  rep(i,m){
    cin>>v[i];
    sum+=v[i];
  }
  cout<<max(n-sum,-1)<<endl;
return 0;
}

Measured memory_bytes: 3628
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = a[1] / a[0];
        if (n >= a[2])
            Console.WriteLine(a[2]);
        else
            Console.WriteLine(n);
        
    }
}

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

void solve(long long N)
{

    ll ans = 0;
    for (ll A = 1; A <= N; A++)
    {
        for (ll B = 1; A * B < N; B++)
        {
            ll C = N - A * B;
            ans++;
        }
    }
    cout << ans << endl;
}

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


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

using namespace std;

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

	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.size(); ++i) {
		ans += s[i] == t[i];
	}
	cout << ans;

	return 0;
}

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#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 all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(std::string s, std::string t) {
  int N = sz(s);
  int M = sz(t);
  vector<vector<int>> dp(N + 1, vector<int>(M + 1, 0));

  rep(i, N) {
    rep(j, M) {
      if (s.at(i) == t.at(j))
        dp.at(i + 1).at(j + 1) = dp.at(i).at(j) + 1;
      else
        dp.at(i + 1).at(j + 1) = max(dp.at(i).at(j + 1), dp.at(i + 1).at(j));
    }
  }

  string ans = "";
  int l = dp.at(N).at(M);
  int i = N - 1;
  int j = M - 1;
  while (l > 0) {
    if (s.at(i) == t.at(j)) {
      ans += s.at(i);
      i--;
      j--;
      l--;
    } else if (dp.at(i + 1).at(j + 1) == dp.at(i).at(j + 1) && i > 0) {
      i--;
    } else if (j > 0) {
      j--;
    }
  }
  reverse(all(ans));
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  std::string s;
  std::cin >> s;
  std::string t;
  std::cin >> t;
  solve(s, t);
  return 0;
}


Measured memory_bytes: 38532
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>
 
using namespace std;
 
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
// #define ll long long
typedef long long ll;
typedef pair<int, int> P;
 
const int V = 100005;
vector<int> to[V*2];
bool visited[V*2];
vector<int> cnt;
 
int main(int argc, const char * argv[]) {
 
    int n;
    cin >> n;
    int p[n];
    rep(i,n) cin >> p[i];
    int ans = 0;
    rep(i,n-2){
      if (p[i] > p[i+1] && p[i+1] > p[i+2]){
        ans += 1;
      }else if (p[i] < p[i+1] && p[i+1] < p[i+2]){
        ans += 1;
      }
    }
    cout << ans << endl;
    
 
    return 0;
}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int D=365,A=26,K=6;

int d;
int c[A],s[D][A],last[A];

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

    cin>>d;
    for(int j=0;j<A;j++)
        cin>>c[j],
        last[j]=-1;
    for(int i=0;i<d;i++)
        for(int j=0;j<A;j++)
            cin>>s[i][j];
    for(int i=0;i<d;i++)
    {
        int best=0;
        for(int j=0;j<A;j++)
            if(s[i][j]+c[j]*(i-last[j])*min(K,d-i)>
               s[i][best]+c[best]*(i-last[best])*min(K,d-i))
                best=j;
        last[best]=i;
        cout<<best+1<<"\n";
    }
}


Measured memory_bytes: 3732
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <iomanip>
#include <cmath>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
	int N;
	cin>>N;
	long double total = 0;
	for(int i = 0; i < N; i++){
		double x;
		string u;
		cin>>x>>u;
		if(u == "JPY"){
			total+=x;
		}else{
			total += (x * 380000);
		}
	}
	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 256
while True:
    h,w=map(int,input().split())
    if h==0 and w==0:break
    else:
        for i in range(1,h+1):
            for j in range(1,w+1):
                if i%2==1 and j%2==0:
                    print(".",end="")
                elif i%2==0 and j%2==1:
                    print(".",end="")
                else:
                    print("#",end="")
            print()
        print()


Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    int ALL=0,O=0;
    rep(i,S.size()){
        if(S[i]=='a'){
            if(ALL<A+B){
                cout << "Yes" << endl;
                ALL++;
            }else{
                cout << "No" << endl;
            }
        }else if(S[i]=='b'){
            if(ALL<A+B&&O<B){
                cout << "Yes" << endl;
                ALL++;
                O++;
            }else{
                cout << "No" << endl;
            }
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef pair<int,int> pii;
int n,arr[101010],ck;

main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",arr+i);
	} for(int i=0;i<n;i++)
	{
		if(arr[i]%2) continue;
		if(arr[i]%3==0||arr[i]%5==0) continue;
		ck=1;	
	} if(ck) puts("DENIED");
	else puts("APPROVED");
}

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

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
/////////////////////

int const N = 41;
int const INF = 1e9 + 41;

int a, b;
int d[N][N], w[N][N];

struct Edge{
	int x, y, c;
	bool f;
	Edge(){};
	Edge(int x, int y, int c, bool f) :
		x(x), y(y), c(c), f(f) {};
};

vector<Edge> e;

void bad(){
	printf("Impossible\n");
	exit(0);
}

void pushedge(int x, int y, int c, bool f){
	e.pb(Edge(x, y, c, f));
}

void solve(){
	fi(1, 101){
		pushedge(i, i+1, 'X', false);
	}
	fi(102, 201){
		pushedge(i, i+1, 'Y', false);
	}
	fi(0, 101) fj(0, 101){
		int v = 0;
		int y = -1, x = -1;
		for(int i1=0;i1<a;++i1) for(int j1=0;j1<b;++j1){
			int c = d[i1][j1] - (i1 + 1) * i - (j1 + 1) * j;
			if(v < c){
				v = c;
				y = i1;
				x = j1;
			}
		}
		int v0 = INF;
		for(int i1=0;i1<a;++i1) for(int j1=0;j1<b;++j1){
			if(w[i1][j1]) continue;
			int c = (i1 + 1) * i + (j1 + 1) * j + v;
			int v1 = d[i1][j1] - (i1 + 1) * i - (j1 + 1) * j;
			if(c <= d[i1][j1]){
				if(v0 > v1){
					v0 = v1;
				}
			}
		}
		if(v0 < INF){
			pushedge(1+i, 201-j, v0, true);
			for(int i1=0;i1<a;++i1) for(int j1=0;j1<b;++j1){
				if(w[i1][j1]) continue;
				int c = (i1 + 1) * i + (j1 + 1) * j + v;
				int v1 = d[i1][j1] - (i1 + 1) * i - (j1 + 1) * j;
				if(c <= d[i1][j1]){
					if(v0 == v1){
						w[i1][j1] = 1;
					}
				}
			}
			//cerr << 1+i << " " << 201-j << " " << y1 << " " << x1 << " " << v0 << endl;
		}
	}
	fi(0, a) fj(0, b) if(!w[i][j]) bad();
}

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

	scanf("%d %d",&a,&b);
	fi(0, a) fj(0, b) scanf("%d",&d[i][j]);

	solve();

	printf("Possible\n");
	printf("201 %d\n",sz(e));
	fi(0, sz(e)){
		if(e[i].f) printf("%d %d %d\n",e[i].x,e[i].y,e[i].c);
		else printf("%d %d %c\n",e[i].x,e[i].y,(char)e[i].c);
	}
	printf("1 201\n");

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[] a = new int[3];
        a[0] = in.nextInt(); a[1] = in.nextInt(); a[2] = in.nextInt();
        int cnt = a[0]%2 + a[1]%2 + a[2]%2;
        int ans = 0;
        if(cnt == 1 || cnt == 2) {
            ans++;
            for (int i = 0; i < 2; i++) {
                if(a[i]%2== (cnt == 1 ? 0 : 1)) a[i]++;
            }
        }
        Arrays.sort(a);
        ans += (a[2] - a[0]) / 2;
        ans += (a[2] - a[1]) / 2;

        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(){
  int n,i,j;
  cin >> n;
  while(n!=0) {
    long long sum[5001]={};
    int b;
    long long o=1<<20;
    o*=-1;
    cin >> sum[1];
    for(i=2;i<=n;i++){
      cin >> b;
      sum[i]=sum[i-1]+b;
      //cout << sum[i] << endl;
    }
    
    for(i=0;i<=n;i++){
      for(j=i+1;j<=n;j++){
	o=max(o,sum[j]-sum[i]);
      }
    }
    cout << o << endl;
    cin >> n;
  }
  return 0;
  
}



Measured memory_bytes: 3120
N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]
cnt = 0
for i in range(N):
    for j in range(N):
        sum = 0.0
        if i != j:
            for k in range(len(X[i])):
                sum += (X[i][k] - X[j][k])**2
        sum = sum**0.5
        if sum.is_integer() and sum!=0.0:
            cnt += 1
print(cnt//2)

Measured memory_bytes: 9236
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


public class Test
{	
    public static void Main()
	{
        int[] nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int n = nums[0];
        
        /*
        int a = 0;
        for(int i = 1 ; i<=n ; i++) a += i;
        Console.WriteLine(a);
        */
        Console.WriteLine(((n+1)*n)/2);
	}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,k;
  cin >> n >> k;
  vi a(n);
  rep(i,n)cin>>a[i];

  rep(d,k){
    vi b(n+1,0);
    rep(i,n){
      int l = max(0,i-a[i]);
      int r = min(n-1,i+a[i]);
      b[l]++;
      b[r+1]--;
    }
    rep(i,n)b[i+1]+=b[i];
  a = b;
  bool ok = true;
  rep(i,n)ok&=(a[i]==n);
  if(ok)break;
  }
  rep(i,n)cout<<a[i]<< " ";
  cout<<endl;
  return 0;
}

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

int main(void){


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

    int ans = 1;
    int past; //trueは＋ falseはー

    if(A[1]>A[0]) past=1;
    else if(A[1]<A[0]) past=-1;
    else past = 0;

    for (int i = 1; i < N; ++i) {
        int now;
        if(A[i]>A[i-1]){
            now = 1;
        }else if(A[i]<A[i-1]){
            now = -1;
        }else{
            now = 0;
            continue;
        }
        if(now!=past && past!=0){
            ans++;
            past=0;
            continue;
        }
        past=now;
    }
    cout<<ans<<endl;

    return 0;
}

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

point_tarou = 0
point_hanako = 0

for turn in range(n):

    tarou, hanako = input().split()

    if   tarou >  hanako:
        point_tarou += 3
    elif tarou <  hanako:
        point_hanako += 3
    else:
        point_tarou += 1
        point_hanako += 1

print(f"{point_tarou} {point_hanako}")



Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int n=s.size();
	int sum=0;
	for(int i=0;i<n;i++)
	sum+=(s[i]-'0');
	if(sum%9)
	cout<<"No";
	else
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3724
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;


#define REP(i,n) for(int i= 0;i < n;i++)
	
char mozi[][5] = {
	{'.',',','!','?',' '},
	{'a','b','c'},
	{'d','e','f'},
	{'g','h','i'},
	{'j','k','l'},
	{'m','n','o'},
	{'p','q','r','s'},
	{'t','u','v'},
	{'w','x','y','z'}};
int a[] = {5,3,3,3,3,3,4,3,4};

int c;
char buf;
string str;
int n;
	
int main()
{
	n = 0;
	cin >> n;
	REP(i,n)
	{
		cin >> str;
		REP(j,str.size())
		{
			buf = str[j];
			if(buf == '0')continue;
			c = 0;j++;
			while(str[j] != '0')
			{
				c++;j++;
			}
			cout << mozi[(buf - '0')-1][c%a[buf - '0'-1]] ;
		}
		
		cout << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e2 + 5;
ll i,j,n,ans;
ll a[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,0,n) cin>>a[i];
    rep(i,0,n) rep(j,i + 1,n) ans += a[i] * a[j];
    cout<<ans;
    return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int e=sc.nextInt(),y=sc.nextInt();
        int[] l= {1911,1925,1988,2016};
        int[] f= {1868,1912,1926,1989};
        char[] g= {'M','T','S','H'};
        if(e==0) {
            for(int i=0;i<4;i++) {
                if(y<=l[i]) {
                    System.out.println(g[i]+""+((y-f[i])+1));
                    break;
                }
            }
        }else {
            System.out.println(y+f[e-1]-1);
        }
    }
}


Measured memory_bytes: 26388
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    double a,b,x,c;
    cin >> a >> b >> x;
	
  	if(2*x/a/a-b>=0){
    	c=atan(2*b/a-2*x/a/a/a);
  		c=c*180/PI;
    }
  	else{
      c=atan(a*b*b/2/x);
  	  c=c*180/PI;
    }
  	
  
  cout << std::setprecision(10) << c <<endl;
        
}

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

using namespace std;




int gcd(int x, int y) {
    if(x < y) swap(x, y);
    int r;
    while(y > 0) {
      r = x % y;
      x = y;
      y = r;
    }
    return x;
}

int main(void) {
  int x, y;
  cin >> x; cin >> y;
  cout << gcd(x,y) << '\n';
  return 0;
}



Measured memory_bytes: 3076
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char) 
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
    
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let n: usize = read();
  let s: String = read();
  
  println!("{}",
    if n % 2 == 1 || &s[0..n/2] != &s[n/2..n] { "No" }
    else { "Yes" }
  );
}

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

int n;
int data[5][20];

class State {
public:
  int clock;
  int cnt;
  int task[5][40];

  bool operator <(const State &s) const {
    return clock > s.clock;
  }

  State() {
    clock = 0;
    cnt = 0;
    for(int i = 0; i < 5; i++) {
      for(int j = 0; j < 40; j++) {
	task[i][j] = 0;
      }
    }
  }

  bool isPut() {
    for(int i = 0; i < 5; i++) {
      for(int j = 0; j < n; j++) {
	if(data[i][j] == 1 && task[i][40-n+j] != 0) return false;
      }
    }
    return true;
  }

  void put() {
    for(int i = 0; i < 5; i++) {
      for(int j = 0; j < n; j++) {
	task[i][40-n+j] += data[i][j];
      }
    }
    cnt++;
  }

  void shiftL() {
    for(int i = 0; i < 5; i++) {
      for(int j = 0; j < 40; j++) {
	if(j+1 == 40) task[i][j] = 0;
	else          task[i][j] = task[i][j+1];
      }
    }
    clock++;
  }
};

void bfs() {
  priority_queue<State> PQ;
  State s;
  s.put();
  s.clock = n;
  PQ.push(s);
  while(!PQ.empty()) {
    s = PQ.top();
    PQ.pop();

    if(s.cnt == 10) {
      cout << s.clock << endl;
      break;
    }

    for(int i = 0; i < n; i++) {
      s.shiftL();
      State s2 = s;
      if(s2.isPut()) {
	s2.put();
	PQ.push(s2);
      }
    }
  }
}

int main() {
  while(1) {
    cin >> n;
    if(n == 0) break;
    for(int i = 0; i < 5; i++) {
      for(int j = 0; j < n; j++) {
	char c;
	cin >> c;
	if(c == 'X') data[i][j] = 1;
	else         data[i][j] = 0;
      }
    }

    bfs();
  }
  return 0;
}

Measured memory_bytes: 12000
a, b, x = map(int, input().split())
#b以下で小さくかつbに最も近いxの倍数 x*i (x*i=0を含める)
i = b // x
#aより小さくかつaに最も近いxの倍数 x*j (x*j=0を含める)
j = (a-1) // x
print(i-j)

Measured memory_bytes: 38384
<?php
	$num = trim(fgets(STDIN));
	$abc = range('a', 'z');

	while (true) {
  		$num--;
  		$a = $num % 26;
  		$num = floor($num / 26);
  		$name[] = $abc[$a];
  		if ($num < 1){
        	break;
        }
	}
	for($i=count($name); $i>=0; $i--){
    	echo $name[$i];  
    }

?>

Measured memory_bytes: 16244
#include<cstdio>
#include<iostream>
using namespace std;
int n,h,w,t=1,j;
int a[100000],p[1000];

void print(int x)
{
	if(x==1)
	for(int i=1;i<=w;i++)
	{
		if(a[t])cout<<t<<" ",a[t]--;
		else if(a[t]==0)t++,cout<<t<<" ",a[t]--;		
	}
	if(x==0)
	{
		
	j=0;
	for(int i=w;i>=1;i--)
	{
		if(a[t])p[++j]=t,a[t]--;
		else if(a[t]==0)t++,p[++j]=t,a[t]--;
	}
	for(int i=w;i>=1;i--)
	cout<<p[i]<<" ";
}
	cout<<endl;
}

int main()
{
	scanf("%d%d",&h,&w);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for(int i=1;i<=h;i++)
	{
		int k=i%2;
	//	cout<<k<<endl;
	print(k);
	}
	return 0;
}

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

int main() {
  int N, Y;
  cin >> N >> Y;
  bool flag = false;
  for (int x = 0; x <= N; x++) {
    for (int y = 0; y <= N-x; y++) {
      int z = N-x-y;
      int sum = 10000*x + 5000*y + 1000*z;
      if (sum == Y) {
        flag = true;
        cout << x << " " << y << " " << z << endl;
        break;
      }
    }
    if (flag) break;
  }
  if (!flag) cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#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 n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int sum=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      sum+=a[i]*a[j];
      //cout << sum <<endl;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
# def makelist(n, m):
#     return [[0 for i in range(m)] for j in range(n)]

import math

N = 55555
prime = [True]*(N+1)
prime[0] = False
prime[1] = False

R = int(math.sqrt(N))

for i in range(2, R+1):
    if prime[i]:
        cnt = 2
        while i * cnt <= N:
            prime[i * cnt] = False
            cnt += 1


##
n = int(input())
ans = []
i = 2
cnt = 0
while cnt < n:
    if prime[i] and (i - 1) % 10 == 0:
        ans.append(i)
        cnt += 1
    i += 1

print(" ".join(map(str,ans)))



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

int N, x;

inline void solveA () {
	scanf ("%d%d", &N, &x);
	if (N == 1) { printf ("Yes\n1\n"); return; }
	if (x == 1 || x == 2 * N - 1) { printf ("No\n"); return; }
	if (N == 2) { printf ("Yes\n1 2 3\n"); return; }
	printf ("Yes\n");
	if (x == 2) {
		int p = 5;
		for (int i = 1; i < N - 1; i++, p++) printf ("%d\n", p);
		printf ("3\n1\n2\n4\n");
		for (int i = N + 3; i < 2 * N; i++, p++) printf ("%d\n", p);
	} else {
		int p = 1;
		for (int i = 1; i < N - 1; i++, p++) {
			if (p == x - 2) p = x + 2;
			printf ("%d\n", p);
		}
		printf ("%d\n%d\n%d\n%d\n", x - 1, x + 1, x, x - 2);
		for (int i = N + 3; i < 2 * N; i++, p++) {
			if (p == x - 2) p = x + 2;
			printf ("%d\n", p);
		}
	}
}

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

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {
	
	ll n, k;
	cin >> n >> k;
	
	ll allsum = 0;
	vector<vector<int>> v(35);
	
	vector<ll> a(n), b(n);
	
	rep(i, n){
		cin >> a[i] >> b[i];
		ll tmp = a[i];
		if(tmp > k) continue;
		
		allsum += b[i];
		int cnt = 0;
		while(tmp != 0){
			if(tmp % 2 == 1) v[cnt].push_back(i);
			tmp /= 2;
			cnt++;
		}
	}
	
	vector<bool> k_one(35, 0);
	rep(i, 35){
		k_one[i] = (k % 2 == 1);
		k /= 2LL;
	}
	
	ll ans = 0;
	set<int> st;
	for(int i = 34; i >= 0; i--){
		if(!k_one[i]) rep(j, v[i].size()) st.insert(v[i][j]);
		else{
			set<int> st2(st);
			rep(j, v[i].size()) st2.insert(v[i][j]);
			ll tmp = allsum;
			for(auto sx : st2){
				tmp -= b[sx];
			}
			ans = max(ans, tmp);
		}
	}
	
	ll tmp = allsum;
	for(auto sx : st){
		tmp -= b[sx];
	}
	ans = max(ans, tmp);
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 17156
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

    int n;
    cin >> n;
    LL a[SIZE];
    for( int i = 0; i < n; ++i ) cin >> a[i];
    LL b[SIZE];
    vector< LL > v;

    LL sum = 0;
    int res = 0;
    for( int i = 0; i < n; ++i ) {
        cin >> b[i];
        if( b[i] < a[i] ) {
            v.pb( a[i] - b[i] );

        } else if( b[i] > a[i] ) {
            ++res;
            sum += b[i] - a[i];

        }
    }

    sort( v.begin(), v.end(), greater<LL>() );
    int pos = 0;
    while( pos < v.size() && sum != 0 ) {
        if( sum - v[pos] <= 0 ) {
            sum = 0;
            ++res;

        } else {
            sum -= v[pos];
            ++res;

        }
        ++pos;

    }
    if( sum != 0 ) cout << -1;
    else cout << res;
    cout << endl;


    return 0;
}



Measured memory_bytes: 2424
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 400000;
map < int, int > cnt;
vector < int > v;
int a[N];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt",  "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        cnt[a[i]]++;
    }
    int l1 = 0;
    int l2 = 0;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    if (cnt[a[i]] > 1){
        cnt[a[i]] -= 2;
        v.pb(a[i]);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    if (v.size() < 2){
        cout << 0;
        return 0;
    }
    cout << v[0] * v[1];
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define maxn 22
using namespace std;
typedef long long LL;
const int mod = 1000000007;
int f[maxn][1 << maxn];
int a[maxn][maxn];
int next(int x) {
	int t = x & -x;
    return x + t | ((x ^ x + t) >> 2) / t;
}
int main(){
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	f[0][0] = 1;
	for(int i = 1; i <= N; i += 1)
		for(int j = 1; j <= N; j += 1) cin >> a[i][j];
	for(int i = 1; i <= N; i += 1)
		for(int j = (1 << i) - 1; j < (1 << N); j = next(j))
			for(int k = 1; k <= N; k += 1)
				if(a[i][k] && 1 << k - 1 & j) f[i][j] = (f[i][j] + f[i - 1][j ^ 1 << k - 1]) % mod;
	cout << f[N][(1 << N) - 1];
}

Measured memory_bytes: 178432
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int N,A,B;
	scanf("%d %d %d",&N,&A,&B);
	if(N*A>B)
	{
		printf("%d",B);
	}else
	{
		printf("%d",N*A);
	}
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;



/*
 a
 b
 c
 d
 ab
 ac
 ad
 bc
 bd
 cd
 abc
 abd
 acd
 bcd
 abcd
 */
int dp[4001]  = {0};
int dp2[4001] = {0};
int dp3[4001] = {0};
int dp4[4001] = {0};

int main(){
    
    
    for(int i=1; i<=1000; i++){
        dp[i]++;
    }
    
    for(int i=1; i<=1000; i++){
        for(int j=1; j<=4000; j++){
            if(dp[j]!=0){
                if(j+i<=4000){
                    dp2[i+j]++;
                }
            }
        }
    }
    
    for(int i=1; i<=1000; i++){
        for(int j=1; j<=4000; j++){
            if(dp2[j]!=0){
                if(j+i<=4000){
                    dp3[i+j]+=dp2[j];
                }
            }
        }
    }
    
    for(int i=1; i<=1000; i++){
        for(int j=1; j<=4000; j++){
            if(dp3[j]!=0){
                if(j+i<=4000){
                    dp4[i+j]+=dp3[j];
                }
            }
        }
    }
    
    /*
    for(int i=0; i<=35; i++){
        cout<<i<<" "<<dp[i]*4+dp2[i]*6+dp3[i]*4+dp4[i]<<endl;
    }
    */
    
    int n;
    while(cin>>n){
        cout<<dp[n]*4+dp2[n]*6+dp3[n]*4+dp4[n]<<endl;
    }
    
    
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define ll long long
#define ii pair <int, int>
#define dl pair <ll, ll>
#define vi vector <int>
#define vl vector <ll>
#define vii vector <ii>
#define mod 1000000007
#define REP(a, b) for (int i = a; i < b; i++)
#define REP2(a, b) for (int j = a; j < b; j++)
#define REPS(a, b, c) for (int i = a; i < b; i += c)

using namespace std;

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

    int n;
    cin >> n;
    ll arr[n];
    ll pre[n + 1] = {0};
    REP(0, n) {
        cin >> arr[i];
        pre[i + 1] = pre[i] + arr[i];
        pre[i + 1] %= mod;
    }
    ll suma = 0;
    REP(0, n) {
        suma += ((arr[i] * ((pre[n] + mod - pre[i + 1]) % mod)) % mod);
        suma %= mod;
    }
    cout << suma << "\n";
	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int main(){
    double a, b, x, res;
    cin >> a >> b >> x;
    if(2*x < a*a*b){
        res = atan(a*b*b / (2*x));
    }else{
        res = atan(2 * (a*a*b - x) / (a*a*a));
    }
    res *= 180.0 / M_PI;
    printf("%.7f\n", res);
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main() {
	int H, N, Z;
	cin >> H >> N;
	int A;
	for (int i=0;i<N;i++){
		cin >> A;
		Z = Z + A;
	}

	if (H<=Z) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}


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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int tmp = n;
  int sum = 0;
  while(tmp){
    sum += tmp % 10;
    tmp /= 10;
  }
  if(n % sum) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MOD 1000000007
long long factorial(long long x){
	long long ans=x;
	while(--x){
		ans*=x;
		ans%=MOD;
	}
	return ans;
}

int main(){
	long long n,m;
	cin >> n >> m;
	if(abs(n-m)>1) cout << 0 << endl;
	else{
		if(n==m)
			cout << factorial(n)*factorial(m)*2%MOD << endl;
		else
			cout << factorial(n)*factorial(m)%MOD << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	int n, t, ans = 0;
	cin >> n >> t;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; i++) {
		ans += min(t, a[i + 1] - a[i]);
	}
	ans += t;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C; cin>>A>>B>>C;
  vector<int>D(A);
  vector<int>E(B);
  vector<int>d(A);
  vector<int>e(B);
  map<pair<int,int>,int>F;
  for(int i=0;i<C;i++){
    int a,b; cin>>a>>b;
    D[a-1]++;
    E[b-1]++;
    F[make_pair(a-1,b-1)]=1;
  }
  d=D;e=E;
  sort(D.begin(),D.end());
  sort(E.begin(),E.end());
  vector<int>Z(0,-1);
  vector<int>z(0,-1);
  int Y=0,y=0;
  for(int i=0;i<A;i++)if(D[A-1]==d[i]){Y++;Z.push_back(i);Z.resize(Y);}
  for(int i=0;i<B;i++)if(E[B-1]==e[i]){y++;z.push_back(i);z.resize(y);}
  for(int i=0;i<Y;i++){
    for(int j=0;j<y;j++){
      if(F[pair(Z[i],z[j])]==0){cout<<D[A-1]+E[B-1]<<endl; return 0;}
    }
  }
  cout<<D[A-1]+E[B-1]-1<<endl;
}

Measured memory_bytes: 30740
#pragma GCC optimize("O2")
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
int gcd(int a, int b) {
   if (b == 0)
      return a;
   return gcd(b, a % b);
}
using namespace std;
const int maxn = 5000*100+5 ;
const ll inf = 9223372036854775807 ;
const ll mod = 1e9 + 7 ;
int n , k , a[maxn] , b[maxn] , c[maxn] , g  ; 
int main()
{
	migmig ;
 	cin>>n>>k ; 
 	for(int i = 1 ; i <= n ; i ++ )
 	{
 		cin>>a[i] ; 
 		if(a[i] > 0 ) g = 1 ; 
	 }
	 if(k >= 1000 )
	 {
	 	for(int i = 1 ; i <= n ; i ++ )
	 	{
	 		cout<<n<< " " ; 
		 }
		 cout<<endl ;
		 return 0 ;  
	 }
	 for(int j = 1 ; j <= k ; j ++ )
	 {
	 	memset(b , 0 , sizeof b) ; 
	 	memset(c , 0 , sizeof c) ; 
	 	for(int i = 1 ; i <= n ; i ++ )
	 	{
	 		b[i] += 1 ; 
	 		b[i+a[i]+1] -= 1 ; 
	 		//cout<<b[i]<< " " ; 
		 }
		 //cout<<endl; 
		 for(int i = 1 ; i <= n ; i ++ )
		 {
		 	c[i] += 1 ; 
		 	c[max(i-a[i]-1 , 0)] -= 1 ; 
		 }
		int cnt = 0 ; 
		 for(int i = 1 ; i <= n ; i ++ )
		 {
		 	cnt+=b[i] ; 
		 	a[i] = cnt ; 
		 }
		 cnt = 0 ; 
		for(int i = n ; i >=  1 ; i -- )
		{
			cnt+=c[i] ; 
			a[i] -- ; 
			a[i] += cnt ; 
		}
	 }
	 for(int i = 1;  i<= n ; i ++ )
	 {
	 	cout<<a[i] <<  ' ' ; 
	 }
	 

}
//////
////////
///////////




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



int main() {

	int N;
	int A[15];
	int X[15][15];
	int Y[15][15];
	int MaxHonest = 0;
	int Honest = 0;
	int Flag = 0;
	

	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		for (int j = 0; j < A[i]; j++) {
			scanf("%d %d", &X[i][j], &Y[i][j]);
		}
	}

	for (int i = 0; i < (1 << N); i++) {
		for (int j = 0; j < N; j++) {
			if (i & (1 << j)) {
				if (A[j] == 0) {
					Flag = 1;
				}
				for (int k = 0; k < A[j]; k++) {
					if (Y[j][k] == 1) {
						if (i & (1 << X[j][k] - 1)) {
							Flag = 1;
						}
						else {
							Flag = 0;
							break;
						}

					}
					else {
						if (!(i & (1 << X[j][k] - 1))) {
							Flag = 1;
						}
						else {
							Flag = 0;
							break;
						}
					}
				}
				if (Flag != 1) {
					break;
				}
			}
		}
		if (Flag == 1) {
			for (int h = 0; h < N; h++) {
				if (i & (1 << h)) {
					Honest += 1;
				}
			}
			if (MaxHonest < Honest) {
				MaxHonest = Honest;
			}
		}

		Honest = 0;
	}


	printf("%d", MaxHonest);
	
	return 0;
}

	





Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define assign(x,val) memset(x,val,sizeof(x))
#define motherfucker  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(ll i=0;i<n;++i)
#define for1(i,n) for(ll i=1;i<=n;++i)
#define ford(i,n) for(ll i=n;i>=1;--i)
#define forg(i,a,b) for(ll i=a;i<b;++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpl;
long long mod = 1000000007;
const long double PI = (long double)(3.1415926535897932384626433832795);
 
 
void solve(){
	int x;cin>>x;
	for(int i = x;;++i){
		int j = i;
		bool ok = true;
		for1(k, sqrt(j)){
			if(k==1) continue;
			if(j%k==0){
				//cout<<j<<" "<<k<<endl;
				ok = false;
				break;
			}
		}
		if(ok){
			cout<<i<<endl;
			return;
		}
	}
}
 
int main(){
	motherfucker
	ll t = 1;
	//cin>>t;
	for0(i, t){
		solve();
	}
	return 0;
}

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

struct cards {
    char mark;
    int num;
};

int main()
{
    struct cards a[52];

    int flag[13][4] = {
        1,1,1,1, 1,1,1,1,
        1,1,1,1, 1,1,1,1,
        1,1,1,1, 1,1,1,1,
        1,1,1,1, 1,1,1,1,
        1,1,1,1, 1,1,1,1,
        1,1,1,1, 1,1,1,1,
        1,1,1,1
    };

    int n, i, j;

    cin >> n;

    for(i = 0; i < n; i++) {
        cin >> a[i].mark >> a[i].num;
        switch(a[i].mark) {
            case 'S' :
                flag[a[i].num-1][0] = 0;
                break;
            case 'H' :
                flag[a[i].num-1][1] = 0;
                break;
            case 'C' :
                flag[a[i].num-1][2] = 0;
                break;
            case 'D' :
                flag[a[i].num-1][3] = 0;
                break;
            default:
                break;
        }
    }

    for(j = 0; j < 4; j++) {
        for(i = 0; i < 13; i++) {
            if(flag[i][j]) {
                switch(j) {
                    case 0 :
                        cout << 'S' << ' ' << i+1 << endl;
                        break;
                    case 1 :
                        cout << 'H' << ' ' << i+1 << endl;
                        break;
                    case 2 :
                        cout << 'C' << ' ' << i+1 << endl;
                        break;
                    case 3 :
                        cout << 'D' << ' ' << i+1 << endl;
                        break;
                    default :
                        break;
                }
            }
        }
    }

    return 0;
}



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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >>d;
    if((abs(a-b)<=d && abs(b-c)<=d) || abs(a-c)<=d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256