akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;

int n, m;
vector<string> a(60);
vector<string> b(60);

bool match(int x, int y) {
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      if (a[x + i][y + j] != b[i][j]) return false;
    }
  }
  return true;
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> b[i];
  bool found = false;
  for (int i = 0; i <= n - m; i++) {
    for (int j = 0; j <= n - m; j++) {
      if (match(i, j)) found = true;
    }
  }
  if (found)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 100000000000
#define int long long int
#define hell (int)(1e9+7)

using namespace std;

vector <int> adj[2005];

vector < vector <int> > dp(2005,vector <int> (2005,0));
int n;

void bfs(int s){
    queue <int> q;
    vector <int> dist(n+1,-1);
    q.push(s);
    dist[s]=0;
    while(!q.empty()){
        int src=q.front();
        q.pop();
        for(int x:adj[src]){
            if(dist[x]==-1){
                dist[x]=1+dist[src];
                q.push(x);
            }
        }
    }
    for(int i=1;i<=n;i++)
        dp[s][dist[i]]++;
}

void solve(){
    int x,y;
    cin>>n>>x>>y;
    for(int i=1;i<n;i++){
        adj[i].push_back(i+1);
        adj[i+1].push_back(i);
    }
    adj[x].push_back(y);
    adj[y].push_back(x);
    for(int i=1;i<=n;i++)
        bfs(i);
    for(int i=1;i<n;i++){
        int ans=0;
        for(int j=1;j<=n;j++)
            ans+=dp[j][i];
        cout<<ans/2<<"\n";
    }
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 31872
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long	int n;
	cin>>n;
long long	int sum=n*(n+1)/2;
long long	int x1=n/3;
	x1=3*(x1)*(x1+1)/2;
long long	int x2=n/5;
	x2=5*(x2)*(x2+1)/2;
long long	int f=n/15;
	f=15*f*(f+1)/2;
	f=x1+x2-f;
	sum=sum-f;
	cout<<sum;
	
}

Measured memory_bytes: 3532
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000
#define EMPTY -10
#define mp(a, b) make_pair(a,b)

bool resuelveCaso() {
	string s, t;
	cin >> s;
	if (!cin) return false;
	cin >> t;

	map<char, char> biy, bij;
	bool pos = true;
	for (int i = 0; i < s.size(); ++i) {
		if (biy.find(s[i]) == biy.end()) {
			biy.insert(mp(s[i], t[i]));
		}
		else {
			if (biy[s[i]] != t[i]) {
				pos = false;
				break;
			}
		}

		if (bij.find(t[i]) == bij.end()) {
			bij.insert(mp(t[i], s[i]));
		}
		else {
			if (s[i] == bij[t[i]]) {}
			else {
				pos = false;
				break;
			}
		}
	}

	if (pos)cout << "Yes\n";
	else cout << "No\n";

	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    while (true) {
        int m, t, p, r;
        cin >> m >> t >> p >> r;
        if (m == 0)break;

        vector<vector<int>> solved(t, vector<int>(3));
        for (int i = 0; i < t; i++)solved[i] = {0, 1145141919, i};
        vector<vector<int>> penalty(t, vector<int>(p));
        for (int i = 0; i < r; i++) {
            int a, b, c, d;
            cin >> a >> b >> c >> d;
            b--;
            c--;
            if (d == 0) {
                solved[b][0]++;
                solved[b][1] -= a + penalty[b][c] * 20;
            } else {
                penalty[b][c]++;
            }
        }

        sort(solved.begin(), solved.end(), greater<>());

        for (int i = 0; i < t - 1; i++) {
            cout << solved[i][2] + 1;
            if (solved[i][0] != solved[i + 1][0] || solved[i][1] != solved[i + 1][1])cout << ",";
            else cout << "=";
        }
        cout << solved[t - 1][2] + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3040
# -*- coding: utf-8 -*-
n, k = map(int,input().split())
p = [int(i) for i in input().split()]

ans = 0
tmp = 0
for i in range(k):
    tmp2 = (p[i] * (1 + p[i])) // 2
    #print(tmp2)
    ans += tmp2 / p[i]
    tmp = ans
#print(ans)
for i in range(n - k):
    tmp3 = (p[i] * (1 + p[i])) // 2
    tmp4 = (p[i + k] * (1 + p[i + k])) // 2
    tmp = tmp + (tmp4 / p[i + k]) - (tmp3 / p[i])
    #print(p[i], p[i + k], tmp)
    #print(p[i], sum([i for i in range(1, p[i] + 1)]) / p[i])
    #print(p[i + k], sum([i for i in range(1, p[i + k] + 1)]) / p[i + k])
    if tmp > ans:
        ans = tmp
print(ans)


Measured memory_bytes: 25188
#if 1

#include <bits/stdc++.h>
using namespace std;
long long a[405],d[405][405],sum[405];
int n;

int main()
{
    scanf("%d",&n);
    for(int i = 1;i <= n;i++)
    {
        scanf("%lld",&a[i]);
        sum[i] = sum[i-1]+a[i];
    }
    for(int i = n;i >= 1;i--)
    {
        for(int j = i+1;j <= n;j++)
        {
            d[i][j] = 9000000000000000000;
            for(int k = i;k <= j;k++)
            {
                d[i][j] = min(d[i][j],d[i][k]+d[k+1][j]+sum[j]-sum[i-1]);
            }
            //cout << d[i][j] << " ";
        }
        //cout << '\n';
    }
    printf("%lld",d[1][n]);
}

#endif // 1++


Measured memory_bytes: 1536
/*
AizuOnline A2424
Title Kakezan
13/08/06 
*/
#include <stdio.h>
//Global data section
int Q,N;
int histoty[1000000];


//
int power_10(int x)
{
        if(x<=0)
                return(1);
        return(10*power_10(x-1));
} 
int ketasuu (int num)
{
        if(num < 10)
                return(1);
        else
                return(1+ketasuu(num/10));
}
int sousa(int num)
{
        int i,len,ret,maxret,p10,m1,m2;

        maxret=0;
        len=ketasuu(num);
        for(i=0;i<len-1;i++)
        {
                p10=power_10(1+i);
                m1=num / p10;
                m2=num % p10;
                ret=m1*m2;
                if(ret > maxret)
                        maxret=ret;
        }       
#ifdef DEBUG
        printf("MAXRET=%d\n",maxret);
#endif
        return(maxret);
}
int solve(int num,int cnt)
{
        if(num<10)
                return(cnt);
        return(solve(sousa(num),1+cnt));
}

main()
{
        int i,ret;

        scanf("%d",&Q);
        for(i=0;i<Q;i++)
        {
                scanf("%d",&N);
                ret=solve(N,0);
                printf("%d\n",ret);
        }
return(0);
}

Measured memory_bytes: 604
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)

	int cnt[26];
	int current[26];
int main(){
	ll n;
	cin>>n;
	string s[55];
	rep(i,0,n)cin>>s[i];
	rep(i,0,s[0].size()){
		int x=s[0][i]-'a';
		cnt[x]++;
	}
	rep(i,1,n){
		rep(j,0,s[i].size()){
			int x=s[i][j]-'a';
			current[x]++;
		}
		rep(i,0,26)cnt[i]=min(cnt[i],current[i]);
		memset(current,0,sizeof(current));
	}
	rep(i,0,26){
		while(cnt[i]>0){
			char x=i+'a';
			cout<<x;
			cnt[i]--;
		}
	}
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())
j = 0

if a >= b:
    a, b = b, a

ans = [0] * a

for i in range(1, a + 1):
    if a % i == 0 and b % i == 0:
        ans[j] = i
        j = j + 1

ans.sort(reverse = True)
print(ans[k - 1])

Measured memory_bytes: 3316
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k==x:
        ans+=1
print(ans)

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b;
    cin>>a>>b;
    for (int i=0;i<1000000;i++){
        if((i*8)/100==a and (i*10)/100==b){
            cout<<i<<"\n";
            return 0;
        }
    }
    cout<<-1<<"\n";
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>

int main()
{
    std::string alphabet("abcdefghijklmnopqrstuvwxyz");

    std::string input;

    std::cin >> input;

    if (alphabet.find(input) != std::string::npos)
    {
        std::cout << 'a' << std::endl;
    }
    else
    {
        std::cout << 'A' << std::endl;
    }
}

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

int main() {
    int N, L;
    cin >> N >> L;
    vector <string> Sset;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        Sset.push_back(s);
        s.clear();
    }
    sort(Sset.begin(), Sset.end());
    string answer;
    
    for (int i = 0; i< N; i++) {
        answer += Sset[i];
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
X, K, D = map(int, input().split())
X = abs(X)

k = X // D
if abs(X - k * D) <= abs(X - (k + 1) * D):
    best_k = k
else:
    best_k = k + 1

if K < best_k:
    print(abs(X - K * D))
elif (K - best_k) % 2 == 0:
    print(abs(X - best_k * D))
else:
    print(min(abs(X - best_k * D + D), abs(X - best_k * D - D)))


Measured memory_bytes: 9188
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[344];
int N,n,m;
int vis[344] , match[344];
bool bpm( int u ){
	for(int i = 0;i<adj[u].size();i++){
		if(!vis[adj[u][i]]){
			vis[adj[u][i]]=1;
			if(match[adj[u][i]]<0||bpm( match[adj[u][i]])){
				match[adj[u][i]]=u;
				match[u]=adj[u][i];
				return true;
			}
		}
	}
	return false;
}
int main(){
	int e;
	cin>>n>>m>>e;
	N=m+n;
	for(int i =0;i<e;i++){
		int x, y;
		cin>>x>>y;
		adj[x].push_back(y+n);
		adj[y+n].push_back(x);
	}
	for(int i = 0;i<N;i++){
		match[i]=-1;
	}	
	int res =0;
	for(int  i = 0;i<N;i++){
		if((match[i]<0)){
			memset(vis, 0 , sizeof(vis));
			if(bpm(i))
				res =res+1;
		}
	}
	cout<<res<<"\n";

	
}


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

int main() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

int main() {
    int N;
    cin >> N;
    vector<set<int>> edge(N);
    vector<int> c(N);
    for(int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[a].insert(b);
        edge[b].insert(a);
    }
    for(auto &x : c) cin >> x;
    sort(REV_WHOLE(c));
    cout << accumulate(WHOLE(c), -c[0]) << endl;
    vector<i64> ans(N);
    queue<pair<int, int>> q;
    q.push({0, 0});
    int j = 0;
    while(q.size()) {
        int prev, cur;
        tie(cur, prev) = q.front(); q.pop();
        ans[cur] = c[j];
        for(auto next : edge[cur]) {
            if(next == prev) continue;
            q.push({next, cur});
        }
        j++;
    }
    for(int i = 0; i < N; i++) {
        cout << (i ? " " : "") << ans[i];
    }
    cout << endl;
    return 0;
}

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

using namespace std;
const int mod = 1e9 + 7;

void add_self(int &a, int b)
{
    a += b;

    if(a >= mod)
        a -= mod;
}

int dif(int x)
{
    if(x < 0)
        x += mod;

    return x;
}

int main()
{
    int n;
    string s;

    cin >> n;
    cin >> s;

    vector<int>dp(n + 1);

    dp[1] = 1;
    for(int l = 2; l <= n; l++)
    {
        vector<int>new_dp(n + 1);

        for(int i = 1; i < l; i++)
            add_self(dp[i], dp[i - 1]);

        for(int b = 1; b <= l; b++)
        {
            int L, R;

            if(s[l - 2] == '<')
            {
                L = 1;
                R = b - 1;
            }
            else
            {
                L = b;
                R = l - 1;
            }

            if(L <= R)
                add_self(new_dp[b], dif(dp[R] - dp[L - 1]));
        }

        dp = new_dp;
    }

    int answer = 0;
    for(int i = 1; i <= n; i++)
        add_self(answer, dp[i]);

    cout << answer;

    return 0;
}


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

namespace Algorithm
{
    class Program
    {
        const int ShopCount = 10;
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var openTimes = new int[N][];
            var prices = new int[N][];
            for (var i = 0; i < N; i++)
                openTimes[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (var i = 0; i < N; i++)
                prices[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var res = -(int.MaxValue);
            for (var bit = 1; bit < (1 << ShopCount); bit++)
            {
                var cc = 0;
                for (var i = 0; i < N; i++)
                {
                    var c = 0;
                    for (var j = 0; j < ShopCount; j++)
                    {
                        if ((bit & (1 << j)) != 0 && openTimes[i][j] == 1) c++;
                    }
                    cc += prices[i][c];
                }
                res = Math.Max(cc, res);
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13396
/*MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWO:,'..'xXWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMO. .:kOo.,kNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMO. .lNWWo..lXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MNOxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxMMMMWKxoloxKWNc  .:xxd;  ,dxxxkXMXkxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxMM
MKc''''''''''''''''.  ..'''''.   .''''.  .''MMMWx..,:. .xXo''.  .''.  ..'';kMk;'''''.  .'.''.  .''''''.  ..''.   .''MM
MWNXNNNNNNNNNNNNNNNO' ;KNNNNNKo. cKNNNd. lXNMMMK; ,0Wx. :NWXXl .dNNO' ;KNNNWMWNNNNNXc .kNNNNx. cXNNNNNO' ;KNN0; 'ONNMM
MMMMMMMMMMMMMMMMMWM0' :NMMMMWMX: .OMWWx. oWMMMMWx. ';. .dNMWWo .xMM0' :NWWMMMMMMMMWWl .OMMMWk. lWWMMWM0' ;XMMX: ,KMMMM
MMMMMMWMWkccccccccc;. :NMWNNNKd. :XMMWx. oWMMMWKo. .',. .,ldx; .dMM0' :NMMMMMMMNNWMWl .OMMMWk. lWMMMMM0' ;XMMX: ,0MMMM
MMWXKNWMWxcc,. .;cc;. :XMk,''..'lKWMMWx. oWMNx:. .lONNKxl.     .xMM0' :NMMMMMM0:,oKO' ,KMMMMk. lWWNkoc,. .;::;. ,KMMMM
MMXc.lXMMWWWNd..xWM0' :NM0;  ;kXWMMMWNl  oWMK:.;xXWWMWXx:. ,c' .dMM0' :NMMMMMMKc. ...;kWMMMMk. lWWc .:;. .clc:. ,KMMMM
MWWx. lXMWMMMK, lWM0' :NMMNx'.,ldxxoc'   oWMWNKNWWWN0o' .:kNWo .dMM0' :NMMMMMMMNO;  ,OWWWMMMk. lWM' lXx. lNMMX: ,KMMMM
MMMWk'.,xKNX0c..kWM0' :NMMMMNkl;,'',:l:  oWMMMMMWMWO' 'l0WMWWo .xMM0' :NMMMMMMMMMNd. .oXWMMMk. lWMd.....;0WMMX: ,KMMMM
MMMMWKo'...'..:kWMM0' :NMMMMMMMWWNNWWWx. oWMMMMMMMMWOxXWMWMWWo .xMM0' :NMMMMMMMMMMMKl. ,kNMMk. lWMWKkxx0NMWMMX: ,KMMMM
MMMMMMMN0kxk0XNWMMWKl;xNMMMMMMMMMMMMWM0c;kWMMMMMMMMMMMWWMMMMWk;:OMMXl,dNMMMMMMMMMMMMWO; .dNM0c;kWWMMMMMMMMMMMNd,oXMMMM
MMMMMMMMWWMWMMMMMMMMMWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWWMMWWMMWMMMMMMMMMMMMMMNkxKWMMWWMMMMMMMMMMMMMMWMMWMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM*/

//             Author: Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)                  //


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;

#define         TESTCASES()    cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define         _input(V3C)    for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define   mems(A77AY, V4LU)    memset((A77AY), (V4LU), sizeof((A77AY)))
#define    CH3K(I7, E4, S7)    (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define   for4(I7,S4,E4,S7)    for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))



void solveEachTest(lld T35TC453N = 1) {
	vector<int> arr(3);
	_input(arr);

	sort(arr.begin(), arr.end());

	if (arr[0] == 5 and arr[1] == 5 and arr[2] == 7) {
		cout << "YES";
	} else {
		cout << "NO";
	}

	cout << "\n";

	return;
}


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

	lld T3X0 = 0, T353 = 1;

	// TESTCASES()
	solveEachTest(T353 - T3X0);
	return 0;
}
// Random Thought :  null

Measured memory_bytes: 3556
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x=[0]*M
y=[0]*M
c=[0]*M
xyc=[0]*M
for i in range(M):
  x[i],y[i],c[i] = map(int,input().split())
  xyc[i]=a[x[i]-1]+b[y[i]-1]-c[i]
  
ans1=min(xyc)
ans2=min(a)+min(b)

print(min(ans1,ans2))

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

template <uint MD> struct ModInt {
    using M = ModInt;
    uint v;
    ModInt() : v{0} {}
    ModInt(ll _v) { set_v(_v % MD + MD); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M(0) - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(ull(v) * r.v % MD); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return (*this).pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<TEN(9) + 7>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;
    int n, q;
    cin >> n >> q;
    V<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];

    using P = pair<int, int>;
    V<P> qu(q);
    for (int i = 0; i < q; i++) {
        cin >> qu[i].first >> qu[i].second;
        qu[i].first--; qu[i].second--;
    }

    VV<Mint> dp(n, V<Mint>(n));
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            dp[i][j] = Mint(1);
        }
    }
    Mint i2 = Mint(2).inv();
    for (int ph = q-1; ph >= 0; ph--) {
        int a = qu[ph].first, b = qu[ph].second;
        if (a > b) swap(a, b);
        dp[a][b] = i2;
        for (int i = 0; i < a; i++) {
            Mint x = dp[i][a], y = dp[i][b];
            dp[i][a] = (x + y) * i2;
            dp[i][b] = (y + x) * i2;
        }
        for (int i = a + 1; i < b; i++) {
            Mint x = dp[a][i], y = dp[i][b];
            dp[a][i] = (x + (Mint(1) - y)) * i2;
            dp[i][b] = (y + (Mint(1) - x)) * i2;
        }
        for (int i = b + 1; i < n; i++) {
            Mint x = dp[a][i], y = dp[b][i];
            dp[a][i] = (x + y) * i2;
            dp[b][i] = (y + x) * i2;
        }
    }

    Mint sm = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (v[i] > v[j]) sm += dp[i][j];
            else if (v[i] < v[j]) sm += Mint(1) - dp[i][j];
        }
    }

    cout << sm * Mint(2).pow(q) << endl;
    return 0;
}

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

using namespace std;

int n;
int k;
vector<int> values;

int f(int i) {
	vector<int> tmp;

	for (int next : values) {
		tmp.push_back(next % i);
	}

	sort(tmp.begin(), tmp.end());

	int used = 0;
	int p1 = 0;
	int p2 = tmp.size() - 1;

	while (p1 < p2) {
		int toRemove = tmp[p1];
		int toAdd = i - tmp[p2];

		if (toRemove == toAdd) {
			used += toAdd;
			tmp[p1] = 0;
			tmp[p2] = i;
			p1++;
			p2--;
		} else if (toRemove < toAdd) {
			tmp[p1] = 0;
			tmp[p2] += toRemove;
			p1++;
			used += toRemove;
		} else {
			tmp[p1] -= toAdd;
			tmp[p2] = i;
			p2--;
			used += toAdd;
		}
	}

	return (used > k) ? -1 : i;

	/*while (p1 < p2 && used < k) {
		used += tmp[p1];		
		tmp[p2] -= tmp[p1];
		tmp[p1] = 0;
		if(tmp[p2] == 0){
			p1++;
			p2--;
		}
		else if(tmp[p2] < 0){
			tmp[p1] -= tmp[p2];
			p2--;
		}	
	}*/

	//return (tmp[p1] == 0 && tmp[p2] == 0) ? i : -1;
}


int main() {
	cin >> n >> k;
	
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int next;
		cin >> next;

		values.push_back(next);
		sum += next;
	}

	int output = 1;

	for (int i = 1; i * i <= sum; i++) {
		if (sum % i != 0) continue;

		output = max(output, f(i));
		if (sum / i != i) output = max(output, f(sum / i));	
	
	}

	cout << output << endl;
	
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace practice001
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            string[] input2 = Console.ReadLine().Split(' ');

            int allGoods = int.Parse(input[0]);
            int choiceGoods = int.Parse(input[1]);
            int min = 4 * choiceGoods;

            int[] voteNum = new int[allGoods];
            for (int i = 0; i < allGoods; i++)
            {
                voteNum[i] = int.Parse(input2[i]);
            }

            int allVoteNum = 0;
            for (int i = 0; i < allGoods; i++)
            {
                allVoteNum = allVoteNum + voteNum[i];
            }

            int count = 0;
            for (int i = 0; i < allGoods; i++)
            {
                if (allVoteNum <= min * voteNum[i])
                {
                    count += 1;
                }
            }

            if (count >= choiceGoods)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
//Om Sree Sai Ram
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
using namespace std;
vector<int> dp;



int main() 
{

int n,W;
cin>>n>>W;
vector<int> wt(n);
vector<int> val(n);
int max_val = 0;
for(int i=0;i<n;i++)
{
  cin>>wt[i]>>val[i];
  max_val+= val[i];
}

vector<long long> dp(max_val+1,LLONG_MAX/4);

dp[0] = 0;

for(int i=0;i<n;i++)
{
  int curr_val = val[i];
  int curr_weight = wt[i];
  for(int j=max_val-curr_val;j>=0;j--)
  {
    dp[j+curr_val] = min(dp[j+curr_val],dp[j]+curr_weight);
  }
}
//cout<<" check "<<endl;
int ans =0;
for(int i=0;i<=max_val;i++)
{
 if(dp[i]<=W)
 ans = max(ans,i);
}
cout<<ans<<endl;


}


Measured memory_bytes: 1024
x = input()
x = [int(i) for i in x]
xCount = len(x)

aaa = 0
for i in range(2**(xCount -1)):
    binaryNumber = format(i,'b')
    binaryNumber = binaryNumber.zfill(xCount-1)
    binaryNumber = list(binaryNumber)
    binaryNumber = [int(i) for i in binaryNumber]
    
    for i in range(xCount-1):
        if binaryNumber[i] == 1 :
            binaryNumber[i] = '+' 
        
        if binaryNumber[i] == 0 :
            binaryNumber[i] = '-'
            
    
    result = []
    for i in range(xCount):
        result.append(x[i])
        if i < (xCount -1):
            result.append(binaryNumber[i])
    
    #result = [None]*(len(x)+len(binaryNumber))
    #result[::2] = x
    #result[1::2] = binaryNumber
    
    result = map(str, result)
    resultStr = ''.join(result)
    a = eval(resultStr)    
    #print(resultStr)
    #print(a)
    if (a == 7) :
        print(str(resultStr) + '=7')
        break

    




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

int main(){
	int n,sum=0,ans=0;
	cin>>n;
	vector<int> a(1000000);
	vector<int> b(1000000);
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[a[i]]++;
	}
	for(int i=0;i<1000000;i++){
		if(b[i]!=0){
			sum+=b[i]-1;
		}
	}
	ans=n-((sum+1)/2)*2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8064
import sys

class RMQ(): #range minimum query
    def __init__(self, N, V): #create segment tree with initial value V
        d, k = 1, 0
        while d < N:
            d <<= 1
            k += 1
        self.tree = [V for _ in range(2 * d - 1)]
        self.size = d 
    
    def update(self, i, a): #update cell i by value a
        now = self.size - 1 + i
        if self.tree[now] != a:
            self.tree[now] = a
            while now > 0:
                now = (now - 1) // 2
                self.tree[now] = self.tree[2 * now + 1] | self.tree[2 * now + 2]

    def search(self, lower, higher, lbound, hbound, pos): #search minimum value of [lower, higher) init: lbound = 0, hbound = self.size, pos = 0
        if higher <= lbound or hbound <= lower: return 0
        if lower <= lbound and hbound <= higher: return self.tree[pos]
        else:
            left = self.search(lower, higher, lbound, (lbound + hbound) // 2, 2 * pos + 1)
            right = self.search(lower, higher, (lbound + hbound) // 2, hbound, 2 * pos + 2)
            return left | right


def solve():
    input = sys.stdin.readline
    ab = ["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"]
    abn = dict()
    for i, st in enumerate(ab): abn[st] = i
    N = int(input())
    S = list(input().strip("\n"))
    SegTree = RMQ(N, 0)
    for i, s in enumerate(S):
        ns = 1 << abn[s]
        SegTree.update(i, ns)
    Q = int(input())
    for _ in range(Q):
        t, l, r = input().strip("\n").split()
        if t == "1": SegTree.update(int(l) - 1, 1 << abn[r])
        elif t == "2": 
            bitans = SegTree.search(int(l) - 1, int(r), 0, SegTree.size, 0)
            ans = 0
            while bitans > 0:
                if bitans & 1 == 1: ans += 1
                bitans >>= 1
            print(ans)
    return 0

if __name__ =="__main__":
    solve()

Measured memory_bytes: 114216
#include<bits/stdc++.h>
using namespace std;
#define MAX 87

int main() {
	int N;
	cin >> N;
	vector<int64_t> lucas(MAX);
	lucas.at(0) = 2;
	lucas.at(1) = 1;
	for (int i = 2; i < MAX; i++) {
		lucas.at(i) = lucas.at(i - 1) + lucas.at(i - 2);
	}
	cout << lucas.at(N) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string S;
    cin >> S;
    string ans = "Yes";
    for (int i = 0; i < S.length(); i++) {
        if (i % 2 == 1) {
            if (S.at(i) == 'R') {
                ans = "No";
                break;
            }
        } else {
            if (S.at(i) == 'L') {
                ans = "No";
                break;
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(num) cerr << #num << " " << num << endl;
#define F0(itr, limit) for(int itr=0;itr<limit;itr++) 
#define F(itr, init, limit) for(int itr=init;itr<limit;itr++) 
#define FR(itr, init, limit) for(int itr=init;itr>limit;itr--) 
#define Fll(itr,limit) for(long long itr=0;itr<limit;itr++) 
#define coutarr(list_name) for(auto it: list_name) cout << it << " ";
#define cinarr(list_name) for(auto &it: list_name) cin >> it;
#define sz(list_name) (int)((list_name).size())
#define all(list_name) (list_name).begin(), (list_name).end()
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define umap unordered_map
#define endl "\n"
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
using namespace std;
// "If I die here, then I'm a man that could only make it this far."


int main()
{
    IOS;
	int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    F(i, L, R + 1)
    {
        if(i % d == 0) ans++;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3596
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <fstream> //ofstream
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int data1,data2;
void solve(){
        if(data1*500>=data2) {
                cout<<"Yes"<<endl;
        }else{
                cout<<"No"<<endl;
        }
}

int main(){
        cin>>data1>>data2;

        solve();
        return 0;
}


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

typedef long long ll;

int main() {

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

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

    int n = 0;
    cin >> n;
    vector<ll> v(n, 0);
    ll temp = 0;
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        temp = temp ^ v[i];
    }


    for(int i = 0; i < n; i++) {
        cout << (temp ^ v[i]) << " ";
    }
    cout << endl;


    
    return 0;
}

Measured memory_bytes: 4772
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    cin >> H >> W;
    
    int S[50][50];
    
    // # : 5000
    
    for( int i = 0; i < H; ++i ){
        char s[50];
        cin >> s;
        for( int j = 0; j < W; ++j ) {
            if( s[j] == '.' ){
                S[i][j] = 0;
            }else{
                S[i][j] = 5000;
            }
        }
    }
    
    for( int i = 0; i < H; ++i ){
        for( int j = 0; j < W; ++j ) {
            if( S[i][j] == 5000 ){
                if( i != 0 && j   != 0   && S[i-1][j-1] != 5000 ) ++S[i-1][j-1];
                if( i != 0               && S[i-1][j]   != 5000 ) ++S[i-1][j];
                if( i != 0 && j+1 != W   && S[i-1][j+1] != 5000 ) ++S[i-1][j+1];
                
                if(           j   != 0   && S[i][j-1]   != 5000 ) ++S[i][j-1];
                if(           j+1 != W   && S[i][j+1]   != 5000 ) ++S[i][j+1];
                
                if( i+1 != H && j   != 0 && S[i+1][j-1] != 5000 ) ++S[i+1][j-1];
                if( i+1 != H             && S[i+1][j]   != 5000 ) ++S[i+1][j];
                if( i+1 != H && j+1 != W && S[i+1][j+1] != 5000 ) ++S[i+1][j+1];
            }
        }
    }
    
    for( int i = 0; i < H; ++i ){
        for( int j = 0; j < W; ++j ) {
            if( S[i][j] == 5000 ){
                cout << '#';
            }else{
                cout << S[i][j];
            }
        }
        cout << endl;
    }
    
    return 0;
}


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

int main(){
  int n,s,w,q,a[100100];
  while(cin >> n >> s >> w >> q, n){
    int g = s;
    rep(i,n){
      a[i] = (g/7) % 10;
      g = (g/2) ^ ((g%2)*w);
    }

    int ans = 0, non_zeros = 0;
    if(q==2 || q==5){
      rep(i,n){
	if(a[i])non_zeros++;
	if(a[i]%q == 0)ans += non_zeros;
      }
    }else{
      unordered_map<int,int> memo;
      memo[0] = 1;
      int rem = 0, k = 1;
      for(int i=n-1;i>=0;i--){
	rem = (rem + a[i] * k) % q;
	(k *= 10) %= q;
	if(a[i])ans += memo[rem];
	memo[rem]++;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
int main(){
int i, j, k, N; cin >> N;
int prms[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47}, freq[15];
for(i=0; i<15; i++){ for(j=1, k=prms[i], freq[i]=0; k<=N; k*=prms[i]){freq[i]+=N/k;} }
int a, b, c, d, e; a=b=c=d=e=0;
for(i=0; i<15; i++){
if(freq[i]>=74){a++;} if(freq[i]>=24){b++;}
if(freq[i]>=14){c++;} if(freq[i]>=4){d++;} if(freq[i]>=2){e++;} 
}
cout << a+b*(e-1)+c*(d-1)+(e-2)*(d*(d-1))/2 << "\n";
}

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

using namespace std;
using ll = long long;

int main() {
	ll n;
	scanf("%lld", &n);

	vector<ll> ans;

	auto divisors = [](ll x) {
		vector<ll> d;
		for(ll i = 1; i * i <= x; i++) if(x % i == 0) {
			d.push_back(i);
			if(x / i != i) d.push_back(x / i);
		}
		return d;
	};

	auto test = [n](ll cand) {
		if(cand == 1) return false;
		ll x = n;
		while(x % cand == 0) x /= cand;
		return x % cand == 1;
	};

	for(ll d : divisors(n)) {
		if(test(d)) {
			ans.push_back(d);
		}
	}
	for(ll d : divisors(n - 1)) {
		if(test(d)) {
			ans.push_back(d);
		}
	}
	sort(ans.begin(), ans.end());
	ans.erase(unique(ans.begin(), ans.end()), ans.end());
	printf("%d\n", (int)ans.size());
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
 
int main(void){
    // Your code here!
  int n,x,t;
  cin >> n >> x >> t;

  cout <<(n + (x-1)) / x*t << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  cout << (n + 2 - 1) / 2 << "\n";
  return 0;
}

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

long long gcd(long long x, long long y){
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long p, q, r, s, t, u;
    p = (a - 1) / c;
    q = b / c;
    r = (a - 1) / d;
    s = b / d;
    t = (a - 1) / (c * d / gcd(c, d));
    u = b / (c * d / gcd(c, d));
    cout << (b - a + 1) - ((q - p) + (s - r) - (u - t)) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>

using namespace std;

int main()
{
	int pq; cin>>pq;
    string str; cin>>str;
    vector<set<int>> v(26);
    
    for(int i=0;i<str.size();i++)
    {
        v[str[i]-'a'].insert(i);
    }

    int qq; cin>>qq;
    while(qq--)
    {
        int type ; cin>>type;
        if(type == 1)
        {
            int pos; cin>>pos;
            char c ; cin>>c;
            pos-=1;
            v[str[pos]-'a'].erase(pos);
            str[pos]=c;
            v[str[pos]-'a'].insert(pos);
        }
        else
        {
            int l,r; cin>>l>>r;
            l-=1;
            r-=1;
            int cnt = 0;
            for( int i=0;i<26;i++)
            {
                auto key = v[i].lower_bound(l);
                if(key!=v[i].end() and *key<=r) cnt++;
            }
            cout<<cnt<<endl;
        }
    }


    return 0;
}

Measured memory_bytes: 24196
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<string>
#include<cmath>
#include<cassert>
#include<map>
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ (i)=0;(i)<(j);(i)++)
#define repeat(i,j,k) for(int__ i=(j);i<(k);(i)++)
#define all(v) v.begin(),v.end()

#define N_MAX 100 +10
#define W_MAX 10000 +10
int main()
{
  ios::sync_with_stdio(false);
  int N,W;
  cin >> N >> W;
  vector<int> value(N+1),weight(N+1);
  for(int i=1;i<=N;i++){
    cin >> value[i] >> weight[i];
  }
  int DP[N_MAX][W_MAX]={};
  for(int n=1;n<=N;n++){
    rep(w,W+1){
      if(weight[n]<=w){
        //DP[n][w]=max(DP[n-1][w],DP[n-1][w-weight[n]]+value[n]);//????????????
        DP[n][w]=max(DP[n-1][w],DP[n][w-weight[n]]+value[n]);
      }else{
        DP[n][w]=DP[n-1][w];
      }
    }
  }
  cout<<DP[N][W]<<endl;
  
  return 0;
  return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#include<string.h>
using namespace std;

int main(){
	string s;
	int i,j,k;
		
	cin  >> s;
	j=s.length();
	if(j>100)exit(1);
		
	i=0;
	while(i<j){
		s[i]='x';
		cout << s[i];
		i++;
	}
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector <vector <int> > a(15,vector<int>(15,0));
  int c,d,size,o=0;
  char s1,s2;
  while(cin>>c>>s1>>d>>s2>>size){
      c+=3;d+=3;
    if(size==1){
      a[c][d]++;
      a[c][d-1]++;
      a[c-1][d]++;
      a[c+1][d]++;
      a[c][d+1]++;
    }
    if(size==2){
      a[c][d]++;
      a[c][d-1]++;
      a[c-1][d]++;
      a[c+1][d]++;
      a[c][d+1]++;
      a[c-1][d-1]++;
      a[c+1][d+1]++;
      a[c-1][d+1]++;
      a[c+1][d-1]++;
    }
    if(size==3){
      a[c][d]++;
      a[c][d-1]++;
      a[c-1][d]++;
      a[c+1][d]++;
      a[c][d+1]++;
      a[c-1][d-1]++;
      a[c+1][d+1]++;
      a[c-1][d+1]++;
      a[c+1][d-1]++;
      a[c+2][d]++;
      a[c-2][d]++;
      a[c][d+2]++;
      a[c][d-2]++;
    }
  }
  int maxi = 0;
  for(int i = 3; i < 13; i++){
    int d = *max_element(a[i].begin(),a[i].end());
    maxi = max (maxi, d);
    for(int j = 3; j < 13; j++){
      if(a[j][i]==0) o++;
    }
  }
 cout<<o<<endl<<maxi<<endl;
}

Measured memory_bytes: 0
import java.util.Scanner;

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

		while (true) {
			int n = sc.nextInt();
			if(n==0)break;
			int[] a = new int[100];
			int max = 0;
			int min = 1000;
			int sum = 0;
			int point;
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}

			for (int i = 0; i < n; i++) {
				if (max < a[i])
					max = a[i];
				if (min > a[i])
					min = a[i];
				sum += a[i];
			}

			sum = sum - min - max;
			point = sum / (n - 2);
			System.out.println(point);
		}
		sc.close();
	}
}

Measured memory_bytes: 20940
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }



int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll r, g, b, n;
  cin >> r >> g >> b >> n;

  ll ans = 0;
  for(ll i = 0; i <= 3000; i++){
    for(ll j = 0; j <= 3000; j++){
      ll k = n - i * r - j * g;

      if(k == 0 || (k > 0 && k % b == 0)) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)998244353, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, s, i, j, a[3003], dp[3003][3003] = {}, ans;

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


    for (i = 0; i < n; i++) for (j = 0; j <= s; j++) {
        if (j == 0) {
            dp[i + 1][j] = dp[i][j] + 1;
        }
        else {
            dp[i + 1][j] = dp[i][j];
            if (j >= a[i]) dp[i + 1][j] = (dp[i + 1][j] + dp[i][j - a[i]]) % mod;
            if (j == a[i]) dp[i + 1][j] = (dp[i + 1][j] + 1) % mod;
        }
    }

    ans = 0;
    for (i = 1; i <= n; i++) {
        ans = (ans + dp[i][s]) % mod;
    }

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

    return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  vector<int> V = {A, B, C};
  sort(V.begin(), V.end());
  V.erase(unique(V.begin(), V.end()), V.end());

  cout << ((V.size() == 2) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define MN 300000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,K,a[MN+5];
int Del(int x)
{
    --a[x];
    if(a[x]<0) a[x]=K,Del(x-1);
    else if(a[x]==0) for(int i=x+1;i<=n;++i) a[i]=0;
}
int main()
{
    K=read();n=read();
    if(K==1) for(int i=1;i<=n+1>>1;++i) printf("1 ");
    else if(~K&1) for(int i=1;i<=n;++i) printf("%d ",i==1?K/2:K);
    else
    {
        for(int i=1;i<=n;++i) a[i]=K/2+1;
        int d=n>>1;
        for(int t=1;t<=d;++t) Del(n);
        for(;a[n]==0;--n);
        for(int i=1;i<=n;++i) printf("%d ",a[i]);
    }
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
string s,t,u;
int a,b;
int main()
{
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(u==s)
        cout<<a-1<<" "<<b;
    else
        cout<<a<<" "<<b-1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>

using namespace std;




int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long long a, b, c, k, ans, x;
	cin >> a >> b >> c >> k;
	ans = 0;

	x = min(a, k);
	ans += 1 * x;
	k -= x;

	x = min(b, k);
	ans += 0 * x;
	k -= x;

	x = min(c, k);
	ans += -1 * x;
	k -= x;

	cout << ans << "\n";
	return 0;
}


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

lld gcd( lld m, lld n ){
  if ( ( 0 == m ) || ( 0 == n ) ) return 0;
  while( m != n ){
    if ( m > n ) m = m - n;
    else         n = n - m;
  }
  return m;
}

lld lcm( lld m, lld n ){
  if ( ( 0 == m ) || ( 0 == n ) ) return 0;
  return ((m / gcd(m, n)) * n);
}

int main(){
  lld a[3],m[3];
  while(cin >> a[0] >> m[0] >> a[1] >> m[1] >> a[2] >> m[2] , a[0]){
    int now[3],cnt[3] = {1,1,1};
    for(int i=0;i<3;i++){
      now[i] = a[i] % m[i];
      while(now[i] != 1){
	now[i] = (a[i]*now[i])%m[i];
	cnt[i]++;
      }
    }
    cout << lcm(cnt[0],lcm(cnt[1],cnt[2])) << endl;
  }
}

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

int main(){
    
    // 1. 入力情報.
    char c[101010];
    scanf("%s", c);
    string S(c);
    
    // 2. 文字列を後ろから照合していく.
    int l = S.size();
    while(l > 0){
        if(l > 6 && S.substr(l - 7, 7) == "dreamer"){
            l -= 7;
            continue;
        }
        if(l > 5 && S.substr(l - 6, 6) == "eraser"){
            l -= 6;
            continue;
        }
        if(l > 4 && S.substr(l - 5, 5) == "dream"){
            l -= 5;
            continue;
        }
        if(l > 4 && S.substr(l - 5, 5) == "erase"){
            l -= 5;
            continue;
        }
        break;
    }
    
    // 3. 出力.
    printf("%s\n", (l == 0) ? "YES" : "NO");
    return 0;
    
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

typedef struct TIME {
  int a;
  int b;
}T;

int cmp(const void *a, const void *b) {
  return ((struct TIME*)a)->b - ((struct TIME*)b)->b;
}

int main(void) {
  int n;
  long long int sum = 0;
  scanf("%d",&n);
  T t[n];
  for (int i = 0; i < n; i++) {
    scanf("%d %d",&t[i].a,&t[i].b);
  }
  
  qsort(t,n,sizeof(struct TIME),cmp);
  
  for (int i = 0; i < n; i++) {
    sum += t[i].a;
    
    if(sum > t[i].b) {
      printf("No\n");
      return 0;
    }
  }
  
  printf("Yes\n");
  
  return 0;
}

Measured memory_bytes: 3324
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    N, A, B = map(int, input().split())

    ans = A * (N // (A + B))
    m = N % (A + B)
    if m > A:
        ans += A
    else:
        ans += m
    
    print(ans)


if __name__ == '__main__':
    main()

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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 10){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { 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> ostream &operator<<(ostream &os, 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> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

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); }

void solver() {
  int N = input();
  string s = input< string >();

  int x = 0, y = 0;
  for (auto i : s) {
    if ('A' <= i && i <= 'M') y++;
    if ('N' <= i && i <= 'Z') y--;
    if ('a' <= i && i <= 'm') x++;
    if ('n' <= i && i <= 'z') x--;
  }

  string ans = (y > 0 ? string(y, 'A') : string(-y, 'N')) + (x > 0 ? string(x, 'a') : string(-x, 'n'));

  cout << ans.size() << endl;
  cout << ans << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}



Measured memory_bytes: 3352
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
void q1(){
	int a,b;
	cin>>a>>b;
	if(a<10 && b<10)
	cout<<a*b;
	else
	cout<<"-1";
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q1();
	return 0;}


Measured memory_bytes: 256