akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	int k, t;
	cin>>k>>t;
	vi v(t);
	rep(i, t) cin>>v[i];
	priority_queue<int> q;
	rep(i, t) q.push(v[i]);
	if(t == 1) {
		cout<<v[0]-1<<endl;
		return 0;
	}
	int ans = 0;
	while(1){
		int a = q.top(); q.pop();
		int b = q.top(); q.pop();
		//cout<<a<<" "<<b<<endl;
		if(q.size()==0){
			ans = a-b;
			break;
		}
		else q.push(a-b);
	}
	cout<<(ans ==0 ? 0:ans-1)<<endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int A,B,K;
    cin>>A>>B;
    K=(A+B)/2;
    if((A+B)%2==0)
    {
        cout<<K<<endl;
    }
    else
    {
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#define N 100002
#define M 1000002
using namespace std;
int head[N],ver[M*2],nxt[M*2],edge[M*2],l;
int n,i,dis[N];
int read()
{
	char c=getchar();
	int w=0;
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0'){
		w=w*10+c-'0';
		c=getchar();
	}
	return w;
}
void insert(int x,int y,int z)
{
	l++;
	ver[l]=y;
	edge[l]=z;
	nxt[l]=head[x];
	head[x]=l;
}
void Dijkstra()
{
	priority_queue<pair<int,int> > q;
	memset(dis,0x3f,sizeof(dis));
	dis[1]=0;
	q.push(make_pair(0,1));
	while(!q.empty()){
		int x=q.top().second,d=-q.top().first;
		q.pop();
		if(d!=dis[x]) continue;
		for(int i=head[x];i;i=nxt[i]){
			int y=ver[i];
			if(dis[y]>dis[x]+edge[i]){
				dis[y]=dis[x]+edge[i];
				q.push(make_pair(-dis[y],y));
			}
		}
	}
}
int main()
{
	n=read();
	for(i=0;i<n;i++) insert(i,(i+1)%n,1),insert(i,i*10%n,0);
	Dijkstra();
	printf("%d\n",dis[0]+1);
	return 0;
}


Measured memory_bytes: 6988
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <queue>
using namespace std;

int main()
{
	string s;
	char c[] = { "rgb" };

	while( cin >> s && s != "0" ){
		set< string > memo;
		vector< string > sample;
		for( int i = 0; i < 3; ++i ){
			sample.push_back( string( s.size(), c[ i ] ) );
		}

		queue< string > pattern;
		pattern.push( s );
		int sec = 0;
		bool found = false;
		while( !pattern.empty() ){
			int size = pattern.size();
			while( size > 0 ){
				string p = pattern.front();
				pattern.pop();
				if( memo.find( p ) != memo.end() ){
					--size;
					continue;
				}
				memo.insert( p );
				for( int i = 0; i < 3; ++i ){
					if( p == sample[ i ] ){
						found = true;
						break;
					}
				}
				if( found ) break;

				for( int i = 0; i < (int)p.size() - 1; ++i ){
					if( p[ i ] == p[ i + 1 ] ){
						continue;
					}
					int oo = p[ i ] + p[ i + 1 ];
					char color;
					switch( oo ){
						case 'r' + 'g': color = 'b'; break;
						case 'g' + 'b': color = 'r'; break;
						case 'b' + 'r': color = 'g'; break;
					}
					string cpy = p;
					cpy[ i ] = cpy[ i + 1 ] = color;
					pattern.push( cpy );
				}
				--size;
			}
			if( found ) break;
			++sec;
		}
		if( found ){
			cout << sec << endl;
		}else{
			cout << "NA" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3072
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
   
    int n,i;
    cin>>n;
    int a[n+2];
    unordered_map<int,int> ma;
    for(i=1;i<=n;i++) cin>>a[i],ma[a[i]] = i;
    sort(a+1,a+n+1);
    for(i=1;i<=n;i++)
    {
    	cout<<ma[a[i]]<<" ";
    }
}

Measured memory_bytes: 5284
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)


int main() {
	i64 n, m;
	cin >> n >> m;
	i64 ans = 0;
	if (2*n >= m) {
		ans = m / 2;
	}
	else {
		ans = n;
		m -= 2 * ans;
		ans += m / 4;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import math
import fractions
from functools import reduce
from collections import Counter
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)

N, K = MI()
x = LI()
ans = INF
for i in range(N-K+1):
    ans = min(
            ans,
            abs(x[i]) + abs(x[i+K-1] - x[i]),
            abs(x[i+K-1]) + abs(x[i+K-1] - x[i]))
print(ans)


Measured memory_bytes: 16236
#include<cstdio>
#include<algorithm>
const int mod=998244353;
int N,pw2[210];
struct Point{int x,y;}P[210];
int o,L[210];
bool cmp(int i,int j){
	int ti=P[i].y<P[o].y||P[i].y==P[o].y&&P[i].x<P[o].x,
		tj=P[j].y<P[o].y||P[j].y==P[o].y&&P[j].x<P[o].x;
	if(ti!=tj)return ti<tj;
	return(P[i].x-P[o].x)*(P[j].y-P[o].y)>(P[i].y-P[o].y)*(P[j].x-P[o].x);
}
int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d%d",&P[i].x,&P[i].y);
	for(int i=*pw2=1;i<=N;i++)pw2[i]=pw2[i-1]*2%mod;
	int s=0;
	for(o=0;o<N;o++){
		int m=0;
		for(int i=0;i<N;i++)if(i!=o)L[m++]=i;
		std::sort(L,L+m,cmp);
		for(int i=0,t=0;i<m;i++){
			if(i&&cmp(L[i-1],L[i]))t=0;
			(s+=pw2[t++])%=mod;
		}
	}
	s=(s*(mod+1ll)/2+N+1)%mod;
	printf("%d\n",(pw2[N]+mod-s)%mod);
}

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

int main(){
    ll t,i,j,k;
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    ll m[a],n[b],o[c];
    for(i=0;i<a;i++)
    cin>>m[i];
    for(i=0;i<b;i++)
    cin>>n[i];
    for(i=0;i<c;i++)
    cin>>o[i];
    sort(m,m+a);
    sort(n,n+b);
    sort(o,o+c);
    i=a-x;
    j=b-y;
    k=c-1;
    
    vector<ll>p;
    for(t=0;t<c;t++)
    p.push_back(o[t]);
    for(t=i;t<a;t++)
    p.push_back(m[t]);
    for(t=j;t<b;t++)
    p.push_back(n[t]);
    sort(p.begin(),p.end());
    ll sum=0;
    x=x+y;
    i=p.size()-1;
    while(x)
    {
        sum+=p[i--];
        x--;
    }
    cout<<sum;
}

Measured memory_bytes: 8688
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
// const int INF = 2000000000;

int N;
vector<int> V, C;

int dfs(int idx) {
  if (idx == N) {
    return 0;
  }

  int m1 = dfs(idx + 1) + V[idx] - C[idx];
  int m2 = dfs(idx + 1);
  return max(m1, m2);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  V.resize(N);
  C.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> V[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> C[i];
  }

  int ans = dfs(0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>
#include <time.h>
#include <stdio.h>

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

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) a.begin(), a.end()

template<typename T>
void vdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		if (i == size - 1) {
			cout << da[i] << endl;
		}
		else {
			cout << da[i] << ' ';
		}
	}
}
template<typename T>
void vvdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		vdeb(da[i]);
	}
}

P operator+(const P &le, const P &ri){
	P ret = {le.first + ri.first, le.second + ri.second};
	return ret;
}

ll score(const P &x){
	return abs(x.first - x.second) + min(x.first, x.second)/2;
}

bool operator>(const P &le, const P &ri){
	return (score(le) > score(ri));
}

int main(){
	int l; cin >> l;
	vector<ll> da(l+1);
	rip(i,l,0) cin >> da[i];
	vector<vector<ll>> dp(l+2, vector<ll>(5)); // . n <>  n 1
	dp[0][0] = 0;
	rip(i,l+1,0){
		dp[i+1][0] = dp[i][0];
		rip(j, 5, 1){
			dp[i+1][j] = min(dp[i+1][j-1], dp[i][j]);
		}
		dp[i+1][0] += da[i];
		dp[i+1][4] += da[i];
		if(da[i] == 0){
			dp[i+1][1]+=2;dp[i+1][2]++;dp[i+1][3]+=2;
		}
		else{
			if(da[i]%2 == 0){
				dp[i+1][2]++;
			}
			else{
				dp[i+1][1]++;dp[i+1][3]++;
			}
		}
	}
	//vvdeb(dp);
	cout << dp[l+1][4] << endl; 
}

Measured memory_bytes: 15872
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
long long a[100005];
long long ans[100005];
int main()
{
	int n;
	long long tmp = 0, sum = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum += a[i];
		if (!(i & 1))tmp += a[i];
	}
	ans[1] = sum - 2ll * tmp;
	for (int i = 2; i <= n; i++)
		ans[i] = 2 * a[i - 1] - ans[i - 1];
	for (int i = 1; i <= n; i++)
		cout << ans[i] << (i < n ? ' ' : '\n');
	return 0;
}

Measured memory_bytes: 2816
package main

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

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

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

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

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

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

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

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

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	ans := "Borys"

	_ = getNextInt(scanner)
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	if (b-a-1)%2 == 1 {
		ans = "Alice"
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int main(){
    string s, t;
    cin >> s >> t;
    int count = 0;
    int N = s.size();
    for(int i = 0; i < N; i++){
        if(s[i] != t[i]) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3884
S = input()
T = input()
A = [-1]*26
B = [-1]*26
L = len(S)
ans = 'Yes'
for i in range(L):
    ords = ord(S[i])-97
    ordt = ord(T[i])-97
    if A[ords] == -1 and B[ordt] == -1:
        A[ords] = ordt
        B[ordt] = ords
    elif A[ords] == ordt and B[ordt] == ords:
        continue
    else:
        ans = 'No'
print(ans)

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(){
  int n, i;
  cin >> n;
  if(n%2){
    cout << "No" << endl;
    return 0;
  }
  char s[n+1];
  cin >> s;
  for(i=0; i<n/2; i++)
    if(s[i]!=s[n/2+i]){
      cout << "No" << endl;
      return 0;
    }
  cout << "Yes" << endl;
  return 0;
}

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	string s;
	cin >> s;

	if(s[0] == s[1] && s[1] == s[2] && s[2] == 'R'){
		cout << 3 << endl;
	}else if(s[0] == s[1] && s[0] == 'R' || s[1] == s[2] && s[1] == 'R'){
		cout << 2 << endl;
	}else if(s.find('R') != string::npos){
		cout << 1 << endl;
	}else{
		cout << 0 << endl;
	}


	return 0;
}


Measured memory_bytes: 3616
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <climits>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> dat(3 * n);
  for (int i = 0; i < 3 * n; i++) {
    scanf("%d", &dat[i]);
  }
  vector<long long > firstScore(3*n);

  priority_queue<int> pq1;
  long long curScore = 0;
  for (int i = 0; i < n; i++) {
    pq1.push(-dat[i]);
    curScore += dat[i];
  }
  for (int i = n; i <= 2 * n; i++) {
    firstScore[i] = curScore;
    if (i == 2 * n) break;
    curScore += dat[i];
    pq1.push(-dat[i]);
    curScore += pq1.top();
    pq1.pop();
  }

  priority_queue<int> pq2;
  curScore = 0;
  for (int i = 2 * n + 1; i < 3 * n; i++) {
    pq2.push(dat[i]);
    curScore += dat[i];
  }
  long long ans = LLONG_MIN;
  for (int i = 2 * n; i >= n; i--) {
    curScore += dat[i];
    pq2.push(dat[i]);
    ans = max(ans, firstScore[i] - curScore);
    curScore -= pq2.top();
    pq2.pop();
  }
  printf("%lld\n", ans);
  return 0;
}

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

using namespace std;
using namespace __gnu_pbds; 
#define     mod            (int)1e9+7
#define     MOD             998244353
#define     ll              long long
#define     mp              make_pair
#define     F               first
#define     S               second
#define     t()             int test;cin>>test;while(test--)
#define     ii              pair<int,int>
#define     que_max         priority_queue <int>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n"
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#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;
        //use cerr if u want to display at the bottom
    }
    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



 
int main()
 
{  
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif

    IOS; 
      
   int n, k;
   cin>>n>>k;
   std::vector<ll int> v(n+1);
   
   for(int i= 1; i<=n; i++)cin>>v[i];

    std::vector<ll> ans;

  
  int j = 1;

    for(int i = 1; i<=n; i++)
    {
      if(i >= k+1)
      {

        if(v[j] < v[i])
        {
          cout<<"Yes"<<endl;
        }
        else
        {
          cout<<"No"<<endl;
        }
        j++;
      }
    }

        
        

   
  
}

Measured memory_bytes: 4780
from functools import lru_cache
@lru_cache()
def gcd(x,y):
    r = x%y
    if r == 0:
        return y
    return gcd(y,r)

K = int(input())
Sum = 0

for i in range(1,K+1):
    Sum += i
    for j in range(i+1,K+1):
        Sum += 6*gcd(i,j)
        for k in range(j+1,K+1):
            Sum += 6*gcd(gcd(i,j),k)
print(Sum)

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

int top=0;
int pop(string *s);
int push(string *s, string c);


int main(){
    string c;
    string s[1000];

    while(cin>>c){
        if(c=="+"){
            int a1=pop(s);
            int a2=pop(s);
            ostringstream a3;
            a3<<a2+a1;
            push(s, a3.str());
        }

        else if(c=="*"){
            int a1=pop(s);
            int a2=pop(s);
            ostringstream a3;
            a3<<a1*a2;
            push(s, a3.str());
        }

        else if(c=="-"){
            int a1=pop(s);
            int a2=pop(s);
            ostringstream a3;
            a3<<a2-a1;
            push(s, a3.str());
        }
        else push(s,c);
    }

    cout<<atoi(s[1].c_str())<<endl;
}

int push(string *s, string c){
    if(top>1000) return 0;
    top++;
    s[top]=c;
    return 1;
}

int pop(string *s){
    if(top==0) return 0;
    string g = s[top];
    top--;
    return atoi(g.c_str());
}


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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

const int N = 1e5;
int dp[N];
vi g[N];

int dfs(int u){
    if(dp[u] == -1){
        dp[u] = 0;
        for(int v:g[u]) 
            dp[u] = max(dp[u], dfs(v) + 1);
    }
    return dp[u];
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    int n,m; cin >> n >> m;
    while(m--){
        int x,y; cin >> x >> y;
        g[x-1].pb(y-1);
    }
    int r = 0;
    forn(i,n) dp[i] = -1;
    forn(i,n) r = max(r, dfs(i));
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 7552
N, K = input().split()
D = list(map(int, input().split()))

for i in range(0, 10):
    if i in D:
        D.remove(i)
    else:
        D.append(i)

digit = len(N)
con = ''

for i in range(digit):
    if int(N[i]) in D:
        con += N[i]

    else:
        flag = True
        for j in D:
            if j > int(N[i]):
                N = con + str(j) + str(D[0]) * (digit-len(con)-1)
                flag = False
                break

        if flag:
            if D[0] == 0:
                N = str(D[1]) + str(D[0]) * digit
            else:
                N = str(D[0]) * (digit+1)

        break

print(N)


Measured memory_bytes: 3064
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  list($s) = explode(" ", trim(fgets(STDIN)));

  $len = strlen($s);
  if($len%2 == 1){
    echo "No";
    exit;
  }

  
  if(substr($s, 0, $len/2) == substr($s, $len/2, $len/2)){
    echo "Yes";
    exit;
  }else{
    echo "No";
    exit;
  }

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

#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define tiii tuple<int,int,int>
#define tiiii tuple<int,int,int,int>
#define popcount __builtin_popcountll

const int INF = 1LL<<60;
const int MOD = 1000000007;

template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
string to_string(string s) {return s;}
template <typename A, typename B>
string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) { return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";}
template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}

string bin_string(int x) {
    const int d = 32;
    string result(d, ' ');
    RREP(i, d-1, -1) result[d-1-i] = '0'+((x&1LL<<i)!=0);
    return result;
}

int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int a, b;
    cin >> a >> b;
    cout << 6-a-b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int n, m; cin >> n >> m;
    vvint g(n);
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i,n) {
        cout << g[i].size() << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;






int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    set<int>s;
    for(int i =0;i < n;i++) {
        int no;
        cin>>no;
        auto it  = s.find(no);
        if(it==s.end()){
            s.insert(no);
        }
        else{
            s.erase(it);
        }
    }
    cout<<s.size()<<endl;







}















































Measured memory_bytes: 4992
#include <stdio.h>

main(){
  double a, b, c, d, e, f, x, y;

  while(1){
    if(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f)==EOF) break;
    if(a!=0.0){
      y=(f-c*d/a)/(e-b*d/a);
      x=(c-b*y)/a;
    }
    else if(d!=0.0 && b!=0.0){
      y=c/b;
      x=(f-e*y)/d;
    }
    else if(d==0.0){
      x=0.0;
      if(b!=0.0) y=c/b;
      else if(e!=0.0) y=f/e;
    }
    /*  x=(x*10000+5)/10000;
        y=(y*10000+5)/10000; */
    printf("%.3f %.3f\n", x, y);
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pair2;
typedef pair<int, pair<int, int> > pair3;
typedef pair<int, pair<int, pair<int, int> > > pair4;
#define MAXN 200013
#define INF 1000000000000000000LL
#define MOD 1000000007LL
#define IINF 1000000000
#define mp make_pair
#define pb push_back
#define remove pop
#define all(x) x.begin(), x.end()

int main() {
	if (fopen("FILENAME.in", "r")) {
		freopen("FILENAME.in", "r", stdin);
		freopen("FILENAME.out", "w", stdout);
	}
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);

	int r;
	cin >> r;

	cout << r * r << endl;
}

//GCD GCD GCD USE GCD IN MATH

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	A, B := sc.NextInt(), sc.NextInt()
	fmt.Println(A * B / gcd(A, B))
}

func gcd(a, b int) int {
	for b > 0 {
		a, b = b, a%b
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
n, x =map(int,input().split())
def burger(n, x):
    if n == 0:
        if x == 0:
            return 0
        elif x == 1:
            return 1
    else:
        if x == 1:
            return 0
        elif x == 2**(n+2)-3:
            return 2**(n+1)-1
        elif x == 2**(n+1) -1 :
            return 2**n
        elif x > 2**(n+1) - 1: #(2**(n+1)-1)/2 + 1:
            return 2**n + burger(n-1, x - (2**(n+1) - 1))
        else:
            return burger(n-1, x-1)
          
print(burger(n, x))

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
int N;
struct data
{
    char s;
    int n;
}a[105],a1[105],a2[105];
void BubbleSort(int N)
{
    for(int i = 0; i < N; i++)
        for(int j = N - 1; j >= i + 1; j--)
            if(a1[j].n < a1[j - 1].n)
                swap(a1[j].s,a1[j - 1].s),swap(a1[j].n,a1[j - 1].n);
    for(int i = 0; i < N - 1; i++)
        printf("%c%d ",a1[i].s,a1[i].n);
    printf("%c%d\n",a1[N - 1].s,a1[N - 1].n);
}
void SelectionSort(int N)
{
    for(int i = 0; i < N; i++)
    {
        int mini = i;
        for(int j = i; j < N; j++)
            if(a2[j].n < a2[mini].n)
                mini = j;
        if(i != mini)
            swap(a2[i].n,a2[mini].n),swap(a2[i].s,a2[mini].s);
    }
    for(int i = 0; i < N - 1; i++)
        printf("%c%d ",a2[i].s,a2[i].n);
    printf("%c%d\n",a2[N - 1].s,a2[N - 1].n);
}
bool cmp()
{
    for(int i = 0; i < N; i++)
        if(a1[i].s != a2[i].s)
            return 0;
    return 1;
}
int main()
{
    cin.tie(0);
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        cin >> a[i].s >> a[i].n;
        a1[i].s = a2[i].s = a[i].s;
        a1[i].n = a2[i].n = a[i].n;
    }
    BubbleSort(N);
    puts("Stable");
    SelectionSort(N);
    if(cmp())
        puts("Stable");
    else
        puts("Not stable");
    return 0;
}


Measured memory_bytes: 3208
import java.util.Scanner;

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

    int a = sin.nextInt();
    int b = sin.nextInt();
    int c = sin.nextInt();

    if ( a < b && b < c) { System.out.println("Yes"); }
    else { System.out.println("No"); }
  }
}


Measured memory_bytes: 26216
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
#define F first
#define S second

const int mxn = 1e5+5;
int n, d1[mxn], dn[mxn], v[mxn];
vector<int> adj[mxn];

void bfs(int start, int d[]){
    memset(v, false, n*4);
    queue<int> q;
    q.push(start);
    v[start] = true;
    d[start] = 0;
    while(!q.empty()){
        int node = q.front();
        q.pop();
        for(int next : adj[node]){
            if(!v[next]){
                v[next] = true;
                d[next] = 1+d[node];
                q.push(next);
            }
        }
    }
}

void solve(){
    cin >> n;
    for(int i = 0; i < n-1; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    bfs(0, d1);
    bfs(n-1, dn);

    int fc = 0;
    for(int i = 0; i < n; ++i){
        fc += d1[i] <= dn[i];
    }
    int sc = n-fc;
    cout << (fc > sc ? "Fennec\n" : "Snuke\n");
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 10240
import sys
input = sys.stdin.readline
from collections import deque

n = int(input())

graph = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

c = list(map(int, input().split()))
c.sort(reverse=True)

value = 0
ans = [0] * n
memo = [0] * n
q = deque([0])
i = 0

while q:
    v = q.popleft()
    ans[v] = c[i]
    memo[v] = 1
    if i > 0:
        value += c[i]
    i += 1
    for nv in graph[v]:
        if memo[nv] == 1:
            continue
        memo[nv] = 1
        q.append(nv)

print(value)
print(*ans)





Measured memory_bytes: 46320
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;






public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    //public static long mod = (long) (1e9+7);
    public final static int MAX = (int)1e5;
  // static Scanner sc = new Scanner(System.in);
   static List<Integer>[] edge;
   private static int N = (int) (2e5 + 11);
	public static void main(String[] args) {
	   
	 FastReader sc = new FastReader();

	 char[] s = sc.next().toCharArray();
	 char[] t = sc.next().toCharArray();
	 int ans = 0;
	 for(int i=0;i<3;++i) if(s[i] == t[i]) ++ans;
	 out.print(ans);
	 out.close();
	}
}


Measured memory_bytes: 21200
#include <iostream>
#include <cstdio>
using namespace std;
//@date: 2020-02-16 20:21:45
//@state:
//@purpose:

int main()
{
    int n,t,f=1;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t;
        if(t%2==0&&t%3!=0&&t%5!=0)
            f=0;
    }
    if(f)cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
    return 0;
}

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

int main(){
int a;
cin >> a;
vector <int> b(a+1);
int count = 0;
for (int i = 1; i<=a; i++){
cin >> b[i];
}
for (int j = 2; j<a;j++){
if ((b[j] > b[j-1] && b[j] < b[j+1]) || (b[j] < b[j-1] && b[j] > b[j+1])){
count++;
}
}
cout << count << "\n";
return 0;
}


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



int main(){
	int n,q;scanf("%d", &n);
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%d", &a[i]);// cin >> ;
	}
	cin >> q;
	int b[q];
	int ans=0;
	for(int i=0;i<q;i++){
		scanf("%d", &b[i]);// cin >> b[i];
		int l=0,r=n;
		while(l<r){
			int j=(l+r)/2;
			if(b[i] == a[j]){
				ans++;
				break;
			}else if(b[i] > a[j]){
				l = j + 1;
			}else if(b[i] < a[j]){
				r = j;
			}
		}
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

ll N, K;
string S;

int main() {
    cin >> N >> K;
    cin >> S;

    // 1 0 1 0 1 という配列を作る
    vector<ll> nums;
    int current = 1;
    int cnt = 0;

    for (int i = 0; i < N; i++) {
        // cout << (char)(current - '0') << endl;
        if (S[i] - '0' == current) {
            cnt++;
        } else {
            nums.push_back(cnt);

            // 0 と 1の切り替え
            current = 1 - current;
            // cout << current << " " << (char)current << endl;
            cnt = 1;
        }
        // cout << cnt << endl;
    }
    if (cnt != 0) nums.push_back(cnt);

    // 1 で終わらない場合は 足してあげる
    if (nums.size() % 2 == 0) nums.push_back(0);

    // rep(i, nums.size()) {
    //     cout << nums[i] << " ";
    // }
    // cout << endl;


    // しゃくとりでやる
    // 先頭を固定

    ll left = 0, right = 0;
    ll add = 2 * K + 1;

    ll ans = 0;
    ll tmp = 0;

    // 左端の移動
    for (ll i = 0; i < nums.size(); i += 2) {
        ll next_left = i;
        ll next_right = min(i + add, (ll)nums.size());

        while (next_left > left) {
            tmp -= nums[left];
            left++;
        }

        while (next_right > right) {
            tmp += nums[right];
            right++;
        }
        // cout << "l: " << next_left << " r: " << next_right << " " << tmp << endl;
        ans = max(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 4388
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() { 
    ll N, A, B;
    string S;
    cin >> N >> A >> B >> S;

    ll kokunai=0, kaigai=0;
    for(int i=1; i<=N; i++){
        char c = S[i-1];
        if(c=='a'){
            if(kokunai+kaigai<A+B){
                kokunai++;
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
        else if(c=='b'){
            if(kokunai+kaigai<A+B && kaigai < B){
                kaigai++;
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
        else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 896
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
//using ll = long long;
int n,m;
int a[1005];
bool cmp(int a,int b){
	return a>b;
}
int main(){
	//freopen("in.txt","r",stdin);
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i];
	int sum=0;
	for(int i=0;i<n;i++) sum+=a[i]; 
	int b=ceil((double)sum/(4*m));
	//cout<<sum;
	//cout<<b;
	
	bool ok=true;
	sort(a,a+n,cmp);
	//int ans=0;
	for(int i=0;i<m;i++){
		//ans+=a[i];
		if(a[i]<b){
			ok=false;
			break;
		}
	}
	    puts(ok? "Yes":"No");
	 	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
 
using namespace std;
 
     
int main(void){
  ios::sync_with_stdio(false);
  int a = 0;
  int b = 0;
  int c = 0;
  int d = 0;
  int left = 0;
  int right = 0;
  
  cin >> a >> b >> c >> d;
 
  left = a + b;
  right = c + d;
  
  if(left > right){
    cout << "Left" << endl;
  }else if(left == right){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
  
 
  return 0;
}

Measured memory_bytes: 256
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
if a == b:
  print('YES')
elif a < b and a+v*t >= b+w*t:
  print('YES')
elif a > b and a-v*t <= b-w*t:
  print('YES') 
else:
  print('NO')

Measured memory_bytes: 9208
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val v = readLine()!!.split(" ").map { it.toDouble() }

    val s = v.sorted()

    var value = s[0]
    for (i in 1 until v.size) {
        value = (value + s[i]) / 2.0
    }
    println(value)
}

Measured memory_bytes: 37608
n,l=map(int,input().split())

saisho=100000000

all=(l-1)*n+n*(n+1)//2

aji=[l+i for i in range(n)]
absaji=[abs(l+i) for i in range(n)]
absaji.sort()
if absaji[0] in aji:
  print(all-absaji[0])
else:
  print(all+absaji[0])

Measured memory_bytes: 3064
from collections import defaultdict
n, m = map(int, input().split())
an = list(map(int,input().split()))

d_mod = defaultdict(int)
ruiseki = 0
for a in an:
    ruiseki = (ruiseki + a) % m
    d_mod[ruiseki] += 1

ans = 0
for key, value in d_mod.items():
    ans += value*(value-1)//2
    if not key:
        ans += value
print(ans)

Measured memory_bytes: 14636
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[3];
int main()
{
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    printf("%s",(a[0]==a[1]&&a[1]==a[2])?"Yes":"No");
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int m;
    long long int sum = 0;
	scanf("%d", &m);
    for(int n=1;n<=m;n++)
    {
	if(n%5 && n%3)
       sum += n;
    }
    printf("%lld", sum);
	return 0;
}


Measured memory_bytes: 1736
N = int(input())
xy = [[-1]*N for i in range(N)]

for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        xy[i][x-1] = y

honest = 0
for i in range(2 ** N): #bit全探索
    count = 0
    flag = True
    for j in range(N): #人数分シフトする必要がある
        if((i >> j) & 1): #ビットシフト部(bit全探索に必ず必要)
            count += 1
            for k in range(N): #最大N人いるので．
                if xy[j][k] == -1:
                    continue
                elif ((i >> k) & 1) != xy[j][k]: #bit全探索でj人目を正直とした人が，証言で正しいことを言っているか
                    flag = False
    if flag:
        honest = max(honest, count)

print(honest)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    int cnt = 0;
    while(1){
        bool wareru = true;
        rep(i,n){
            if(a[i] % 2 == 1){
                wareru = false;
                break;
            }
            a[i] = a[i]/2;
        }
        if(wareru)cnt++;
        else break;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    d = int(input())

    c =list(map(int, input().split()))

    s = [[] for i in range(d)]
    for i in range(d):
        s[i] = list(map(int, input().split()))

    t = [0 for i in range(d)]
    for i in range(d):
        t[i] = int(input())

    ans = 0
    last = [0 for i in range(26)]

        
    for i in range(d):
        ans += s[i][t[i]-1]
        last[t[i]-1] = i+1

        sum_ = 0
        for j in range(26):
            sum_ += c[j] * (i+1-last[j])

        ans -= sum_
        print(ans)
        
main()


Measured memory_bytes: 9536
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	
	int n;
	cin>>n;
	cout<<24+24-n<<endl;
	
	
	
//////////////////////////////////////////////////////
return 0;}











Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool compare(pair<ll, ll>a, pair<ll, ll>b)
{
	if (a.first == b.first)
		return a.second < b.second;
	return a.first < b.first;
}
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt" , "r" , stdin);
// 	freopen("output.txt" , "w" , stdout);
// #endif

	ll n, mx = 0;
	cin >> n;
	vector<pair<ll, ll>>v;
	map<pair<ll, ll>, ll>m;
	for (ll i = 1; i <= n; i++)
	{
		ll a, b;
		cin >> a >> b;
		m[ {a, b}] = 1;
		v.push_back({a, b});
	}
	sort(v.begin(), v.end(), compare);
	for (ll i = 0; i < n; i++)
	{
		ll x = v[i].first;
		ll y = v[i].second;
		//cout << 1 << endl;
		for (ll j = i + 1; j < n; j++)
		{
			ll p = v[j].first - x;
			ll q = v[j].second - y;
			ll x1 = x, y1 = y, c = 0;
			for (ll k = 0; k < v.size(); k++)
			{
				ll x1 = v[k].first;
				ll y1 = v[k].second;
				if (m[ {x1 + p, y1 + q}])
					c++;
			}
			mx = max(c, mx);
		}
	}
	cout << n - mx << endl;



}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <functional>
using namespace std;

int main(){
	int n,len;
	priority_queue<string,vector<string>,greater<string>> buf;
	string str;
	cin >> n>>len;
	for(int i=0;i<n;i++){
		cin >> str;
		buf.push(str);
	}
	while(!buf.empty()){
		cout << buf.top();
		buf.pop();
	}
}

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

using namespace std;

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i)
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i)

#define DEBUG(...) fprintf(stderr , __VA_ARGS__)

template<typename T>inline int chkmin(T &x , const T &y){ return x > y ? x = y , 1 : 0; }
template<typename T>inline int chkmax(T &x , const T &y){ return x < y ? x = y , 1 : 0; }

template<typename T>inline T read(T &f)
{
	f = 0 ; int x = 1 ; char c = getchar();
	while(!isdigit(c)) c = x == '-' ? -1 : 1 , c = getchar();
	while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
	return f *= x;
}

using int64 = long long;
using uint64 = unsigned long long;

const int N = 5000 + 5;

int n , A[N];

struct Edge
{
	int to ; Edge *next;
} E[N << 1] , *pre[N];

void addedge(int u , int v)
{
	static int cnt = 0;
	E[++cnt] = {v , pre[u]} , pre[u] = &E[cnt];
	E[++cnt] = {u , pre[v]} , pre[v] = &E[cnt];
}

int f[N] , d[N] , g[N];

const int INF = 0x3f3f3f3f;

void dfs(int u , int fa)
{
	for(Edge *i = pre[u] ; i ; i = i->next)
	{
		int v = i->to;
		if(v == fa) continue;
		dfs(v , u);
	}
	rep(i , 1 , 5000) d[i] = INF;
	d[0] = 0;
	for(Edge *i = pre[u] ; i ; i = i->next)
	{
		int v = i->to;
		if(v == fa) continue;
		per(x , f[u] , 0)
		{
			int t = INF;
			if(x >= f[v]) chkmin(t , d[x - f[v]] + g[v]);
			if(x >= g[v]) chkmin(t , d[x - g[v]] + f[v]);
			d[x] = t;
		}
	}
	int ret = INF;
	rep(i , 0 , f[u]) chkmin(ret , d[i]);
	g[u] = ret;
}

int main()
{
	read(n);
	rep(i , 2 , n)
	{
		static int u , v;
		u = i , read(v);
		addedge(u , v);
	}
	rep(i , 1 , n) read(f[i]) , g[i] = INF;
	dfs(1 , 0);
	puts(g[1] < INF ? "POSSIBLE" : "IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;

    for(int i = 0; i < 3; i++) {
        if(s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+2;
const int mod=1e9+7;
int dp[N],sdp[N];
void add(int &x,int y){
	x+=y;
	if(x>=mod){
		x-=mod;
	}
}
int mul(int x,int y){
	return (1ll*x*y)%mod;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,ans=0;
	cin>>n;
	dp[0]=1;
	sdp[0]=1;
	for(i=1;i<=n;i++){
		add(dp[i],dp[i-1]);
		if(i>2){
			add(dp[i],sdp[i-3]);
		}
		sdp[i]=sdp[i-1];
		add(sdp[i],dp[i]);
	}
	for(i=1;i<=n;i++){
		if(i<n){
			add(dp[n],mul(dp[i-1],mul(n-1,n-1)));
		}
		add(dp[n],mul(dp[i-1],min(i,n-1)));
	}
	cout<<dp[n];
}

Measured memory_bytes: 8064
import java.math.BigInteger;
import java.util.Scanner;


class Solver {

    private final int[] A;
    private final int N;

    Solver(Scanner in) {
        N = in.nextInt();
        A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = in.nextInt();
        }
    }

    void solve() {
        int[] count = new int[N];
        count[0]++;
        for (int a : A) {
            count[a]++;
            if (count[a] >= 3) {
                System.out.println(0);
                return;
            }
        }
        System.out.println(BigInteger.valueOf(2).modPow(BigInteger.valueOf(N / 2), BigInteger.valueOf(1000000007)).intValue());
    }
}

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

        new Solver(in).solve();

        in.close();
    }
}

Measured memory_bytes: 50980
#include<bits/stdc++.h>
using namespace std;
int a[10005];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        int k;
        scanf("%d",&k);
        for(int i=1;i<=k;i++)
        {
            int x;
            scanf("%d",&x);
            a[x]++;
        }
    }
    int ans=0;
    for(int i=1;i<=m;i++) if(a[i]==n) ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c=0;
    cin>>n;
    int a[n],b[n],i;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    for(i=0;i<n;i++)
    {
        if(a[i]!=b[i]) c++;
    }
    if(c==2||c==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}




Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var k int
	fmt.Scan(&k)

	xs := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	fmt.Println(xs[k-1])
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define inf 1000000000
#define mod 1000000007
using namespace std;
int main () {
	ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
	scanf("%lld %lld %lld %lld %lld", &a, &b, &c, &d, &e);
	e *= 4;
	f = min(min(a * 8, b * 4), min(c * 2, d)) * int(e / 8); e %= 8;
	f += min(min(a * 4, b * 2), c) * int(e / 4); e %= 4;
	f += min(a * 2, b) * int(e / 2); e %= 2;
	f += a * e;
	printf("%lld\n", f);
	return 0;
}

Measured memory_bytes: 256