akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200005;
const int MOD=1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())

int Q;
multiset<int>L,R;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>Q;
	ll off=0,l=0,r=0;
	while(Q--){
		int op;cin>>op;
		if(op==1){
			int a,b;cin>>a>>b;
			off+=b;
			L.insert(a);
			l+=a;
			while(sz(L)&&sz(L)-sz(R)>1){
				R.insert(*L.rbegin());
				r+=*L.rbegin();
				l-=*L.rbegin();
				L.erase(--L.end());
			}
			while(sz(R)&&sz(L)<sz(R)){
				l+=*R.begin();
				L.insert(*R.begin());
				r-=*R.begin();
				R.erase(R.begin());
			}
			while(sz(L)&&sz(R)&&*L.rbegin()>*R.begin()){
				int tmp=*L.rbegin();
				l-=tmp;
				r+=tmp;
				L.erase(--L.end());
				l+=*R.begin();
				r-=*R.begin();
				L.insert(*R.begin());
				R.erase(R.begin());
				R.insert(tmp);
			}
		}
		else{
			if(!sz(L)){
				cout<<"0 0\n";
			}
			else{
				cout<<*L.rbegin()<<' '<<off+(ll)(*L.rbegin())*(sz(L)-sz(R))-l+r<<"\n";
			}
		}
	}
}
/*
1 3
#.#


2 3
#.#
..#

3 3
##.
#.#
..#

3
2 5
6 1
3 7
Ans:6

4
3 7
2 9
8 16
10 8
Ans:9
*/


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

int main()
{
    ios::sync_with_stdio(false);
    int n,w;
    cin >> n >> w;
    
    vector<pair<int,int> > v(n);
    for(int i=0;i<n;i++)
        cin >> v[i].first >> v[i].second;
    
    vector<long long int> dp(w+1,0);
    
    // first = weight & second = value
    
    for(int i=0;i<n;i++)
        for(int j=w;j>=v[i].first;j--)
            dp[j] = max(dp[j],dp[j-v[i].first]+v[i].second);
    
    cout << dp[w] << "\n";
    
    return 0;
}

Measured memory_bytes: 3972
#include <iostream>

using namespace std;

int main() {
    int h, w;
    char area[100][100];
    cin >> h >> w;
    for (int y = 0; y < h; ++y) {
        cin.ignore();
        for (int x = 0; x < w; ++x) {
            cin >> area[y][x];
        }
    }
    for (int y = 0; y < h; ++y) {
        for (int x = 0; x < w; ++x) {
            bool has_found = false;
            for (int dx = 0; x - dx >= 0; ++dx) {
                if (area[y][x - dx] == 'c') {
                    has_found = true;
                    cout << dx;
                    break;
                }
            }
            if (!has_found) {
                cout << -1;
            }
            x == w - 1? cout << endl: cout << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 1168
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

ans = 0
for i in range(1, N+1):
	if i%3 != 0 and i%5 != 0:
		ans += i
print(ans)


Measured memory_bytes: 10040
#include<iostream>

using namespace std;


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

	if (x == 1 && (y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)) {
		cout << "Yes" << endl;
	}
	else if (x == 3 && (y == 5 || y == 7 || y == 8 || y == 10 || y == 12)) {
		cout << "Yes" << endl;
	}
	else if (x == 5 &&( y == 7 || y == 8 || y == 10 || y == 12)) {
		cout << "Yes" << endl;
	}
	else if (x == 7 && ( y == 8 || y == 10 || y == 12)) {
		cout << "Yes" << endl;
	}
	else if (x == 8 && (y == 10 || y == 12) ){
		cout << "Yes" << endl;
	}
	else if (x == 10 && y == 12) {
		cout << "Yes" << endl;
	}
	else if (x == 4 && (y == 6 || y == 9 || y == 11)) {
		cout << "Yes" << endl;
	}
	else if (x == 6 && (y == 9 || y == 11)) {
		cout << "Yes" << endl;
	}
	else if (x == 9 && y == 11) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return (0);
}

Measured memory_bytes: 256
#include <cstdio>

const char *TABLE[] = {
	".,!? ",
	"abc",
	"def",
	"ghi",
	"jkl",
	"mno",
	"pqrs",
	"tuv",
	"wxyz"
};

int main(){
	int N;
	scanf("%d", &N);
	while(N--){
		char input[1025];
		scanf("%s", input);
		int key = -1, idx = -1;
		for(char *p = input; *p != '\0'; p++){
			int k = *p - '0' - 1;
			if(k < 0){
				if(idx >= 0 && key >= 0){
					putc(TABLE[key][idx], stdout);
					idx = -1;
				}
			}else{
				if(k != key){ idx = -1; }
				if(TABLE[k][++idx] == '\0'){ idx = 0; }
			}
			key = k;
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int max = 0;
		int count = 0;
		for(int i=0;i<s.length();i++) {
			if(s.substring(i,i+1).equals("R")) {
				count++;
			} else {
				max = Math.max(max,count);
				count=0;
			}
		}
		max = Math.max(max,count);
		System.out.println(max);
	}
}

Measured memory_bytes: 26856
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		long[] x = new long[n];
		long[] y = new long[n];
		for (int i = 0; i < n; i++) {
			sa = br.readLine().split(" ");
			x[i] = Integer.parseInt(sa[0]);
			y[i] = Integer.parseInt(sa[1]);
		}
		br.close();

		long ans = Long.MAX_VALUE;
		for (int a = 0; a < n; a++) {
			for (int b = 0; b < n; b++) {
				for (int c = 0; c < n; c++) {
					for (int d = 0; d < n; d++) {
						int cnt = 0;
						for (int i = 0; i < n; i++) {
							if (x[a] <= x[i] && x[i] <= x[b]
									&& y[c] <= y[i] && y[i] <= y[d]) {
								cnt++;
							}
						}
						if (cnt >= k) {
							ans = Math.min(ans, Math.abs((x[b] - x[a]) * (y[d] - y[c])));
						}
					}
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26056
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int base[8];
string target="01234567";
map<string,int> dist;
void exec()
{
	string v=target;
	for(int i=0;i<8;i++){
		if (cin >> v[i]){
		}
		else
		{
			exit(0);
		}
	}
	cout << dist[v] << endl;
}
int main() {
	base[0]=1;
	for(int i=1;i<8;i++){
		base[i]=10*base[i-1];
	}
	dist[target]=0;
	int d=1;
	vector<string> cur;
	vector<string> nex;
	cur.push_back(target);
	while(cur.size()){
		for(int i=0;i<cur.size();i++){
			for(int r=0;r<2;r++){
				for(int c=0;c<4;c++){
					if(cur[i][r*4+c]=='0'){
						if(0<c){
							string v=cur[i];
							swap(v[r*4+c],v[r*4+c-1]);
							if(dist.find(v)==dist.end()){
								dist[v]=d;
								nex.push_back(v);
							}
						}
						if(c<3){
							string v=cur[i];
							swap(v[r*4+c],v[r*4+c+1]);
							if(dist.find(v)==dist.end()){
								dist[v]=d;
								nex.push_back(v);
							}
						}
						{
							int rr=(r+1)%2;
							string v=cur[i];
							swap(v[r*4+c],v[rr*4+c]);
							if(dist.find(v)==dist.end()){
								dist[v]=d;
								nex.push_back(v);
							}
						}
					}
				}
			}
		}
		cur.swap(nex);
		nex.clear();
		d++;
	}
	while(1){
		exec();
	}
}

Measured memory_bytes: 3492
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
	int n,a,b; cin>>n>>a>>b;
	cout << min(n*a,b) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner kb = new Scanner(System.in);
		final long m = 1000000007;
		int n = kb.nextInt();

		long arr[] = new long[n];

		for(int i = 0 ; i < n ; i++)
			arr[i] = kb.nextLong();

		long suffix[] = new long[n];

		suffix[n-1] = arr[n-1];

		for(int i = n-2 ; i >= 0 ; i--)
		{
			suffix[i] = (suffix[i+1] + arr[i]) % m;
		}

		long res = 0;
		for(int i = 0; i < n-1 ; i++)
		{
			res = (res + (arr[i] * suffix[i+1])) % m;
		}

		System.out.println(res);
	}
}

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

int mint[1000000], mink[1000000];
int main() {
	memset(mint, 0x3f, sizeof(mint));
	memset(mink, 0x3f, sizeof(mink));
	mint[0] = mink[0] = 0;
	for (int i = 1;; i++) {
		int a = i*(i + 1)*(i + 2) / 6;
		if (a >= 1000000)break;
		for (int j = a; j < 1000000; j++) {
			mint[j] = min(mint[j], mint[j - a] + 1);
			if (a & 1)mink[j] = min(mink[j], mink[j - a] + 1);
		}
	}
	int n;
	while (scanf("%d", &n), n)
		printf("%d %d\n", mint[n], mink[n]);
}

Measured memory_bytes: 11004
#include<stdio.h>

int main(){
	int n[3][3];
	int bing[9];
	int ctr[3][3]={0};
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			scanf("%d", &n[i][j]);
		}
	}
	int tc;
	scanf("%d", &tc);
	for(int i; i<tc; i++){
		scanf("%d", &bing[i]);
		if(bing[i] == n[0][0]){
			ctr[0][0]++;
		}
		else if(bing[i] == n[0][1]){
			ctr[0][1]++;
		}
		else if(bing[i] == n[0][2]){
			ctr[0][2]++;
		}
		else if(bing[i] == n[1][0]){
			ctr[1][0]++;
		}
		else if(bing[i] == n[1][1]){
			ctr[1][1]++;
		}
		else if(bing[i] == n[1][2]){
			ctr[1][2]++;
		}
		else if(bing[i] == n[2][0]){
			ctr[2][0]++;
		}
		else if(bing[i] == n[2][1]){
			ctr[2][1]++;
		}
		else if(bing[i] == n[2][2]){
			ctr[2][2]++;
		}
	}
	if(ctr[0][0]>0 && ctr[0][1]>0 && ctr[0][2]>0){
		printf("Yes\n");
	}
	else if(ctr[1][0]>0 && ctr[1][1]>0 && ctr[1][2]>0){
		printf("Yes\n");
	}
	else if(ctr[2][0]>0 && ctr[2][1]>0 && ctr[2][2]>0){
		printf("Yes\n");
	}
	else if(ctr[0][0]>0 && ctr[1][0]>0 && ctr[2][0]>0){
		printf("Yes\n");
	}
	else if(ctr[0][1]>0 && ctr[1][1]>0 && ctr[2][1]>0){
		printf("Yes\n");
	}
	else if(ctr[0][2]>0 && ctr[1][2]>0 && ctr[2][2]>0){
		printf("Yes\n");
	}
	else if(ctr[0][0]>0 && ctr[1][1]>0 && ctr[2][2]>0){
		printf("Yes\n");
	}
	else if(ctr[0][2]>0 && ctr[1][1]>0 && ctr[2][0]>0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

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


#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)   for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<ll, ll>
#define    mem(a)       memset(a,0,sizeof(a))
const ll mod = 1000000007;

void fio()
{
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("o.txt", "w", stdout);
#endif
}

template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
    double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
    time_taken *= 1e-9;
    cout << "\nExecuted in: " << fixed
         << time_taken << setprecision(9);
    cout << " sec";
#endif
}


void solve(){
    int n;
    cin>>n;
    int d1[n],d2[n];
    for(int i=0;i<n;i++)
        cin>>d1[i]>>d2[i];

    int c=0, mx=0;

    for(int i=0;i<n;i++){
        if(d1[i]==d2[i])
            c++;
        else c=0;

        if(c>mx)
            mx=c;
    }

    if(mx>=3)
        cout<<"Yes";
    else cout<<"No";

}   


int main()
{
    //auto start = chrono::high_resolution_clock::now();
    boost;
    fio();
    ll t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    //auto end = chrono::high_resolution_clock::now();
    //TIME(start, end);
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
  string S; cin>>S;
  int N=0; // こたえ
  int K=S.size();
  if(K%2==0){
    for(int i=0; i<K/2; i++){
      if(S.at(i)!=S.at(K-i-1))
         N++;
         else continue;
         }
         }
         else {
           for(int i=0; i<(K-1)/2; i++){
              if(S.at(i)!=S.at(K-i-1))
         N++;
         else continue;
                 }
                 }
                 cout<<N<<endl;
                 }


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

int main(){
    int N,X,Y;
    cin >> N >> X >> Y;
    vector<int>dp(N+1);
    vector<int>cnt(N);
    // dp[1]=0;
    // dp[X]=X-1;
    // dp[Y]=X;
    // for(int i=1;i<=N;i++){
    //     dp[i]=min(i-1,dp[Y]+abs(Y-i));
    // }
    for(int i=1;i<=N-1;i++){
        for(int j=i+1;j<=N;j++){
            ll d = min(abs(j-i),abs(i-X)+1+abs(Y-j));
            cnt[d]++;
        }
    }
    for(int i=1;i<N;i++){
        cout << cnt[i] << endl;
    }
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  char a[n], b[n], c[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) cin >> c[i];

  int cnt = 0;
  for (int i = 0; i < n; i++)
  {
    if (a[i] == b[i] && b[i] == c[i])
      continue;
    else if (a[i] == b[i] || a[i] == c[i] || b[i] == c[i])
      cnt++;
    else
      cnt += 2;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
typedef pair<ll, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<ll> vll;
const int MN = 1e3+5, MOD=1e9+7;
int lcm (int a, int b) {return a*b/__gcd(a,b);}
ll multiplyMod(ll a, ll b) { return (a % MOD * b % MOD) % MOD; }
ll addMod(ll a, ll b) { return (a % MOD + b % MOD) % MOD; }
ll subMod(ll a, ll b) { return (a % MOD - b % MOD) % MOD; }
string S;
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> S;
    if (S == "SUN") {
        cout << 7 << "\n";
    }
    else if (S == "SAT") {
        cout << 1 << "\n";
    }
    else if ( S == "MON") {
        cout << 6 << "\n";
    }
    else if (S == "TUE") {
        cout << 5 << "\n";
    }
    else if (S == "WED") {
        cout << 4 << "\n";
    }
    else if (S == "THU") {
        cout << 3 << "\n";
    } 
    else {
        cout << 2 << "\n";
    }
    

}

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

int main(){
    
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    vector<int> nx(n);
    vector<int> ny(m);
    for(int i=0; i<n; i++){
        cin >> nx.at(i);
    }
    for(int i=0; i<m; i++){
        cin >> ny.at(i);
    }
    sort(nx.begin(),nx.end(),greater());
    sort(ny.begin(),ny.end());
    for(int z=x+1; z<=y; z++){
        if(nx.at(0) < z && z <= ny.at(0)){
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
}

Measured memory_bytes: 3632
program snack
  implicit none
  integer(8) :: a, b
  read(*,*) a, b
  write(*,'(i0)') lcm(a,b)
contains
  integer(8) function lcm(a,b)
    integer(8), intent(in) :: a, b
    lcm = a/gcd(a,b)*b
  end
  integer(8) function gcd(a,b)
    integer(8), intent(in) :: a, b
    integer(8) :: x, y
    x = max(a,b)
    y = min(a,b)
    do while (y > 0_8)
      gcd = y
      y = mod(x,y)
      x = gcd
    end do
  end
end program snack

Measured memory_bytes: 768
a, b, c, x, y = [int(_) for _ in input().split()]
ans = 0
if a + b <= 2*c:
    ans = a * x + b * y
else:
    if x <= y:
        ans += x * 2 * c
        if b <= 2*c:
            ans += (y-x) * b
        else:
            ans += (y-x) * 2 * c
    else:
        ans += y * 2 * c
        if a <= 2*c:
            ans += (x-y) * a
        else:
            ans += (x-y) * 2 * c
print(ans)

Measured memory_bytes: 3064
//subset sum problem

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define pb push_back
ll mod1=pow(10,9)+7;
int mod2=998244353;
ll inf=1e9;
ll maxxy=1e6+9;
typedef long double ld;
const double PI =  3.141592653589793238;

ll power(ll x, ll y, ll pp)
{
    ll res = 1;
    x = x % pp;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % pp;
        y = y>>1;
        x = (x*x) % pp;
    }
    return res;
}

ll modInverse(ll n, ll pp)
{
    return power(n, pp-2, pp);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,W;
    cin>>n>>W;
    vector<ll> w(n),v(n);
    for (int i = 0; i <n ; ++i) {
        cin>>w[i]>>v[i];
    }
    ll dp[W+1][n+1];
    for (int i = 0; i <=W ; ++i) {
        for (int j = 0; j <=n ; ++j) {
            if(i==0 || j==0){
                dp[i][j]=0;
            }
            else{
                dp[i][j]=dp[i][j-1];
                if(i-w[j-1]>=0){
                    dp[i][j]=max(dp[i][j],v[j-1]+dp[i-w[j-1]][j-1]);
                }
            }
        }
    }
    cout<<dp[W][n]<<"\n";
    return 0;
}


Measured memory_bytes: 82400
#include <iostream>
#include <sstream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <iomanip>
#include <functional>
#include <array>
#include <climits>
#include <cmath>

using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;

int main()
{
    const int C_MAX = 30;
    ll a[C_MAX];
    for (ll i = 0; i < C_MAX; i++)
    {
        a[i] = 0;
    }
    ll n, m;
    cin >> n >> m;
    for (ll i = 0; i < n; i++)
    {
        ll k;
        cin >> k;
        for (ll j = 0; j < k; j++)
        {
            ll x;
            cin >> x;
            a[x - 1]++;
        }
    }
    ll num = 0;
    for (ll i = 0; i < m; i++)
    {
        if (a[i] >= n) num++;
    }

    cout << num;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }


int main() {
	ll A,B;
	cin >> A >> B;
	cout << (A+B)%24 << endl;
	cin >> A;
	return 0;
}

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

using namespace std;

long long ans = -999999999999;
int a[25];
int N;
bool F[100][11];
long long P[100][11];

void func(void) {
	long long  sco = 0;
	bool abc = false;
	for(int i=0;i<N;i++){
		int abcd = 0;
		for(int j =0;j<10;j++) {
          
			if (a[j] == 1)abc = true;
          
			if (F[i][j] == 1)if (a[j] == 1)abcd++;
		}
		sco += P[i][abcd];
	}
  
	if(abc)ans = max(ans, sco);
}
void dfs(int pos) {
	if (pos == 10) {
		func();
		return;
	}
	a[pos] = 0; dfs(pos + 1);
	a[pos] = 1; dfs(pos + 1);
}
int main() {
	cin >> N;
	for(int i=0;i<N;i++){
      for( int j=0;j<10;j++)cin >> F[i][j];
    }
	for(int i=0;i<N;i++){
      for(int j=0;j<11;j++)cin >> P[i][j];
    }
  
	dfs(0);
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        k: u64,
        a: [u64; n],
        b: [u64; m],
    }
    let (a_cum, b_cum) = (cumsum(&a), cumsum(&b));
    let mut j = m;
    println!(
        "{}",
        a_cum
            .iter()
            .take_while(|&&x| x <= k)
            .enumerate()
            .map(|(i, &aci)| {
                while j > 0 && aci + b_cum[j] > k {
                    j -= 1;
                }
                i + j
            })
            .max()
            .unwrap_or(0)
    );
}

fn cumsum(a: &Vec<u64>) -> Vec<u64> {
    std::iter::once(&0)
        .chain(a.iter())
        .scan(0, |cum, &x| {
            *cum += x;
            Some(cum.to_owned())
        })
        .collect()
}


Measured memory_bytes: 12668
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int N;
    int L;
    int tmp;
    int sum_a=0;
    int sum_b=200000;
    vector<int> Ap;

    cin >> N >> L;

    for(int i=0;i<N;i++){
        tmp = L+i;
        sum_a += tmp;
        Ap.push_back(tmp);
    }

    for(int i=0;i<N;i++){
        tmp = sum_a - Ap[i];
        if(abs(sum_a-tmp)<abs(sum_a-sum_b)){
            sum_b = tmp;
        }
    }
    cout<<sum_b<<endl;

    return 0;

}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li n,d;

    cin>>n>>d;

    d=d*d;

    li x[n],y[n];

    vi v;

    f(i,0,n-1)
    {
        cin>>x[i]>>y[i];

        v.PB(x[i]*x[i]+y[i]*y[i]);
    }

    sort(v.B,v.E);

    cout<<(upper_bound(v.B,v.E,d)-v.B);
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 8164
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,a,b,c,i,j;
    string str;
    set<long long int>se;
    cin>>n>>m;
    for(i=1; i<=m; i++)
    {
        cin>>a;
        for(j=1; j<=a; j++)
        {
            cin>>c;
            se.insert(c);
        }
    }
  cout<<n-se.size()<<endl;
}



Measured memory_bytes: 3652
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] & s[1] == s[2]) {
		cout << "No" << endl;
		return 0;
	}
	if (
		s[0] == s[1] && s[2] == s[3] ||
		s[0] == s[2] && s[1] == s[3] ||
		s[0] == s[3] && s[1] == s[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 998244353

N = int(input())
XY = [[int(x) for x in input().split()] for _ in range(N)]
XY.sort() # X ascending
X,Y = zip(*XY)
Y_rank = {x:i for i,x in enumerate(sorted(Y),1)}

def BIT_update(tree,x):
    while x <= N:
        tree[x] += 1
        x += x & (-x)

def BIT_sum(tree,x):
    ret = 0
    while x:
        ret += tree[x]
        x -= x & (-x)
    return ret

pow2 = [1]
for _ in range(N):
    pow2.append(pow2[-1] * 2 % MOD)

answer = 0
tree = [0] * (N+1)
for L,(x,y) in enumerate(XY):
    y = Y_rank[y]
    R = N - 1 - L
    D = y - 1
    U = N - 1 - D
    LD = BIT_sum(tree,y)
    BIT_update(tree,y)
    LU = L - LD
    RD = D - LD
    RU = R - RD
    # bounding box が自分自身を含むような集合を数える
    # 全体から引く
    cnt = pow2[N]
    cnt -= pow2[L]
    cnt -= pow2[R]
    cnt -= pow2[D]
    cnt -= pow2[U]
    cnt += pow2[LD]
    cnt += pow2[LU]
    cnt += pow2[RD]
    cnt += pow2[RU]
    cnt -= 1
    answer += cnt

answer %= MOD

print(answer)


Measured memory_bytes: 178216
N=int(input())
inlis=[int(i) for i in input().split()]
csum=[0]*(N+1)
for i, v in enumerate(inlis, start=1): csum[i] = csum[i-1] + v
i, k = 1, 3
resmin = 9223372036854775807
for j in range(2, N-1):
    while abs((csum[i]-csum[0]) - (csum[j]-csum[i])) > abs((csum[i+1]-csum[0]) - (csum[j]-csum[i+1])): i += 1
    while abs((csum[k]-csum[j]) - (csum[N]-csum[k])) > abs((csum[k+1]-csum[j]) - (csum[N]-csum[k+1])): k += 1
    resmin = min(resmin, max(csum[i]-csum[0], csum[j]-csum[i], csum[k]-csum[j], csum[N]-csum[k]) - min(csum[i]-csum[0], csum[j]-csum[i], csum[k]-csum[j], csum[N]-csum[k]))
print(resmin)


Measured memory_bytes: 25676
n=int(input())
s=str(input())

alp=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
l=[]
for i in range(n):
    x=s[:i]
    y=s[i:]
    c=0
    for j in alp:
        if (j in x) and (j in y):
            c+=1
    l.append(c)
print(max(l))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int N, A, B;
	cin >> N >> A >> B;

	cout << min(B, A*N) << endl;

	return 0;
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
m=a,b,c
if a>b:
    m=b,a,c
    if a>c:
        m=b,c,a
        if b>c:
            print(c,b,a)
        else:
            print(b,c,a)
    else:
        print(b,a,c)
else:
    m=a,b,c
    if b>c:
        print(a,c,b)
    else:
        print(a,b,c)


Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Main bst = new Main();
		int ops = in.nextInt();
		while (in.hasNextLine()) {
			String[] holder;
			holder = in.nextLine().split(" ");
			
			if (holder[0].equals("insert")) {
				bst.insert(bst, new Node(Integer.parseInt(holder[1])));
			}
			else if (holder[0].equals("print")) {
				bst.print();
			}
			else if (holder[0].equals("find")) {
				if (bst.find(bst, Integer.parseInt(holder[1])) != null) {
					System.out.println("yes");
				}
				else {
					System.out.println("no");
				}
			}
			else if (holder[0].equals("delete")) {;
				bst.delete(Integer.parseInt(holder[1]));
			}
		}
		
		
	}
	
	Node root;
	
	public Main() {
		root = null;
	}
	
	public void delete(int k) {
		recurDel(this.root, k);
	}
	
	private Node recurDel(Node r, int k) {
		if (k < r.key) { // if k is less than the current root, then it must be in the left half. So we recur there
			r.left = recurDel(r.left, k);			
		}
		else if (k > r.key) {
			r.right = recurDel(r.right, k);
		}
		else { // In the else case, k must be equal to the value of the root
			if (r.left == null) { // If it has no left child, then just return the right side without the node
				return r.right;
			}
			else if (r.right == null) { // Same idea as before
				return r.left;
			}
			
			// Otherwise, the node has two children. So we pick the successor as the minimum of the right subtree and copy the value
			// Then we will delete the old leaf containing the value
			Node succ = r.right;
			while (succ.left != null) {
				succ = succ.left;
			}
			r.key = succ.key;
			r.right = recurDel(r.right, r.key);
		}
		return r;
	}
	
	public Node find(Main T , int k) {
		Node result = null;
		Node curr = T.root;
		while (curr != null) {
			if (k == curr.key) {
				result = curr;
				return result;
			} 			
			else if (k < curr.key) {
				curr = curr.left;
			} else {
				curr = curr.right;
			}
		}
		return result;
	}
	
	public void insert(Main T, Node z) {
		Node y = null;
		Node x = T.root;
		
		while (x != null) {
			y = x;
			if (z.key < x.key) {
				x = x.left;
			}
			else {
				x = x.right;
			}
		}
		z.p = y;
		
		if (y == null) {
			T.root = z;
		}
		else if (z.key < y.key) {
			y.left = z;
		}
		else {
			y.right = z;
		}
	}
	
	public String inOrder(Node z) {
		String result = "";
		if (z == null) {
			return result;
		}
		else {
			return inOrder(z.left) + " " + z.key + inOrder(z.right); 
		}
	}
	
	public String preOrder(Node z) {
		String result = "";
		if (z == null) {
			return result;
		}
		else {
			return " " + z.key + preOrder(z.left) + preOrder(z.right); 
		}
	}
	
	public void print() {
		System.out.println(this.inOrder(root));
		System.out.println(this.preOrder(root));
	}
}



class Node {
	int key; // Key of the node
	Node p; // Parent of the node
	Node left; // Left child
	Node right; // Right child
	
	public Node(int val) {
		key = val;
		p = null;
		left = null;
		right = null;
	}
	
	public String toString() {
		return key + "";
	}
	
	
}




Measured memory_bytes: 587940
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    if(n%2)cout<<b[n/2]-a[n/2]+1<<endl;
    else cout<<b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1<<endl;
    return 0;
}

Measured memory_bytes: 5152
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    ans = 0
    M = -1
    for _ in range(N):
        p = int(input())
        ans += p
        if p > M:
            M = p
    print(ans - M // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
N, K, Q = map(int,input().split())

A = [int(input()) for _ in range(Q)]

Point = [ 0 for _ in range(N)]

if K-1 >= Q:
    for _ in range(N):
        print("Yes")

else:
    for a in A:
        Point[a-1] += 1

    for p in Point:
        if K - Q + p > 0:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 8636
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, right = 0, sum = 0, ans = 0;
    cin >> N;
    vector<int64_t> A(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    for (int64_t left = 0; left < N; left++) {

        while(right < N && sum + A.at(right) == (sum ^ A.at(right))){
            sum += A.at(right);
            right++;
        }
        
        ans += right - left;
        if (right == left) {
            right++;
        }
        else {
            sum -= A.at(left);
        }
    }
    cout << ans << endl;
}


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

bool isConnected(int s, int t, vector<pair<int, int>> a) {
	for (int i = 0; i < a.size(); ++i) {
		if ((s == a[i].first and t == a[i].second) or (s == a[i].second and t == a[i].first)) {
			return true;
		}
	}
	return false;
}

bool isPath(vector<int> n, vector<pair<int, int>> p) {
	for (int i = 0; i < n.size() - 1; ++i) {
		if (!isConnected(n[i], n[i + 1], p)) {
			return false;
		}
	}
	return true;
}

signed main() {
	int n, m, cnt = 0;
	cin >> n >> m;

	vector<pair<int, int>> p(m);
	vector<int> num;

	for (int i = 1; i <= n; ++i) {
		num.push_back(i);
	}

	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		p[i] = make_pair(a, b);
	}

	do {
		if (isPath(num, p)) cnt++;
	} while (next_permutation(num.begin() + 1, num.end()));


	cout << cnt << endl;
}



Measured memory_bytes: 256
#include<stdio.h>

int digit(int i){
    if(i == 0)return 0;
    int sum = 1;
    while(i/10 != 0){
        i = i/10;
        sum++;
    }
    return sum;
}

int main(){
    int a,b;
    while(scanf("%d %d",&a,&b) != EOF){
        printf("%d\n",digit(a+b));
    }
    return 0;
}

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

int main() {
  int D, G; cin >> D >> G;
  vector<int> p(D), c(D); for (int i = 0; i < D; i++) cin >> p[i] >> c[i];

  int ans = 1001;
  for (int b = 0; b < 1 << D; b++) {
    int sum = 0, score = 0, partial = -1;
    for (int i = 0; i < D; i++) {
      if (b & 1 << i) {
        sum += p[i];
        score += 100 * (i + 1) * p[i] + c[i];
      } else partial = i;
    }

    if (score < G) {
      for (int i = 1; i < p[partial]; i++) {
        sum++, score += 100 * (partial + 1);
        if (score >= G) break;
      }
    }

    if (score >= G) ans = min(sum, ans);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN2(a,b);
  Yes(a%2==1 && b%2==1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    # define LL long long
    # define int long long
    #define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    # define mo 998244353
    # define pi acos(-1)
    //vector<pair<int,int>> v;
    //int x0=INT_MAX,y0=INT_MAX;
    /*int crossprod(pair<int,int> a,pair<int,int> b,pair<int,int> c)
    {
        int x1 = a.first-b.first;
        int x2 = a.first-c.first;
        int y1 = a.second-b.second;
        int y2 = a.second-c.second;
        return x1*y2 - y1*x2;
    }
    int direction(pair<int,int> a,pair<int,int> b,pair<int,int> c) {
       int val = (b.y-a.y)*(c.x-b.x)-(b.x-a.x)*(c.y-b.y);
       if (val == 0)
          return 0;     //colinear
       else if(val < 0)
          return 2;    //anti-clockwise direction
          return 1;    //clockwise direction
    }*/
   vector<int> v[102];
    signed main(){
        gok
        int n,m;
    cin>>n>>m;
   cout<<(n*(n-1))/2 + (m*(m-1))/2;



        return 0;
    }


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

int main() {
  int n;
  while(cin >> n && n) {
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    for(int i = 1; i < n; ++i) {
      a[i] += a[i-1];
    }
    a.insert(a.begin(), 0);
    int res = INT_MIN;
    for(int i = 0; i < n; ++i) {
      for(int j = i+1; j <= n; ++j) {
	int tmp = a[j]-a[i];
	res = max(res, tmp);
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/

int main(){
    int N,K; cin>>N>>K;
    double ans=0;
    for(int i=1; i<=N; i++){
        double p=1.0/N;
        int x=i;
        while(x<K){
            x*=2;
            p/=2;
        }
        ans+=p;
    }
    cout<<fixed<<setprecision(13)<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int search(int);

int S[100000], n = 0;
int main(){
  int m = 0, q = 0, left = 0, right = 0, mid = 0;
  int i = 0, j = 0, cnt = 0;
  int T[50000];

  /*Input S[N]*/
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }
  
  /*Input T[N]*/
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&T[i]);
  }

  /*Search*/
  for(i = 0; i < q; i++){
    m = search(T[i]);
    if(m != n)cnt++;
  }
  /*Print*/
  printf("%d\n",cnt);

  return 0;
}

int search(int key){
  int mid = 0, left = 0, right = 0;
  
  left = 0;
  right = n;
  
  while(left < right){
    mid = (left + right)/2;
    if(S[mid] == key){
      return mid;
    }
    else if(key < S[mid]){
      right = mid;
    }
    else if(key > S[mid]){
      left = mid + 1;
    }
  }
  return n; 
}



Measured memory_bytes: 2380
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;
 

int main()
{
	fastio
  ll n, m;
  cin >> n >> m;
  if(n&1)
  {
    for(int i=1; i<=m; i++) cout << i << " " << n-i+1 << "\n";
    return 0;
  }
  int cnt=0, p=0, q=n-2, ind=1;
  while(p<q && cnt<m)
  {
    cout << ind << " " << n-ind+1 << "\n";
    p+=2, q-=2;
    ind++;
    cnt++;
  }
  int rem = m - cnt;
  int r = ind+rem*2;
  while(rem>0)
  {
    cout << ind << " " << r << " " << "\n";
    ind++;
    r--;
    rem--;
  }

	return 0;
}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    int H, N;
    cin >> H >> N;
    vint A(N), B(N);
    int Amax = 0;
    rep(i, N)
    {
        cin >> A[i] >> B[i];
        Amax = max(Amax, A[i]);
    }
    vint dp(H + Amax + 1, INT_MAX);
    dp[0] = 0;
    rep2(i, 1, H + Amax + 1)
    {
        int Min = INT_MAX / 2;
        rep(j, N)
        {

            if (i - A[j] >= 0)
            {
                Min = min(Min, dp[i - A[j]] + B[j]);
            }
        }
        dp[i] = Min;
    }

    int ans = INT_MAX;
    rep2(i, H, H + Amax)
    {
        ans = min(ans, dp[i]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
import sys
def main():

    n=int(input())
    p=list(map(int,input().split()))
    s=1
    p=sorted(p)
    for i in p:
        s*=i
        if i==0:
            print(0)
            sys.exit()
        elif s>=10**18+1:
            print(-1)
            sys.exit()
    print(s)

if __name__ == '__main__':
    main()

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  int t;
  t = a;
  a = b;
  b = t;
  t = c;
  c = a;
  a = t;

  cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
def main():
  n = int(input())
  p = list(input_list())
  dp = p[:]
  count = 0
  skip = False
  for i, v in enumerate(p):
    if skip:
      skip = False
      continue
    if i+1 == v:
      if i + 1 > len(p) - 1:
        count += 1
        continue
        
      count += 1
      skip = True
  print(count)
  
def input_list():
  return map(int, input().split())

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c 

import math
import fractions
from functools import reduce
main()

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = line[0], B = line[1];

            if (8 >= A && 8 >= B)
                Console.WriteLine("Yay!");
            else
                Console.WriteLine(":(");
        }
    }
}

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

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n = 0;
    cin >> n;
    vector<int> dp(3, 0);

    for(int i = 0; i < n; i++) {
        vector<int> c(3, 0);
        vector<int> new_dp(3, 0);
        for(int i = 0; i < 3; i++) {
            cin >> c[i];
        }

        for(int i = 0; i < 3; i++) {
            for(int j = 0; j < 3; j++) {
                if(i != j) {
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
                }
            }
        }
        dp = new_dp;
    }

    cout << *max_element(dp.begin(), dp.end()) << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    void InsertSort(int arr[],int n);
    void show(int arr[],int n);
    int n;
    cin>>n;
    int *arr = new int[n+1];
    for(int i = 0;i<n;i++)
        cin>>arr[i];
    show(arr,n);
    InsertSort(arr,n);
    return 0;
}
void show(int arr[],int n)
{
    for(int i = 0;i< n;i++)
    {
        cout<<arr[i];
        if(i<n-1)
            cout<<" ";
    }
    cout<<endl;
}
void InsertSort(int arr[],int n)
{
    int temp,j;
    for(int i = 1;i<n;i++)//下标是从0开始！
    {
        temp = arr[i];
        j = i - 1;
        while(j>=0&&arr[j]>temp)
        {
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = temp;
        show(arr,n);
    }
}



Measured memory_bytes: 3104
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#define MOD 1000000007
#define oo 987654321
#define INT long long
using namespace std;

INT n, a, s[110], dt[60][3000][60][2];

INT dp(int x, int y, int z)
{
    if( x == n ) return (bool)(y && (y%z==0 && y/z==a));
    if( dt[x][y][z][1] ) return dt[x][y][z][0];
    dt[x][y][z][1] = 1;
    INT &ret = dt[x][y][z][0] = 0;
    return ret = (dp(x+1, y, z) + dp(x+1, y+s[x], z+1));
}

int main()
{
    scanf("%lld%lld", &n, &a);
    for(int i = 0 ; i < n ; i++ ) scanf("%d", s+i);
    printf("%lld\n", dp(0, 0, 0));
    return 0;
}




Measured memory_bytes: 29568
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

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

int n, m;
Graph G;

int main(void) {
    cin >> n >> m;
    G.resize(n);

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist(n,-1);
    int start = 0;
    dist[start] = 0;
    queue<int> que;
    vector<int> pre(n,0);
    que.push(start);

    while(!que.empty()) {
        int v = que.front();
        que.pop();
        for(int nv : G[v]) {
            if(dist[nv] != -1) continue;
            dist[nv] = dist[v] +1 ;
            pre[nv] = v;
            que.push(nv);
        }
    }

    cout << "Yes" << endl;
    rep(i, n) {
        if( i == 0 ) continue;
        cout << pre[i] + 1<< endl;
    }

    return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

vector< int > z_algorithm(const string &s) {
  vector< int > prefix(s.size());
  for(int i = 1, j = 0; i < s.size(); i++) {
    if(i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      int k = max(0, j + prefix[j] - i);
      while(i + k < s.size() && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int) s.size();
  return prefix;
}

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

  vector< string > S(N);
  cin >> S;

  vector< bitset< 10001 > > reach(N + 1);
  reach.back().set(K);
  for(int i = N - 1; i >= 1; --i) {
    reach[i] = reach[i + 1] | (reach[i + 1] >> S[i].size());
  }

  bitset< 10001 > dp;
  dp[0] = true;

  string ans;
  for(int i = 0; i < N; ++i) {

    vector< int > d = z_algorithm(S[i] + ans);
    for(int j = 0; j <= ans.size() && j + S[i].size() <= K; ++j) {
      int t = (j == ans.size() ? 0 : d[S[i].size() + j]);

      if(dp[j] && reach[i + 1][j + S[i].size()] && (j == ans.size() || (t < S[i].size() && ans[j + t] > S[i][t]))) {
        for(int l = j + t + 1; l <= ans.size(); ++l) dp[l] = false;
        ans = ans.substr(0, j) + S[i];
        dp[j + S[i].size()] = true;
        break;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3968
n, m = list(map(int, input().split()))
a = [0] * m
b = [0] * m
for i in range(m):
    a[i], b[i] = list(map(int, input().split()))

road = [0] * n

for i in range(m):
    road[a[i] - 1] += 1
    road[b[i] - 1] += 1

for i in range(n):
    print(road[i])

Measured memory_bytes: 3064