akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && a != c || a == c && a != b || b == c && a != b){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3652
#include "stdio.h"
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <queue>
#include <algorithm>

#define MAX 4000
#define WMAX 10000
#define NMAX 50
#define AMAX 1000
#define BMAX 100
#define inf 1000000

using namespace std;

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

const ll MOD = 1000000007;
ll dp[1010][1010];
char mp[1010][1010];

int main(){

    ll H, W;
    cin >> H >> W;
    for(ll y = 1; y <= H; y++){
        for(ll x = 1; x <= W; x++){
            cin >> mp[y][x];
        }
    }
    dp[1][1] = 1;
    for(ll y = 1; y <= H; y++){
        for(ll x = 1; x <= W; x++){
            if(mp[y][x] == '#')continue;
            dp[y][x] = (dp[y][x] + dp[y - 1][x] + dp[y][x - 1]) % MOD;
        }
    }
    cout << dp[H][W] << endl;

    return 0;
}

Measured memory_bytes: 9088
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;
int n;
vector<int> s(100);
int main(){
    int sum=0;
    cin>>n;
    REP(i,n){
        cin>>s[i];
        sum+=s[i];
    }
    debug(sum);
    if(sum%10!=0){
        cout<<sum<<endl;
        return 0;
    }
    sort(s.begin(),s.begin()+n,std::less<int>());

    REP(i,n){
        if(s[i]%10==0){continue;}
        sum-=s[i];
        debug(sum);
        if(sum%10!=0){
            cout<<sum<<endl;
            return 0;
        }
    }
    cout<<0<<endl;



}


Measured memory_bytes: 256
//
// Created by Myabu on 2020/01/14.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    string a,b;
    cin>>a>>b;

    int c = stoi(a+b);
    for (int i = 0; i < 1000; ++i) {
        if(c==i*i){
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    cout<<"No"<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int Y=0;
  int X=0;
  int goukei=0;
  cin >> N;
  vector<int>vec(N);
  for (int L=0; L<N; L++){
    cin >>vec.at(L);
  }
  for (X=0; X<N; X++){
    for (Y=0; Y<N; Y++){
      goukei+=vec.at(X)*vec.at(Y);
    }
    goukei-=vec.at(X)*vec.at(X);
  }
  cout << goukei/2 << endl;
}

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

const int N = 100000 + 5;

int dp[N];


int solve(int* a, int n, int k) {
	dp[0] = 0;
	int i, j;
	for (i = 1; i <= k; i++) {
		int ans = 0;
		for (j = 0; j < n; j++) {
			if (i - a[j] >= 0) {
				if (dp[i - a[j]] == 0){
				    ans = 1;
				    break;
				}
			}
		}
		dp[i] = ans;
	}
	return dp[k];
}

int32_t main() {

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
// 	std::ios::sync_with_stdio(false);
// 	cout.tie(0);
// 	cin.tie(0);

	int n, k;
	cin >> n >> k;
	int a[n];
	int i;
	for (i = 0; i < n; i++)cin >> a[i];

	int ans = solve(a, n, k);

// 	cout << ans << endl;

// 	for (i = 1; i <= k; i++)cout << dp[i] << " ";
// 	cout << endl;
	
	if(ans == 1)cout << "First" << endl;
	else cout << "Second" << endl;

	return 0;
}

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


int main() {

    string s;
    cin >> s;
    int ans = 1000;
    for (int i = 0; i < s.size()-2; ++i) {
        int num = (s[i]-'0')*100 + (s[i+1]-'0')*10 + s[i+2]-'0';
        ans = min(ans, abs(num-753));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
inline 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<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int a,b;
int main(){
	a=read(),b=read();
	for(int i=1;i<=1000000;i++){
		if(i*8/100==a&&i/10==b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 256
import math

a,b,C=map(int,input().split())
C2=math.radians(C)
sin=math.sin(C2)
cos=math.cos(C2)
S = 0.5*a*b*sin
L = a+b+(math.sqrt((a**2+b**2)-(2*a*b*cos)))
H = (a*b*sin/2)/(a/2)
print("{0:.8f}".format(S))
print("{0:.8f}".format(L))
print("{0:.8f}".format(H))

Measured memory_bytes: 7848
#include<stdio.h>
int main(void){
  int h,w,i,j,k;

  for(i = 0;;i++){
    scanf("%d%d",&h,&w);
    
    if(h==0 && w==0)break;
    
    for(j = 0;j < h;j++){
      for(k = 0;k < w;k++){
	if(j == 0 || j == h-1)
	  printf("#");
	else if(k == 0 || k == w-1)
	  printf("#");
	else
	  printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    int N, X;
    cin >> N >> X;
    vector<int> S(N);
    for (int i = 0; i < N; ++i) {
        cin >> S[i];
    }
    sort(begin(S), end(S));

    constexpr int MOD = 1'000'000'007;
    vector<vector<int>> dp(N + 1, vector<int>(X + 1, 0));
    for (int x = 0; x <= X; ++x) 
        dp[0][x] = x;
    for (int i = 0; i < N; ++i) {
        for (int x = 0; x <= X; ++x) {
            dp[i + 1][x] = (dp[i][x % S[i]] + 1LL * dp[i][x] * i) % MOD;
        }
    }

    int res = dp[N][X];
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 79488
n = int(input())
m = n

exp = []

cnt = 0
while n%2 == 0:
    cnt += 1
    n //= 2
if cnt > 0:
    exp.append(cnt)

i = 3
while i*i <= n:
    cnt = 0
    while n%i == 0:
        cnt += 1
        n //= i
    exp.append(cnt)
    i += 2

if n != 1:
    exp.append(1)

opr = 0
for x in exp:
    opr += int((-1+(8*x+1)**(1/2))/2)

print(opr)

Measured memory_bytes: 12948
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long start = sc.nextInt();
        long time = sc.nextInt();

        if(start < time){
           System.out.println("0"); 
        }else{
            System.out.println(start-time);
        }
	}
}

Measured memory_bytes: 21588
package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func main() {
	defer writer.Flush()
	var N, K int
	fmt.Fscanf(reader, "%d %d\n", &N, &K)
	if N % K == 0 {
		fmt.Fprintf(writer, "%d\n", 0)
		return
	}
	fmt.Fprintf(writer, "%d\n", 1)
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define NUM 100


int main(void){
	int goukei;
	int i=0, j=0,r=0;
	int a,b,c;
	int cnt=0;

	scanf("%d%d%d%d",&a,&b,&c,&goukei);
	
	for (i = (goukei / 500);i >= 0 ;i--) {
		if (i <= a) {
			for (j = (goukei / 100);j >= 0;j--) {
				if (j <= b) {
					for (r = (goukei / 50);r >= 0;r--) {
						if (r <= c) {
							if (500 * i + 100 * j + 50 * r == goukei) {
								//printf("i:%d,j:%d,r:%d\n", i, j, r);
								cnt++;
							}
						}
					}
				}
			}
		}
	}


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

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
//#define int long long
#define ll long long
#define endl "\n"
#define inf ULLONG_MAX
#define gcd __gcd
#define deb(x) cout << #x << " " << x << endl;
#define pr(x) cout << x << endl;
 
#define sz(a) ((ll)(a).size())
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())
#define cpres(c, val) (find(all(c), val) != (c).end())
#define dec greater<ll>()
#define sortv(x) sort(all(x))
#define revsortv(x) sort(all(x), dec)
#define com(x) ((x) * (x + 1) / 2)
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define ed end()
#define bs binary_search // to find if an element is present or not in Ologn time, return a boolean
#define ub upper_bound   // to find an element strictly greater than the given no.
#define lb lower_bound   // lb(v,begin(), v.end(), n) gives the iterator
 
#define fo(n) for (ll i = 0; i < n; i++)
#define fo1(n) for (ll i = 1; i < n; i++)
#define fo2(i, n) for (ll i = 0; i < n; i++)
#define fo3(i, a, b) for (ll i = a; i < b; i++)
#define fors(a) cin >> a[i]
#define forp(a) cout << a[i] << " "
#define prv(a, n)  \
    fo(n) forp(a); \
    cout << endl;
#define fob(i, a, b) for (ll i = (b); i >= (a); i--)
 
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef unordered_map<string, ll> umsl;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
 
#define scan(v, n)   \
    vl v;            \
    fo(n)            \
    {                \
        ll item;     \
        cin >> item; \
        v.pb(item);  \
    }
 
const ll INF = 0xFFFFFFFFFFFFFFFL;;
const ll N = 1e9 + 7;
void swap1(ll a,ll b){
    ll temp;
    temp=a;
    a=b;
    b=temp;
}
void solve()
{
string s,k;
cin>>s>>k;
int flag=1;
fo(s.size()){
    if(s[i]!=k[i])flag=0;
}
if(flag==1)cout<<"Yes";
else cout<<"No";
 
}
 
int32_t main(int32_t argc, char **argv)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("inputf.txt", "r", stdin);
    freopen("outputf.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif*/
 
    ll t;
   // cin >> t;
    t=1;
   while (t--)
        solve();
 
    cerr << endl
         << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
    return 0;
}


Measured memory_bytes: 3728
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

vector<vector<ll>> grid;
ll R,C,K;

//dp
bool movable(ll sx,ll sy){
  if(sx<0||sy<0) return false;
  
  return true;
}

vector<vector<vector<ll>>> table;

ll dp(ll i,ll x,ll y){
  if(i<0) return -INF;
  if(x==0&&y==0){
    if(i==0) return 0;
    return grid[0][0];
  }
  if(table[i][y][x]>-INF) return table[i][y][x];
  
  ll ret=-INF;
  if(movable(x-1,y)){
    chmax(ret,dp(i,x-1,y));
    chmax(ret,dp(i-1,x-1,y)+grid[y][x]);
  }
  if(movable(x,y-1)){
    chmax(ret,dp(3,x,y-1));
    if(i>0) chmax(ret,dp(3,x,y-1)+grid[y][x]);
  }
  
  return table[i][y][x]=ret;
}

int main()
{
  cin>>R>>C>>K;
  grid=vector<vector<ll>>(R,vector<ll>(C,0));
  rep(i,K){
    ll r,c,v; cin>>r>>c>>v; r--,c--;
    grid[r][c]=v;
  }
  
  //dp
  table=vector<vector<vector<ll>>>(4,vector<vector<ll>>(R,vector<ll>(C,-INF)));
  cout<<dp(3,C-1,R-1)<<endl;
  
  return 0;
}

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

main(){
  int n; cin>>n;
  vector<int> a(n),b(n);
  rep(i,n){
    cin>>a[i]>>b[i];
  }
  int ans=0;
  for(int i=a.size()-1; i>=0; i--){
    if((a[i]+ans)%b[i]!=0) ans+=b[i]-(a[i]+ans)%b[i];
  }
  cout<<ans<<endl;
}


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


int main() {
  int n;
  int a[101];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    if (i == 0) {
      cout << a[i] << endl;
    }
    else {
      cout << a[i] << " ";
    }
  }
  return 0;
}


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

const int N = 100;
const int INFTY = (1 << 21);
int n, A[N][N];
int d[N];

void bfs(int u) {
	queue<int> q;
	for(int i = 0; i < n; i++) d[i] = N;
	q.push(u);
    d[u] = 0;
    int s;
    while( !q.empty() ) {
    	s = q.front(); q.pop();
    	for( int v = 0; v < n; v++) {
    		if( A[s][v] && d[v] == N ) {
    			q.push(v);
    			d[v] = d[s] + 1;
    		}
    	}


    }
    for ( int i = 0; i < n; i++) {
    	cout << i+1 << ' ' << ( (d[i] == N) ? -1 : d[i] )<< endl;
    }


}
int main() {
	int u, k, v;
	cin>>n;
	for( int i = 0; i < n; i++ ) {
		for( int j = 0; j< n; j++ ) A[i][j] = 0;
	}
	
	for ( int i = 0; i < n; i++ ) {
		cin >> u >> k;
		u--;
		while( k-- ) {
			cin >> v;
			A[u][ v - 1] = 1;
		}
	}
	bfs(0);

	return 0;
}


Measured memory_bytes: 3140
N=int(input())
A=list(map(int,input().split()))
MIN=10**9
for i in range(N):
  count=0
  while 1:
    if A[i] % 2 == 0:
      A[i] //= 2
    else:
      break
    count += 1
  MIN = min(MIN,count)
  if MIN==0:
    print(0)
    exit()
print(MIN)

Measured memory_bytes: 9132
#include<cstdio>
void func (int x,int y);
char fd[13][13];
int main()
{
    int ans;
    for(int i=0;i<13;i++){
        fd[13][i]='0';
    }
    while(scanf("%s",&fd[0])!=EOF){
        ans=0;
        for(int i=1;i<12;i++){
            scanf("%s",&fd[i]);
        }
        for(int i=0;i<12;i++){
            for(int j=0;j<12;j++){
                if(fd[i][j]=='1'){
                    func(i,j);
                    ans++;
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}
void func (int x,int y)
{
    if(fd[x][y]=='0'||fd[x][y]=='\0')return ;
    else {
        fd[x][y]='0';
        func(x+1,y);
        func(x,y+1);
        if(y-1>=0) func(x,y-1);
    }
}

Measured memory_bytes: 964
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,c,t,i;
    cin>>n;
    map<int,int>mp;
    int ar[n];
    for(i = 0;i < n-1;i++)
    {
        cin>>ar[i];
        mp[ar[i]]++;
    }
    for(i = 1;i <= n;i++)
        cout<<mp[i]<<endl;
    return 0;
}


Measured memory_bytes: 13788
from math import *
PI = 3.1415926535898
while True:
	try:
		s = str(raw_input())
		res = ""
		for a in s:
			if a.isalpha():
			 	c = chr(ord(a) + ord('A') - ord ('a'))
				if ord(c) > ord('Z'):
				 	c = chr(ord(c) - 26)
				elif ord(c) < ord('A'):
				 	c = chr(ord(c) + 26)
			 	res += c
			else:
			 	res += a
		print res
	except EOFError:
		break

Measured memory_bytes: 6348
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
 
using namespace std;
const int MOD=1e9+7;
typedef long long ll;
const int MAXN=1e5+15;
const ll INF=0x3f3f3f3f;
 
typedef pair<ll,ll>PA;
 
inline ll qpow(ll x,ll n){ll res=1;for(;n;n>>=1){if(n&1)res=(res*x);x=(x*x);}return res;}
pair<ll,ll>P;
vector<PA> V;
multiset<ll>R,B;
int cmp(PA a,PA b)
{
    return a.first<b.first;
}
int main()
{
    int n;
    ll x,y;
    ll res2,ans;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x>>y;
        V.push_back(make_pair(min(x,y),max(x,y)));
        R.insert(min(x,y));
        B.insert(max(x,y));
    }
    ll maR=-INF,maB=-INF;
    ll miR=INF,miB=INF;
    int col_max=0,col_min=0;
    sort(V.begin(),V.end(),cmp);
    for(int i=0;i<V.size();i++)
    {
        maR=max(V[i].first,maR);
        maB=max(V[i].second,maB);
        miR=min(V[i].first,miR);
        miB=min(V[i].second,miB);
    }
 
    ans=(maR-miR)*(maB-miB);
    //cout<<ans<<endl;
    for(int i=0;i<V.size();i++)
    {
        R.erase(R.find(V[i].first));
        B.insert(V[i].first);
        //swap
        B.erase(B.find(V[i].second));
        R.insert(V[i].second);
 
        //cout<<( *R.rbegin()-*R.begin() )<<" "<<( *B.rbegin()-*B.begin())<<endl;
        ans= min (ans,( *R.rbegin()-*R.begin() )*( *B.rbegin()-*B.begin()) );
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s.at(0) == s.at(1) || s.at(0) == s.at(2) || s.at(1) == s.at(2)) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


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

int main(){
	int a, b;
    cin >> a >> b;
    int ans = a/b;
    if(a%b != 0) ans++;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf (int)50000000000 //5･10^10
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  string s;
  cin>>s;
  int n=s.size(),ans=0,cnt=0;
  rep(i,n) ans+=s[i]-'0';
  cnt=(s[0]-'1')+(n-1)*9;
  cout<<max(ans,cnt)<<endl;
}

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

using namespace std;
typedef long long LL;

int main(){
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans=0;
  rep(r,3001){
    rep(g,3001){
      int res=N-R*r-G*g;
      if(res>=0&&res%B==0) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, raw_input().split())
A = map(int, raw_input().split())
BC = []
A.sort()
for i in range(m):
    b, c = map(int, raw_input().split())
    BC.append((b, c))
BC.sort(key=lambda x : x[1], reverse=True)
def binary_search(val, lo, hi):
    if hi < lo:
        return -1
    mid = (lo + hi) / 2
    if A[mid] <= val and mid + 1 >= len(A):
        return mid
    elif A[mid] <= val and A[mid+1] > val:
        return mid
    elif A[mid] <= val:
        return binary_search(val, mid+1, hi)
    elif A[mid] > val:
        return binary_search(val, lo, mid-1)

boundery = 0
left = []
for b, c in BC:
    lte_index = binary_search(c, 0, len(A)-1)
    if lte_index < boundery:
        continue
    if lte_index + 1 > boundery + b:
        number = b
    else:
        number = lte_index - boundery + 1
    left.append((c, number))
    boundery = boundery + number
    if boundery >= n:
        break
total = 0
num_of_elements = 0
for i in range(len(left)):
    c, num = left[i]
    total += c * num
    num_of_elements += num
for i in range(num_of_elements, n):
    total += A[i]
print total



Measured memory_bytes: 24852
#include <algorithm>
#include <iostream>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <iterator>
#include <cctype>
#include <cstdio>
#include <cstring>
#define rep(counter, limit) for (int counter = 0; counter < limit; counter++)
typedef long long ll; using namespace std;const int INF=1001001001;
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
int main() {

  double r;
  cin>>r;
  cout<<(r*2)*3.1415926535<<endl;

}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define chmin(i, j) i = min(i, j);
#define chmax(i, j) i = max(i, j);
#define rep(i, n) for(int i=0;i<n;i++)
int main() {
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a_s = [int(a) for a in input().split()]

b_s = [0 for _ in range(n)]
for i in range(n - 1, -1, -1):
  name = i + 1
  m_sum = a_s[i]
  for m_name in range(2 * name, n + 1, name):
    m = m_name - 1
    m_sum += b_s[m]
  b_s[i] = m_sum % 2

b_s_in = [str(i + 1) for i in range(n) if b_s[i] > 0]
print(len(b_s_in))
print(" ".join(b_s_in))

Measured memory_bytes: 17204
#include<iostream>
 using namespace std;
 int main(){
     int n,i,j,m;
     string s;
     cin>>n;
     int cards[4][13];
     for (i=0;i<4;i++){
         for (j=0;j<13;j++){
          cards[i][j]=0;   
         }
     }
     
     for (i=0;i<n;i++){
         cin>>s>>m;
         m--;
         if (s=="S"){
             cards[0][m]=1;
         }else if (s=="H"){
             cards[1][m]=1; 
         }else if (s=="C"){
             cards[2][m]=1; 
         }else if (s=="D"){
             cards[3][m]=1;
         }
     }
     for (i=0;i<4;i++){
        for (j=0;j<13;j++){
            if (cards[i][j]==0){
              if (i==0){
                  j++;
                  cout<<"S "<<j<<endl;
                  j--;
              }else if (i==1){
                  j++;
                  cout<<"H "<<j<<endl;
                   j--;
              }else if (i==2){
                  j++;
                  cout<<"C "<<j<<endl;
                   j--;
              }else if (i==3){
                  j++;
                  cout<<"D "<<j<<endl;
                   j--;
              }
            }
        } 
     }
     
     return 0;
     
 }


Measured memory_bytes: 3152
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m;
    cin >> n >> m;

    vvl a(n, vl(m));  // a[i][j] : 人iがj番目に好きなスポーツ
    rep(i, n) {
        rep(j, m) {
            cin >> a[i][j];
            a[i][j]--;
        }
    }

    vl used(m);  // used[i] : 0のときスポーツiを実施する。1のとき実施しない
    vl v(n);  // 人iはv[i]番目に好きなスポーツに参加する
    ll ans = n;
    rep(loop, m) {
        vl cnt(m);  // cnt[i] : スポーツiに参加する人数
        rep(i, n) {
            while(used[ a[i][v[i]] ]) {  // 実施されているスポーツの中で人iが最も好きなスポーツを探す
                v[i]++;
            }
            cnt[ a[i][v[i]] ]++;  // 人iはスポーツa[i][v[i]]に参加する
        }
        pair<ll, ll> p = make_pair(-1, -1);  // p = (参加人数の最大値, スポーツの番号)
        rep(i, m) {
            chmax(p, make_pair(cnt[i], i));
        }
        chmin(ans, p.first);  //「参加人数の最大値」の最小値を更新
        used[p.second] = 1;  // 以降p.second番目のスポーツは実施しないものとする 
    }
    
    out(ans);
    re0;
}

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



int main() {
    int N;
    cin>>N;
    vector <int> a(N,0);

    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }
    int k=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,j=0,s=0;

    for(int i=0;i<N;i++){
        if(a.at(i)<400){
            k=1;
        }else if(a.at(i)<800){
            b=1;
        }else if(a.at(i)<1200){
            c=1;
        }else if(a.at(i)<1600){
            d=1;
        }else if(a.at(i)<2000){
            e=1;
        }else if(a.at(i)<2400){
            f=1;
        }else if(a.at(i)<2800){
            g=1;
        }else if(a.at(i)<3200){
            h=1;
        }else{
            s=1;
            j++;
        }
    }

    
    int min = k+b+c+d+e+f+g+h;
    if(min==0) {
        min += s;
    }
    int max = k+b+c+d+e+f+g+h+j;

    cout<<min<<' '<<max<<endl;

}


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

int main() {
   int N,T,A;
   cin >>N>>T>>A;
   map<double,int>mp;
   for(int i=1;i<=N;i++){
       int heighti;
       cin >>heighti;
       double tem = A -(T-heighti*0.006);
       if(tem<0)tem = -tem;
       mp[tem] =i;
   }
   for(auto p:mp){
       cout << p.second <<endl;
       break;
   }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
// #include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
    cin >> n;
    vector<long long int> arr(n, 0);
    vector<long long int> pre(n, 0);
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    long long int mod = 1000000007;
    pre[n-1] = 0;
    for(int i = n-2; i >= 0; i--){
        pre[i] = (pre[i+1] + arr[i+1])%mod;
    }
    long long int ans = 0;
    for( long long int i = 0; i < n-1; i++){
        ans = (ans + (arr[i]*pre[i])%mod)%mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6052
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  string s,t;cin >> s >> t;
  cout << t << s << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main() {
    char c = 0;
    int count = 0;
    int len = 0;
    for (int i=0; i<15; i++) {
        c = getchar();
        if (c == 'o') {
            len++;
            count++;
        }
        else if (c == 'x') {
            len++;
        }
        else {
            break;
        }
    }
    int hoge = 15 - len + count;
    if (hoge >= 8) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
N = int(input())
A = list(int(input())for i in range(N))
A.sort()
L = []
R = []
for i in range(N):
    if i%2 == 0:
        L.append(A[i//2])
        R.append(A[-(i//2)-1])
    else:
        L.append(A[-(i//2)-1])
        R.append(A[i//2])
saL,saR = [],[]
for i in range(N):
    saL.append(abs(L[i]-L[i-1]))
    saR.append(abs(R[i]-R[i-1]))
print(max(sum(saL)-min(saL),sum(saR)-min(saR)))

Measured memory_bytes: 16964
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, K;
	cin >> N >> K;


	vector<Int> a(N);
	vector<Int> f(N);

	for (Int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	for (Int i = 0; i < N; i++) {
		cin >> f[i];
	}
	sort(f.begin(), f.end(), greater<Int>());

	Int ok = 1e12;
	Int ng = -1;
	while (abs(ok - ng) > 1) {
		Int mid = (ok + ng) / 2;
		Int cnt = 0;
		for (Int i = 0; i < N; i++) {
			if (a[i] * f[i] < mid)continue;
			//else cnt += a[i] * f[i] - mid;
			else cnt += a[i] - mid / f[i];
		}
		(cnt <= K ? ok : ng) = mid;
    }
	cout << ok << "\n";
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>

#define max 5

//qsort(d, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}

int main()
{
    int a[max], n, m, i;
    char s[max];
    
    //scanf("%d %d", &n, &m);
    for (i=0; i<4; i++) {
        scanf("%c", &s[i]);
    }
    
        if (s[0]!=s[1]&&s[1]!=s[2]&&s[3]!=s[2]) {
            printf("Good");
        } else {
            printf("Bad");
        }
    
    return 0;
}




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

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

using namespace std;

int main() {
  while(1){
    int n,d;
    cin>>n>>d;
    if(!n)break;
    vector<vector<int>> m(n);
    vector<int> st(n);
    REP(i,n){
      int mi;
      cin>>mi;
      REP(j,mi) {
        int c;
        cin>>c;
        m[i].push_back(c);
        st[i] += c;
      }
    }
    bool ok = true;
    while(1){
      int mi = max_element(begin(st),end(st))-begin(st);
      int mx = st[mi];
      if (mx == 0) break;
      int nmx = 0;
      REP(i,n) {
        if (i==mi) continue;
        while(st[i] && st[i]-m[i].back() >= mx-d) {
          st[i] -= m[i].back();
          m[i].pop_back();
        }
        nmx = max(nmx, st[i]);
      }
      st[mi] -= m[mi].back();
      if (nmx - st[mi] > d) {
        ok = false;
        break;
      }
      m[mi].pop_back();
    }
    if (ok)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,T;
    cin>>N>>T;
    vector<int>t(N);
    for(int i=0;i<N;i++){
        cin>>t[i];
    }
    int a=N*T;
    for(int i=1;i<N;i++){
        if((T-(t[i]-t[i-1]))>0){
            a-=(T-(t[i]-t[i-1]));
        }
    }
    cout<<a<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll x, y;
	cin >> x >> y;
	
	
	if( x == y) cout << 0;
	else if(-x == y) cout << 1;
	else if(x > 0 && y > 0){
		if(x < y) cout << y-x;
		else cout << x-y+2;
	}
	else if(x < 0 && y < 0){
		if(x < y) cout << y - x;
		else cout << 2 + x - y;
	}
	else if(x == 0){
		if( y > 0 ) cout << y;
		else cout << abs(y) + 1;
	}
	else if(y == 0){
		if(x > 0) cout << x +1;
		else cout <<  abs(x);
	}
	else cout << abs(abs(y) - abs(x)) + 1;

			

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const string nl="\n";
const ll MOD=1000000007;

int main(){
    int l=-1000000;
    int r=1000000;
    int k,x;cin>>k>>x;
    l=max(l,x-k+1);
    r=min(r,x+k-1);
    for(int i=l;i<=r;i++) cout<<i<<" ";
    return 0;
}

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

ll ans=0;
string s;

void dfs(ll i,ll val,ll cnt)
{
    if(i==s.length())
    {
        ans+=val+cnt;
        return;
    }
    ll x=s[i]-'0';
    dfs(i+1,x,val+cnt);
    dfs(i+1,val*10+x,cnt);
}

int main()
{
    cin>>s;
    dfs(1,s[0]-'0',0);
    cout<<ans;
    return 0;
}


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

int main() {
    char list[] = {'a','e','i','o','u'};
    char c;
    cin >> c;
    for(int i = 0;i < 5;i++) {
        if(list[i] == c) {
            cout << "vowel" << endl;
            return 0;
        }
    }
    cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
  int S, hour, minutes, seconds;
  cin >> S;
  hour = S/3600;
  minutes= (S%3600)/60;
  seconds = (S%3600)%60;
  cout << hour << ":" << minutes << ":" << seconds << endl;
}
/*??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ,,,z=~'???'+''?????????,??? 
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????,??¨?´ ??????????????? "':';:;???;, 
??????????????????????????????????????????????????????????????????????????????????????????????????????????????? ,???' ????´`????????????,????????????????????? "',`, 
????????????????????????????????????????????????????????????????????????????????????????????????????????? ,??? ????????? `????????????????????????????????? ???:;:, 
??????????????????????????????????????????????????????????????????????????????????????? /??????????????? _ =???????????????=;,z,???????????? ???;???::??????????????????????????? ?????????????????? 
??????????????????????????????????????????????????????????????? ?????????????????????/???????????? ,???,?´?????? /????´`??? ??????`??? ??????,??????:????????????????????????????????????????????? 
???????????????????????? ????????? ??? ??????????????????????????????????????? / ?????????, '-???_`???_/,????????????????????? ??? ???;::???;:???????????????????????????????????? 
???????????????????????? ????????????????????£????????????????????? ??? ?????? ,'?????????,????´?????? ???`i???!???????????????????????? ,,???;::???:????????? ???????????? ?????????????????? 
????????????????????????????????? ???????????? ??? ????????????????????????;i?????????????´ ??£`??? / '???????????????????????????:???;:???::???"???????????????????????????????????? 
?????????????????????????????? ???????????? ??? ??? ????????? ???????????????:!?????? ??????`??° =;??¨'????????????????????????,,???:;???;????????????????????????????????????????????????????????? 
??????????????????????????? ??? ????????? ??? ??? ??? ????????? ????????? ?´:::::.???. ???????????£?´?????????*/

Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <sstream>
using namespace std;
#define rep(i,n) for (int i=0; i<n; i++)
typedef long long ll;


int main(){
    int n;
    cin >> n;
    int k;
    cin >> k;
    int q;
    cin >> q;
    k -= q;
    vector<int> a(q);
    rep(i,q) cin >> a[i];
    vector<int> point(n);
    rep(i,n) point[i] = k;

    rep(i,q){
        point[a[i]-1]++;
    }

    rep(i,n){
        if (point[i]<=0){
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
n, k = map(int, input().split())
s = input()
l = [0,0] if (s[0] == '0') else [0]
for i in range(1, n):
    if s[i-1] != s[i]:
        l += [i];
l += [n] if (s[-1] == '1') else [n,n]
ll = len(l)
pl = 2 * k + 1
if ll <= pl:
    print(n)
else: 
    print(max(l[pl+i]-l[i] for i in range(0, ll-pl+1, 2)))


Measured memory_bytes: 7108
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
using namespace std;
int main(){
int n,s;
cin>>n>>s;
if (s > n)
cout<<"0";
else
cout<<n-s;
system ("pause");
return 0;
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	for(size_t i = 0; i < N; i++)
	{
		long double p , q;
		cin >> p >> q;
		int count = 0;
		for(long double m = 0; m < 145; m++)
		{
			for(long double n = 0; n < 145; n++)
			{
				if(m || n)
				{
					long double x = ( m*q - p*n ) / ( m*m + n*n );
					long double y = ( p*m + n*q ) / ( m*m + n*n );
					if(x == ( long long int )x&&y == ( long long int )y)
					{
						count++;
					}
				}
			}
		}
		if(count > 4)
		{
			cout << 'C' << endl;
		} else
		{
			cout << 'P' << endl;
		}
	}
}

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

int main(){
    unsigned long N;
    cin >> N;
    vector<long> A(N);
    for(auto &i : A)cin >> i;
    cout << accumulate(A.cbegin(), A.cend(), 0L, [](auto a, auto b) { return abs(a) + abs(b); }) -
            (1 & count_if(A.cbegin(), A.cend(), [](auto a) { return a < 0; }) ?
             abs(*min_element(A.cbegin(), A.cend(), [](auto a, auto b) { return abs(a) < abs(b); })) * 2 : 0) << endl;
}

Measured memory_bytes: 1024
/***** author : C0d1ngPhenomena *****/

	#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	
	using namespace std;
	ll arr[1000000];
	int main()
	{
		std::ios::sync_with_stdio(false);
		cin.tie(NULL);
		ll N;
		cin >> N;
		ll a;
		for (int i = 1; i < N; ++i)
		{
			cin >> a;
			arr[a]++;
		}

		for (int i = 1; i <= N; ++i)
		{
			cout << arr[i]<<endl;
		}
		
		

		return 0;
	}


Measured memory_bytes: 5216
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin>>n;
	int a[2][110] = {};
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cin>>a[i][j];
		}
	}

	int ans = 0;
	for (int p = 0; p < n; p++)
	{
		int res = 0;
		int r = 0;
		for (int i = 0; i < n; i++)
		{
			res += a[r][i];
			if(i == p){
				res += a[r+1][i];
				r = 1;
			}
		}
		ans = max(ans,res);
	}
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
typedef pair<int, P>PP;
constexpr long long inf = 1e17;
constexpr int mod = 1000000007;

int p[200006];
int rm[200006];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> p[i];
	rm[0] = inf;
	rep(i, n)rm[i + 1] = min(rm[i], p[i]);
	int ans = 0;
	rep(i, n)if (rm[i] > p[i])ans++;
	cout << ans << endl;
}

Measured memory_bytes: 6720
// Problem : D - Handstand 2
// Contest : AtCoder Beginner Contest 152
// URL : https://atcoder.jp/contests/abc152/tasks/abc152_d
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

map<int, int> ht;

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll ans = 0;
	int N; cin >> N;
	rep1(i, N) {
		int ld = i%10;
		int v = i;
		while(v/10) v /= 10;
		ht[ld*10+v]++;
	}
	rep1(i, N) {
		int ld = i%10;
		int v = i;
		while(v/10) v /= 10;
		ans += ht[v*10+ld];
	}
	cout << ans << endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> a(N+1);
    for(int i(1);i<N+1;++i) cin >> a[i];
    int b_sum;
    vector<int> b(N+1,0);
    for(int i(N);i>=1;--i){
        b_sum = 0;
        for(int j(i);j<=N;j+=i){
            b_sum += b[j];
        }
        if(b_sum%2 != a[i]){
            b[i] = 1;
        }
    }
    int M(0);
    for(int i(1);i<N+1;++i){
        if(b[i] == 1) M++;
    }
    cout << M << endl;
    if(M > 0){
        for(int i(1);i<N+1;++i){
            if(b[i]) cout << i << ' ';
        }
    }
    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int v,e;
int cnt[10000]={};
bool visited[10000]={};
vector<int> edge[10000];

void print(int v){
  int i;
  if(visited[v])return;

  printf("%d\n",v);
  visited[v]=1;
  for(i=0;i<edge[v].size();i++){
    cnt[edge[v][i]]--;
    if(cnt[edge[v][i]]==0){
      print(edge[v][i]);
    }
  }
}

int main(void){
  int s,t,i,j;
  cin>>v>>e;
  for(i=0;i<v;i++){
    edge[i].clear();
  }

  for(i=0;i<e;i++){
    cin>>s>>t;
    edge[s].push_back(t);
    cnt[t]++;
  }

  for(i=0;i<v;i++){
    if(cnt[i]==0)print(i);
  }

  return 0;
}


Measured memory_bytes: 3868
EOL = '0 0'
stdin = [line for line in iter(input, EOL)]
lines = (map(int, line.split()) for line in stdin)

for H, W in lines:
    even = ('#.' * (W // 2 + 1))[:W]
    odd  = ('.#' * (W // 2 + 1))[:W]
    for i in range(H):
        if i % 2 == 0:
            print(even)
        else:
            print(odd)
    print()
            


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define mod 1000000007
#define maxn 200005
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
#define pb(x) push_back((char)(x))
#define pf(x) push_front((ll)(x))
#define nl cout << "\n";
 
// struct Data{
// 	ll val,pos;
// };

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

// bool comp(Data &a,Data &b){
// 	return (a.val<b.val);
// }



int main(){
	ini();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	ll n,k;
	cin >> n >> k;
	ll a[n];
	f(i,0,n){
		cin >> a[i];
	}

	sort(a,a+n);

	ll ans=0;
	f(i,0,k){
		ans+=a[i];
	}

	cout << ans;

}

Measured memory_bytes: 3660
#賢く解くと...
n=int(input())
mod=10**9+7
memo=[{} for _ in range(n+1)]

def judge(last4):
    for i in range(4):
        t=list(last4)
        if i<3:
            t[i],t[i+1]=t[i+1],t[i]
        s=''.join(t)
        if 'AGC' in s:
            return False
    return True

def dfs(i,last3):
    if last3 in memo[i]:
        return memo[i][last3]
    if i==n:
        return 1
    res=0
    for c in 'ACGT':
        if judge(last3+c):
            res=(res+dfs(i+1,last3[1:]+c))%mod
    memo[i][last3]=res
    return res

print(dfs(0,'TTT'))

Measured memory_bytes: 3888
import sys
input = sys.stdin.readline

s = input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])

if 1 <= 10*a+b <=12:
  if 1 <= 10*c+d <=12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1 <= 10*c+d <=12:
      print('YYMM')
  else:
      print('NA')

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    int ans=0;
    for(int i=0;i<n;++i){
        int k=upper_bound(all(a),a[i]+2)-lower_bound(all(a),a[i]);
        ans=max(ans,k);
    }
    cout<<ans<<endl;
}


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

using namespace std;

int main()
{
	int temp = 1;
	for (int i =0; i < 5; i++)
	{
		cin >> temp;
		if (temp == 0)
		{
			cout << i + 1 << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int x1=sc.nextInt(),x2=sc.nextInt(),x3=sc.nextInt(),x4=sc.nextInt(),x5=sc.nextInt();
	  if(x1==0) {
		  System.out.println(1);
	  }else if(x2==0) {
		  System.out.println(2);
	  }else if(x3==0) {
		  System.out.println(3);
	  }else if(x4==0) {
		  System.out.println(4);
	  }else {
		  System.out.println(5);
	  }
  }
}



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

#define ll long long
#define pb push_back
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define inf 0x3f3f3f3f

const int N = 1e5+5;
int L[N], R[N];

int main(){
    fcin;
    int n, m;
    cin >> n >> m;
    int l = 1, r = n;
    for(int i = 0; i < m; i++){
        cin >> L[i] >> R[i];
        l = max(l, L[i]);
        r = min(r, R[i]);
    }
    
    cout << max(r - l + 1, 0);

    return 0;
}


Measured memory_bytes: 1024