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

using namespace std;
#define ff(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define rep(i, a, b) for(int i = (a), _b = (b); i < _b; ++i)
#define fd(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define SZ(x) ((int)(x).size())
#define db(x) cout << #x << " == " << x << endl
#define _ << ", " <<
#define X first
#define Y second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define endl '\n'
#define pc putchar
#define gc getchar

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;

const int MD=1e9+7;

int n,cnt[1005];

void enter(){
    cin>>n;
}

void process(){
    ff(i,2,n){
        int num=i,j=2;
        while (num>1){
            while (num%j==0){
                ++cnt[j];
                num/=j;
            }
            ++j;
        }
    }

    ll ans=1;

    ff(i,2,n) {
        ans=ans*(cnt[i]+1)%MD;
    }
    cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	//freopen("test.inp","r",stdin);
//	freopen("test.out","w",stdout);

	enter();
	process();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

bool is_int(vector<int> x1, vector<int> x2) {
    float sum_v = 0;
    rep(i, x1.size()) {
        sum_v += pow(x1[i] - x2[i], 2);
    }
    sum_v = sqrt(sum_v);
    return floor(sum_v) == sum_v;
}

int main() {
    cout << fixed << setprecision(10);
    
    int N, D; cin >> N >> D;
    vector<vector<int>> x(N, vector<int>(D));
    rep(i, N) {
        rep(j, D) {
            cin >> x[i][j];
        }
    }
    int ans = 0;
    rep(i, N) {
        repr(j, i+1, N) {
            if (is_int(x[i], x[j])) {
                ans += 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

signed main(){
    int A,B,K;
    cin>>A>>B>>K;
    int tmp=min(A,K);
    A-=tmp;
    K-=tmp;

    tmp=min(B,K);
    B-=tmp;

    cout<<A<<" "<<B<<endl;
    return 0;
}

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

string isBeautiful(string w) {
    int freq[26] = {};

    for (char c: w) {
        int i = c - 'a';
        freq[i]++;
    }

    for (int i = 0; i < 26; i++) {
        if (freq[i] % 2 != 0) {
            return "No";
        }
    }

    return "Yes";
}

int main(int argc, char** argv) {
    string w;
    cin >> w;

    cout << isBeautiful(w) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
int n,q,t;
string name;
queue<pair<string,int> >Q;
int main(){
	cin>>n>>q;
	for(int i=0;i<n;i++){
		cin>>name>>t;
		Q.push(make_pair(name,t)); 
	}
	pair<string,int>u;
	int elaps=0;
	int a;
	while(!Q.empty() ){
		u=Q.front() ;
		Q.pop() ;
		a=min(u.second ,q);
		u.second -=a;
		elaps+=a;
		if(u.second >0){
			Q.push(u); 
		}
		else{
			cout<<u.first<<" "<<elaps<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 6296
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <vector>

using namespace std;

int N, K;
vector<int> g[2001];
vector<pair<int, int>> e;

void dfs(int s, int& cnt, set<int>& v, int ignore = -1, int d = 0) {
  v.insert(s);
  if (d > K / 2) ++cnt;
  for (const auto& i : g[s]) {
    if (v.find(i) != v.end() || i == ignore) continue;
    dfs(i, cnt, v, ignore, d + 1);
  }
}

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

  for (int i = 0; i < N - 1; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
    e.push_back({a, b});
  }

  int ans = 2001;
  if (K % 2 == 0) {
    for (int i = 1; i <= N; ++i) {
      int cnt = 0;
      set<int> v;
      dfs(i, cnt, v);
      ans = min(ans, cnt);
    }
  } else {
    --K;
    for (const auto& i : e) {
      int cnt = 0;
      set<int> v;
      dfs(i.first, cnt, v, i.second);
      v.clear();
      dfs(i.second, cnt, v, i.first);
      ans = min(ans, cnt);
    }
  }
  printf("%d\n", ans);
}


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

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

using namespace std;

int main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	cout<<(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)?"Yes":"No")<<endl;

	return 0;
}


Measured memory_bytes: 256
import numpy as np

D = int(input()) 
c = list(map(int,input().split())) 
s = [list(map(int,input().split())) for i in range(D)]
t = [int(input().strip()) for _ in range(D)]

last = []
for i in range(26):
    last.append(0)

last = np.array(last)
ans = 0
for i in range(D):
    last[t[i]-1] = i+1
    dec = c * (i+1-last)
    #ans = ans + s[i][t[i]] 
    ans = ans + s[i][t[i]-1] - sum(dec)
    print(ans)

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());

    // while (M--) {
    //     int b, c;
    //     cin >> b >> c;
    // }
    vector<P> q(M);
    rep(i, M) {
        cin >> q[i].second >> q[i].first;
    }
    sort(q.begin(), q.end(), greater<P>());

    ll res = 0;
    // int id = 0;
    // rep(i, M) {
    //     printf("C, B = %d, %d\n", q[i].first, q[i].second);
    //     while (id < q[i].second) {
    //     // for(int j = id; j < q[i].second; j++) {
    //         res += max(A[id], q[i].first);
    //         id++;
    //     }
    // }
    // // for (int i = id; i < N; i++) {
    // //     res += A[i];
    // // }
    // while (id < N) {
    //     res += A[id++];
    // }

    int id = 0;
    rep(i, M) {
        rep(j, q[i].second) {
            // while (id < N && A[id] < q[i].first) {
            //     // res += max(A[id], q[i].first);
            //     res += q[i].first;
            //     id++;
            // }
            if (id < N && A[id] < q[i].first) {
                res += q[i].first;
                id++;
            } else {
                break;
            }
        }
    }

    while (id < N) {
        res += A[id++];
    }

    cout << res << endl;
}

Measured memory_bytes: 4480
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long 
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define print_time cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
   // cout<<x<<' '<<y<<endl;
    if(y==0)
    return x;
    else
    return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
    if(m%2)
	r=(r*n)%p;
    n=(n*n)%p;
    m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
    if (n%i == 0 || n%(i+2) == 0)
       return false;
 
    return true;
}
vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r)
	z[i] = min (r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]])
	++z[i];
    if (i + z[i] - 1 > r)
	l = i, r = i + z[i] - 1;
    }
    return z;
}
vector<int>adj[100005];
int dp[100005];
int solve(int s)
{
	if(dp[s]!=-1)
		return dp[s];
	int ans=0;
	for(int i=0;i<adj[s].size();i++)
	{
		ans=max(ans,1+solve(adj[s][i]));
	}
	dp[s]=ans;
	return ans;
}
int32_t main()
{
   IOS;
   /*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif
   /********************* Code starts here ***********************/
   int n,m;
   cin>>n>>m;
   memset(dp,-1,sizeof(dp));
   for(int i=0;i<m;i++)
   {
   	int x,y;
   	cin>>x>>y;
   	adj[x].pb(y);
   }
   int ans=-inf;
   for(int i=1;i<=n;i++)
   {
   	ans=max(ans,solve(i));
   }	
   cout<<ans<<endl;
}                       

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

const int MAX_N = 1e5 + 5;
int n, ans = 1000000000;
int Arr[MAX_N];

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

	for (int i = -100; i <= 100; i++) {
		int res = 0;
		for (int j = 0; j < n; j++)
			res += (Arr[j] - i) * (Arr[j] - i);

		ans = min(ans, res);
	}

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

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

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<pair<int, int>> x(n);
    for(ll i = 0; i < n; i++){
        cin >> x[i].first >> x[i].second;
    }
    sort(x.begin(), x.end());
    ll i = 0;
    ll sum = (ll)x[i].second;
    while(k > sum){
        i++;
        sum += (ll)x[i].second;
    }
    cout << x[i].first << endl;
    return 0;
}

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

int main(){
    int A[3][3] = {0};
    bool check[3][3] = {false};
    int N;
    rep(i,3){
        rep(j,3){
            cin >> A[i][j];
        }
    }
    cin >> N;
    //3重ループで間に合う

    rep(i,N){
        int b;
        cin >> b;
        rep(j,3){
            rep(k,3){

                if(A[j][k] == b) check[j][k] = true;
            }
        }
    }
    bool ans = false;
    rep(i,3){
        if(check[0][i] == 1 && check[1][i] == 1 && check[2][i] == 1) ans = true;
        if(check[i][0] == 1 && check[i][1] == 1 && check[i][2] == 1) ans = true;
    }
    if(check[0][0] == 1 && check[1][1] == 1 && check[2][2] == 1) ans = true;
    if(check[2][0] == 1 && check[1][1] == 1 && check[0][2] == 1) ans = true;

    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
H=int(input())+1
A=[0]+list(map(int,input().split()))
def h(i):
 l=2*i;r=l+1
 g=l if l<H and A[i]<A[l]else i
 if r<H and A[g]<A[r]:g=r
 if g>i:A[i],A[g]=A[g],A[i];h(g)
for i in range(H//2,0,-1):h(i)
print(' '+' '.join(map(str,A[1:])))


Measured memory_bytes: 64176
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	alist := make([]int, n)

	for i := 0; i < n; i++ {
		alist[i] = nextInt()
	}
	rev(alist)

	sa := 0
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			sa += alist[i]
		} else {
			sa -= alist[i]
		}
	}

	fmt.Println(sa)
}

// 降順ソート
func rev(alist []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(alist)))
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

using namespace std;

int main(){
	int n,k,x,t,i,j,min;
	vector <int> v;
	cin>> n >> k;
	for(i = 0; i < n; i++){
		cin >> x;
		v.push_back(x);
	}
	sort(v.begin(),v.end());
	/*for(i = 0; i < n; i++){
		for(j = i+1; j <n; j++){
			if (v[i] > v[j] ){
				t = v[i];
				v[i] = v[j];
				v[j] = t;
			}
		}
	 	
	}*/

	i= 0;
	j=i+k-1; 
	min = v[j] - v[i];
	while(j < n){
		if( (v[j]-v[i]) < min) min =v[j]-v[i];
		i++;
		j++; 
	}
	cout << min;
	return 0;
}

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

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

	int C = K;
	int I = 0;

	if (K < A) {
		while (B >= C) {
			C += K;

			if (C >= A && C <= B) {
				I = 1;
				break;
			}
		}
	}
	else if (C >= A && C <= B) {
		I = 1;
	}

	if (I == 1) {
		cout << "OK";
	}
	else {
		cout << "NG";
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

map<int, int> mp;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, d, m, t;
	cin>>n;
	REP(i, n){
		cin>>d;
		++mp[d];
	}
	cin>>m;
	REP(i, m){
		cin>>t;
		if(mp[t]<=0){
			cout<<"NO"<<'\n';
				return 0;
		}
		else{
			--mp[t];
		}
	}
	cout<<"YES"<<'\n';
	return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;
 
#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define in1(a,n) F(i,1,n)cin>>a[i]
#define ff first
#define ss second
#define F(i,a,b) for (ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) F(i,0,n-1)
#define clr clear
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define len(s) (s).length()

int main()
{
	crap;
	int n;
	cin>>n;
	int a[n],ans=0,m1=0,mf1=0,m2=0,mf2=0,f=0,a1=0,t=0,t1=0,a2=0;
	in(a,n);

    map<int,int>f1;
    map<int,int>f2;
    
    for(int i=0;i<n;i+=2)
      f1[a[i]]++;
    for(int i=1;i<n;i+=2)
      f2[a[i]]++;
    for(int i=0;i<n;i+=2)
    {
        if(f1[a[i]]>mf1)
        {
            mf1=f1[a[i]];
            m1=a[i];
        }
    }

    for(int i=1;i<n;i+=2)
    {
         if(f2[a[i]]>mf2)
         {
            mf2=f2[a[i]];
            m2=a[i];
         }
    }

    if(m1!=m2)
    {
      for(int i=0;i<n;i+=2)
      {
          if(a[i]!=m1)
            ++ans;
      }
      for(int i=1;i<n;i+=2)
      {
          if(a[i]!=m2)
          ++ans;
      }
      cout<<ans;
    }
    else
    {
		for(int i=0;i<n;i+=2)
		{
		    if(f1[a[i]]>=a1 && a[i]!=m1)
		    {
		         a1=f1[a[i]];
		         f=a[i];
		    }
		}

		for(int i=1;i<n;i+=2)
		{
		    if(f2[a[i]]>=t1&&a[i]!=m2)
		    {
		        t1=f2[a[i]];
		        t=a[i];
		    }
		}
		if(f==0&&t==0)
		{
		    cout<<n/2;
		    return 0;
		}
		a1=a2=0;
		for(int i=1;i<n;i+=2)
		{
		    if(a[i]!=t)
		      ++a1;
		}
		for(int i=0;i<n;i+=2)
		{
		   if(a[i]!=f)
		    ++a2;
		}
		for(int i=0;i<n;i+=2)
		  if(a[i]!=m1)
		    a1++;
		for(int i=1;i<n;i+=2)
		  if(a[i]!=m2)
		    a2++;
		cout<<min(a1,a2);
	}
	cout<<"\n";
}

Measured memory_bytes: 5376
using System;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        bool judge = true;
        h[0]--;
        for (int i = 0; i < h.Length - 1; i++)
        {
            if (h[i] < h[i + 1]) h[i + 1]--;
            else if (h[i] > h[i + 1]) judge = false;
        }
        Console.WriteLine(judge ? "Yes" : "No");
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

#define int long long

typedef pair<int, int> P;

int H, W, S;
vector< vector<int> > A;
bool m1[40][40][40][40];
P m2[40][40][40][40];
int m[50][50];

void setM(int x, int y, int val) {
	m[y+1][x+1] = val;
}
int getM(int x1, int y1, int x2, int y2) {
	return m[y2][x2] - m[y2][x1] - m[y1][x2] + m[y1][x1];
}
void initM() {
	REP(x, W+1) REP(y, H+1) {
		m[y+1][x] += m[y][x];
	}
	REP(x, W+1) REP(y, H+1) {
		m[y][x+1] += m[y][x];
	}
}

// [x1, x2) && [y1, y2)
P solve(int x1, int y1, int x2, int y2) {
	if (m1[x1][y1][x2][y2]) return m2[x1][y1][x2][y2];

	P res(1, S-(getM(0, 0, W, H) - getM(x1, y1, x2, y2)));
	if (res.second < 0) {
		res = P(-inf, -inf);
	}
	else {
		// [y1, y) [y, y2)
		FOR(y, y1+1, y2) {
			P a1 = solve(x1, y1, x2, y);
			P a2 = solve(x1, y, x2, y2);
			P a = P(a1.first+a2.first, min(a1.second, a2.second));
			res = max(res, a);
		}
		// [x1, x) [x, x2)
		FOR(x, x1+1, x2) {
			P a1 = solve(x1, y1, x, y2);
			P a2 = solve(x, y1, x2, y2);
			P a = P(a1.first+a2.first, min(a1.second, a2.second));
			res = max(res, a);
		}
	}
//	cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << res.first << " " << res.second << endl;
	return m1[x1][y1][x2][y2] = true, m2[x1][y1][x2][y2] = res;
}

signed main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	while (cin >> H >> W >> S, H || W || S) {
		fill(m[0], m[50], 0);
		fill(m1[0][0][0], m1[39][39][40], false);
		A = vector< vector<int> >(H, vector<int>(W, 0));
		REP(y, H) REP(x, W) {
			cin >> A[y][x];
			setM(x, y, A[y][x]);
		}
		initM();
		int sum = 0;
		REP(y, H) REP(x, W) sum += A[y][x];
		P ans = solve(0, 0, W, H);
		assert(ans.first >= 0 && ans.second >= 0);
		cout << ans.first << " " << ans.second << endl;
	}
}

Measured memory_bytes: 43772
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String A = in.next();
			String B = in.next();
			String C = in.next();
			out.println("A" + B.charAt(0) + "C");
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

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

	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
ll n,a[N],p[N],s[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		p[i]=p[i-1]+abs(a[i-1]-a[i]);
	}
	for(int i=n-1;i>=1;i--)
		s[i]=s[i+1]+abs(a[i+1]-a[i]);	
	for(int i=1;i<=n;i++)
	{
		ll res=p[i-1]+s[i+1];
		if(i+1<=n)
			res+=abs(a[i-1]-a[i+1]);
		if(i==n)
			res+=abs(a[n-1]);
		else
			res+=abs(a[n]);
		cout<<res<<'\n';	
	}
	
	
	
		
	
	
	
	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    ll p,y;
    ll index=0;
    ll maki[m][2],wa[m][2];
    memset(wa,0,sizeof(wa));
    vector< pair <ll,pair<ll,ll> > > v;

    for(int i=0;i<m;i++){
        cin>>p>>y;
        v.pb(make_pair(p,make_pair(y,i)));
    }
    sort(be(v));
    v[0].second.first=1;
    for(int i=1;i<m;i++){
        if(v[i].first==v[i-1].first){
            v[i].second.first=i+1-index;
        }
        else{
            index=i;
            v[i].second.first=1;
        }
    }
    for(int i=0;i<m;i++){
        maki[v[i].second.second][0]=v[i].first;
        maki[v[i].second.second][1]=v[i].second.first;
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<2;j++){
            ll niko=maki[i][j];
            ll hoge=0;
            while(niko){
                niko/=10;
                hoge++;
            }
            wa[i][j]=6-hoge;
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<wa[i][j];k++){
                cout<<'0';
            }
            cout << maki[i][j];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 7792
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<string>
using namespace std;
const int MAX_N = 10005;
const int INF = 0x3f3f3f3f;
typedef long long ll;
struct vote {
	string name;
	int num;
	int used;
}xp[200005];
bool cmp(vote a, vote b) {
	if (a.num != b.num) return a.num > b.num;
	return a.name < b.name;
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> xp[i].name;
		xp[i].num = 1;
		xp[i].used = 0;
	}
	sort(xp, xp + n, cmp);
	int p = 0;
	for (int i = 1; i < n; i++) {
		if (xp[i].name != xp[p].name) {
			p = i;
		}
		else {
			xp[p].num++;
			xp[i].used = 1;
		}
	}
	sort(xp, xp + n, cmp);
	int maxn = xp[0].num;
	for (int i = 0; i < n; i++) {
		if (xp[i].num == maxn && xp[i].used == 0) {
			cout << xp[i].name << endl;
		}
	}
	return 0;
}




Measured memory_bytes: 15872
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;

ll gcd(ll x, ll y) {
  while (y != 0) {
    ll r = x % y; x = y; y = r;
  }
  return x;
}

std::map<ll, int> prime_factor(ll n) {
  std::map<ll, int> ret;
  for (ll i = 2; i*i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) { ret[n]++; }
  return ret;
}

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

  ll g = gcd(a, b);

  cout << prime_factor(g).size() + 1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib> 
#include<cstring>
using namespace std;
int read()
{
	int x=0,f=1; char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
	return x*f;
}
/*long long MI(long long a,int b){
  long long r=1;
  long long base=a;
  while(b){
    if(b&1) r*=base;
//    if (r>=1000000007) r%=1000000007;
    base*=base; 
//    if (base>=1000000007) base%=1000000007;
    b>>=1;
  }
  return r;
}*/
long long q,h,s,n,sum,d;
int main()
{
	cin>>q>>h>>s>>d>>n;
	q=4*q; h=2*h; 
	if (d<2*q&&d<2*h&&d<2*s) {
		sum+=(n/2)*d;
		n%=2;
	}
	if (q>h) q=h;
	if (q>s) q=s;
	sum+=n*q;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define sort(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;

using namespace std;

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

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

using namespace std;

#define pb push_back
#define mp make_pair
#define lli long long int
#define F first
#define S second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX1 998244353
#define MAX2 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define input(data,n,command) for(lli i=0;i<n;i++){lli tmp;cin>>tmp;data.pb(tmp);command}
#define sort(a) sort(a.begin(),a.end());
#define display(a) for(lli i = 0 ;i<a.size();i++){cout<<a[i]<<" ";} cout<<endl;
#define rep(i,n,p) for(lli i = 0;i<n;i= i +p)
#define endl "\n"

//Written By GHATAK...
/*--------------------------------------------------------------------*/
//vector<pair<lli,lli>>adj[300010];

std::vector<lli> v;

int main()
{
    ios
    lli T=1;
    //cin>>T;
    while(T--)
    {
        //start from here
        lli n;
        cin>>n;
        map<lli,lli>ar;
        // lli ar[10010] = {0};
        rep(i,n,1)
        {
            lli a;
            cin>>a;
            v.pb(a);
            ar[a]++;
        }
        map<lli,lli>dp;
        // lli dp[1000010] = {0};
        dp[0] = 0;
        for(lli i = 1;i<20010;i++)
        {
            dp[i] = dp[i-1] + ar[i-1];
        }
        sort(v);
        lli ans = 0;
        for(lli i = 0;i<n-1;i++)
        {
            for(lli j = i+1;j<n;j++)
            {
                lli sum = v[i] + v[j];
                ans = ans + (dp[sum] - j-1);
                // trace(sum,v[i],v[j],dp[sum]-j-1);
                // if(sum<=1000)
                // {
                    
                // }
                // lli ind = binary(sum,j+1,n);
            }
        }
        cout<<ans;
    }
    return 0;
}
/*-----------------------------------------------------------------------*/
/*
--->  reverse(vec.begin(),vec().end());
*/

Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(int, H, W);
	ll cnt = 0;
	loop(i, H) loop(n, W) {
		in(char, c);
		cnt += (c == '#');
	}
	cout << (cnt == H + W - 1 ? "Possible" : "Impossible") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n, res;
char p[610][610];
int main() {
	int i, j, k, l;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", p[i]);
	}
	for (i = 0; i < n + n; i++)for (j = 0; j < n + n; j++) {
		p[i][j] = p[i%n][j%n];
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (i&&j)continue;
			int s = 0;
			for (k = 0; k < n; k++)for (l = k+1; l < n; l++) {
				if (p[i + k][j + l] == p[i + l][j + k])s++;
			}
			if (s == n*(n-1)/2)res++;
			int x = i, y = j;
			while (x + 1 < n && y + 1 < n) {
				for (k = 1; k < n; k++) {
					if (p[x][y + k] == p[x + k][y])s--;
					if (p[x+n][y+n-k] == p[x+n-k][y+n])s++;
				}
				x++, y++;
				if (s == n*(n - 1) / 2)res++;
			}
		}
	}
	printf("%d\n", res);

}

Measured memory_bytes: 512
//BISMILLAHIR RAHMANIR RAHIM
//SOTO MEAW
//SOTO SONDESH
#include<bits/stdc++.h>

#define ls ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define __ <<" "<<
#define loop(m,n) for(m=0;m<n;m++)
#define case(z) "Case " << z++ << ": "
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define quit return 0

using namespace std;

void showmyDS(set<int> ds)
{
    set<int> ::iterator it;
    for (it=ds.begin();it!=ds.end();it++)
    {
        cout << *it << endl ;
    }
    cout << endl;
}
int main()
{
    ls
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //int t,l=1;cin>>t;while(t>0){
        ll int n;
        cin >> n ;
        ll int a[n],i,c=1,mn=INT_MAX;
        loop(i,n)
        {
            cin >> a[i];
            if(i==0)
                mn=a[i];
            else
            {
                if(a[i]<mn)
                {
                    c++;
                    mn=a[i];
                }
            }
        }
        cout<<c;
    //t--;}

    quit;
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, M;
int pos[100010], cnt[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  pos[0] = 1;
  fill_n((int*)cnt, 100010, 1);
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    cnt[x]--; cnt[y]++;
    if (pos[x]) {
      if (cnt[x] == 0) pos[x] = 0;
      pos[y] = 1;
    }
  }
  cout << accumulate(pos, pos + N, 0) << endl;

  return 0;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			BigInteger b = BigInteger.ONE;
			BigInteger[] d = new BigInteger[n];
			BigInteger[] v = new BigInteger[n];

			for (int i = 0; i < n; i++) {
				d[i] = new BigInteger(scanner.next());
				v[i] = new BigInteger(scanner.next());
				b = v[i].multiply(b.divide(b.gcd(v[i])));
			}
			for (int i = 0; i < n; i++) {
				d[i] = d[i].multiply(b.divide(v[i]));
			}
			b = BigInteger.ONE;
			for (int i = 0; i < n; i++) {
				b = d[i].multiply(b.divide(b.gcd(d[i])));
			}
			for (int i = 0; i < n; i++) {
				System.out.println(b.divide(d[i]));
			}

		}
	}
}

Measured memory_bytes: 41748
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    count = 0
    bl = False
    for _ in range(N):
        a, b = map(int, readline().split())
        if a==b:
            count += 1
            if count>=3:
                bl = True
                break
            else:
                continue
        else:
            count = 0
    if bl:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int n,m;cin >> n >> m;
  map<string,int> mp;
  for(int i=0;i<n;i++){
    int t;cin >> t;
    for(int j=0;j<t;j++){
      string s;cin >> s;
      mp[s]++;
    }
  }
  Int ans = 0;
  for(auto &i:mp){
    if(i.second==n) ans++;
  }
  cout << ans << endl;
}


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

#define ll long long
#define pb push_back
#define fi first
#define se second
using namespace std;
const ll N = 5e5 +9;

ll a, b, c, n;

int main(){
    cin >> n;
    if(n%2==0){
        cout<<n;
        return 0;
    }
    cout<<2*n;



}


Measured memory_bytes: 256
#include <iostream>
    #include <string>
    #include <math.h>
    #include<algorithm>
    using namespace std;
     
    int main(){
      long long N,K;
      cin >> N >> K;
      long long ans=0;
      for(int i=1;i<=N;i++){
        int j=i%K;
        if((2*j)%K==0){
        ans+=(((-j+K)%K+N)/K)*(((-j+K)%K+N)/K);
        }
      }
      cout << ans << endl;
      return 0;}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#define MAXN 100010
int n, m, a[MAXN], b[MAXN], c[MAXN << 1];
typedef long long lnt;
lnt sum[MAXN << 1], suma, sumb, ans;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &a[i], &b[i]);
		suma += (c[++m] = a[i]);
		sumb += (c[++m] = b[i]);
	}
	ans = std::min(suma, sumb);
	std::sort(c + 1, c + m + 1);
	for (int i = 1; i <= m; i++) sum[i] = sum[i - 1] + c[i];
	for (int i = 1; i <= n; i++) {
		int pa = std::upper_bound(c + 1, c + m + 1, a[i]) - c - 1;
		int pb = std::upper_bound(c + 1, c + m + 1, b[i]) - c - 1;
		if (pa > n - 2 && pb > n - 2) {
			ans = std::min(ans, sum[n - 2] + a[i] + b[i]);
		} else if (pa > n - 1) {
			ans = std::min(ans, a[i] + sum[n - 1]);
		} else if (pb > n - 1) {
			ans = std::min(ans, b[i] + sum[n - 1]);
		} else {
			ans = std::min(ans, sum[n]);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int a,b;
  cin>>a>>b;
  cout << ((b%a==0) ? a+b : b-a) << endl;
  return 0;
}


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

A=N//3
B=N//5
AanB=N//15
Ssum=(1+N)*N*(1/2)
Asum=(1+A)*A*(1/2)*3
Bsum=(1+B)*B*(1/2)*5
AanBsum=(1+AanB)*AanB*(1/2)*15
print(int(Ssum-Asum-Bsum+AanBsum))

Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
ll mx(ll x,ll y) 
{ 
   return (x | y) & (~x | ~y); 
} 
int main()
{
    rkc;
    ll a,b,c=0,d=0;
    cin>>a>>b;
    ll q=(a-1)%4,w=b%4;
    if(q==0)
    c=a-1;
    else if(q==1)
    c=1;
    else if(q==2)
    c=a;
    else
    c=0;
    if(w==0)
    d=b;
    else if(w==1)
    d=1;
    else if(w==2)
    d=b+1;
    else
    d=0;
    //cout<<c<<endl;
    //cout<<d<<endl;
    cout<<mx(c,d);
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        ArrayList<String> numList = new ArrayList<String>();
        while(sc.hasNext()){
            String x = sc.next();
            if(x.equals("0")){
                break;
            }
            numList.add(x);
        }
        for(int i = 0; i < numList.size(); i++){
            String str = numList.get(i);
            int sum = 0;
            for(int j = 0; j < str.length(); j++){
                char c = str.charAt(j);
                int n = Character.getNumericValue(c);
                sum += n;
            }
            System.out.println(sum);
        }
    }
}


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


int main()
{
	
	int n,k;
	cin>>n>>k;
	int s=0;
	for(int i=0;i<k;i++)
	{
		int a;
		cin>>a;
		s+=a;
	}
	int res = n-s;
	if(res < 0 )
		cout<<-1<<endl;
	else
		cout<<res<<endl;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define hell 1000000007  
#define hell2 998244353 

int solve(){
    int n,p=1;
    cin>>n;
    int a[n];
    rep(i,0,n){
        cin>>a[i];
        if(a[i]==0) return cout<<"0",0;
    }
    sort(a,a+n);
    repn(i,n-1,0){
        if(a[i]>(1000000000000000000/p)) return cout<<"-1",0;
        if((p*a[i])<0||(p*a[i])>1000000000000000000) return cout<<"-1",0;
        p=p*a[i];  
    }
    cout<<p;
    return 0;
}   
     
signed main(){
    IOS;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
      // cout<<" * "<<t<<"\n";
    }
//    return 0;
} 

Measured memory_bytes: 4412
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=1e6;
ll d[mm];
ll vis[mm];
int main()
{
	ll n,m,i,j,k,kk,a,b,t;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	cin>>d[i];
	for(i=0;i<m;i++)
	{
		cin>>a>>b;
		if(d[a]<d[b]) vis[a]=1;
		if(d[b]<d[a])  vis[b]=1;
		if(d[b]==d[a]) vis[a]=1,vis[b]=1;
	}
	ll s=0;
	for(i=1;i<=n;i++)
	if(vis[i]==0)
	s++;
cout<<s<<endl;
}

Measured memory_bytes: 5148
#include<stdio.h>

#define N 100000

typedef struct{
    char name[11];
    int time_process;
    int time_count;
} queue_in;
void enqueue(queue_in data1);
void dequeue(queue_in data2);
queue_in A[N],B[N],tmp;
int first = 0;
int n;

int main(){
    int q,i,j,tmp_sort,k=0,count=0,tmp_i,flag;
    queue_in sortfor;
    scanf("%d%d",&n,&q);
    tmp_sort = n;
    for(i=0;i<n;i++){
        scanf("%s%d",A[i].name,&A[i].time_process);
    }
    while(n>0){
        if((A[first].time_process -q) <=0){
            A[first].time_count = (A[first].time_process) + count;
            count += A[first].time_process;
            B[k] = A[first];
            k++;
            dequeue(A[first]);
            continue;
        }
        A[first].time_process -= q;
        count += q;
        dequeue(A[first]);
        enqueue(tmp);
    }
    for(i=0;i<tmp_sort;i++){
        tmp_i = i;
        flag = 0;
        for(j=i;j<n;j++){
            if(B[j].time_count<B[tmp_i].time_count){
                tmp_i = j;
                flag = 1;
            }
        }
        if(flag==1){
            sortfor = B[i];
            B[i] = B[tmp_i];
            B[tmp_i] = sortfor;
        }
    }
    for(i=0;i<tmp_sort;i++){
        printf("%s %d\n",B[i].name,B[i].time_count);
    }
}

void enqueue(queue_in data1){
    if(n<N){
        A[(first+n) % N] = data1;
        n++;
    }
}
void dequeue(queue_in data2){
    if(n>0){
        tmp = data2;
        first = (first+1) % N;
        n--;
    }
}


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

int main(){
    int N;
    cin >> N;
    for(int i=1; i<=9; i++) {
        for(int j=1; j<=9; j++){
            if(i*j == N) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 384
from collections import deque
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    k=INT()
    que=deque([1,2,3,4,5,6,7,8,9])
    for i in range(k):
        q=que.popleft()
        if q%10!=0:
            que.append(10*q+q%10-1)
        que.append(10*q+q%10)
        if q%10!=9:
            que.append(10*q+q%10+1)
        
    print(q)
if __name__ == '__main__':
    do()

Measured memory_bytes: 18752
#include<iostream>
#include<cstring>
using namespace std;
#define maxn 110
#define INFTY (1<<30)
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,m[maxn][maxn];

int prim() //返回最小生成树各边权值总和
{
    int u,minv;
    int d[maxn],p[maxn],color[maxn];

    for(int i=0;i<n;i++) //初始化
    {
        d[i]=INFTY;
        p[i]=-1;
        color[i]=WHITE;
    }
    d[0]=0;

    while(1)
    {
        minv=INFTY;
        u=-1;
        for(int i=0;i<n;i++)
        {
            if(minv>d[i]&&color[i]!=BLACK) //寻找最小权值的边
            {
                u=i;
                minv=d[i];
            }
        }
        if(u==-1) break;
        color[u]=BLACK; //标记为黑
        for(int v=0;v<n;v++)
        {
            if(color[v]!=BLACK&&m[u][v]!=INFTY) //如果u和v之间存在边
            {
                if(m[u][v]<d[v]) //注意这里是d[v]不是d[u]
                {
                    d[v]=m[u][v];
                    p[v]=u;
                    //color[v]=GRAY;
                }
            }
        }
    }
    int sum=0;
    for(int i=0;i<n;i++)
        if(p[i]!=-1) sum+=m[i][p[i]];
    return sum;
}

int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>m[i][j];
            if(m[i][j]==-1) m[i][j]=INFTY;
        }
    }
    cout<<prim()<<endl;
    return 0;
}


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

using namespace std;

const int kMod = 1e9 + 7;

int main() {
    
    int n, k; cin >> n >> k;
    vector<int> a(n);
    vector<int> dp(k + 1, 0), ndp(k + 1, 0), psum(k + 2, 0);
    dp[0] = 1;

    for (int i = 0; i < n; ++i) {
        int maxx; cin >> maxx;
        for (int i = 0; i <= k; ++i)
            psum[i + 1] = (psum[i] + dp[i]) % kMod;

        for (int i = 0; i <= k; ++i) {
            ndp[i] = (psum[i + 1] - psum[max(0, i - maxx)]) % kMod;
        }
        swap(dp, ndp);
    } 

    cout << (dp[k] + kMod) % kMod;

    return 0;
}


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

using namespace std;

vector < string> a;
void make753(int nn,string s) {
	if (nn < 0) {
		a.push_back(s);
		return;
	}

	s += '7';
	make753(nn - 1, s);
	s.pop_back();
	s += '5';
	make753(nn - 1, s);
	s.pop_back();
	s += '3';
	make753(nn - 1, s);
	s.pop_back();

}

int main() {

	int n;
	cin >> n;
	int nn;
	nn = (int)((double)log(n) / (double)log(10));

	string s;
	for (int i = 2; i <= nn; i++) {
		make753(i, s);
	}

	int counter = 0;
	for (int i = 0; i < a.size(); i++) {
		if (stoi(a[i]) > n) { continue; }
		vector<int> b(3,0);
		for (int j = 0; j < a[i].size(); j++) {
			if (a[i][j] == '7') { b[0] = 1; }
			if (a[i][j] == '5') { b[1] = 1; }
			if (a[i][j] == '3') { b[2] = 1; }
		}
		if (b[0] + b[1] + b[2] == 3) { counter++; }

//		cout << a[i] << endl;
	}
	cout << counter << endl;
	return 0;

}

Measured memory_bytes: 2172
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
typedef pair<int, int> P;
int par[100006], siz[100006];
void init(int n) {
	rep(i, n) {
		par[i] = i; siz[i] = 1;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x), y = find(y);
	if (x == y)return;
	if (siz[x] < siz[y])swap(x, y);
	par[y] = x;
	siz[x] += siz[y];
}

vector<P>v1;
signed main() {
	int n, m, q; cin >> n >> m >> q;
	init(n);
	rep(i, q) {
		int a, b, c; cin >> a >> b >> c;
		if (c)v1.push_back(P(a, b));
		else unite(a, b);
	}

	if (v1.size()) {
		set<int>S;
		rep(i, n)S.insert(find(i));
		if (S.size() <= 2) {
			puts("No"); return 0;
		}
		rep(i, v1.size()) {
			if (find(v1[i].first) == find(v1[i].second)) {
				puts("No"); return 0;
			}
		}
		int M = 0;
		for (auto itr = S.begin(); itr != S.end(); itr++) {
			M += siz[find(*itr)] - 1;
		}
		int z = S.size();
		M += z*(z- 1) / 2;
		if(n-1<m&&m<=M)puts("Yes");
		else puts("No");
	}
	else {
		if(m==n-1)puts("Yes");
		else puts("No");
	}
}

Measured memory_bytes: 8048
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

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


Measured memory_bytes: 3632
#include <stdio.h>
int main(void){
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b){
        d=a;
        a=b;
        b=d;
    }
    if(b>c){
        d=b;
        b=c;
        c=d;
    }
    if(a>b){
        d=a;
        a=b;
        b=d;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 2676