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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,a[200000],sum,ans=2000000000;

main() {
    cin >> n;
    rep(i,n) cin >> a[i];n--;
    rep1(i,n) a[i] += a[i-1];
    rep(i,n) ans = min(ans,abs(a[i]-(a[n]-a[i])));
    ct(ans)
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;


int main() {
  string n;
  cin >> n;
  rep(i,3) {
    if (n[i] == '1') n[i] = '9';
    else if (n[i] == '9') n[i] = '1';
  }
  cout << n << endl;
}



Measured memory_bytes: 256
MOD = 10 ** 9 + 7


def solve(n, k):
    # primes
    is_prime = [1] * (k + 1)
    is_prime[0] = 0
    is_prime[1] = 0
    for p in range(2, k + 1):
        if p * p > k:
            break
        if is_prime[p]:
            for q in range(p * p, k + 1, p):
                is_prime[q] = 0
    primes = [p for p in range(k + 1) if is_prime[p]]

    res_arr = [0] + [pow(k // i, n, MOD) for i in range(1, k + 1)]
    # print(res_arr)
    for p in primes:
        for i in range(1, k // p + 1):
            res_arr[i] -= res_arr[i * p]
    # print(res_arr)
    res = sum([i * res_arr[i] for i in range(k + 1)]) % MOD
    # print(res)
    return res


def main():
    n, k = map(int, input().split())
    res = solve(n, k)
    print(res)


def test():
    assert solve(3, 2) == 9
    assert solve(3, 200) == 10813692
    # assert solve(100000, 100000) == 742202979


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 16628
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define sz(a) (a).size()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define dump(x) cerr << #x << " = " << (x) << endl;
#define dumpi(i, x) cerr << string((i), ' ') << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
using pii = pair<int, int>;
constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr double EPS = 1e-10;

void no() {
  cout << "NO" << endl;
  exit(0);
}

int N;
int A[100010];
int d[100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  int sum = 0;
  rep(i, 0, N) {
    cin >> A[i];
    sum += A[i];
  }
  int tmp = N*(N+1)/2;
  if (sum % tmp != 0) no();
  int k = sum / tmp;
  d[0] = A[0]-A[N-1];
  rep(i, 1, N) {
    d[i] = A[i]-A[i-1];
  }
  int sum2 = 0;
  rep(i, 0, N) {
    int x = d[i]+k*(N-1);
    if (x % N != 0) no();
    x /= N;
    if (k-x < 0 || k-x > k) no();
    sum2 += k-x;
  }
  cout << (sum2 == k ? "YES" : "NO") << endl;

  return 0;
}

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

int main() {
	int N;	// 操作回数.
	cin >> N;
	int K;	// 加算数.
	cin >> K;

	int x = 1;
	for (int i = 0; i < N; i++) {
		if (x < K) {
			x *= 2;
		}
		else {
			x += K;
		}
	}
	cout << x << endl;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------
int H, W, N;
set<pair<int, int>> F, cand;
ll ans[10];

void add_cand(int y, int x) {
   if (y >= 0 && y < H-2 && x >= 0 && x < W-2) cand.insert({y, x});
}

int main() {
   cin >> H >> W >> N;
   rep (i, N) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      F.insert({a, b});
      rep (dy, 3) {
         rep (dx, 3) {
            add_cand(a-dy, b-dx);
         }
      }
   }

   ans[0] = (ll)(H-2) * (W-2);
   for (auto c : cand) {
      int y = c.first, x = c.second;
      int num = 0;
      rep (i, 3) {
         rep (j, 3) {
            if (F.count({y+i, x+j})) ++num;
         }
      }
      ans[0]--;
      ans[num]++;
   }

   rep (i, 10) {
      cout << ans[i] << endl;
   }

   return 0;
}

Measured memory_bytes: 47104
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <set>
#include <algorithm>

using namespace std;

#define mP make_pair
#define pB push_back
#define X first
#define Y second

int main(){
	string s;
	cin >> s;

	int cnt =0 , ans = 0;
	for(int i = 0 ; i < s.size() ; ++i){
		if(s[i] == 'S'){
			++cnt;
		}else if(s[i] == 'T'){
			if(cnt > 0){
				--cnt;
				ans += 2;
			}
		}
	}

	cout << s.size() - ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
using namespace std;
int main(){
    int n;cin >>n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int count=0;
    bool ans=true;
    for(int i=0;i<n;i++){
        if(p[i]-1!=i){
            count++;
        }
    }
    if(count>2) ans=false;
    
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
    
}

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

using namespace std;
typedef long long ll;
typedef long double ld;

ll n, r;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> r;
    if (n >= 10) {
        cout << r << endl;
    } else {
        cout << r + 100*(10-n) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define rep(i,a,b)	for(i=a;i<b;i++)
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
int main()
{
	string str;
	lli i,a,b;
	cin >> a;
	cout << a*a << endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
public class Main {
	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		//StringBuilder sb = new StringBuilder();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int d = a / b;
		int r = a % b;
		double da = (double) a;
		double db = (double) b;
		double f = da / db;
		System.out.print(d + " " + r + " ");
		System.out.printf("%.5f",f);
		System.out.println();
	}
}

Measured memory_bytes: 26372
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

string s, t, u;
int a, b;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> s >> t >> a >> b >> u;
	
	if(u == s)
	{
		a --;
	}
	else
	{
		b--;
	}
	
	cout << a << ' ' << b << '\n';
	
}


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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}


/*FUNCs=================================================*/
//約数列挙配列生成
vector<ll> divisor(ll n){
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    ll n; cin >> n;
    vll a = divisor(n);
    ll p = a[a.size()/2];
    ll q = n / p;
    cout << p +q -2<< '\n';
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
using namespace std;
int gcd(int a, int b){
    if (b == 0){
        return a;
    }
    return gcd(b, a % b);
}
int main(){
	int n;
	scanf("%d",&n);
	int a[n + 1];
	scanf("%d",&a[n]);
	for (int i = 0; i < n; i++){
		scanf("%d",&a[i]);
	}
	sort(a, a + n + 1);
	int ans = a[1] - a[0];
	for (int i = 1; i < n; i++){
		ans = gcd(a[i + 1] - a[i], ans);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define ll              long long
#define dd              double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vll             vector<long long>
#define vdd             vector<double>
#define vpii            vector<pair<int,int>>
#define vpll            vector<pair<long long,long long>>
#define vvi             vector<vector<int>>
#define vvl             vector<vector<long long>>
#define mii             map<int,int>
#define mll             map<long long,long long>
#define umii            unordered_map<int,int>
#define umll            unordered_map<long long,long long>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep2(i,a,b)     for(int i=a;i<b;i++)
#define rev(i,n)        for(int i=n;i>=0;i--)
#define rev2(i,a,b)     for(int i=a;i>=b;i--)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             9e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define fio             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl            '\n'
#define all(x)          x.begin(),x.end()
#define d0(x)           cout <<x<<" "
#define d1(x)           cout <<x<<endl
#define d2(x,y)         cout <<x<<" "<<y<<endl
#define d3(x,y,z)       cout <<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w)     cout <<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define read2(x,y)      cin>>x>>y
#define read3(x,y,z)    cin>>x>>y>>z
#define read4(x,y,z,w)  cin>>x>>y>>z>>w
#define read5(x,y,z,w,a)cin>>x>>y>>z>>w>>a
#define sz(a)           (int)a.size()
const ll mod=1e9+7;
const double PI = 3.14159265359;
const ll MOD=998244353;
void i_o()
{
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
}

int main() {

   fio
   i_o();
   string s,t;
   cin>>s>>t;
   if(t.substr(0,s.length())==s) d1("Yes");
   else d1("No");

   return 0;
}



Measured memory_bytes: 3652
using System;
using System.Linq;

namespace PracticeForAtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            string n = Console.ReadLine();
            int k = int.Parse(Console.ReadLine());

            int ans = Solve(n, k);

            Console.WriteLine(ans);
            //ここまで
        }

        static int ncr(int n, int r)
        {
            int temp = 1;
            int bunbo = 1;
            for (int i = 1; i <= r; i++)
            {
                temp *= (n - i + 1);
                bunbo *= i;
            }

            return temp / bunbo;
        }
        static int Ketain(int ketasuu, int k)
        {
            return ncr(ketasuu, k) * (int)Math.Pow(9, k);
        }

        static int Solve(string n, int k)
        {
            while (n[0] == '0' && n.Length > 1) {
                n = n.Remove(0, 1);
            }
            int ans = 0;
            int length = n.Length;
            if (length < k) return 0;

            if (length > k)     ans += Ketain(length - 1, k);
            if (k > 1)
            {
                ans += Ketain(length - 1, k - 1) * (n[0].ToInt() - 1);
                ans += Solve(n.Remove(0, 1), k - 1);
            }
            if (k == 1) ans += n[0].ToInt();

            return ans;
        }

        

    }
    public static class CharExt
    {
        public static int ToInt(this char self)
        {
            return self - '0';
        }
    }

}


Measured memory_bytes: 13140
S = input()
flag = []
yoko = 0
tate = 0
for i in S:
    if i not in flag:
        flag.append(i)
        if i == "W":
            yoko += 1
        elif i == "E":
            yoko -= 1
        elif i == "N":
            tate += 1
        else:
            tate -= 1
if yoko == 0 and tate == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int a,b;
  cin >> a >> b;
  cout << max(0,a - 2*b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;

const ll mod = 1000000007;
const int N = 2e5+6;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int n;
int pre[N], suf[N];
void init() {
	mt(pre, 0);
	mt(suf, 0);
}
int main() {
	while(~scanf("%d", &n)) {
		init();
		rep(i, 1, n + 1) {
			scanf("%d", pre + i);
			suf[i] = pre[i];
		}
		rep(i, 2, n + 1) {
			pre[i] = gcd(pre[i-1], pre[i]);
		}
		repd(i, n - 1, 1) {
			suf[i] = gcd(suf[i+1], suf[i]);
		}
		ll ans = -1;
		rep(i, 1, n + 1) {
			ans = max(ans, gcd(pre[i-1], suf[i+1]));
		}
		printf("%lld\n", ans);
	}
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define MP make_pair
#define PB push_back
typedef long long LL;
const LL P = 998244353;
const int N = 1e5+10;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;

int main(){
	map<vector<int>,int> mp;
	scanf("%d",&n);
	rep(i,1,n){
		char s[20];
		vector<int>cnt(26);
		scanf("%s",(s+1));
		rep(j,1,10)cnt[s[j]-97]++;
		mp[cnt]++;
	}
	LL ans = 0;
	for(auto &ele:mp){
		int num = ele.second;
		ans += 1ll * num * (num-1) / 2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 18944
from sys import stderr, setrecursionlimit, exit
from functools import reduce
from operator import add
setrecursionlimit(2147483647)
def f(n=1, flag=False):
    res = []
    for _ in range(n):
        line = [int(i) for i in input().split()]
        if flag or len(line) == 1:
            res.append(line[0])
            flag = True
        else:
            res.append(line)
    if n == 1:
        return res[0]
    return res
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

n = f()
s = []
for i in range(n):
    s.append(int(input()))
s.sort(reverse=True)
su = sum(s)
# 10で割り切れるなら一番小さいやつを引く
# それでもだめなら2つ目，それもだめなら3つ目
# ↑1つ目≡0(mod 10),2つ目≡0(mod 10)なら当然1つ目+2つ目≡0(mod 10)なので3つ目のみ検討すればOK
if su % 10 != 0:
    print(su)
    exit()
i = -1
while True:
    su -= s[i]
    if su % 10 != 0:
        print(su)
        exit()
    su += s[i]
    i -= 1
    if i < -n:
        print(0)
        exit()


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

using namespace std;
const int maxn = 1e5 + 5;
int a[maxn], b[maxn], c[maxn];
int dp[maxn][3];

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[1][0] = a[0];
    dp[1][1] = b[0];
    dp[1][2] = c[0];
    for(int i = 2; i <= n; i++){
        for(int j = 0; j < 3; j++){
            if (j == 0){
                dp[i][j] = a[i - 1] + max(dp[i - 1][1], dp[i - 1][2]);
            } else if (j == 1){
                dp[i][j] = b[i - 1] + max(dp[i - 1][0], dp[i - 1][2]);
            } else {
                dp[i][j] = c[i - 1] + max(dp[i - 1][1], dp[i - 1][0]);
            }
        }
    }
    int maxi = -1;
    for(int i = 0; i < 3; i++){
        maxi = max(maxi, dp[n][i]);
    }
    cout << maxi;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(){
    int n,m,x;
    cin>>n>>m>>x;
    int a[100]={0};
    int cost0=0,costn=0;
    for(int i=0;i<m;i++) {
        int y;
        cin>>y;
        a[y]=1;
    }
    for(int i=0;i<n;i++){
        if(i<x)cost0+=a[i];
        else costn+=a[i];
    }
    if(costn<cost0)cout<<costn<<endl;
    else cout<<cost0<<endl;
    return 0;

}

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


ll cnt(ll k) {
  return ((k*(k-1))/2);
}

int main() {
  ll N;
  cin >> N;
  map<ll,ll> mp;
  vector<ll> vec(N);
  for (ll i = 0;i<N;i++) {
    ll a;
    cin >> a;
    vec.at(i) = a;
    mp[a]++;
  }
  ll ans = 0;
  for (pair<ll,ll> p : mp) {
    ans += cnt(p.second);
  }
  
  for (int i = 0;i<N;i++) {
    ll k = vec.at(i);
    ll ansk = ans;
    ansk += cnt(mp[k] - 1);
    ansk -= cnt(mp[k]);
    cout << ansk << endl;
  }       
}


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

int main() {
    int n;cin>>n;
    int a[n],ans=0;
    
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=1;i<n;++i){
        if(a[i-1]!=a[i])ans+=1;
    }
    ans+=1;
    cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((int)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

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

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}


string compare(string a, string b){
	if(a.size()>b.size())return a;
	if(a.size()<b.size())return b;
	if(a>b)return a;
	return b;
}

int main(){
	int cost[]={INF, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	int N, M;
	cin >> N >> M;
	vector<int> can(M);
	foreach(i, can){
		cin >> i;
	}
	vector<string> dp(N+1, "");
	dp[0]="~";
	REP(i, N+1){
		foreach(j, can){
			if(dp[i]=="")continue;
			if(cost[j]+i>N)continue;
			dp[cost[j]+i] = compare(dp[cost[j]+i], dp[i] + (char)('0' + j));
		}
	}
	dp[N].erase(dp[N].begin());
	cout << dp[N] << endl;
	return 0;
}


Measured memory_bytes: 43776
#include <iostream>
#include <algorithm>
#include <cstring>
#include <fstream>
using namespace std;
using ll = long long;

constexpr ll nlim = 1e5, clim = 1e14;

ll n, c;
ll x[nlim+2], v[nlim+2];
ll f[nlim+2];
ll cum[nlim+2];

ll solve(){
  ll f[n+2], g[n+2];
  memset(f, 0, sizeof(f));
  memset(g, 0, sizeof(g));
  for(int i=1; i<=n+1; i++){
    f[i] = cum[i] - x[i];
    g[i] = max(g[i-1], f[i]);
  }
  
  ll res = 0;
  for(int b=1; b<=n+1; b++){
    res = max(res, g[b-1] + (cum[n] - cum[b-1]) - 2*(c-x[b]));
    //cout << res << " " << g[b-1] << " " << (cum[n] - cum[b-1]) - 2*(c-x[b]) << endl;
  }

  //cout << res << endl;
  return res;
}

/*
ll solve(){
  for(int i=1; i<=n; i++) f[i] = f[i-1] - (x[i] - x[i-1]) + v[i];
  for(int i=1; i<=n; i++) f[i] = max(f[i-1], f[i]);

  ll res = 0, s = 0, mx = 0;
  for(int i=1; i<=n+1; i++){
    res = max(res, f[i-1] + mx);
 
		s = s + (x[i-1]-x[i])*2 + v[i-1];
		mx = max(mx,s);
  }

  for(int i=1; i<=n; i++) cout << f[i] << endl;

  return res;
}
*/

int main(){
  cin >> n >> c;
  for(int i=1; i<=n; i++){
    cin >> x[i] >> v[i];
  }
  x[n+1] = c;   

  cum[0] = 0;
  for(int i=1; i<=n+1; i++) cum[i] = cum[i-1] + v[i];

  ll ans = 0;
  ans = max(ans, solve());

  reverse(x, x+n+2);
  reverse(v, v+n+2);
  for(int i=0; i<=n+1; i++){
    x[i] = c - x[i];
  }

  cum[0] = 0;
  for(int i=1; i<=n+1; i++) cum[i] = cum[i-1] + v[i];

  ans = max(ans, solve());

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4096
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops"
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define MOD 998244353
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
#define ar array
#define ld long double

void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
// char c[4]={'D' , 'R' , 'U' , 'L'};
const ll maxN=2e3+5;
ll n , dp[maxN];
void solve(){
   cin>> n ;
   dp[0]=1;
   for(ll i=3;i<=n ; i++){
       for(ll j=0;j+3<=i ; j++){
           dp[i]=(dp[i] + dp[j])%mod;
       }
   }
   
   cout<<dp[n]<<endl;
    
}

int main(){
// 	mahakal();
	fast;
	ll t =1 ;
// 	cin>> t ; 
	while(t--)solve();
// 	cerr << "\ntime taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0;
}


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

int main(){
  int n;
  int table[20][20];

  while(cin >> n,n){
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)table[i][j] = 0;

    int y = n/2+1, x = n/2;

    for(int i=1;i<=n*n;i++){
      table[y][x] = i;
      y++; x++;

      while(true){
	if(i==n*n)break;

	if(y>=n)y=0;
	if(x<0)x=n-1;
	if(x>=n)x=0;
	
	if(table[y][x]){
	  y++; x--;
	}else{
	  break;
	}
      }
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cout << setw(4) << right << table[i][j];
      }
      cout << endl;
    }
  }
}
	

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

int divide (int n){
	int count=0;
	bool find=true;
	if (n==0) return 0;
	while (find){
		if (n%2==0){
			n/=2;;
			count++;
		}
		else find=false;
		if (n==0){
			find=false;
		}
	}
	return count;
}

int main() {
	int n,max=0;
	cin>>n;
	for (int i=1;i<=n;i++){
		if (divide(i)>divide(max)) max=i;
	}
	if (n==1){
		cout<<1;
	}
	else 
	cout<<max<<endl;
	//cout<<divide(0);
	return 0;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
xy = inpll(n)

sum = 0
l = list(itertools.permutations(range(n),n))
for i in range(len(l)):
    for j in range(1,len(l[i])):
        sum += math.sqrt((xy[l[i][j]][0] - xy[l[i][j - 1]][0]) ** 2 + (xy[l[i][j]][1] - xy[l[i][j - 1]][1]) ** 2)

print(sum / len(l))

Measured memory_bytes: 35396
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
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();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll A,V,B,W,T;
  cin>>A>>V>>B>>W>>T;
  bool CAN=true;
  
  if(abs(B-A)>T*(V-W)) CAN=false;
  
  if(CAN) COYE;
  else CONO;
  return 0;
}

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

using namespace std;
typedef long long ll;

int n;
int dp[100100][2];
int head[200100], nxt[200100], to[200100];
int edgeCount;
int md = 1e9+7;
void addEdge(int x, int y)
{
    to[edgeCount] = y;
    nxt[edgeCount] = head[x];
    head[x] = edgeCount;
    ++edgeCount;
}
int f(int u, int p, bool blockBlack)
{
    int &ret = dp[u][blockBlack];
    if (~ret) return ret;
    ll ret1 = 1;
    ll ret2 = !blockBlack;
    for (int v = head[u]; ~v; v = nxt[v])
        if (to[v] != p)
        {
            ret1 *= f(to[v], u, 0);
            if (ret1 >= md)
                ret1 %= md;
            if (!blockBlack)
            {
                ret2 *= f(to[v], u, 1);
                if (ret2 >= md)
                    ret2 %= md;
            }
        }
    ret1 += ret2;
    if (ret1 >= md)
        ret1 -= md;
    return ret = ret1;
}
int main()
{
    memset(head, -1, sizeof head);
    memset(dp, -1, sizeof dp);

    scanf("%d", &n);
    for (int i = 1, x, y; i < n; ++i)
    {
        scanf("%d%d", &x, &y);
        --x; --y;
        addEdge(x, y);
        addEdge(y, x);
    }
    printf("%d\n", f(0, 0, 0));

    return 0;
}


Measured memory_bytes: 10368
#include<iostream>
#include<algorithm>
using lint=long long;
using namespace std;

int main()
{
	int N;
	string str;
	lint num[10]={};
	lint ans=0;
	string march="MARCH";
	
	cin >> N;
	for(int i=0;i<N;i++)
	{
		cin >> str;
		for(int j=0;j<march.size();j++)
			if(str[0]==march[j])num[j]++;
	}
	
	int cnt=0;
	for(int i=0;i<march.size();i++)
		if(num[i]!=0)cnt++;
	if(cnt<3)
	{
		cout << 0 << endl;
		return 0;
	}
	
	for(int i=0;i<march.size();i++)
		for(int j=i+1;j<march.size();j++)
			for(int k=j+1;k<march.size();k++)
				ans+=(num[i]*num[j]*num[k]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    string s;
    cin >> s;

    int counter=0;
    for(int i=0;i<(s.size()/2);i++){
        if(s.at(i)!=s.at(s.size()-1-i)) counter++;
    }

    cout << counter << endl;
}

Measured memory_bytes: 3632
//aea ctmr
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
//v.erase(unique(v.begin(),v.end()),v.end());
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define PI 3.14159265358979323846
 
typedef long double ld;
typedef long long ll;
const ll N = 100500;
const ll mod = 1e9 + 7;
using namespace std;
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif

int xd[N][30];
vector <int> uwu;

int solve(vector <int> v, int pos){
    if(pos >= 30 or v.size() == 0) return 0;
    vector <int> uno, zero;
    for(int i = 0; i < v.size(); i++){
        if(xd[v[i]][pos] == 0) zero.push_back(v[i]);
        else uno.push_back(v[i]);
    }

    if(zero.size() == 0) return solve(v, pos + 1);
    else if(uno.size() == 0) return solve(v, pos + 1);
    else{
        return (1 << (29 - pos)) + min(solve(zero, pos + 1), solve(uno, pos + 1));
    }
}

int main(){
    fastio;
    char c;
    cin >> c;

    cout << (char)(c + 1) << endl;

    return 0;
}


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

int main() {
    ll N,A,B,C,D,E;
    cin >> N >> A >> B >> C >> D >> E;
    ll mn = min({A,B,C,D,E});
    ll neck = (N + (mn-1)) / mn;
    cout << neck +4 << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    h, n = LI()
    ab = LIR(n)
    maxa = max(map(lambda x: x[0], ab))
    rangeh = h + maxa
    dp = [inf] * (rangeh + 1)
    dp[0] = 0
    for a,b in ab:
        for hi in range(rangeh - a):
            dp[hi + a] = min(dp[hi + a], dp[hi] + b)
        for hi in range(rangeh-1, -1, -1):
            dp[hi] = min(dp[hi], dp[hi + 1])
    print(dp[h])
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 51292
#include <bits/stdc++.h>
using namespace std;
#define maxn (int)3010
#define int long long
int tab[maxn], dp[maxn][maxn][3], n;
bool odw[maxn][maxn][3];

int rob(int start, int stop, int kto)
{
	if (odw[start][stop][kto]) return dp[start][stop][kto];
	odw[start][stop][kto]=true;
	//printf("Przedzial %lld %lld %lld\n", start, stop, kto);
	if (kto==1)
	{
		if (start==stop) 
		{
			dp[start][stop][kto]=tab[stop]*(-1);
			//printf("DLa przedzialu %lld %lld %lld mamy %lld\n", start, stop, kto, dp[start][stop][kto]);
			return dp[start][stop][kto];
		}
		dp[start][stop][kto]=min(rob(start, stop-1, 2)-tab[stop], rob(start+1, stop, 2)-tab[start]);
		//printf("DLa przedzialu %lld %lld %lld mamy %lld\n", start, stop, kto, dp[start][stop][kto]);
		return dp[start][stop][kto];
	}
	else
	{
		if(start==stop)
		{
			dp[start][stop][kto]=tab[stop];
			//printf("DLa przedzialu %lld %lld %lld mamy %lld\n", start, stop, kto, dp[start][stop][kto]);
			return dp[start][stop][kto];
		}
		dp[start][stop][kto]=max(rob(start, stop-1, 1)+tab[stop], rob(start+1, stop, 1)+tab[start]);
		//printf("DLa przedzialu %lld %lld %lld mamy %lld\n", start, stop, kto, dp[start][stop][kto]);
		return dp[start][stop][kto];
	}
}

int32_t main()
{
	scanf("%lld", &n);
	for (int i=1; i<=n; i++)
	{
		scanf("%lld", &tab[i]);
	}
	rob(1, n, 2);
	printf("%lld", dp[1][n][2]);
}


Measured memory_bytes: 238080
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
    getchar();
    for(int i=0;i<N;i++){
        string S;
        getline(cin,S);
        while(S.find("Hoshino")!=-1){
            S.replace(S.find("Hoshino"),7,"Hoshina");
        }
        cout<<S<<endl;
    }
    return 0;
}

Measured memory_bytes: 1212
N = input()
S = list(map(int, input()[:]))
ans = 0
for num in range(1000):
    n1,n2,n3 = 0, 0, num%10
    n2= (num %100-n3)// 10
    n1 = (num-n2*10- n3) //100
    f1 = False
    f2 = False
    f3 = False
    for n in S:
        if not f1:
            if n == n1:
                f1 = True
        elif not f2:
            if n == n2:
                f2 = True
        elif not f3:
            if n == n3:
                f3 = True
                break
    if f1 and f2 and f3:
        ans += 1
print(ans)


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

int main() {
  string s, t;
  cin >> s >> t;

  if (s == t) {
    cout << "Yes" << endl;
    return 0;
  }

  for (int i = 0; i < s.size(); ++i) {
    char tmp = t[t.size()-1];
    for (int j = t.size()-1; j > 0; --j) {
      t[j] = t[j-1];
    }
    t[0] = tmp;

    if (s == t) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  
  return 0;
}

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

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }

constexpr int SIZE = 5;
int field[SIZE][SIZE];

bool ok(int l, int r, int u, int d) {
	for(int y = u; y < d; ++y) {
		for(int x = l; x < r; ++x) {
			if(field[y][x] == 0) return false;
		}
	}
	return true;
}

int solve() {
	for(auto &row : field) for(auto &e : row) cin >> e;

	int ans = 0;
	for(int l = 0; l < SIZE; ++l) {
		for(int r = l + 1; r <= SIZE; ++r) {
			for(int u = 0; u < SIZE; ++u) {
				for(int d = u + 1; d <= SIZE; ++d) {
					if(ok(l, r, u, d)) chmax(ans, (r - l) * (d - u));
				}
			}
		}
	}

	return ans;
}

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

	int n;
	cin >> n;
	while(n--) cout << solve() << endl;

	return EXIT_SUCCESS;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int N,K;
    cin>>N>>K;

    vector<int> vec(N);


    for(auto &x:vec){
        cin>>x;
    }

    long sum=0;

    for(int i=0;i<N;++i){
        int tmp=min(vec[i],K-vec[i]);
        sum+=tmp*2;
    }

    cout<<sum<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;

bool cmp(pair<int,int> cmp0,pair<int,int> cmp1){
	return (cmp0.second < cmp1.second);
}
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	inl(n);
	vpll a;
	FOR(i,0,n){
		inl(x);
		inl(x1);
		a.push_back(make_pair(x,x1));
	}
	sort(all(a),cmp);
	ll dp[10000010];
	dp[0] = a[0].first;
	if (dp[0] > a[0].second) { out("No");return 0; }
	FOR(i,1,a.size()){
		dp[i] = dp[i-1]+a[i].first;
		if(dp[i]>a[i].second){
			out("No");
			return 0;
		}
	}
	out("Yes");
	return 0;
}

Measured memory_bytes: 7532
import java.util.*;
import java.io.*;

class Combination{
    static int MAX = 3000;
    static int MOD = 1000000007;

    static long[] fac = new long[MAX];    //iまでの階乗
    static long[] inv = new long[MAX];    //iの逆元
    static long[] finv = new long[MAX];   //iまでの逆元の階乗
    
    public static long calculate(int n, int k){
        fac[0] = finv[0] = 1;
        fac[1] = finv[1] = 1;
        inv[1] = 1;

        for(int i = 2; i < MAX; i++){
            fac[i] = fac[i-1] * i % MOD;
            inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;    //p = (p/a) * a + (p % a) (プログラミングの意味で)が成り立つから両辺mod pをとってa^-1が導ける。
            finv[i] = finv[i-1] * inv[i] % MOD;
        }

        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;    // nCk = n! * (k!)^-1 * ((n-k)!)^-1
    }   

}



public class Main{
    static int INFTY=Integer.MAX_VALUE;
    static int MOD = 1000000007;
    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // try{
            // int n = Integer.parseInt(br.readLine());
            
        int n = sc.nextInt();
        int k = sc.nextInt();
            for(int i=1;i<=k;i++){
                long ans=Combination.calculate(n-k+1, i) * Combination.calculate(k-1, i-1) % MOD;
                System.out.println(ans);
            }
    }


}

Measured memory_bytes: 23892
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
       int S=scanner.nextInt();
       int s=S%60;
       int M=S/60;
       int m=M%60;
       int h=M/60;
        System.out.println(h+":"+m+":"+s);
        
              
              
       
    }

}

Measured memory_bytes: 26120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int x, y; cin >> x >> y;
    cout << x + y/2 << endl;
}

Measured memory_bytes: 256
using System;
//using System.Collections.Generic;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			string[] card1 = Console.ReadLine().Split(' ');
			string[] card2 = new string[N];
			for (int i = 0; i < N; i++)
			{
				card2[i] = card1[i];
			}
			Bubble(card1);
			Selection(card2);
		}

		public static void Bubble(string[] card)
		{
			for (int i = 0; i < card.Length; i++)
			{
				for (int j = card.Length - 1; j > i; j--)
				{
					if (card[j][1] < card[j - 1][1])
					{
						string tmp = card[j];
						card[j] = card[j - 1];
						card[j - 1] = tmp;
					}
				}
			}
			for (int i = 0; i < card.Length; i++)
			{
				Console.Write(card[i]);
				if (i == card.Length - 1) Console.Write("\n");
				else Console.Write(" ");
			}
			Console.WriteLine("Stable");
		}

		public static void Selection(string[] card)
		{
			bool b = true;
			for (int i = 0; i < card.Length; i++)
			{
				int min = i;
				for (int j = i; j < card.Length; j++)
				{
					if (card[j][1] < card[min][1])
					{
						min = j;
					}
				}
				if (min != i)
				{
					for (int j = i + 1; j < min + 1; j++)
					{
						if (card[j][1] == card[i][1])
							b = false;
					}
				}
				string tmp = card[min];
				card[min] = card[i];
				card[i] = tmp;
			}
			for (int i = 0; i < card.Length; i++)
			{
				Console.Write(card[i]);
				if (i == card.Length - 1) Console.Write("\n");
				else Console.Write(" ");
			}
			if(b == true) Console.WriteLine("Stable");
			else Console.WriteLine("Not stable");
		}
	}
}

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

int main() {
  int N, ways=0; cin >> N;
  for (int i=0; i<N/4+1; i++) {
    for (int j=0; j<N/7+1; j++) {
      if (4*i+7*j==N) ways++;
    }
  }
  if (ways>0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main
{
	static int getComb(int n)
	{
		int total = 0;
		for(int i = 0; i <= 9; i++)
			for(int j = 0; j <= 9; j++)
				for(int k = 0; k <= 9; k++)
					for(int z = 0; z <= 9;z++)
						if(i + j + k + z == n)
							total +=1;
		
		return total;
	}
	
	public static void main(String args[]) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s;
		while((s = br.readLine()) != null)
		{
			int n = Integer.parseInt(s);
			System.out.println(getComb(n));
		}
	}
		
}

Measured memory_bytes: 24528
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    int ans = 0;
    FOR(i,1,n+1){
        if(to_string(i).size() % 2 != 0) ans++;
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final char[] s1 = sc.next().toCharArray();
			final char[] s2 = sc.next().toCharArray();
			
			int answer = Integer.MAX_VALUE;
			
			for(int start = 0; start <= (s1.length - s2.length); start++) {
				int score = 0;
				
				for(int index = 0; index < s2.length; index++) {
					score += s1[start + index] == s2[index] ? 0 : 1;
				}
				
				answer = Math.min(answer, score);
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 32828