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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  string s;
  cin >> n >> s;

  VI a(n), b(n);
  a[0] = s[0]=='W'?1:0;
  b[n-1] = s[n-1]=='E'?1:0;
  FOR(i, 1, n) a[i] = a[i-1] + (s[i]=='W'?1:0);
  for(int i=n-2; i>=0; --i) {
    b[i] = b[i+1] + (s[i]=='E'?1:0);
  }

  int ret = INF;
  REP(i, n) {
    int x = i==0?0:a[i-1];
    int y = i==n-1?0:b[i+1];
    chmin(ret, x+y);
  }
  cout << ret << endl;

  return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    string S;
    ll K;
    cin >> S >> K;
    
    REP(i,0,SZ(S)-1) {
        if(K >= 'z' - S[i] + 1 && S[i] != 'a') {
            K -= 'z' - S[i] + 1;
            S[i] = 'a';
        }
        if(K <= 0) break;
    }
    if(K > 0) S[SZ(S)-1] = 'a' + (char)(((ll)S[SZ(S)-1] - 'a' + K) % 26);
    PR(S);

    return 0;
}

/*



*/

Measured memory_bytes: 3732
#include<iostream>
using namespace std;
int main()
{
  int n,t,b,i,res=0;
  cin >> n;
  b=n;
  for(i=0;i<n;i++){
    cin >> t;
    if(t<=b){
      res++;
      b=t;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int n,m,x[10],y[10];
int ma() {
    if(n==1) {
        for(int i=0;i<10;i++) 
		{
            int a=1;
            for(int j=0;j<m;j++)
			{
                if(i!=y[j]) 
				a=0;
            }
            if(a) 
			return i;
        }
        return -1;
    }
    else if(n==2) {
        for(int i=10;i<100;i++) 
		{
            int b=1;
            for(int j=0;j<m;j++) 
			{
                if(x[j]==1&&i/10!=y[j]) 
				b=0;
                if(x[j]==2&&i%10!=y[j]) 
				b=0;
            }
            if(b) 
			return i;
        }
        return -1;
    }
    else
	{
	for(int i=100;i<1000;i++) 
	{
        int c=1;
        for(int j=0;j<m;j++) 
		{
            if(x[j]==1&&i/100!=y[j]) 
			c=0;
            if(x[j]==2&&(i/10)%10!=y[j]) 
			c=0;
            if(x[j]==3&&i%10!=y[j]) 
			c=0;
        }
        if(c) 
		return i;
    }
    return -1;	
	}
    
}
int main() {
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++) {
        scanf("%d%d",&x[i],&y[i]);
    }
    printf("%d\n",ma());
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

// int main() {
//     ll A[4];
//     rep(i,3){
//         cin >> A[i];
//     }
//     //sort(A,A+3);
//     cout << min(A[0]*A[1],A[2]) << endl;
// }

int main(){
    char X[2],Y[2];cin >> X >> Y;
    cout <<(strcmp(X,Y)>0 ? ">" :(strcmp(X,Y)==0 ? "=": "<"))<<endl;;
}

Measured memory_bytes: 256
N = int(input())
S = list(str(input()))

ans = 'Yes'

if N % 2 == 1:
  ans = 'No'
else:
  for i in range(int(N/2)):
    if S[i] != S[i+int(N/2)]:
      ans = 'No'
      
print(ans)

Measured memory_bytes: 2940
N = int(raw_input())
score = [0] * N

for x in xrange(N * (N - 1) / 2):
    a, b, sa, sb = map(int, raw_input().split(' '))
    if sa > sb:
        score[a - 1] += 3
    elif sa < sb:
        score[b - 1] += 3
    else:
        score[a - 1] += 1
        score[b - 1] += 1

for t in score:
    print len(filter(lambda x: x > t, score)) + 1

Measured memory_bytes: 4236
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
constexpr long long mod = 998244353;
constexpr int MAX = 5000000;

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n; cin >> n;
	vector<int> cnt(n + 1);
	vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i], cnt[a[i]]++;
	vector<int> b(n); for (int i = 0; i < n; i++) cin >> b[i], cnt[b[i]]++;
	for (int i = 1; i <= n; i++) {
		if (cnt[i] > n) {
			cout << "No" << endl;
			return 0;
		}
	}

	reverse(b.begin(), b.end());
	int lf = 0;
	int rg = n - 1;
	for (int i = 0; i < n; i++) {
		if (a[i] == b[i]) {
			if (a[lf] != b[i] and a[i] != b[lf]) {
				swap(b[lf], b[i]);
				lf++;
			}
			else {
				swap(b[i], b[rg]);
				rg--;
			}
		}
	}
	cout << "Yes" << "\n";
	for (int i = 0; i < n; i++) cout << b[i] << " \n"[i + 1 == n];
	return 0;
}

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

int main(){
	int card[4][13], i, j, t, n;
	string s;

	cin>>n;
	
	for(i = 0; i < 4; i++){	
		for(j = 0; j < 13; j++) card[i][j] =1;
	}

	for(i = 1; i <= n; i++){
		cin>>s>>t;
		if(s == "S") card[0][t-1] = 0;
		if(s == "H") card[1][t-1] = 0;
		if(s == "C") card[2][t-1] = 0;
		if(s == "D") card[3][t-1] = 0;
	}

	for(i = 0; i < 4; i++){
		for(j = 0; j < 13; j++) {
			if(card[i][j]){
				if(i == 0) cout<<"S "<<j+1<<endl;
				if(i == 1) cout<<"H "<<j+1<<endl;
				if(i == 2) cout<<"C "<<j+1<<endl;
				if(i == 3) cout<<"D "<<j+1<<endl;
			}
		}
	}

	
	return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	long long ans;
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		ans = 0;
	}else {
		ans = min(min(a * b, c * b), a * c);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define rall(n) std::rbegin(n), std::rend(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void init() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
}

void calc() {

	Int N; std::cin >> N;
	std::vector<std::vector<std::pair<Int, Int>>> data(N);
	rep(i, N) {
		Int A; std::cin >> A;
		data[i].resize(A);
		rep(j, A) {
			Int x, y; std::cin >> x >> y; x--;
			data[i][j].first = x, data[i][j].second = y;
		}
	}

	Int ans = 0;

	for (Int bit = 1; bit < (1 << N); ++bit) {
		Int res = -1;
		bool flag = true;
		rep(i, N) {
			rep(j, data[i].size()) {
				if (bit & (1 << i)) {
					Int y = data[i][j].second, x = data[i][j].first;
					if (y == 1) {
						if (!(bit & (1 << x)))flag = false;//xが正直者なのに違ったらだめ
					}
					else {
						if (bit & (1 << x))flag = false;
					}
				}
			}
		}

		if (flag) {
			res = __builtin_popcount(bit);
			ans = std::max(ans, res);
		}

	}

	std::cout << ans;

}


int main() {

	init();
	calc();

	return 0;
}

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

int main()
{
	int a,b,i;
	
	string s;
	
	cin>>a>>b;
	
	cin>>s;
	
	for(i=0;i<s.size();i++){
		if(i!=a){
			if(!isdigit(s[i])){
				cout<<"No"<<endl;
				return 0;
			}}
			else{
				if(s[i]!='-'){
					cout<<"No"<<endl;
					return 0;
				}
			}
		
	}
	cout<<"Yes"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	ll ans = 1e18;
	for(ll i = 1;i*i<=n;i++){
		if(n%i == 0){
			ans = min(ans,n/i+i-2);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main() {
  int L,N;
  cin >> L >> N;
  vector<int> P(N);
  vector<int> D(N);
  cin >> P[0]; 
  for( int i = 1 ; i < N ; i++ ) {
    cin >> P[i];
    D[i] = P[i] - P[i-1];
  }
  D[0] = P[0] + (L - P[N-1] ) ;
  sort(D.begin(),D.end());
  reverse(D.begin(),D.end());
  
  cout << L -D[0]<< endl;
}

Measured memory_bytes: 1792
def resolve():
    X, Y, A, B, C = map(int, input().split())
    apple_A = sorted(map(int, input().split()), reverse=True)[:X]
    apple_B = sorted(map(int, input().split()), reverse=True)[:Y]
    apple_C = sorted(map(int, input().split()), reverse=True)

    ans = apple_A + apple_B + apple_C
    ans.sort(reverse=True)
    
    print(sum(ans[:X+Y]))

if __name__ == "__main__":
    resolve()


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, A, B;
int ra, cnt;
string s;

int main() {
	cin >> N >> A >> B;
	cin >> s;
	rep(i, N) {
		bool ok = 0;
		if (cnt < A + B) {
			if (s[i] == 'a') {
				ok = 1;
			} else if (s[i] == 'b') {
				if (ra < B) {
					ok = 1;
					++ra;
				}
			}
		}

		cnt += ok;

		puts(ok ? "Yes" : "No");
	}
	return 0;
}

Measured memory_bytes: 896
N, M = map(int, input().split())
onptns = []
for i in range(M):
    k, *s= list(map(int, input().split()))
    onptn = 0
    for i in s:
        onptn += 1 << (i - 1)
    onptns.append(onptn)
ps = list(map(int, input().split()))

ans = 0

s = 0
while s < (1 << N):
    ans += 1
    for onptn, p in zip(onptns, ps):
        if bin(s & onptn).count('1') % 2 != p:
            ans -= 1
            break
    s += 1

print(ans)


Measured memory_bytes: 3064
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    A, B = MI()
    print(A * B)



if __name__ == '__main__':
    main()


Measured memory_bytes: 68344
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }



void solve(long long N, long long K, std::vector<long long> h){
	ll res = 0;
	REP(i, N) {
		if (h[i] >= K) res++;
	}
	cout << res << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
    solve(N, K, std::move(h));
    return 0;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

const int MAX=2e6+1; //nCrのnのMAX+1
ll fac[MAX],finv[MAX],inv[MAX],sinv[MAX];

void cominit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  sinv[0]=0,sinv[1]=1;
  for (int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
    sinv[i]=sinv[i-1]+inv[i]%mod;
  }
}
ll com(int n,int k){ //1≦k≦n≦10^7
  if (n<k) return 0;
  if (n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
//Add cominit(); in main function.

int main(){
  cominit();
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll ans=0;
  rep(i,n){
    ll left=(sinv[i+1]-1+mod)%mod;
    ll right=(sinv[n-1-i+1]-1+mod)%mod;
    ans+=a[i]*fac[n]%mod*(left+right+1)%mod;
    ans%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 66580
#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<int> retval;
		retval.reserve(num);

		for (int i = 0; i < num; ++i)
		{
			std::getline(stream, buf, delim);
			retval.push_back(std::stoi(buf));
		}

		return retval;
	}

	int GetValue(std::istream& stream)
	{
		int in;
		stream >> in;

		return in;
	}

	std::vector<std::string> GetValueString(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<std::string> retval;
		retval.reserve(num);

		std::getline(stream, buf);
		std::stringstream sstr(buf);

		for (int i = 0; i < num; ++i)
		{
			std::getline(sstr, buf, delim);
			retval.push_back(std::move(buf));
		}

		return retval;
	}

	template<typename Pred>
	std::vector<std::string> BubbleSort(std::vector<std::string> sequence, 
		Pred pred)
	{
		bool flag = true;

		while (flag)
		{
			flag = false;

			for (size_t i = sequence.size() - 1; i > 0; --i)
			{
				if(pred(sequence[i - 1], sequence[i]))
				{
					flag = true;
					std::swap(sequence[i], sequence[i - 1]);
				}
			}
		}

		return sequence;
	}

	template<typename Pred>
	std::vector<std::string> SelectionSort(std::vector<std::string> sequence,
		Pred pred)
	{
		for (size_t i = 0; i < sequence.size() - 1; ++i)
		{
			size_t min_index = i;

			for (size_t j = i; j < sequence.size() - 1; ++j)
			{
				if(pred(sequence[min_index], sequence[j + 1]))
				{
					min_index = j + 1;
				}
			}

			if (i != min_index)
			{
				std::swap(sequence[i], sequence[min_index]);
			}
		}

		return sequence;
	}

	template<typename T>
	void Print(const std::vector<T>& sequence)
	{
		std::cout << sequence[0];

		for (size_t i = 1; i < sequence.size(); ++i)
		{
			std::cout << ' ' << sequence[i];
		}

		std::cout << std::endl;
	}
}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;

	int num = GetValue<1>(stream)[0];
	std::vector<std::string> values = GetValueString(stream, num, ' ');

	auto f = [](const std::string& p1, const std::string& p2)
	{
		if (p2[1] < p1[1])
		{
			return true;
		}
		else
		{
			return false;
		}
	};

	std::vector<std::string> bubble = BubbleSort(values, f);
	std::vector<std::string> selection = SelectionSort(values, f);

	Print(bubble);
	std::cout << "Stable" << std::endl;
	Print(selection);
	if (bubble == selection)
	{
		std::cout << "Stable" << std::endl;
	}
	else
	{
		std::cout << "Not stable" << std::endl;
	}
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  LLI a,b;
  while(cin >> a >> b){
    cout << lcm(a,b) << endl;
    
  }


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
struct union_find {
	ll par[MAX_N];
	ll Size[MAX_N];
	union_find(ll n) {
		for (int i = 0; i < n; i++) {
			par[i] = i;
			Size[i] = 1;
		}
	}
	ll root(ll x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	bool same(ll x, ll y) {
		return root(x) == root(y);
	}
	void unite(ll x, ll y) {
		if (same(x, y))return;
		Size[root(x)] += Size[root(y)];
		par[root(y)] = root(x);
	}
};

int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> ans(n,0);
    struct union_find U(n);
    for(ll i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        a--; b--;
        U.unite(a,b);
        ans[a]--; ans[b]--;
    }
    for(ll i=0;i<k;i++){
        ll c,d;
        cin>>c>>d;
        c--; d--;
        if(U.same(c,d)){
            ans[c]--; ans[d]--;
        }
    }
    for(ll i=0;i<n;i++) ans[i]+=U.Size[U.root(i)]-1;
    for(ll i=0;i<n;i++) cout<<ans[i]<<" ";
    cout<<endl;

}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin>>N;
    vector<int> p(N); cin >> p;

    int max_p = *max_element(ALL(p));
    int sum = accumulate(ALL(p),0);
    sum -= max_p / 2;

    cout << sum << endl;
}


Measured memory_bytes: 256
//sort1.cpp
#include<iostream>
using namespace std;

int main(){
	int a[3],i,s,k;
	
	for(i=0;i<3;i++){
		cin>>a[i];
	}
	for(i=0;i<2;i++){
		for(k=i+1;k<3;k++){
			if(a[i]>a[k]){
				s=a[i];
				a[i]=a[k];
				a[k]=s;
			}
		}
	}
	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
}


Measured memory_bytes: 3092
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    
    n = int(input())
    edges = 0
    for i in range(n-1):
        u, v = map(int, input().split())
        edges += min(u, v)*(n-max(u, v)+1)
    ans = n*(n+1)*(n+2)//6 - edges
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9068
s = input()
length = len(s)

x = [s[i] for i in range(length)]

if "N" in s:
    if "S" not in s:
        print("No")
        exit()
if "S" in s:
    if "N" not in s:
        print("No")
        exit()
if "E" in s:
    if "W" not in s:
        print("No")
        exit()
if "W" in s:
    if "E" not in s:
        print("No")
        exit()

print("Yes")

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

int main()
{
    string s,n;
    cin>>s>>n;
    int count=0;

    for(int i=0;i<s.size();i++)
    {
        if(s[i]==n[i])
            count++;
    }
    cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys 
import numpy as np 

def distance():
    N,D=map(int,input().split())
    y=[]
    ans=0
    for i in range(N):
        x=list(map(int,input().split()))
        y.append(x)
    y=np.array(y)
    y.reshape(N,-1)
    for i in range(N-1):
        for j in range(i+1,N):
            dis=(((y[i]-y[j])**2).sum())**(1/2)
            if dis.is_integer():
                ans+=1
    
    print(ans)

distance()               


Measured memory_bytes: 12500
<?php
$H = explode(" ",(fgets(STDIN)));
$W = explode(" ",(fgets(STDIN)));
             
$blank=$H[0]*$H[1];

$black=0;

$black_H = $H[0]*$W[1];
$black_W = $H[1]*$W[0];
$black_kaburi = $W[0]*$W[1];

$black_sum = $black_H+$black_W-$black_kaburi;

print($blank-$black_sum);
?>

Measured memory_bytes: 4728
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;
using int64 = long long;

int main() {
    int n;
    cin >> n;
    n %= 10;
    if (n == 3)
        cout << "bon" << endl;
    else if (n==0 || n==1 || n==6 || n==8)
        cout << "pon" << endl;
    else
        cout << "hon" << endl;
}


Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  
  char grid[3][3];
  while(1) {
    for(int i=0; i<3; i++) {
      for(int j=0; j<3; j++) {
        cin >> grid[i][j];
        if(grid[i][j] == '0') return 0;
      }
    }
    
    for(int i=0; i<3; i++) {
      bool b = 1, w = 1;
      for(int j=0; j<3; j++) {
        if(grid[i][j] == 'b') w = 0;
        else if(grid[i][j] == 'w') b = 0;
        else b = 0, w = 0;
      }
      if(b) {
        cout << 'b' << endl;
        goto EXIT;
      }
      if(w) {
        cout << 'w' << endl;
        goto EXIT;
      }
    }
    
    for(int i=0; i<3; i++) {
      bool b = 1, w = 1;
      for(int j=0; j<3; j++) {
        if(grid[j][i] == 'b') w = 0;
        else if(grid[j][i] == 'w') b = 0;
        else b = 0, w = 0;
      }
      if(b) {
        cout << 'b' << endl;
        goto EXIT;
      }
      if(w) {
        cout << 'w' << endl;
        goto EXIT;
      }
    }
    
    bool b, w;
    
    b = 1, w = 1;
    for(int i=0; i<3; i++) {
      if(grid[i][i] == 'b') w = 0;
      else if(grid[i][i] == 'w') b = 0;
      else b = 0, w = 0;
    }
    if(b) {
      cout << 'b' << endl;
      goto EXIT;
    }
    if(w) {
      cout << 'w' << endl;
      goto EXIT;
    }
    
    b = 1, w = 1;
    for(int i=0; i<3; i++) {
      if(grid[i][2-i] == 'b') w = 0;
      else if(grid[i][2-i] == 'w') b = 0;
      else b = 0, w = 0;
    }
    if(b) {
      cout << 'b' << endl;
      goto EXIT;
    }
    if(w) {
      cout << 'w' << endl;
      goto EXIT;
    }
    
    cout << "NA" << endl;
    
  EXIT:;
  }
  
  return 0;
}

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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 1e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

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

ll n, m;

int main () {
    SpeedForce;
    cin >> n >> m;
    if (n * 2 > m) {
        cout << min(m / 2, n);
    } else {
        cout << n + (m - n * 2) / 4;
    }
    return Accepted;
}

// Coded By OB

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int num[26],co[26];

int main(){
  for(int i=0;i<26;i++){
    num[i]=100;
  }
  int n;
  string s,al;
  al="abcdefghijklmnopqrstuvwxyz";
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    for(int j=0;j<s.size();j++){
      co[s[j]-'a']++;
    }
    for(int k=0;k<26;k++){
      num[k]=min(num[k],co[k]);
      co[k]=0;
    }
  }
  for(int i=0;i<26;i++){
    for(int j=0;j<num[i];j++){
      cout<<al[i];
    }
  }
  cout<<endl;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n, c;
  cin >> n >> c;
  vector<vector<int> > d(c, vector<int>(c));
  for (auto &x: d) {
    for (auto &y: x) cin >> y;
  }
  vector<vector<int> > a(n, vector<int>(n));
  for (auto &x: a) {
    for (auto &y: x) {
      cin >> y;
      y--;
    }
  }

  vector<int> c0Count(c), c1Count(c), c2Count(c);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if ((i + j) % 3 == 0) c0Count[a[i][j]]++;
      else if ((i + j) % 3 == 1) c1Count[a[i][j]]++;
      else if ((i + j) % 3 == 2) c2Count[a[i][j]]++;
    }
  }

  int ans = 1000000007;
  for (int c0 = 0; c0 < c; c0++) {
    for (int c1 = 0; c1 < c; c1++) {
      if (c0 == c1) continue;
      for (int c2 = 0; c2 < c; c2++) {
        if (c0 == c2 || c1 == c2) continue;
        int cost = 0;
        for (int i = 0; i < c; i++) {
          cost += d[i][c0] * c0Count[i];
          cost += d[i][c1] * c1Count[i];
          cost += d[i][c2] * c2Count[i];
        }
        if (cost < ans) ans = cost;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

struct edge {
	int from,to;
	int cost;

	edge(int t,int c) : to(t),cost(c) {}
	edge(int f,int t,int c) : from(f),to(t),cost(c) {}

	bool operator<(const edge &e) const {
		return cost < e.cost;
	}
};

int n, m, l, k, a, h;
vector<edge> G[105];
int d[105][105];
bool L[105];

void dijkstra(int s) {
	priority_queue<PI, vector<PI>, greater<PI> > que;
	rep(i, 105) {
		rep(j, 105) {
			d[i][j] = INF;
		}
	}

	d[s][m] = 0;
	que.push(PI(P(0, m), s));

	while(que.size()) {
		PI p = que.top();
		que.pop();

		int cost = p.first.first;
		int t = p.first.second;
		int v = p.second;
		if(d[v][t] < cost) continue;

		if(L[v]) {
			REP(i, t+1, m+1) {
				if(d[v][i] > d[v][t] + (i - t)) {
					d[v][i] = d[v][t] + (i - t);
					que.push(PI(P(d[v][i], i), v) );
				}
			}
		}

		rep(i, G[v].size()) {
			edge e = G[v][i];
			int nt = t - e.cost;
			if(nt >= 0 && d[e.to][nt] > d[v][t] + e.cost) {
				d[e.to][nt] = d[v][t] + e.cost;
				que.push(PI(P(d[e.to][nt], nt), e.to));
			}
		}
	}
}


int main() {
	while(cin >> n >> m >> l >> k >> a >> h) {
		if(n == 0 && m == 0 && l == 0 && k == 0 && a == 0 && h == 0) break;

		rep(i, 105) G[i].clear();
		memset(L, 0, sizeof(L));

		rep(i, l) {
			int x;
			cin >> x;
			L[x] = true;
		}

		rep(i, k) {
			int s, t, c;
			cin >> s >> t >> c;
			G[s].push_back(edge(t, c));
			G[t].push_back(edge(s, c));
		}

		dijkstra(a);

		int ans = INF;
		rep(i, m + 1) {
			ans = min(ans, d[h][i]);
		}

		if(ans == INF) cout << "Help!" << endl;
		else cout << ans << endl;
	}
	return 0;
}

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

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

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
const int MAX=1401;
int dp[MAX][MAX];
int main()
{
    int H,W,S[MAX][MAX],maxv=0;
    cin>>H>>W;
    for(int i=0;i<H;i++)
        for(int j=0;j<W;j++)
            cin>>S[i][j];
    for(int i=0;i<H;i++)
        for(int j=0;j<W;j++)
        {
            dp[i][j]=(S[i][j]+1)%2;
            maxv |= dp[i][j];
        }
    
    for(int i=1;i<H;i++)
        for(int j=1;j<W;j++) {
            dp[i][j]=S[i][j]==0?
                    min(min(dp[i - 1][j - 1], dp[i - 1][j]), dp[i][j - 1]) + 1:0;
            maxv=max(maxv,dp[i][j]);
        }
    cout<<maxv*maxv<<endl;
}


Measured memory_bytes: 18320
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
using namespace std;

int answerNum(deque<pair<int, bool> >& plus, deque<pair<int, bool> >& minus, int total, vector<bool>& used)
{
    if(plus.size() == 0 && minus.size() == 0){
        if(total == 0)
            return 1;
        else
            return 0;
    }

    int tmp = total;
    int a = -1;
    for(unsigned i=0; i<plus.size(); ++i){
        while(used[++a]);
        tmp += plus[i].first * a;
    }
    a = 10;
    for(unsigned i=0; i<minus.size(); ++i){
        while(used[--a]);
        tmp += minus[i].first * a;
    }
    if(tmp > 0)
        return 0;

    tmp = total;
    a = 10;
    for(unsigned i=0; i<plus.size(); ++i){
        while(used[--a]);
        tmp += plus[i].first * a;
    }
    a = -1;
    for(unsigned i=0; i<minus.size(); ++i){
        while(used[++a]);
        tmp += minus[i].first * a;
    }
    if(tmp < 0)
        return 0;

    bool isNonZero;
    if(minus.size() == 0 || (plus.size() > 0 && plus[0].first > -minus[0].first)){
        a = plus[0].first;
        isNonZero = plus[0].second;
        plus.pop_front();
    }else{
        a = minus[0].first;
        isNonZero = minus[0].second;
        minus.pop_front();
    }

    int answer = 0;
    for(int i=(isNonZero?1:0); i<10; ++i){
        if(!used[i]){
            used[i] = true;
            answer += answerNum(plus, minus, total+a*i, used);
            used[i] = false;
        }
    }

	if(a >= 0)
		plus.push_front(make_pair(a, isNonZero));
	else
		minus.push_front(make_pair(a, isNonZero));

    return answer;
}

void solve(vector<string>& mask)
{
    vector<int> num(26, 0);
    vector<bool> isUsed(26, false);
    vector<bool> isNonZero(26, false);
    for(unsigned i=0; i<mask.size(); ++i){
        int tmp = 1;
        for(int j=mask[i].size()-1; j>=0; --j){
            if(i < mask.size()-1)
                num[mask[i][j]-'A'] += tmp;
            else
                num[mask[i][j]-'A'] -= tmp;
            tmp *= 10;
            isUsed[mask[i][j]-'A'] = true;
        }
        if(mask[i].size() > 1)
            isNonZero[mask[i][0]-'A'] = true;
    }

    deque<pair<int, bool> > plus;
    deque<pair<int, bool> > minus;
    for(int i=0; i<26; ++i){
        if(isUsed[i]){
            if(num[i] >= 0)
                plus.push_back(make_pair(num[i], isNonZero[i]));
            if(num[i] < 0)
                minus.push_back(make_pair(num[i], isNonZero[i]));
        }
    }
    sort(plus.rbegin(), plus.rend());
    sort(minus.begin(), minus.end());

    vector<bool> used(10, false);
    cout << answerNum(plus, minus, 0, used) << endl;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            break;

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

        solve(mask);
    }

    return 0;
}

Measured memory_bytes: 948
A, B, C = list(map(int, input().split()))

if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
    ans = 0
else:
    arr = [A, B, C]
    arr.sort()
    ans = arr[0] * arr[1]

print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int maxn=200009;
const int P=1000000007;

int n;
int a[maxn];
long long sum[maxn];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		sum[i]=(sum[i-1]+a[i])%P;
	}
	long long ans=0;
	for(int i=2;i<=n;++i){
		ans=(ans+a[i]*sum[i-1])%P;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6100
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string.h>
using namespace std;
int cha[105];
struct node
{
    int x;
    int fenshu;
    char name[15];
} a[105],temp;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        getchar();
        a[i].x=i;
        scanf("%s %d",a[i].name,&a[i].fenshu);
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=i+1; j<=n; j++)
        {
            if(strcmp(a[i].name,a[j].name)>0)
            {
                temp=a[i];
                a[i]=a[j];
                a[j]=temp;
            }
            else if(strcmp(a[i].name,a[j].name)==0)
            {
                if(a[i].fenshu<a[j].fenshu)
                {
                    temp=a[i];
                    a[i]=a[j];
                    a[j]=temp;
                }
            }
        }
        printf("%d\n",a[i].x);
    }
}


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


using namespace std;

int main(){

    int n;
    cin >> n;
    
    vector<int> p(n);
    
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    
    
    int ans = 0;
    
    for (int i = 1; i < n-1; i++) {
        if ((p[i-1]-p[i])*(p[i+1]-p[i]) <= 0) {
            if (p[i] == p[i-1] && p[i] == p[i+1]) {
                
            }else{
                ans += 1;
            }
        }
    }
    
    cout << ans << endl;
    
    
    return 0;
    
}


Measured memory_bytes: 256
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


N = I()
A = IL()

SUM = 0
cnt = 0
MIN = MAX_INT
for i in range(N):
  if A[i] < 0:
    tmp = -A[i]
    cnt += 1
  else:
    tmp = A[i]
  MIN = min(MIN,tmp)
  SUM += tmp

if cnt%2 == 0:
  print(SUM)
else:
  print(SUM-MIN*2)

Measured memory_bytes: 23384
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,x = map(int, input().split())
v0 = n
v1 = n-x
ans = x
init = 0
while True:
    num, amari = divmod(v0,v1)
#     print(ans, v0,v1)
    if amari==0:
        ans += (2*(num-1)+init)*v1
        break
    else:
        ans += (2*(num-1)+1+init)*v1
        v0,v1 = v1,amari
    if init == 0:
        init = 1
print(ans)

Measured memory_bytes: 61780
#include<stdio.h>
int main(void)
{
	int k,i,a=0,j;
	scanf("%d",&k);
	for(i=0;i<k;i++){
		for(j=0;j<k;j++){
			if(i%2==0&&j%2==1){
				a++;
			}
		}
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007


string s;



int calc(int b,int e){
	vector<int> v;
	vector<char> ope;
	for(int i=b; i<=e; i++){
		if(s[i]=='('){
			int o=1,c=0;
			for(int j=i+1; j<=e; j++){
				if(s[j]=='(')o++;
				if(s[j]==')'){
					c++;
					if(o==c){
						int a=calc(i+1,j);
						v.pb(a);
						i=j;
						break;
					}
				}
			}
		}
		else if(s[i]>='0'&&s[i]<='9'){
			for(int j=i+1; j<=e; j++){
				if(s[j]<'0'||s[j]>'9'){
					string t=s.substr(i,j);
					v.pb(atoi(t.c_str()));
					i=j-1;
					break;
				}
			}
		}
		else{
			ope.pb(s[i]);
		}
	}
	for(int i=0; i<ope.size(); i++){
		if(ope[i]=='*'){
			v[i+1]=v[i]*v[i+1];
			v[i]=0;
			ope[i]=(i==0?'+':ope[i-1]);
		}
		if(ope[i]=='/'){
			v[i+1]=v[i]/v[i+1];
			v[i]=0;
			ope[i]=(i==0?'+':ope[i-1]);
		}
	}
	for(int i=0; i<ope.size()-1; i++){
		if(ope[i]=='+'){
			v[0]+=v[i+1];
		}
		if(ope[i]=='-'){
			v[0]-=v[i+1];
		}
	}
	return v[0];
}


int main(){
	int n;
	cin>>n;
	rep(i,n){
		cin>>s;
		cout<<calc(0,s.size()-1)<<endl;
	}
}

Measured memory_bytes: 1240
#include <stdio.h>
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const ll MOD = 1000000007;

int main() {
    int n;
    scanf("%d", &n);
    ll a[202020];
    rep(i,n) scanf("%lld", &a[i]);

    ll sum = 0, ans = 0;
    rep(i,n) {
        sum += a[i];
        if(sum >= MOD) sum %= MOD;
    }
    rep(i,n-1){
        sum -= a[i];
        if(sum < 0) sum = (sum + MOD) % MOD;
        ans += (a[i] * sum)%MOD;
        if(ans >= MOD) ans %= MOD;
    }

    printf("%d\n",ans);
}


Measured memory_bytes: 3264
#include<iostream>
using namespace std;
typedef long long li;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
struct modint{
  li num;

  modint(li a=0){
    num=(a%MOD+MOD)%MOD;
  }
  modint operator+(modint a) {return{(num+a.num)%MOD};} 
  modint operator-(modint a) {return{((num-a.num)%MOD+MOD)%MOD};}
  modint operator*(modint a) {return{num*a.num%MOD};}
  modint inv(const modint& a);
  modint operator/(modint a) {return (*this)*inv(a);}
  modint& operator+=(modint a) {
    (num += a.num)%=MOD;
    return *this;
  }
  modint& operator*=(modint a) {
    (num*=a.num)%=MOD;
    return *this;
  }
};

std::ostream& operator<<(std::ostream& os, const modint& m){
  // ここでストリームに obj を書き込みます。
  li a=m.num;
  a%=MOD;
  a+=MOD;
  a%=MOD;
  cout << a;
  return os;
}

std::istream& operator>>(std::istream& os,modint& m){
  // ここでストリームに obj を書き込みます。
  li a; cin >>a;
  m=a;
  return os;
}

modint pow(modint a,int r){
  if(df)print(a,"^",r,"=");
  modint b=a,ans=1;
  while(r){
    if(r%2) ans*=b;
    b*=b;
    r/=2;
  }
  if(df)print(ans);
  return ans;
}

modint modint::inv(const modint& a){
  // MOD: prime
  return pow(a,MOD-2);
}


modint binom(li n,int k){
  if((k<0) or (k>n)) return 0;
  if(k>n-k) k=n-k;
  if(n<MOD){
    modint den=1,num=1;
    rep(i,k){
      den*=i+1;
      num*=n-i;
    }
    if(df)print("binom=",num,"/",den);
    return num/den;
  }
  while(1) print("too large");
}



int main(){
  int n,m;int k; cin >>n >>m >>k;
  if(df)print(m,n);
  modint ans=binom(m*n-2,k-2);
  if(df)print(m*n-2,k-2,ans);
  ans*=m*n;
  if(df)print("->",ans);
  ans*=m*n-1;
  if(df)print("->",ans);
  ans*=m+n;
  if(df)print("->",ans);
  ans=ans/6;
  print(ans);
}


Measured memory_bytes: 3572