akhauriyash/Code-Regression huggingface dataset:
#include <atcoder/fenwicktree>
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    atcoder::fenwick_tree<int64_t> bit(n);
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        bit.add(i, t);
    }
    while (q--) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            bit.add(u, v);
        } else {
            cout << bit.sum(u, v) << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 8252
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
//#define int long long
using namespace std;
const int maxn=5e5+1000;
typedef long long ll;
int n,m;
const int mod=998244353;
int fr[maxn],ans;
inline int ksm(int num,int t){
	int res=1;
	for(;t;t>>=1,num=1ll*num*num%mod){
		if(t&1)res=1ll*res*num%mod;
	}
	return res;
}
inline int c(int m,int n){
	return 1ll*fr[n]*ksm((1ll*fr[m]*fr[n-m])%mod,mod-2)%mod;	
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	fr[0]=fr[1]=1;
	for(int i=2;i<maxn;i++)fr[i]=1ll*fr[i-1]*i%mod;	
	for(int i=0;i<=min(n,m);i++){
		ans=(ans+1ll*ksm(-1,i)*(1ll*c(i,n)*c(i,m)%mod*fr[i]%mod*ksm(m+1,n-i)%mod*ksm(n+1,m-i)%mod)%mod)%mod;	
	}
	ans=(ans%mod+mod)%mod;
	cout<<ans;
	return 0;
}//

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

int main() {
    string s;
    cin >> s;
    stringstream ss;
    int n = s.size();
    vector<int> countx(1);
    rep(i, n) {
        if (s.at(i) == 'x') {
            countx.back()++;
        }
        else {
            ss << s.at(i);
            countx.push_back(0);
        }
    }
    string x = ss.str();
    reverse(x.begin(), x.end());
    
    if (ss.str() != x) {
        cout << -1 << endl;
        return 0;
    }
    
    int ans = 0;
    rep(i, countx.size()) {
        ans += abs(countx.at(i) - countx.at(countx.size()-1-i));
    }
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 4156
def gcd(x, y):
    if y == 0: return x
    return gcd(y, x%y)

def factorize(n):
    i = 2
    factors = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            factors.append(i)
        i += 1
    if n > 1:
        factors.append(n)
    return factors


a, b = map(int, input().split())

g = gcd(a, b)
ans = set(factorize(g))

print(len(ans)+1)

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, x;
	cin >> n >> x;
	vector<int> v;
	v.push_back(x);
	for (int i = 0; i < n; i++)
		cin >> x, v.push_back(x);
	sort(v.begin(), v.end());
	int g = 0;
	for (int i = 1; i < v.size(); i++)
		g = __gcd(g, v[i] - v[i - 1]);
	cout << g << endl;
	return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
Int sx[40][40];
Int sy[40][40];
Int used[4][40][40];

signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n;
  while(cin>>n,n>=0){
    memset(sx,0,sizeof(sx));
    memset(sy,0,sizeof(sy));
    memset(used,0,sizeof(used));
    for(Int i=0;i<n;i++){
      char d;
      Int x,y;
      cin>>d>>x>>y;
      x*=4;y*=4;
      if(d=='x'){
	for(Int k=0;k<4;k++) sx[y][x+k]=1;
      }
      if(d=='y'){
	for(Int k=0;k<4;k++) sy[y+k][x]=1;
      }
    }
    
    Int dy[]={1,1,-1,-1};
    Int dx[]={1,-1,1,-1};
    Int y=1,x=3,d=0;
    
    auto in=[&](Int y,Int x){
      return 0<=y&&y<=32&&0<=x&&x<=32;
    };
    
    while(1){
      if(used[d][y][x]){
	y=1;x=3;
	break;
      }
      //cout<<d<<":"<<y<<" "<<x<<endl;
      used[d][y][x]=1;
      Int ny=y+dy[d],nx=x+dx[d];
      if(!in(ny,nx)) break;
      if(sx[ny][nx]) d^=2;
      if(sy[ny][nx]) d^=1;
      y=ny;x=nx;
    }

    cout<<x*25<<" "<<y*25<<endl;
  }
  return 0;
}



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

#define REP(i, n) for(int i = 0; i < (int) n; ++i)
const int MOD = 1e+9 + 7;
long long ans, K;

void dfs(int pos, int par, int color, vector<vector<int>>& G){
    REP(i, G[pos].size()){
        int v = G[pos][i];
        if(i == 0) color = K-2;
        if(v != par){ 
            ans *= color;
            ans %= MOD;
            dfs(v, pos, color--, G);
            //cout << pos << " " << par << " " << v << " " << ans << endl;
        }
    }
}

int main()
{
    int N;
    cin >> N >> K;
    vector<vector<int>> G(N);
    REP(i, N-1){
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<int> q;
    ans = K;
    REP(i, G[0].size()){
        ans *= K-(i+1);
        ans %= MOD;
        q.push(G[0][i]);
    }

    while(!q.empty()){
        int tmp = q.front();
        q.pop();
        dfs(tmp, 0, K-2, G);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 10368
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <algorithm>
#include <cmath>

using namespace std;

int a[200010];

int main() {
  int N;
  scanf("%d",&N);

  long long sum = 0;

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

  long long ans = LLONG_MAX;
  long long x = 0;

  for(int i=0;i<N-1;++i) {
    x += a[i];
    ans=min(ans,abs(sum-x*2));
  }

  printf("%lld", ans);

  return 0;
}


Measured memory_bytes: 896
function Main(input){
    const XY = input.split(' ').map(Number);
    for(let i=0; i<=XY[0]; i++){
        for(let k=0; k<=XY[0]; k++){
            if(i+k > XY[0]) break;
            if(2*i + 4*k == XY[1] && i+k==XY[0]){
                console.log("Yes");
                return;
            }
        }
    }
    console.log("No");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
  long long int a,b,c;
  cin >> a >> b >> c;
  if(c-a-b<0){
    cout << "No" << endl;
  }else if(a*a+b*b+c*c-2*a*b-2*b*c-2*c*a>0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
using System;

namespace ITP1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int m = int.Parse(input[1]);
            int l = int.Parse(input[2]);
            ulong[,] A = new ulong[n, m];
            ulong[,] B = new ulong[m, l];
            ulong[,] C = new ulong[n, l];
            for (int i = 0; i < n; i++)
            {
                string[] a = Console.ReadLine().Split(' ');
                for (int j = 0; j < m ; j++)
                {
                   A [i, j] = ulong.Parse(a[j]);                  
                }
            }
            for (int i = 0; i < m; i++)
            {
                string[] b = Console.ReadLine().Split(' ');
                for (int j = 0; j < l; j++)
                {
                    B [i, j] = ulong.Parse(b[j]);
                }
            }
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < l; j++)
                {
                    for (int k = 0; k < m; k++)
                    {
                        C[i, j] += A[i, k] * B[k, j];
                    }
                    Console.Write(C[i,j]);
                    if (j == l - 1) Console.WriteLine();
                    else Console.Write(" ");
                }
            }

        } 
    }
}

Measured memory_bytes: 9660
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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; }

int main() {

    ll x;
    cin >> x;
    ll cnt = 0;
    eFOR1(i, x) {
        cnt += i;
        if (cnt >= x) {
            cout << i << endl;
            return 0;
        }
    }
}


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

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

Measured memory_bytes: 3572
from array import *
import time
h, w, a, b = map(int, input().split(' '))
MOD = 10**9 + 7
MAX = max(h+w-a-1, a+w)


def modpow(a, b):
    res = 1
    while b:
        if (b & 1):
            res = (res * a) % MOD
        a = (a * a) % MOD
        b >>= 1
    return res


def nCr(n, r):
    if r == 0 or n == r:
        return 1
    return (((f[n] * ivf[n-r]) % MOD) * ivf[r]) % MOD


f = [1] * MAX
f = array('q', f)
ivf = [0] * MAX
ivf = array('q', ivf)
for i in range(1, MAX):
    f[i] = (f[i-1] * i) % MOD
    ivf[i] = modpow(f[i], MOD-2)
r = 0
for i in range(b, w):
    y1 = h - a - 1
    x1 = i
    y2 = a - 1
    x2 = w - i - 1
    p = (nCr(x1 + y1, x1) * nCr(x2 + y2, x2)) % MOD
    r = (r + p) % MOD
print(int(r))


Measured memory_bytes: 9812
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

x = ni()

print('Yes' if x >= 30 else 'No')

Measured memory_bytes: 9108
// https://atcoder.jp/contests/abc113/tasks/abc113_b
#include <bits/stdc++.h>
using namespace std;
using P = pair<double, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    double t, a;
    cin >> n >> t >> a;
    set<P> ans;
    REP(i, n) {
        double d;
        cin >> d;
        ans.insert({abs(a - (t - 0.006 * d)), i + 1});
    }
    cout << (*ans.begin()).second << endl;

    return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <complex>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

VS s;

int ccnt(char c) {
	int re = 0;
	rep(i, sz(s)) {
		re += count(all(s[i]), c) + count(all(s[i]), (char)(c - 32));
	}
	return re;
}

int main() {
	string t;
	while (cin >> t) {
		s.pb(t);
		//if (t == ".")break;
	}

	for (char c = 'a'; c <= 'z'; c++) {
		cout << c << " : " << ccnt(c) << endl;
	}
}


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

using namespace std;
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(_x)		cerr << #_x << '=' << (_x) << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << (_x) << ' ' << #_y << '=' << (_y) << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << (_x) << ' '; cerr << endl;

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;

int32_t main() {
	FAST_IO;
	
//	freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);

	int x;
	cin >> x;
	
	int s = 100;
	int cnt = 0;
	while (s < x) {
		s += s/100;
		
		cnt++;
	}
	
	cout << cnt << endl;
	
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n, r, p, c;
		int[] x, y;
		while(true){
			n = sc.nextInt();
			r = sc.nextInt();
			if(n == 0 && r == 0)
				break;
			else if(n < 1 || n > 50 || r < 1 || r > 50){
				System.out.println("Error");
				continue;
			}
			else{
				x = new int[n];
				y = new int[n];
				for(int i = 0; i < n; i++)
					x[i] = n - i;
				for(int i = 0; i < r; i++){
					while(true){
						p = sc.nextInt();
						c = sc.nextInt();
						if(p + c <= n + 1)
							break;
						else
							System.out.println("Error");
					}
					shuffle(x, y, n, r, p, c);
				}
			}
			System.out.println(x[0]);
		}
	}
	static void shuffle(int[] x, int[] y, int n, int r, int p, int c){
		for(int i = 0; i < p+c-1; i++)
			y[(i+c)%(p+c-1)] = x[i];
		for(int i = 0; i < p+c-1; i++)
			x[i] = y[i];
	}
}

Measured memory_bytes: 28336
// Aizu Vol-6 0609: Christmas Party
// 2017.9.5 bal4u@uu

#include <stdio.h>

int a[103], s[103];

int main()
{
	int n, m, i, j, k, x;

	scanf("%d%d", &n, &m);
	for (i = 1; i <= m; i++) scanf("%d", a+i);
	for (i = 1; i <= m; i++) {
		for (x = 0, j = 1; j <= n; j++) {
			scanf("%d", &k);
			if (k == a[i]) s[j]++;
			else x++;
		}
		s[a[i]] += x;
	}
	for (j = 1; j <= n; j++) printf("%d\n", s[j]);
	return 0;
}

Measured memory_bytes: 1804
#include <bits/stdc++.h>
using namespace std;
const int N = 3E2;
int n, k, p;
int dp[N + 2], c[N + 2][N + 2], sum[N + 2];
void inc(int &x, int y) {(x += y) >= p ? x -= p : 0;}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k >> p;
    for (int i = 0; i <= N + 1; ++i) {
        c[i][0] = 1;
        for (int j = 1; j <= i; ++j)
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % p;
    }
    for (int r = k; r >= 0; --r) {
        memset(dp, 0, sizeof(dp));
        dp[1] = 1;
        for (int i = 1; i <= n; ++i)
            for (int s = 1; i + s <= n + 1; ++s)
                inc(dp[i + s], 1LL * dp[i] * sum[s] % p * c[i + s - 2][s - 1] % p);
        for (int s = 1; s <= n + 1; ++s)
            inc(sum[s], dp[s]);
    }
    cout << dp[n + 1] << endl;
    return 0;
}

Measured memory_bytes: 640
from collections import defaultdict
import bisect

n = int(input())
s = input()
S = []
cnt_ch = defaultdict(list)
for i in range(n):
    S.append(s[i])
    cnt_ch[s[i]].append(i)
    
    
    
    
q = int(input())
for i in range(q):
    qw = input()
    if qw[0] == "1":
        qw = qw[2:]
        i, ch = map(str, qw.split())
        if S[int(i) - 1] == ch:
            continue
        remove = bisect.bisect_left(cnt_ch[S[int(i) - 1]], int(i) - 1)
        del cnt_ch[S[int(i) - 1]][remove]
        S[int(i) - 1] = ch
        if not cnt_ch[ch]:
            cnt_ch[ch].append(int(i) - 1)
            continue
        bisect.insort_left(cnt_ch[ch], int(i) - 1)
        
        
    else:
        #print(cnt_ch)
        qw = qw[2:]
        l, r = map(int, qw.split())
        cnt = 0
        for i in range(ord("a"),ord("a") + 26):
            if not cnt_ch[chr(i)]:
                continue
            edge = bisect.bisect_left(cnt_ch[chr(i)], l - 1)
            #print(cnt_ch[chr(i)][edge - 1:])
            #if bisect.bisect_left(cnt_ch[chr(i)][edge:], i) < r:
            #print(cnt_ch[chr(i)])
            #print(l, r)
            #print(edge)
            if edge < len(cnt_ch[chr(i)]):
                if cnt_ch[chr(i)][edge] < r:
                    cnt += 1
            #print(cnt, "cnt", chr(i))
        print(cnt)
        
        


Measured memory_bytes: 105560
#include <iostream>
#include <string> 
using namespace std;
int main()
{
	string a,b;
    cin >> a >> b;
    if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0])
		cout << "YES" << endl;
    else 
		cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        String s = sc.next();
        String t = sc.next();

        System.out.println(subCount(n, s, t));

    }

    private static int subCount(int n,String s, String t) {
        for (int i = 0; i < n; i++) {
            if (s.substring(i, n).equals(t.substring(0, n-i))) {
                return n + i;
            }
        }
        return 2 * n;
    }
}

Measured memory_bytes: 9684
#include<stdio.h>
int main(void)
{
  int a, b, c, d, n, m, ans;
  scanf("%d %d", &a, &b);
  scanf("%d %d", &c, &d);
  ans=a*b-a*d-b*c+d*c;
  printf("%d", ans);
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n)cin >> a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int alice=0, bob=0;
  rep(i,n){
    if(i%2==0)alice+=a[i];
    else bob+=a[i];
  }
  cout << alice-bob << endl;
  return 0;
}


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

char a[110];

int main(){
    int n;
    cin>>n;
    cin>>a;
    if(n==1){
        cout<<"No";
        return 0;
    }
    string s1="", s2="";
    for(int i=0; i < n; i++){
        s1 += a[i];
        s2 = "";
        for(int j = i+1; j < n; j++){
            s2+=a[j];
        }
        if(s1==s2){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<string.h>
#include<iostream>
#include<algorithm>
int a[1005];
using namespace std;
int main(){
	int n,m;
	int sum=0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		sum+=a[i];
	}
	sort(a,a+n,greater<int>()); 
	
	
	int time=0;
	for(int i=0;i<n;i++){
		if(a[i]>=sum/float(4*m)){
			time++;
		}
	}
	if(time>=m)cout<<"Yes";
	else cout<<"No";
	
	
	
	
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    vector<VI> A(N,VI(M));
    REP(i,N) REP(j,M){
        cin >> A[i][j];
        A[i][j]--;
    }

    VI se(M);
    REP(i,M){
        se[i] = 1;
    }
    int ans = INF;
    if(M==1){
        cout << N << endl;
        return 0;
    }
    REP(i,M-1){
        VI cnt(M);
        REP(j,N){
            REP(k,M){
                if(se[A[j][k]] == 1){
                    cnt[A[j][k]]++;
                    break;
                }
            }
        }
        int tmax = -1;
        int arg = -1;
        REP(j,M){
            if(cnt[j] > tmax){
                arg = j;
                tmax = cnt[j];
            }

        }
        ans = min(tmax, ans);
        se[arg] = 0;
    }
    cout << ans << endl;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
int arr[MAX];
int cs[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,mx=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    for(int i=2;i<=n;i++){
        if(arr[i]<=arr[i-1])
            cs[i]=cs[i-1]+1;
        mx=max(mx,cs[i]);
    }
    cout<<mx<<endl;


     return 0;
}


Measured memory_bytes: 4364
#include <stdio.h>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    int N;
    scanf("%d", &N);

    int D, X;
    scanf("%d %d", &D, &X);

    int ans = 0;
    int A = 0;
    REP(0, i, N) {
        ans += 1;
        scanf("%d", &A);
        ans += (D - 1) / A;
    }

    ans += X;

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

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const ll LINF=1e18;
const int MOD=1e9+7;
//const int MOD=998244353;

int main(){
	int n; cin>>n;
	ll a[52];
	FOR(i,0,n) cin>>a[i];
	int q=10000;
	ll k=0;
	while(q--){
		int flag=true;
		FOR(i,0,n){
			if(a[i]>=n){
				flag=false;
				k+=a[i]/n;
				FOR(j,0,n){
					if(i!=j) a[j]+=a[i]/n;
				}
				a[i]-=(a[i]/n)*n;
			}
		}
		if(flag) break;
	}
	co(k);
}


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

using namespace std;

#define IO ios_base::sync_with_stdio(0);cin.tie(0);

int main()
{
  IO;
  int n, m, k; cin >> n >> m >> k;
  vector <vector <int>> a(n + 1, vector <int> (m + 1));
  a[0][0] = 0;
  for (int j = 1; j <= m; ++j)
    a[0][j] = a[0][0] + (n * j);

  for (int i = 1; i <= n; ++i)
  for (int j = 0; j <= m; ++j)
    a[i][j] = a[0][j] + (m - j) * i - i * j;

  for (auto elem : a)
  for (auto elem1 : elem)
    if (elem1 == k)
    {
      cout << "Yes" << endl;
      return 0;
    }
  cout << "No" << endl;

  return 0;
}

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

int main() {
  	int L, R, D;
  	cin >> L >> R >> D;
  	int count = 0;
  	for (int i = L; i <= R; i++){
      	if (i % D == 0) count++;
    }
  
  	cout << count << endl;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	//vector<vector<int>>path(m, vector<int>(2));
	vector<int>a(n+1,0);
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		a.at(x)++;
		a.at(y)++;
	}
	for (int i = 2; i <= n; i++) {
		if (a.at(i) % 2 == 1) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
int n, a[3], t;
double p[305][305][305];
double solve(int a, int b, int c){
	if(a < 0 || b < 0 || c < 0 || a + b + c == 0) return 0;
	if(p[a][b][c] > 0) return p[a][b][c];
	return p[a][b][c] = (n + solve(a-1,b,c)*a + solve(a+1,b-1,c)*b + solve(a,b+1,c-1)*c) / (a+b+c);
}
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", &t);
		a[t-1]++;
	}
	printf("%.10lf\n", solve(a[0],a[1],a[2]));
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();

    cout << s[0] << n - 2 << s[n - 1] << endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int>P(N);
    vector<string>S(N);
    for (int i = 0; i < N; ++i) {
      cin >> S[i] >> P[i];
    }
    vector<tuple<string, int, int>> v;
    for (int i = 0; i < N; ++i) {
        v.push_back(make_tuple(S[i], P[i] * -1, i+1));
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < N; ++i) {
        cout << get<2>(v[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	int n, k, i, j, a[101] = { 0 },num=0,m,q;
	scanf("%d%d", &n, &k);
	for (i = 0; i < k; i++)
	{
		scanf("%d", &m);
		for (j = 0; j < m; j++)
		{
			scanf("%d", &q);
			a[q] = 1;
		}
	}
	for (i = 0; i <= 100; i++)
	{
		num += a[i];
	}
	printf("%d", n - num);
	return 0;
}

Measured memory_bytes: 1724
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false); cin.tie(0)
#define int long long
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF (int)1e18

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

signed main() {
  int n = read();
  if(n >= 30) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 3620
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char S[102];
char T[102];
int N;
int main(){
  int i, j;
  N = rd(S);
  rd(T);
  for(i=0;i<(N);i++){
    for(j=0;j<(N);j++){
      if(S[j]!=T[(i+j)%N]){
        break;
      }
    }
    if(j==N){
      break;
    }
  }
  if(i==N){
    wt_L("No");
    wt_L('\n');
  }
  else{
    wt_L("Yes");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// char S[102], T[102];
// int N;
// {
//   int i, j;
//   rd(S@N,T);
//   rep(i,N){
//     rep(j,N) if(S[j]!=T[(i+j)%N]) break;
//     if(j==N) break;
//   }
//   wt( if[i==N, "No", "Yes"] );
// }


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S;
int nex[202020][26];
int ne[26];
int len[202020],ta[202020];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	N=S.size();
	
	FOR(i,26) ne[i]=nex[N+1][i]=N+1;
	for(i=N;i>=0;i--) {
		len[i]=202020;
		FOR(j,26) {
			nex[i][j]=ne[j];
			x = len[ne[j]];
			if(x<len[i]) {
				len[i]=x;
				ta[i]=j;
			}
		}
		len[i]++;
		if(i) ne[S[i-1]-'a']=i;
	}
	
	string R;
	int cur=0;
	while(cur!=N+1) {
		R+='a'+ta[cur];
		cur=nex[cur][ta[cur]];
	}
	
	cout<<R<<endl;
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 22420
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int x, n; cin >> x >> n;
    vector<int> p(n);
    rep(i,n){
        cin >> p[i];
        p[i]-= x;
    }
    sort(all(p));
    
    if(n==0){
        cout << x << ln;
        return 0;
    }
    
    int mn = p[0]-1;
    rep(i,n-1){
        if(p[i]+1 != p[i+1] && abs(mn) > abs(p[i]+1)){
            while(p[i]+1 != p[i+1]){
                p[i]++;
                if(abs(mn) > abs(p[i])) mn = p[i];
            }
        }
    }
    
    if(abs(mn) > abs(p.back()+1)) mn = p.back() + 1;

    cout << mn + x << ln;
    return 0;
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

const int mx = 3000;
const ll inf = 9e18;

struct node {
    int u;
    ll coin;
    ll tm;
};

bool operator<(node a, node b) {
    return a.tm > b.tm;
}

ll c[60], d[60];
vector <node> adj[60];

int main() {
    int a_max = 0;
    int n, m; ll s; scanf("%d %d %lld", &n, &m, &s);
    for (int i = 0; i < m; i++) {
        int u, v, a; ll b;
        scanf("%d %d %d %lld", &u, &v, &a, &b);
        adj[u].push_back({v, a, b});
        adj[v].push_back({u, a, b});
        a_max = max(a_max, a);
    }

    a_max *= (n - 1);
    // printf("%d\n", a_max);

    for (int i = 1; i <= n; i++) {
        scanf("%lld %lld", &c[i], &d[i]);
    }

    if (s >= a_max) {
        vector <ll> dist(n + 2, inf);
        dist[1] = 0;
        
        priority_queue <node> pq;
        pq.push({1, s, 0});

        while (!pq.empty()) {
            auto u = pq.top();
            pq.pop();

            if (dist[u.u] != u.tm) continue;
            for (auto v : adj[u.u]) {
                int new_dist = dist[u.u] + v.tm;
                if (new_dist < dist[v.u]) {
                    dist[v.u] = new_dist;
                    pq.push({v.u, s, new_dist});
                }
            }
        }

        for (int i = 2; i <= n; i++) {
            printf("%lld\n", dist[i]);
        }

        return 0;
    }

    vector < vector <ll> > dist;
    for (int i = 0; i < 60; i++) dist.emplace_back(vector <ll> (mx, inf));
    dist[1][s] = 0;
    priority_queue <node> pq;
    pq.push({1, s, 0});

    while (!pq.empty()) {
        auto u = pq.top();
        pq.pop();

        if (u.coin >= mx) continue;
        ll txx = dist[u.u][u.coin];
        if (txx < u.tm) continue;
        // printf("%d %lld\n", u.u, u.coin);
        for (auto v : adj[u.u]) {
            ll cn = u.coin;
            ll t = txx;
            while (cn < min(2 * a_max, mx)) {
                if (cn >= v.coin) {
                    ll& tyy = dist[v.u][cn - v.coin];
                    ll new_dist = t + v.tm;
                    if (new_dist < tyy) {
                        tyy = new_dist;
                        pq.push({v.u, cn - v.coin, new_dist});
                    }
                }

                cn += c[u.u];
                t += d[u.u];
            }
        }
    }

    for (int i = 2; i <= n; i++) {
        ll ans = inf;
        for (int j = 0; j < mx; j++) ans = min(ans, dist[i][j]);
        printf("%lld\n", ans);
    }
}

Measured memory_bytes: 53976
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)


	int h, w;



int check(int i, int j, vector<vector<char>> t)
{
	int bom = 0;
	if (i > 0)			if ('#'	== t[i - 1][j] ) bom++;
	if (i<h-1)			if ('#' == t[i + 1][j]) bom++;
	if (j > 0)			if ('#' == t[i][j-1]) bom++;
	if (j < w - 1)		if ('#' == t[i][j+1]) bom++;
	if (j>0&&i>0)		if ('#' == t[i - 1][j-1]) bom++;
	if (j>0&&i<h-1)		if ('#' == t[i + 1][j-1]) bom++;
	if (j <w-1 && i>0)	if ('#' == t[i - 1][j + 1]) bom++;
	if (j <w-1&&i<h-1)	if ('#' == t[i + 1][j + 1]) bom++;


	return bom;
}
int main(void)
{


	cin >> h >> w;


	vector<vector<char>> t(h, vector<char>(w));

	rep(i, h)
	{
		rep(j, w)
		{
			char a;
			cin >> a;

			t[i][j] = a;
		}
	}


	rep(i, h)
	{
		rep(j, w)
		{
			if (t[i][j] == '.') cout << check(i, j, t);
			if (t[i][j] == '#') cout << "#" ;

		}
		cout << endl;
	}

}


Measured memory_bytes: 256
#[allow(unused_imports)]
use {
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::ops::*,
};

#[fastout]
fn main() {
    input! {
        n: Bytes,
    }
    let mut m = 0;
    for x in n {
        m += x as usize - b'0' as usize;
        m %= 9;
    }
    if m == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin >> n >>m;
  vector<string> A;
  vector<string> B;
  string a,b;
  REP(i,n){
    cin >> a;
    A.push_back(a);
  }
  REP(i,m){
    cin >> b;
    B.push_back(b);
  }
  REP(i,n-m+1)REP(j,n-m+1){
    bool ok = true;
    REP(k,m)REP(l,m){
      if (A[i+k][j+l] != B[k][l])ok = false;
    }
    if (ok){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
N = int(input())
ans = 0
if N ==1:
  print(1)
  exit()
else:
  for i in range(int(N**0.5)+1):
    for j in range(100):
      if i**j<=N:
        ans =max(ans,i**j)
      else:
        break
print(ans)
    

Measured memory_bytes: 3060
def b():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    max = 10**18
    if 0 in A:
        print(0)
        return

    for a in A:
        ans *= a
        if ans > max:
            print(-1)
            return

    print(ans)


##########
if __name__ == "__main__":
    b()


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

#define int long long
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);

const int N = 1e5 + 5 , MOD = 1e9 + 7;
int p[N] ,  dp[N][15] , n;
string s;

int solve(int id , int val)
{
	if(id == n + 1) return (val % 13 == 5);
	int &ans = dp[id][val];
	if(ans != -1)   return ans;
	ans = 0;
	if(s[id] == '?')
	{
		for(int i=0 ; i<=9 ; i++)
			ans = (ans + solve(id + 1 , (val + i*p[n-id])%13))%MOD;
	}
	else
	{
		ans = (ans + solve(id + 1 , (val + (s[id] -'0')*p[n-id])%13))%MOD;
	}
	return ans;
}
int32_t main(){
	fast;
	cin >> s;
	n = s.length();
	s = "0" + s;

	int x = 10;
	p[0] = 1;
	for(int i=1 ; i<N ; i++ , x = (x*10) %13)    p[i] = x%13;
	
	memset(dp , -1 , sizeof(dp));
	
	int ans = solve(0,0);
	cout << ans;
}







Measured memory_bytes: 19180
from itertools import accumulate
N=int(input())
A=[int(i) for i in input().split()]
A.sort()
B=list(accumulate(A))
c=0
for i in range(N-1):
    #print(B[i],A[i+1])
    if 2*B[i] >= A[i+1]:
        c+=1
    else:
        c=0
print(c+1)

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    string s;
    cin >> s;

    vector<int> suf(s.size() + 1);
    map<int, int> mp;
    suf.back() = (s.back() - '0');

    mp[0]++;
    mp[suf.back()]++;
    int init = 10;
    for (int i = s.size() - 1; i > 0; i--) {
        suf[i] = (suf[i + 1] + (s[i - 1] - '0') * init % 2019) % 2019;
        init *= 10;
        init %= 2019;
        mp[suf[i]]++;
    }
    int ans = 0;
    for (auto x: mp)
        ans += x.second * (x.second - 1) / 2;
    cout << ans << endl;
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 5136
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    int res=0;
    for(int i=0;i<=3030;i++){
        for(int j=0;j<=3030;j++){
            int k=n-r*i-g*j;
            if(0<=k&&k%b==0)res++;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
H = list(map(int,input().split()))
g = [[] for i in range(1,N+1)]
ans = 0
for i in range(M):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
for i in range(N):
    flag = 0
    for j in range(len(g[i])):
        if H[i] <= H[g[i][j]]:
            flag += 1
            break
    if flag == 0:
        ans += 1
print(ans)

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

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



Measured memory_bytes: 256
from collections import defaultdict

S = input()

D = defaultdict(int)
D[0] += 1
x = 0
d = 1
for s in reversed(S):
  x = (x + int(s) * d) % 2019
  D[x] += 1
  d = (d * 10) % 2019

print(sum(x * (x-1) // 2 for x in D.values()))

Measured memory_bytes: 9512
N = int(input())

m = 0
a = 0
r = 0
c = 0
h = 0

for i in range(N):
  s = input()
  if s[0] == 'M':
    m += 1
  if s[0] == 'A':
    a += 1
  if s[0] == 'R':
    r += 1
  if s[0] == 'C':
    c += 1
  if s[0] == 'H':
    h += 1

P = [0, 0, 0, 0, 0, 0, 1, 1, 1, 2]
Q = [1, 1, 1, 2, 2, 3, 2, 2, 3, 3]
R = [2, 3, 4, 3, 4, 4, 3, 4, 4, 4]

d = [m, a, r, c, h]

ans = 0
for i in range(10):
  ans += d[P[i]] * d[Q[i]] * d[R[i]]

print(ans)

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

using namespace std;

typedef long long ll;

class SegmentTree
{
public:
    vector<ll> data;
    const ll INF=1e18+10;
    int num;

    SegmentTree(int n)
    {
        data.resize(n*4);
        for(num=1;num<n;num<<=1);
        fill(data.begin(),data.end(),(1LL<<31)-1);
    }

    void update(int idx,ll x)
    {
        idx+=num-1;
        data[idx]=x;

        while(idx>0)
        {
            idx=(idx-1)/2;
            data[idx]=min(data[idx*2+1],data[idx*2+2]);
        }
    }

    ll query(int p,int l,int r,int a,int b)
    {
        if(a>=r||b<=l) return INF;

        if(a<=l&&r<=b) return data[p];

        int mid=(l+r)/2;
        return min(query(p*2+1,l,mid,a,b),query(p*2+2,mid,r,a,b));
    }
};

int main()
{
    int n,q;

    //freopen("out.txt","w",stdout);

    while(cin>>n>>q)
    {
        SegmentTree tree(n);

        for(int i=0;i<q;i++)
        {
            int op,l,r;
            cin>>op>>l>>r;

            if(op)
            {
                cout<<tree.query(0,0,tree.num,l,r+1)<<endl;
            }else
            {
                tree.update(l,r);
            }
        }
    }

    return 0;
}



Measured memory_bytes: 5920
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 666666666

ll A[17][17];
ll DP[1<<17];

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
        cin>>A[i][j];

    for(int i=0; i<(1<<n); i++)
    {
        bitset<17>b(i);
        for(int j=0; j<n; j++)
            for(int k=j+1; k<n; k++)
            if(b[j] && b[k])
            DP[i]+=A[j][k];

        int sub = i;
        while(sub)
        {
            sub = (sub-1)&i;
            //^so we go through all masks by doing sub-1
            //and because we only want sub-subset we do &subset
            //so unimportant bits get turned off
            //hence we loop only through required sub-subset (some repetition though but whatever)
            DP[i]=max(DP[i],DP[sub] + DP[sub^i]);
        }
    }

    cout<<DP[(1<<n)-1];
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b; cin >> a >> b;
  int ans = (a+b)%24;

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


Measured memory_bytes: 3604
#include <stdio.h>

int main(void)
{
	int t, i, n, s, f, sum;
	
	while (scanf("%d", &t), t != 0){
		sum = 0;
		
		scanf("%d", &n);
		for (i = 0; i < n; i++){
			scanf("%d %d", &s, &f);
			
			sum += f - s;
		}
		
		if (sum >= t){
			printf("OK\n");
		}
		else {
			printf("%d\n", t - sum);
		}
	}
	
	return (0);
}

Measured memory_bytes: 612
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
using namespace std;

int n,m,x,y,r,l,a[105],b[105];

int main(){
	cin >> n >> m >> x >> y;
	r = x; l = y;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		if(a[i] > r)
			r = a[i];
	}
	for(int i = 0;i < m;i++){
		cin >> b[i];
		if(b[i] < l)
			l = b[i];
	}
	if(r < l) cout << "No War" << endl;
	else cout << "War" << endl;
	return 0;
}

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

int main() {

	int n, k;
	cin >> n >> k;
	vector<double> p(n);
	rep(i, n)cin >> p[i];

	vector<double>e(n);
	rep(i, n) e[i] = (p[i] + 1) / 2;

	vector<double>es(n+1);
	es[0] = 0;
	rep(i, n) {
		es[i + 1] = es[i] + e[i];
	}

	double ans=0;
	rep(j, n - k + 1) {
		double sumk;
		sumk = es[k + j] - es[j];
		if (sumk > ans)ans = sumk;
	}

	cout << fixed << setprecision(6);
	cout << ans << endl;
}

Measured memory_bytes: 4992
N = int(input())
nlst =list()
for i in range(1,N+1):
    if i % 3 == 0:
        nlst.append(i)
    else:
        j = i
        while j > 1 :
            if j % 10 == 3 :
                nlst.append(i)
                break
            j = j//10
s = str()
for j in nlst:
    s += " " + str(j)
print(s)


Measured memory_bytes: 5836
#include <iostream>
using namespace std;
int main(){
  int N, MAX = 0, MIN = 1000000001;
  int A[110];
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> A[i];
    if (MAX < A[i]) MAX = A[i];
	if (MIN > A[i]) MIN = A[i];
  }
  cout << MAX - MIN << endl;
}


Measured memory_bytes: 256
import math
from fractions import Fraction
N, K = map(int, input().split())
ans = 0
for i in range(1, N + 1):
  if i >= K:
    ans += Fraction(1, N)
  else:
    ans += Fraction(1, N) * Fraction(1, 2) ** (math.ceil(math.log2(K / i)))
  
print(float(ans))

Measured memory_bytes: 10520
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
using namespace std;

int main(){
    int w, a, b;
    cin >> w >> a >> b;
    if((a <= b && b <= a+w) || (a <= b+w && b+w <= a+w )){
        cout << 0 << endl;
    }else if(a+w < b){
        cout << b-a-w << endl;
    }else if(b+w < a){
        cout << -(b+w-a) << endl;
    }
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
const int MAX=5100;
const int modn=1e9+7;
typedef long long ll ;
#define endl '\n'
#define cwk     freopen("D:\\workplace\\CLion\\in.in","r",stdin),freopen("D:\\workplace\\CLion\\out.out","w",stdout)
using namespace std;
ll n,k;
ll p[MAX],c[MAX];
ll maxnn[MAX];
vector<ll>v[MAX];
int main() {
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>p[i];
    }
    for(int i=1;i<=n;i++){
        cin>>c[i];
    }
    ll maxn=-INT_MAX;
    for(int i=1;i<=n;i++) {
        maxnn[i]=-INT_MAX;
        ll ans = 0;
        for (int j = p[i]; j != i; j = p[j]) {
            ans += c[j];
            v[i].push_back(ans);
            maxnn[i]=max(maxnn[i],ans);
        }
        v[i].push_back(ans + c[i]);
        maxnn[i]=max(maxnn[i],ans+c[i]);
        ll all=v[i][v[i].size()-1];
        int cnt=k;
        ll now=-INT_MAX;
        if(all<=0){
            now=maxnn[i];
        }else{
            for(int j=0;j<cnt%v[i].size();j++){
                now=max(now,v[i][j]);
            }
            if(k>=v[i].size()) {
                if (all - maxnn[i] + now < 0) {
                    now = maxnn[i] + (k / v[i].size() - 1) * all;
                } else {
                    now += k / v[i].size() * all;
                }
            }
        }
        maxn=max(maxn,now);
    }
    cout<<maxn;
    return 0;
}


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

int main()
{
    string S;
    cin >> S;
    int cnt=0;
    if (S=="RRR") cout <<3 << endl;
    if (S=="RSR"|| S=="RSS" || S=="SRS" || S=="SSR") cout << 1 << endl;
    if (S=="RRS" || S=="SRR") cout << 2 << endl;
    if (S=="SSS") cout << 0  << endl;
    return 0;

}

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int R;
	cin >> R;

	cout << R * 3.14159265358979 * 2;

	return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vi = vector<int>;
int main(){
    string S;
    cin >> S;
    for(int i = 0; i < 3; i++){
        cout << S.at(i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3624