akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-3;
const double PI = acos(-1);

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


int main(){
	int m, n, d;
	cin>>m>>n;
	int ans = 0, tmp = 0;
	rep(i, m){
		tmp = 0;
		rep(j, n){
			cin>>d;
			if(d == 1) tmp++;
		}
		ans = max(ans, tmp);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1164
#include <iostream>

int main() {
	unsigned int a, b;
	std::cin >> a >> b;
	a -= 2;
	b -= 2;
	if (a < b) {
		std::cout << "Bob" << std::endl;
	} else if (a == b) {
		std::cout << "Draw" << std::endl;
	} else {
		std::cout << "Alice" << std::endl;
	}
}


Measured memory_bytes: 256
//Energy Drink Collector

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,int> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int n,m;cin>>n>>m;
    vector<p>a(n);
    rep(i,0,n)cin>>a[i].first>>a[i].second;
    sort(range(a));
    ll ans = 0,c=0;
    for(;m>0;){
        ans+=a[c].first;
        m--;
        a[c].second--;
        if(a[c].second==0)c++;
    }
    cout<<ans<<nnn;
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> l(m), r(m);
    for(int i = 0;i < m;i++){
        cin >> l[i] >> r[i];
    }
    int minNumber = l[0];
    int maxNumber = r[0];
    for(int i = 1;i < m;i++){
        minNumber = max(l[i], minNumber);
        maxNumber = min(r[i], maxNumber);
    }
    cout << max(maxNumber - minNumber + 1, 0) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int a[N];
    for(int i = 0;i < N;i++){
        cin >> a[i];
    }
    int ans = 0;
    int count  = 0;
    int j = 1;
    for(int i = 0;i < 100000;i++){
        count++;
        if(j > N)
        break;
        if(a[j - 1] == 2){
             ans = 1;
             break;
         }
         j = a[j - 1];
    }
    if(ans == 1){
        cout << count <<endl;
    }else{
        cout << dec << -1 << endl;
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  
  double x=0,y=0,radian;
  int toward,deg1,deg2;
  char ch;
  
  cin >> toward >> ch >> deg1;
  y += toward;
  
  while(1){
      cin >> toward >> ch >> deg2;
      if (toward==0&&deg2==0)break;
      
      radian = acos(-1) /180  * deg1;
      x += sin(radian)*toward;
      y += cos(radian)*toward;
      deg1 += deg2;
  }
  
  cout << (int)x << endl << (int)y << endl;
  return 0;
  
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
using P = pair<int,int>;
typedef long long ll;


#define rep(i,n) for (int i=0; i<(n); i++)
//const int INF =1001001001;
const ll BIG = 1e9+7;
const double PI = 3.141592653589793;

int main(){
    int n;
    cin >> n;
    map<string, int> a;
    rep(i,n){
        string s;
        cin >> s;
        if(a[s]==1){
            cout << "NO" << endl;
            return 0;
        }
        a[s]+=1;
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define in(s,x) s.find(x) != s.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
//const ll mod=1000000007;
const ll mod = 1000003;
const ll INF= 1LL<<60-1;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}
// head


int m,n,k,res,tmp,tmp2,tmp3,h,w,ans;
//int a[5200] = {};
int a[300000];
deque<PII> que;
string s;
map<int,VPII> kukan;
vector<PII> g[3000];
//int dp[200000];
int flag;
//VPII g2[200000];
int cost[200005];
double dp[1020][2] = {};
double dp2[1020][2] = {};
//VVI g(200005);

const int CMAX = 50000000;
long long fact[CMAX] = {};
long long revFact[CMAX] = {};
void setFact(int N)
{
  fact[0] = 1;
  for (int i = 1; i<N; i++)
  {
    fact[i] = fact[i-1]*i;
    fact[i] %= mod;
  }
  revFact[N-1] = powmod(fact[N-1],mod-2);
  for (int i=N-2;i>=0;i--)
  {
    revFact[i] = revFact[i+1]*(i+1);
    revFact[i] %= mod;
  }
}

int q;
int d[300000];
VI v;
vector<pair<int,pair<int,int>>> sine;

signed main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
	cin>>q;
  setFact(mod);
  rep(i,0,q){
    cin>>h>>w>>n;
    if (w == 0){
      cout<<powmod(h,n)<<endl;
    }
    else{
      w %= mod;
      h%=mod;
      m = powmod(w,mod-2);
      h *= m;
      h%=mod;
      if(h+n-1>=mod){cout<<0<<endl;}
      else if (h==0){cout<<0<<endl;}
      else{
        res = (fact[h+n-1]*revFact[h-1])%mod*powmod(w,n);
        cout<<res%mod<<endl;
      }

    }
  }
}

Measured memory_bytes: 21376
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int a,b,h;
  cin>>a;cin>>b;cin>>h;
  cout<<(a+b)*h/2<<endl;
  return 0;
}



Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

ll ans[base10_6]={};
ll pointR=0;
ll pointL=0;
ll countR=0;
ll countL=0;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string S;
    cin >> S;

    string bef = "L";
    ll si = 0;
    for( ll si = 0 ; si <= (S.size()-1)-1 ; si++ ){
        stmp = S.substr(si,2);
        if(stmp=="RL"){
            pointR = si;
            pointL = si+1;
            countR++;
        }else if(stmp=="RR"){
            countR++;
        }else if(stmp=="LL"){
            countL++;
        }

        if(stmp=="LR" || si == (S.size()-1)-1){
            countL++;
            ans[pointR] = ((countR+1) / 2) + (countL / 2);
            ans[pointL] = ((countL+1) / 2) + (countR / 2);
            countL=0;
            countR=0;
        }
    }

    rep(si,S.size()) cout << ans[si] << " ";

}

Measured memory_bytes: 4532
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int a[N],n,rec;
long long ans;
int main() {
  scanf("%d",&n);
  for (int i = 1 ; i <= n ; ++ i)
    scanf("%d",&a[i]);
  for (int i = 1 ; i <= n ; ++ i) {
    ans = ans + a[i] / 2;
    if (a[i]&1) {
      if (rec) {
	  ans = ans + 1;
	  rec = 0;
      } else rec = i;
    }
    if (a[i] == 0) rec = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

int x, a, b;

void init()
{

}


int main()
{
	init();

	cin >> x >> a >> b;

	if (b <= a)
		cout << "delicious" << endl;
	else if (x + a >= b)
		cout << "safe" << endl;
	else
		cout << "dangerous" << endl;
}


Measured memory_bytes: 256
from collections import deque
n,m = map(int,input().split())
X = sorted(list(map(int,input().split())))
diffs = deque()
if m <= n:
  print(0)
else:
  for i in range(m - 1):
    diffs.append(X[i + 1] - X[i])
  diffs = deque(sorted(diffs,reverse = True))
  for i in range(n - 1):
    diffs.popleft()
  print(sum(diffs))

Measured memory_bytes: 14216
#include <stdio.h>
int max(long long a, long long b) {
	if (a > b)
		return a;
	else
		return b;
}
int main() {
	long long a, b, c, x, y, min = 1e18, ans;
	scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &x, &y);
	for (long long i = 0; i <= 1e5; i++) {
		ans = i * 2 * c;
		ans += max(x - i, 0) * a;
		ans += max(y - i, 0) * b;
		if (ans < min) min = ans;
	}
	printf("%lld\n", min);
	return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 18;
char C[CM + CL], * ci = C + CL, * owa = C + CM, c;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	fread(ci, 1, CM, stdin);
	int N = 0;
	while ((c = *ci++) >= '0') N = N * 10 + c - '0';
	int D[10];
	int d = 1;
	rep(i, 10) {
		D[i] = d;
		d *= 10;
	}

	ll p[20][20] = {};
	rep(i, N) {
		if (ci - owa > 0) {
			memcpy(C, owa, CL);
			ci -= CM;
			fread(C + CL, 1, CM, stdin);
		}

		ll kari = 0;
		while ((c = *ci++) >= '0') kari = kari * 10 + c - '0';
		int d = 9;
		if (*(ci - 1) == '.') {
			ll tmp = *(ll*)ci;
			if ((tmp & ma0) ^ ma0) {
				int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
				tmp = tmp << dig & ma1;
				tmp = tmp * 10 + (tmp >> 8) & ma2;
				tmp = tmp * 100 + (tmp >> 16) & ma3;
				tmp = tmp * 10000 + (tmp >> 32) & ma4;
				ci += (72 - dig >> 3);
				d -= (64 - dig >> 3);
				kari = kari * D[(64 - dig >> 3)] + tmp;
			}
			else {
				tmp = tmp & ma1;
				tmp = tmp * 10 + (tmp >> 8) & ma2;
				tmp = tmp * 100 + (tmp >> 16) & ma3;
				tmp = tmp * 10000 + (tmp >> 32) & ma4;
				ci += 8;
				d -= 8;
				kari = kari * 100000000 + tmp;
				if (*ci >= '0') {
					kari = kari * 10 + *ci++ - '0';
					d--;
				}
				ci++;
			}
		}
		int a = __builtin_ctzll(kari) + d;
		if (a > 18) a = 18;
		int b = d;
		while (kari % 5 == 0) {
			b++;
			kari /= 5;
		}
		p[a][b]++;
	}
	ll kotae = 0;
	rep(a, 19) rep(b, 19) if (p[a][b]) {
		ll P = p[a][b];
		for (int x = 18 - a; x <= 18; x++) {
			for (int y = 18 - b; y <= 18; y++) {
				kotae += P * p[x][y];
			}
		}
	}
	for (int a = 9; a <= 18; a++) {
		for (int b = 9; b <= 18; b++) {
			kotae -= p[a][b];
		}
	}

	printf("%lld\n", kotae / 2);

	Would you please return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 10000;

int main(void){
    ll N;
    ll answer = 0;

    cin >> N;
    rep(i, N){
        ll a;
        cin >> a;
        while(a % 2 == 0){
            a /= 2;
            answer ++;
        }
    } 

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 384
#region using directives
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Convert;
#endregion

class Program
{
    static void Main()
    {
        string[] s = (ReadLine()).Split();
        int n = ToInt32(s[0]);
        int a = ToInt32(s[1]);
        int b = ToInt32(s[2]);
        Console.WriteLine(Math.Min(a*n,b));
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
int val[10000];
bool isPrime(int a){
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
int main(){
	int now=1;
	int sum=0;
	for(int i=2;i<=20000;i++){
		if(isPrime(i)){
			sum+=i;
			val[now++]=sum;
			//printf("%d ",i);
		}
	}
	while(1){
		int t;
		scanf("%d",&t);
		if(t==0)return 0;
		int ret=0;
		for(int i=0;i<now;i++){
			for(int j=i+1;j<now;j++){
				if(val[j]-val[i]==t)ret++;
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 764
N = gets.to_i
h = gets.split.map(&:to_i)
INF = Float::INFINITY
dp = Array.new(100010){INF}

dp[0]=0

N.times do |i|
  dp[i] = dp[i-1]+(h[i]-h[i-1]).abs if dp[i] > dp[i-1]+(h[i]-h[i-1]).abs
  if i>1
    dp[i] = dp[i-2]+(h[i]-h[i-2]).abs if dp[i] > dp[i-2]+(h[i]-h[i-2]).abs
  end
end

puts dp[N-1]

Measured memory_bytes: 8844
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()

int p;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%p;
    }
    return n*rep_jijo(n,x-1)%p;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}
int main(){
    int n;
    ll ans=0;
    string s;
    cin >> n >> p >> s;
    if(p==2){
        rep(i,n){
            int x=s[i]-'0';
            if(x%2==0) ans+=i+1;
        }
        cout << ans << endl;
    }
    else if(p==5){
        rep(i,n){
            int x=s[i]-'0';
            if(x%5==0) ans+=i+1;
        }
        cout << ans << endl;
    }
    else{
        reverse(all(s));
        vector<ll>a(n);
        rep(i,n) a[i]=(s[i]-'0')*rep_jijo(10,i)%p;
        vector<ll>rui(n+1);
        rep(i,n+1){
            if(i==0) rui[i]=0;
            else rui[i]=(rui[i-1]+a[i-1])%p;
        }
        map<ll,ll>mp;
        rep(i,n+1) mp[rui[i]]++;
        for(auto p:mp){
            ans+=p.second*(p.second-1)/2;
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main() {
  int N, M; cin >> N >> M;
  vector<int> a(M), b(M);
  for (int i = 0; i < M; ++i) cin >> a[i] >> b[i];
  sort(begin(a), end(a));
  int ans = 0;
  for (int i = 1; i < M; ++i) ans += max(0, N - a[i]);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N;
    cin >> N;
    long long ans = 0;
    for(int i = 1; i <= N; i++){
        if(i%3 != 0 && i%5 != 0) ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main() {
  string S[] =  {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
  string s;
  cin >> s;
  for (int i = 0; i < 8; i++) {
    if (S[i] == s) {
      cout << 7 - i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
 
int main() {
    int n, d, ans;
    cin >> n >> d;
    int m = 2*d+1;
    if(n%m == 0) {
        ans = n/m;
    }
    else {
        ans = n/m + 1;
    }

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

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

int main(void){
  string s;
  int retval=0;
  while(cin>>s){
    bool flag=true;
    for(int i=0;i<s.size();i++){
      if(s[i]!=s[s.size()-1-i]){
        flag=false;
        break;
      }
    }
    if(flag)retval++;

  }
  cout<<retval<<endl;
  return 0;
}



Measured memory_bytes: 3216
def bubble_sort(a, n):
    for i in range(n-1):
        for j in range(n-1, i, -1):
            if a[j-1][1] > a[j][1]:
                a[j-1], a[j] = a[j], a[j-1]

    return a


def selection_sort(a, n):
    for i in range(n-1):
        min_j = i
        for j in range(i+1, n):
            if a[min_j][1] > a[j][1]:
                min_j = j
        if min_j != i:
            a[min_j], a[i] = a[i], a[min_j]

    return a


if __name__ == "__main__":
    n = int(input())
    a = input().split()

    result1 = bubble_sort(a[:], n)
    result2 = selection_sort(a[:], n)
    print(*result1)
    print("Stable")
    print(*result2)
    print("Stable" if result1 == result2 else "Not stable")


Measured memory_bytes: 5616
def main():
  N = int(input())
  AC = 0
  WA = 0
  TLE = 0
  RE = 0
  for i in range(N):
    s = input()
    if s == "AC":
      AC+=1
    elif s == "WA":
      WA+=1
    elif s == "TLE":
      TLE+=1
    else:
      RE+=1
  print("AC x {}".format(AC))
  print("WA x {}".format(WA))
  print("TLE x {}".format(TLE))
  print("RE x {}".format(RE))



if __name__ == "__main__":
    main()

Measured memory_bytes: 9148
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	long long int a[n]={};
	long long int b[n]={};
	long long int c[n]={};
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&a[i], &b[i]);
	}
	vector<pair<int, int> >CandID;
	
	for(int i=0;i<n;i++){
		c[i]=a[i]+b[i];
		CandID.push_back(make_pair(c[i], i));
	}
	long long int ans=0;
	sort(CandID.begin(), CandID.end());
	for(int i=0;i<n;i++){
		int x=CandID[n-1-i].second;
		if(i%2==0){
			ans=ans+a[x];
		}else{
			ans=ans-b[x];
		}
	}
	printf("%lld\n",ans);
	return 0;
}
	

Measured memory_bytes: 3704
#include<stdio.h>
    int main(void)
    {
    int A,B,C,K;
     
      scanf("%d%d%d",&A,&B,&C);
     
      if(A*C<B)
        printf("%d\n",C);
     
      else if((A<B)||(A*B>C)){
        K=B/A;
        printf("%d\n",K);
      }
      else
        printf("0\n");
     
     
      return 0;
    }

Measured memory_bytes: 128
a, b = list(map(int,input().split()))
z= 0
if b% 2!=0:
    print("No")
    quit()
else:
    while a>=0: 
        c = a*2+z*4
        if c ==b:
            print("Yes")
            quit()
        a-=1
        z+=1
print("No")

Measured memory_bytes: 9180
from pprint import pprint

INF = 1000000
dx = [1, -1, 0,  0]
dy = [0,  0, 1, -1]

# 入力
h, w = map(int, input().split())
maze = []
for i in range(h):
    maze.append(list(input()))

# ワーシャルフロイド用に枠を作る。
# 2次元マップしてもいいが面倒なので、１次元にする。[0 - x][0 - y]を[0- x * y]にflattenする
wsmap = lambda a, b: (a * w + b)
dp = []
# 辺がない時はINFを入れのでデフォルト値とする
for i in range(h * w):
    dp.append([INF] * (h * w))

# 迷路ををグラフにする。
for y in range(h):
    for x in range(w):
        if maze[y][x] == "#": # そのマスが壁なら何もしない(他のマストの連結はないので)
            continue
        # ワーシャルフロイドでは自分自身へのコストは0にしておく。
        dp[wsmap(y, x)][wsmap(y, x)] = 0
        # ４方向に移動できるかの判定
        for dir in range(len(dx)):
            nx, ny = x + dx[dir], y + dy[dir]
            if -1 < nx and nx < w and -1 < ny and ny < h: # 枠をはみ出ないかチェック
                if maze[ny][nx] != "#": # そのマスが壁でないなら
                    #print(wsmap(y, x))
                    #print("--")
                    #print("y, x {0}, {1}".format(ny, nx))
                    #print(wsmap(ny, nx))
                    dp[wsmap(y, x)][wsmap(ny, nx)] = 1 # コストを1にする

# ワーシャルフロイドする
for kk in range(h * w):
    for ii in range(h * w):
        for jj in range(h * w):
            dp[ii][jj] = min(dp[ii][jj], dp[ii][kk] + dp[kk][jj])

# これで結果が出たので
#print(dp)
res = -1
for i in range(h * w):
    for j in range(h * w):
        if dp[i][j] != INF:
            res = max(res, dp[i][j])
print(res)




Measured memory_bytes: 44892
S = input()
l = []
for i in S:
    if i == "0":
        l.append("0")
    if i == "1":
        l.append("1")
    if i == "B" and len(l) > 0:
        del l[len(l) - 1]

for i in l:
    print(f"{i}", end="")
print()


Measured memory_bytes: 9068
# AOJ 1004 Pair of Primes

MAX_N = 10000

# エラトステネスの篩
prime = Array.new(MAX_N + 1, true)
prime[0] = prime[1] = false
(2..(Math.sqrt(MAX_N).to_i)).each do |k|
  next unless prime[k]

  l = 2 * k
  until l > MAX_N
    prime[l] = false
    l += k
  end
end

while line = gets
  n = line.to_i
  n_p = 0
  pair = Array.new(n + 1) {|i| n + 1 - i}

  (1..n).each do |i|
    n_p += 1 if prime[i] && prime[pair[i]]
  end

  puts n_p
end

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i <= (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(v) (v).begin(), (v).end()
#define sp cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, a;
    cin >> h >> a;

    if (h % a == 0)
        cout << h / a << endl;
    else
        cout << h / a + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline
n, m = map(int, input().split())
x = set()
y = set()
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        x.add(b)
    if b == n:
        y.add(a)
print(("POSSIBLE", "IMPOSSIBLE")[len(x & y) == 0])


Measured memory_bytes: 23880
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long N, std::vector<long long> A){
    long long sum = 0;
    for(int i=0;i<N;i++){
        sum += A[i];
    }
    if(sum >= H)cout<<YES<<endl;
    else cout<<NO<<endl;
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(H, N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll mod_pow(ll x, ll n, ll mod) {
	ll bit = 1;
	while (n) {
		if (n & 1)bit = bit * x % mod;
		x = x * x % mod;
		n /= 2;
	}
	return bit;
}
void pyes() { cout << "Yay!" << endl; }
void pno() { cout << ":(" << endl; }
struct edge { ll to, cost; };
ll x, y;
signed main() {
	cin >> x >> y;
	if (x == 1 && y == 1)cout << 1000000 << endl;
	else if (x <= 3 || y <= 3)cout << max((ll)0, (4 - x)) * 100000 + max((ll)0, (4 - y)) * 100000 << endl;
	else cout << 0 << endl;
	ggr
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int edge[10][10];

int main() {
	int N, M;
	cin >> N >> M;
	rep(i,M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		edge[a][b] = edge[b][a] = 1;
	}
	vector<int> v(N);
	rep(i,N) v[i] = i;
	int res = 0;
	do {
		bool f = v[0] == 0;
		for(int i = 1; i < N; i++)
			if(!edge[v[i]][v[i-1]]) f = false;
		res += f;
	} while(next_permutation(all(v)));
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans,dp[6000][6000], a[330020], b[330000],sub[3000];
string str, ss;
bool f[220000];
char c[4000][4000];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>vec,rvec;
vector<edge>ed;
vector<LL>v;
map<string, LL>ma;
set<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct query {
	LL H, P;
};
query qu[6000];
int main() {
	cin >> n;
	rep(i, n) {
		cin >> qu[i].H >> qu[i].P;
	}
	sort(qu, qu + n, [](query x, query y) {return min(x.H - y.P, y.H) < min(y.H - x.P, x.H); });
	rep(i, n + 1)rep(j, n + 1)dp[i][j] = INF;
	dp[0][0] = 0;
	//dp[i][j] : i番目までで、j個とるときのコストの最小
	rep(i, n) {
		rep(j, n) {
			if (dp[i][j] <= qu[i].H)
				dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + qu[i].P);
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
		}
	}
	rep(i, n + 1) {
		if (dp[n][i] != INF)
			ans = max(ans, i);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 237952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = min(a+b, min(b+c, c+a));
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
import java.util.* ;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in) ;
		String line = in.next() ;
		char f1 = '0' , f2 = '1' ;
		int sum1 = 0 , sum2 = 0 ;
		for(int i=0;i<line.length();i++) {
			if(line.charAt(i)!=f1) {
				sum1++ ;
			}
			if(line.charAt(i)!=f2) {
				sum2++ ;
			}
			f1 = rvs(f1) ;
			f2 = rvs(f2) ;
		}
//		System.out.println(sum1+" "+sum2) ;
		if(sum1>sum2)
			System.out.println(sum2) ;
		else
			System.out.println(sum1) ;
	}

	public static char rvs(char c) {
		if(c=='0')
			return '1' ;
		else
			return '0' ;
	}
	
}


Measured memory_bytes: 24808
n = int(input())

if n % 10 == 2:
  print('hon')
elif n % 10 == 4:
  print('hon')
elif n % 10 == 5:
  print('hon')
elif n % 10 == 7:
  print('hon')
elif n % 10 == 9:
  print('hon')
elif n % 10 == 0:
  print('pon')
elif n % 10 == 1:
  print('pon')
elif n % 10 == 6:
  print('pon')
elif n % 10 == 8:
  print('pon')
else:
  print('bon')

Measured memory_bytes: 9152
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <map>
#include <cctype>
#include <string>
#include <cstdlib>
using namespace std;

string trans(string str){
  for(int i=0; i<str.size(); i++) {
    str[i] = tolower(str[i]);
  }
  return str;
}

int main()
{
  cout << setprecision(6);
  cout << setiosflags(ios::scientific);
  cout.flags(ios::fixed);

  string W;
  cin >> W;
  W = trans(W);

  int sum=0;
  string word;
  while(cin >> word){
    if(word == "END_OF_TEXT")
      break;
    word = trans(word);
    if(W==word)
      sum++;
  }

  cout << sum << endl;
}

Measured memory_bytes: 1196
from collections import deque

s = input()

d = deque()
l = deque()


def calc_area(j, i):
    return i - j


for i, c in enumerate(s):
    if c == "\\":
        d.append(i)
    if c == "/":
        if len(d) == 0:
            continue

        j = d.pop()

        s = calc_area(j, i)
        while len(l) > 0:
            _j, _i, _s = l.pop()
            if j < _j:
                s += _s
            else:
                l.append((_j, _i, _s))
                break

        l.append((j, i, s))

ans = str(len(l))
sum_area = 0
for j, i, s in l:
    ans += " " + str(s)
    sum_area += s

print(sum_area)
print(ans)

Measured memory_bytes: 8420
#75 最大公約数-ユークリッドの互除法

while True :
    x, y = map(int, input().split())
    if x == y == 0:
        break
    if x < y: x, y = y, x
    step = 0
    while y > 0:
        x, y, step = y, x%y, step+1
    print(x, step)


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

using namespace std;

int N;
int C;
int D[555][555];
int c[555][555];

int cnt[3][33];

int main() {
    cin >> N >> C;
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            cin >> D[i][j];
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> c[i][j];
            c[i][j]--;
            cnt[(i + j) % 3][c[i][j]]++;
        }
    }
    int ans = 1e9;
    for (int m0 = 0; m0 < C; m0++) {
        for (int m1 = 0; m1 < C; m1++) {
            for (int m2 = 0; m2 < C; m2++) {
                if (set<int>{m0, m1, m2}.size() != 3) continue;
                int m[] = {m0, m1, m2};
                int pre = 0;
                for (int i = 0; i < 3; i++) {
                    for (int j = 0; j < 33; j++) {
                        if (m[i] != j) {
                            pre += cnt[i][j] * D[j][m[i]];
                        }
                    }
                }
                ans = min(ans, pre);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<pair<long long, long long>> v(N);
	for (int i = 0; i < N; ++i) {
		long long X, L;
		cin >> X >> L;
		v[i] = make_pair(X + L, X - L);
	}
	sort(v.begin(), v.end());

	int ans = 0;
	long long x = -10LL * 1000 * 1000 * 1000;

	for (int i = 0; i < N; ++i) {
		if (x <= v[i].second) {
			++ans;
			x = v[i].first;
		}
	}

	cout << ans << endl;
}


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

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

using namespace std;

typedef long long ll;

int n, a, b;
vector<int> h;

// x回の攻撃で魔物を殲滅できるかを判定
bool is_ok(ll x) {
  ll cnt = 0;
  for (int i = 0; i < n; i++) {
    ll hp = h[i] - x * b;
    if (hp > 0) {
      cnt += (hp+a-b-1) / (a-b);
    }
  }
  return cnt <= x;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  cin >> n >> a >> b;
  h.assign(n, 0);

  rep(i, n) { cin >> h[i]; }

  int ok = 1e9+9;
  int ng = -1;
  // めぐる式二分探索!!!
  while ( abs(ok-ng) > 1 ) {
    int mid = (ok + ng) / 2;
    if ( is_ok(mid) ) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  cout << ok << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;
const ll lim = 1e18;
map<ll, int> mp;
void init(void){
    for (int i = 0; ; ++i){
        ll t = pow(i, 5);
        if (t > lim) break;
        mp[t] = i; 
        if (i != 0) mp[-t] = -i;
    }
}
int main(void){
    IOS;
    init();
    ll n; cin >> n;
    for (auto pr : mp){
        ll x = pr.first, y = pr.second;
        if (mp.count(x-n)){
            cout << y << ' ' << mp[x-n] << endl; return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 4744
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template <class T> inline T gcd(T a, T b) {if(a==0) return b; return gcd(b%a,a);}
template <class T> inline T lcm(T a, T b) {return a * b / gcd(a,b);}
template <class T> inline T sum(vector<T> &vec) {T res=0; for (int i = 0; i < vec.size(); i++) res += vec[i]; return res;}
template <class T> inline T mpow(T a, T b) {if(b==0)return 1; T c = mpow(a,b/2);if(b%2==1)return c*c*a; return c*c;}
const int INF = 1 << 30;
const long long INFLL = 1LL << 60;
typedef pair<int, int> P;

#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define FOR(i,n) for (int (i)=0;(i)<(n);(i)++)
#define REPB(i,n) for (int (i)=((n)-1);(i)>=0;(i)--)
#define FORB(i,n) for (int (i)=((n)-1);(i)>=0;(i)--)
#define SORT(A) sort((A).begin(),(A).end())

int cnt[10][10];
int main() {
    
    int N; cin >> N;
    for (int n = 1; n <= N; n++) {
        int tmp = n;
        int b = tmp % 10;
        while (tmp / 10 > 0) tmp /= 10;
        cnt[tmp][b]++;
    }
    ll res = 0;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            res += (ll)cnt[i][j] * cnt[j][i];
        }
    }
    cout << res << endl;





}


Measured memory_bytes: 256
N = int(input())
S1 = list(input())
S2 = list(input())

if N == 1:
    print(3)
else:
    if S1[0] == S1[1]:
        left_domino = 0
        ans, i = 6, 2    
    else:
        left_domino = 1
        ans, i = 3, 1

    while i < N-1:
        if S1[i] == S1[i+1]:
            if left_domino == 0:
                ans *= 3
            else:
                ans *= 2
            left_domino = 0
            i += 2
        else:
            if left_domino != 0:
                ans *= 2
            left_domino = 1
            i += 1

    if S1[-1] == S2[-1] and left_domino != 0:
        ans *= 2

    print(ans % 1000000007)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

char s[110][110];
int cost[110][110];

void dp(int r, int c)
{
  if ((r==0) && (c==0))
  {
    if(s[0][0]=='.')
    {
      cost[0][0]=0;
    }
    else
    {
      cost[0][0]=1;
    }
    return;
  }

  if(r>=1)
  {
    int tc;
    if((s[r][c] == s[r-1][c]) || (s[r][c] == '.'))
    {
      tc = cost[r-1][c];
    }
    else
    {
      tc = cost[r-1][c] + 1;
    }
    if (tc < cost[r][c]) cost[r][c] = tc;
  }
  
  if(c>=1)
  {
    int tc;
    if((s[r][c] == s[r][c-1]) || (s[r][c] == '.'))
    {
      tc = cost[r][c-1];
    }
    else
    {
      tc = cost[r][c-1] + 1;
    }
    if (tc < cost[r][c]) cost[r][c] = tc;
  }

  return;
}

int main()
{
  int H, W;
  cin >> H >> W;
  
  for(int i=0;i<H;i++)
  {
    for(int j=0;j<W;j++)
    {
      cin >> s[i][j];
      cost[i][j] = 100000;
    }
  }
  
  /*
  //test
  cout << H << " " << W << endl;
  for(int i=0;i<H;i++)
  {
    for(int j=0;j<W;j++)
    {
      cout << s[i][j];
    }
    cout << endl;
  }
  */
  
  for(int i=0;i<H;i++)
  {
    for(int j=0;j<W;j++)
    {
      dp(i,j);
    }
  }

  /*
  for(int i=0;i<H;i++)
  {
    for(int j=0;j<W;j++)
    {
      cout << cost[i][j];
    }
    cout << endl;
  }*/

  cout << cost[H-1][W-1] << endl;
  
  return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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

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 round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int n;
	cin >> n;

	vi a(n);
	rep(i, n) cin >> a[i];

	for (int i = n - 1; i >= 0; --i) {
		cout << a[i];
		if (i != 0) cout << " ";
	}
	cout << endl;
}


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

using namespace std;

int main(){
	string s;
	cin >> s;
	int l=0,r=(int)s.size()-1;
	int sum=0;
	while(l<r){
		while(s[l] == 'x' || s[r] == 'x'){
			if(s[l] == 'x' && s[r] == 'x'){
				l++;
				r--;
			} else if(s[l] == 'x'){
				l++;
				sum++;
			} else if(s[r] == 'x'){
				r--;
				sum++;
			}
		}
		if(s[l] == s[r]){
			l++;
			r--;
		} else {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 512
N = int(input())
prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
ans = ["11"]
ans_len = 1
counter = 5
A = 55556
for i in range(31, A, 2):
    if ans_len == N:
        break
    if counter == 5:
        if all(i % j != 0 for j in prime):
            ans_len += 1
            ans.append(str(i))
        counter = 0
    prime.append(i)
    counter += 1

print(" ".join(ans))


Measured memory_bytes: 38640
#include <stdio.h>
typedef long long ll;

int main(){
    ll n, k, a[200000+1]={0};
    scanf("%lld%lld", &n, &k);

    for(int i=0; i<n; i++){
        scanf("%lld", &a[i]);
    }
    for(int i=k; i<n; i++){
        if( a[i] > a[i-k] ){ printf("Yes\n"); }
        else               { printf("No\n");  }
    }
    return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, T; cin >> n >> T;
    using AB = tuple<int, int>;
    vector<AB> ab(n);
    rep(i, n){
        int A, B; cin >> A >> B;
        ab[i] = AB(A, B);
    }
    sort(_all(ab));
    vector<vi> dp(n, vi(T, -1));
    dp[0][0] = 0;

    int res = get<1>(ab[0]);
    int maxval = 0;
    rep(i, n - 1){
        int A, B; tie(A, B) = ab[i];

        rep(j, T){
            int cur = dp[i][j];
            if(cur < 0) continue;

            chmax(dp[i+1][j], cur);

            int nj = j + A;
            if(nj < T){
                int nval = cur + B;
                chmax(dp[i+1][nj], nval);
                chmax(maxval, nval);
            }
        }

        int lA, lB; tie(lA, lB) = ab[i+1];
        chmax(res, maxval + lB);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int H, W, A, B;
void input() { cin >> H >> W >> A >> B; }

int hw[1001][1001];
void solve() {
  int y;
  rep(i, 1, H) {
    if (i <= B) {
      y = 1;
    } else {
      y = 0;
    }
    rep(j, 1, W) {
      if (j <= A) {
        hw[i][j] = 1 ^ y;
      } else {
        hw[i][j] = 0 ^ y;
      }
      cout << hw[i][j];
    }
    cout << endl;
  }
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 9088