akhauriyash/Code-Regression huggingface dataset:
// 12/07/2020  @ 19:54:17
// *****************************************************************
// *****************************************************************
#include <bits/stdc++.h>
// *****************************************************************
// *****************************************************************
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
#define fr(i,n) for(llu i=0;i<n;i++)
#define fl(j,a,b) for(llu j=a;j<=b;j++)
#define Pi 3.1415926535897932384626
#define mod 1e9+7
#define MID(a,b) ((a + b) >> 1)
#define MAX(a,b) ((a) > (b) ? (a): (b))
#define MIN(a,b) ((a) < (b) ? (a) :(b))
#define pb push_back
#define mp make_pair
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define printer(a, n) fr(i,n) cout << a[i] << " ";
// *****************************************************************
// *****************************************************************
typedef long long unsigned int llu;
typedef long long int ll;
// *****************************************************************
// *****************************************************************
using namespace std;
// *****************************************************************
// *****************************************************************

                   // Dream it. Wish it. Do it.

                         // tannatsri //

              // Without tact you can learn nothing.

// *****************************************************************
// *****************************************************************
bool rev(ll a, ll b) {
    return a > b;
}
// *****************************************************************
void solution() {
	string a, b;
	cin >> a;
	cin >> b;
	int n1 = a.length();
	int n2 = b.length();
	if(n2 - n1 == 1) {
		fr(i, n1)  {
			if(a[i] != b[i])  {
				cout << "No";
				return;
			}
		}
		cout << "Yes";
		
	}
	else cout << "No";
}
// *****************************************************************
int main() {
    IOS;
    // #ifndef ONLINE_JUDGE
        // freopen("C:/Users/Mr.Tanishq/Desktop/noc/input.txt", "r", stdin);
        // freopen("C:/Users/Mr.Tanishq/Desktop/noc/output.txt", "w", stdout);
        // freopen("C:/Users/Mr.Tanishq/Desktop/noc/error.txt", "w", stderr);
    // #endif
    // *****************************************************************
    // *****************************************************************
    int t = 1;
    // cin >> t;
    while(t--) {

       solution();
       cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(_x) cout << _x << endl;
using namespace std;
int main()
{
    ll x;
    cin >> x;

    ll v = 100;
    int cnt = 0;
    while (v < x) {
        v += v / 100;
        cnt++;
    }

    put(cnt);
    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    char[] s = sc.next().toCharArray();
    boolean bl = true;
    if(n % 2 == 0){
      for(int i = 0; i < n / 2; i++){
        if(s[i] == s[n / 2 + i]){
          continue;
        }else{
          bl = false;
          break;
        }
      }
      }else{
        bl = false;
      }
      if(bl){
        System.out.println("Yes");
      }else{
        System.out.println("No");
    }
  }
}

Measured memory_bytes: 21460
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

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

using namespace std;

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

  string S;
  cin >> S;

  REP(i, S.size() - 1) {
    if (S[i] == 'A' && S[i + 1] == 'C') {
      cout << "Yes" << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
	ios :: sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	while (cin >> n >> k) {
		bool like[10];
		for (int i = 0; i < 10; ++i) 
			like[i] = 1;
		for (int i = 0; i < k; ++i) {
			int tmp = 0;
			cin >> tmp;
			like[tmp] = 0;
		}
		for (int i = n; i < 100000; ++i) {
			int tmp = i;
			bool fd = 1;
			while (tmp) {
				if (!like[tmp%10]) {
					fd = 0;
					break;
				}
				tmp/=10;
			}
			if (fd) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;

int n, k;

int sche[100];

int dp[100][4][4];

int rec(int day, int a, int b) // a = i - 2 ??\???, b = i - 1 ??\???
{
	if (day == n) return 1;

	if (dp[day][a][b] >= 0) return dp[day][a][b];
	
	int res = 0;
	
	if (sche[day]) {
		if (sche[day] != a || sche[day] != b) {
			res += rec(day + 1, b, sche[day]);
			res %= 10000;
		}
	} else {
		for (int i = 1; i <= 3; ++i) {
			if (a == b && b == i) continue;
			res += rec(day + 1, b, i);
			res %= 10000;
		}
	}

	return dp[day][a][b] = res;
}

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

	for (int i = 0; i < k; ++i) {
		int day; cin >> day; --day;
		cin >> sche[day];
	}

	memset(dp, -1, sizeof(dp));

	printf("%d\n", rec(0, 0, 0));
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
using namespace std;

int n, k;
map<int, int> cnts;

signed main()
{
	int i;
	
	cin >> n >> k;
	for (i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (cnts.find(a) == cnts.end()) cnts[a] = 0;
		cnts[a]++;
	}
	
	int type = 0;
	vector<int> v;
	for (map<int, int>::iterator it = cnts.begin(); it != cnts.end(); it++) {
		v.push_back(it->second);
		type++;
	}
	
	if (type <= k) { cout << 0 << endl; return 0; }
	
	sort(v.begin(), v.end());
	int ans = 0;
	for (i = 0; i < type - k; i++) { ans += v[i]; }
	cout << ans << endl;
	return 0;
}

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


int main(){

    int N,x[10],y[10],a[9] = {0,1,2,3,4,5,6,7,8};
    cin >> N;
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
    double ans = 0;
    int cnt = 0;
    do {
        for (int i = 0; i < N-1; i++) {
            ans += sqrt((x[a[i]]-x[a[i+1]])*(x[a[i]]-x[a[i+1]])+(y[a[i]]-y[a[i+1]])*(y[a[i]]-y[a[i+1]]));
        }
        cnt++;
    } while(next_permutation(a, a + N));
    cout << fixed << setprecision(10) << ans/cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,a,b;
	cin>>n;
	if(n==1){
		cout<<"Hello World";
	}
	else{
		cin>>a>>b;
		cout<<a+b;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll l, r;
    cin >> l >> r;

    if(r-l >= 2018){
        cout << 0 << endl;
    }
    else {
        ll ans = 2019;
        ll low = min(l%2019, r%2019);
        ll high = max(l%2019, r%2019); 
        for(ll i = low; i < high; ++i){
            for(ll j = i+1; j <= high; ++j){
                ans = min(ans, (i*j)%2019);
            }
        }
        
        cout << ans << endl;
    }

}

Measured memory_bytes: 3536
#include<iostream>
#include<algorithm>
using namespace std;
int c[101][10001];
int main(){
	int N, W;
	cin >> N >> W;
	int v_[1000]; int w_[1000];
	for (int i = 1; i <= N; i++){
		cin >> v_[i] >> w_[i];
	}
	//cout << "a" << endl;
	int max_ = -1;
	for (int i = 0; i < W; i++) c[0][i] = 0;
	for (int i = 0; i < N; i++) c[i][0] = 0;
	//cout << "v" << endl;
	for (int i = 1; i <= N; i++){
		for (int j = 1; j <= W; j++){
			if (0 <= j - w_[i]){
				c[i][j] = max(c[i - 1][j], c[i - 1][j - w_[i]] + v_[i]);
			}
			else c[i][j] = c[i - 1][j];
			max_ = max(max_, c[i][j]);
			//cout << c[i][j] << "  ";
		}//cout << endl;
	}
	cout << max_ << endl;
	return 0;
}

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

#define watch(x) cerr << "\n" \
					  << (#x) << " is " << (x) << endl
const double PI = 3.141592653589793238463;
const int MOD = 1000000007;
const long long MAXI = ULONG_MAX;

/*
$alil03

URL: url

Solution Begins here
*/

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, k;
	cin >> n >> k;
	int arr[n];
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for (int i = 2; i < n; i++)
	{
		dp[i] = INT_MAX;
		for (int j = 1; j <= k; j++)
		{
			if (i - j < 0)
			{
				break;
			}
			dp[i] = min(dp[i], dp[i - j] + abs(arr[i] - arr[i - j]));
		}
	}
	cout << dp[n - 1];
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll a, b, v, w, t;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> a >> v >> b >> w >> t;
    if(b >= a){
        ll d = b+w*t-(a+v*t);
        if(d <= 0){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }else{
        ll d = (a-v*t)-(b-w*t);
        if(d <= 0){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 3652
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var x = n[0];
        var y = n[1];

        var ans = "No";
        for (int i = 0; i <= x; i++)
        {
            if (i * 2 + (x - i) * 4 == y) ans = "Yes";
        }


        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 28292
bridge = set()
def connected(a, b):
    for i in bridge:
        if a <= i and i < b:
            return False
    return True
def solve():
    N, M = [int(x) for x in input().split()]
    lst = [[int(x) for x in reversed(input().split())] for i in range(M)]
    lst.sort()
    res = 0
    for l in lst:
        a, b = l
        if connected(b, a):
            bridge.add(a - 1)
    return len(bridge)

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 61712
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;

typedef long long int64;
static int64 MOD = 1e9 + 7;

class ECommonSubsequence {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, m;
        in >> n >> m;
        vector<int> u(n), v(m);
        forn(i, n)in >> u[i];
        forn(i, m)in >> v[i];

        vector<vector<int> > dp(n + 1, vector<int>(m + 1, 0));

        forn(i, n + 1)dp[i][0] = 1;
        forn(i, m + 1)dp[0][i] = 1;

        fore(i, 1, n)fore(j, 1, m) {
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
                if (u[i - 1] != v[j - 1])
                    dp[i][j] -= dp[i - 1][j - 1];

                dp[i][j] = (dp[i][j] + 10 * MOD) % MOD;
            }

        out << dp[n][m] << endl;
    }
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ECommonSubsequence solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 16000
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
	double a, b, c, d, e, f;
	while(cin >> a >> b >> c >> d >> e >> f){
		double x, y;
		y = (a*f - c*d) / (a*e - b*d);
		x = (c - b*y) / a;
		cout << fixed << setprecision(3);
		cout << x << " " << y << endl;
	}
      return 0;
}

Measured memory_bytes: 1280
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long int lnt;
typedef pair<lnt,lnt> P;
lnt ans[10],h,w,n;
lnt y[100000],x[100000];
lnt vx[9]={0,0,0,-1,-1,-1,-2,-2,-2},vy[9]={0,-1,-2,0,-1,-2,0,-1,-2};
lnt dx[9]={2,2,2,1,1,1,0,0,0},dy[9]={1,0,2,1,0,2,1,0,2};
set<P> s;
vector<P> v;
int main()
{
	cin>>h>>w>>n;
	ans[0]=(w-2)*(h-2);
	for(lnt i=0;i<n;i++){
		cin>>y[i]>>x[i];
		s.insert(P(x[i],y[i]));
	}
	for(lnt i=0;i<n;i++){
		for(lnt j=0;j<9;j++){
			
			lnt X=x[i]+vx[j];
			lnt Y=y[i]+vy[j];
			if(X<1||X>=w-1||Y>=h-1||Y<1) continue;
			v.push_back(P(X,Y));
		}
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	for(lnt i=0;i<v.size();i++){
		lnt cnt=0;
		for(lnt k=0;k<9;k++){
			if(s.count( P(v[i].first+dx[k],v[i].second+dy[k]) )!=0 ) cnt++;
		}
		ans[cnt]++;
		ans[0]--;
	}
	
	for(lnt i=0;i<10;i++){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 24556
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion


int32_t main() {
    make(int, n);
    cout << fixed << setprecision(10) <<  2 * n * M_PI;

    return 0;
}

Measured memory_bytes: 3800
/**
 *    author: codeforces-yuhongtao 
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;
#define pi acos(-1.0) 
#define ms(x,n) memset(x,n,sizeof(x));
#define pb push_back
typedef long long ll;//string::npos
typedef long long iint;
ll gcd(ll a,ll b){ return a%b==0?b:gcd(b,a%b); }
const int inf=0x3f3f3f3f;
const int maxn=5e5+5;
const int mod=1e9+7;
//priority_queue<ll,vector<ll>,greater<ll> > q;//小根堆 
//vector<int> vt[205];
//pair<int,int> p;
map<string,int> m;
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string a;
	int cnt=0;
	for(int i=1;i<=n;i++){
		cin>>a;
		if(m[a]==0){
			cnt++;
			m[a]++;
		}
	}
	cout<<cnt<<endl;


}


Measured memory_bytes: 19256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<map>
#include<vector>
#define ll long long
#define INF 0x3f3f3f3f
#define N 505
using namespace std;

struct node{
	int x,y;
};

int a[N];

int main()
{
	int n;
	scanf("%d",&n);
	bool z=false,fu=false;
	int lin=0,ma,p;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]>0) z=1;
		else if(a[i]<0) fu=1;
		else lin++;
	}
	if(lin==n){
		puts("0");
		return 0;
	}
	if(z&&!fu){
		printf("%d\n",n-1);
		for(int i=1;i<n;i++){
			printf("%d %d\n",i,i+1);
		}
		return 0;
	}
	if(!z&&fu){
		printf("%d\n",n-1);
		for(int i=n-1;i>=1;i--){
			printf("%d %d\n",i+1,i);
		}
		return 0;
	}
	ma=a[1];p=1;
	for(int i=2;i<=n;i++)
	{
		if(abs(a[i])>ma){
			ma=abs(a[i]);
			p=i;
		}
	}
	vector<node> vec;
	node nd;
	if(a[p]<0) ma=-ma;
	for(int i=1;i<=n;i++)
	{
		a[i]+=ma;
		nd.x=p;
		nd.y=i;
		vec.push_back(nd);
	}
	if(a[p]<0){
		for(int i=n-1;i>=1;i--){
			nd.x=i+1,nd.y=i;
			vec.push_back(nd);
		}
	}else{
		for(int i=1;i<n;i++){
			nd.x=i,nd.y=i+1;
			vec.push_back(nd);
		}
	}
	printf("%d\n",vec.size());
	for(int i=0;i<vec.size();i++)
	{
		printf("%d %d\n",vec[i].x,vec[i].y);
	}
	return 0;
}

Measured memory_bytes: 256
from math import factorial
n,k = map(int, input().split())
mod = 10**9+7
def comb(n,r):
    return factorial(n) // (factorial(r) * factorial(n - r))
for i in range(1,k+1):
    if n -k + 1 >= i :
        a = comb(n-k+1,i)
        b = comb(k-1,i-1)
        print((a*b)%mod)
    else:
        print(0)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> c(n);
	for(int i = 0; i < m; ++i){
		int a, l;
		cin >> a >> l;
		for(int j = 0; j < l; ++j){ c[(a + j) % n] = 1; }
	}
	int offset = 0;
	while(offset < n && c[offset] != 0){ ++offset; }
	map<int, int> mp;
	int cur_len = 0;
	for(int i = 0; i < n; ++i){
		if(c[(i + offset) % n] == 0){
			if(cur_len > 0){ mp[cur_len]++; }
			cur_len = 0;
		}else{
			++cur_len;
		}
	}
	if(cur_len > 0){ mp[cur_len]++; }
	for(auto it = mp.rbegin(); it != mp.rend(); ++it){
		cout << it->first << " " << it->second << endl;
	}
	return 0;
}


Measured memory_bytes: 1204
#include <algorithm>
#include <bits/stdc++.h>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define INF 1LL << 40;
#define ll long long
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define prique priority_queue
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
template <class T> inline void chmax(T &a, T b) { a < b ? a = b : a; };
template <class T> inline void chmin(T &a, T b) { a > b ? a = b : a; };
int main() {
    int n, q, res = 0;
    cin >> n;
    vi s(n);
    rep(i, n) cin >> s[i];
    cin >> q;
    vi t(q);
    rep(i, q) cin >> t[i];
    rep(i, q) rep(j, n) {
        if(t[i] == s[j]) {
            res++;
            break;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3112
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
aa = [a[0] % mod]
for i in range(1, n-1):
    aa.append((aa[i-1] + a[i]) % mod)
ans = 0
for i in range(n-1):
    ans += ((aa[i] * a[i+1]) % mod)
print(ans % mod)

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

int main()
{
	int sum[1001] = {};
	int count = 0;

	while (1)
	{
		char in[1001];
		int i = 0;
		cin.getline(in, sizeof(in));

		if (in[0] == '0')
		{
			break;
		}

		for (i = 0; in[i] != '\0' ; i++)
		{
			if (in[i] == '1')
			{
				sum[count] = sum[count] + 1;
			}
			else if (in[i] == '2')
			{
				sum[count] = sum[count] + 2;
			}
			else if (in[i] == '3')
			{
				sum[count] = sum[count] + 3;
			}
			else if (in[i] == '4')
			{
				sum[count] = sum[count] + 4;
			}
			else if (in[i] == '5')
			{
				sum[count] = sum[count] + 5;
			}
			else if (in[i] == '6')
			{
				sum[count] = sum[count] + 6;
			}
			else if (in[i] == '7')
			{
				sum[count] = sum[count] + 7;
			}
			else if (in[i] == '8')
			{
				sum[count] = sum[count] + 8;
			}
			else if (in[i] == '9')
			{
				sum[count] = sum[count] + 9;
			}
		}
		count++;
	}
	for (int s = 0; s < count; s++){
		cout << sum[s] << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
#define Imax 1e9+5
#define LLmax 1e18
#define Imin -1e9-5
#define LLmin -1e18
string day [] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
vector <string> v;
bool sortByFirst(const pair<int,int>&a,const pair<int,int>&b){
    return a.first>b.first;
}
void dfs (string str, string t = "", int cnt = 0) {
    if (cnt == 2) {
        v.push_back (t);
        return;
    } else {
        for (int i = 0; i <str.size (); i ++) {
            dfs (str, t + str [i], cnt + 1);
        }
    }
}
int main () {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    string str,st;
    while(cin>>n){
        cin.ignore();
        cin>>str;
        cin>>st;
        int j;
        string rs="";
        for(int i=0;i<n;i++){
            rs+=str[i];
            rs+=st[i];
        }
        cout<<rs<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
//construct SA by SA-IS O(N)
#include<string>
#include<vector>
struct SA{
	string s;
	vector<int>sa;
	SA(const string&s_):s(s_)
	{
		sa=build(vector<int>(s.begin(),s.end()),256);
	}
	vector<int>induced_sort(const vector<int>&S,const vector<int>&id,const vector<bool>&SL,vector<int>last)
	{
		vector<int>first(last);
		vector<int>ret(id.size());
		ret[0]=id[0];
		for(int i=0;i<id.size();i++)
		{
			if(id[i]>=1&&!SL[id[i]-1])
			{
				ret[first[S[id[i]-1]-1]++]=id[i]-1;
			}
			else if(ret[i]>=1&&!SL[ret[i]-1])
			{
				ret[first[S[ret[i]-1]-1]++]=ret[i]-1;
			}
		}
		for(int i=id.size();i--;)
		{
			if(ret[i]>=1&&SL[ret[i]-1])
			{
				ret[--last[S[ret[i]-1]]]=ret[i]-1;
			}
		}
		return ret;
	}
	vector<int>build(vector<int>S,int maxval)
	{
		if(S.size()==1)
		{
			return(vector<int>){1,0};
		}
		S.push_back(0);
		vector<int>cnt(maxval,0);
		vector<bool>SL(S.size());//S=>true,L=>false
		for(int i=S.size();i--;)
		{
			cnt[S[i]]+=1;
			SL[i]=i+1==S.size()||S[i]<S[i+1]||S[i]==S[i+1]&&SL[i+1];
		}
		for(int i=1;i<maxval;i++)cnt[i]+=cnt[i-1];
		vector<int>last(cnt);
		vector<int>id(S.size());
		vector<int>is_LMS(S.size());
		int LMScnt=0;
		for(int i=1;i<S.size();i++)
		{
			if(!SL[i-1]&&SL[i])
			{
				is_LMS[i]=1;
				id[--cnt[S[i]]]=i;
				LMScnt+=1;
			}
		}
		id=induced_sort(S,id,SL,last);
		int LMSsub=1;
		int pre=-1;
		is_LMS[id[0]]=LMSsub++;
		for(int i=1;i<id.size();i++)
		{
			if(is_LMS[id[i]])
			{
				if(pre>=0&&S[pre]==S[id[i]])
				{
					int k;
					for(k=1;S[pre+k]==S[id[i]+k]&&!is_LMS[pre+k]&&!is_LMS[id[i]+k];k++);
					LMSsub-=S[pre+k]==S[id[i]+k]&&is_LMS[pre+k]&&is_LMS[id[i]+k];
				}
				pre=id[i];
				is_LMS[id[i]]=LMSsub++;
			}
		}
		vector<int>newstr(LMScnt);
		vector<int>rev(LMScnt);
		int counter=0;
		for(int i=0;i<S.size();i++)
		{
			if(is_LMS[i])
			{
				newstr[counter]=is_LMS[i];
				rev[counter]=i;
				counter+=1;
			}
		}
		vector<int>sortedLMS=build(newstr,LMSsub);
		id.assign(S.size(),0);
		for(int i=1;i<sortedLMS.size();i++)
		{
			int I=rev[sortedLMS[i]];
			id[cnt[S[I]]++]=I;
		}
		return induced_sort(S,id,SL,last);
	}
	int operator[](int i){return sa[i];}
	int lower_bound(const string&t)
	{
		int L=-1,R=sa.size();
		while(R-L>1)
		{
			int M=L+R>>1;
			if(s.compare(sa[M],t.size(),t)>=0)R=M;
			else L=M;
		}
		return R;
	}
	int upper_bound(const string&t)
	{
		int L=-1,R=sa.size();
		while(R-L>1)
		{
			int M=L+R>>1;
			if(s.compare(sa[M],t.size(),t)<=0)L=M;
			else R=M;
		}
		return R;
	}
	bool contain(const string&t)
	{
		int id=lower_bound(t);
		return id<sa.size()&&s.compare(sa[id],t.size(),t)==0;
	}
	int size(){return sa.size();}
};
main()
{
	string T;
	cin>>T;
	SA X(T);
	int Q;cin>>Q;
	for(;Q--;)
	{
		string s;cin>>s;
		cout<<X.contain(s)<<endl;
	}
}



Measured memory_bytes: 31060
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
string S;

int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  cin >> S;
  rep(i, S.size()) {
    if (i%2==0 && S[i]=='L'){
      cout << "No" << "\n";
      return 0;
    }
    if (i%2==1 && S[i]=='R'){
      cout << "No" << "\n";
      return 0;
    }
  }

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

Measured memory_bytes: 256
//abc084
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+3;
bool prime[N+1];
int c[N+1] = {0};
void sieve()
{
	memset(prime,1,sizeof prime);
	prime[1] = prime[0] = 0;
	for(int p = 2; p * p <= N ; p++) {
		if(prime[p]) {
			for(int j = p * p; j <= N ; j += p) prime[j] = 0;
		}
	}
}

int main() 
{
	sieve();
	for(int i = 2 ; i <= N; ++i) if(prime[i] and prime[(i+1)/2]) c[i] = 1;
	for(int i = 1; i <= N ; ++i) c[i] += c[i - 1];
	int q,l,r; scanf("%d",&q);
	while(q--) {
		scanf("%d %d",&l,&r);
		printf("%d\n",c[r] - c[l-1]);
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1000000007;

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

  vector<int> a(n + 1, 0);
  // 1-index で受け取る
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }

  // dp[i][j] := i番目の人まででj個のアメちゃんを分けるときの場合の数
  vector<vector<long long>> dp(n + 10, vector<long long>(k + 10, 0));
  vector<vector<long long>> dp_sum(n + 10, vector<long long>(k + 10, 0));
  for (int j = 0; j <= k; j++) {
    dp_sum[0][j] = 1;
  }

  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      dp[i][j] = dp_sum[i - 1][j];
      if (j - a[i] - 1 >= 0) {
        dp[i][j] -= dp_sum[i - 1][j - a[i] - 1];
      }
      dp_sum[i][j] = dp[i][j];
      if (j - 1 >= 0) {
        dp_sum[i][j] += dp_sum[i][j - 1];
      }
      dp[i][j] %= MOD;
      dp_sum[i][j] %= MOD;
    }
  }

  if (dp[n][k] < 0) {
    dp[n][k] += MOD;
  }
  cout << dp[n][k] << endl;

  return 0;
}

Measured memory_bytes: 173168
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <limits>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <deque>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <sstream>
#include <type_traits>
#define SET(x,y) x |= (1 << y)
#define CLEAR(x,y) x &= ~(1<< y)
#define READ(x,y) ((0u == (x & (1<<y)))?0u:1u)
#define TOGGLE(x,y) (x ^= (1<<y))
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define sl(n) scanf("%lld",&n)
#define slu(n) scanf("%llu",&n)
#define sd(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pF first
#define pS second
#define CL(a,b) memset(a,b,sizeof(a))
#define sqr(x) ((x)*(x))
#define intLIMIT numeric_limits<int>
#define longLIMIT numeric_limits<long long>
#define GCD(a,b) __gcd((a),(b))
#define dbl(x) (double)(x)
#define vi vector <int>
#define vii vector < pair <int, int> >
#define vll vector <long long>
#define allof(x) (x).begin(), (x).end()
#define fastCin cin.sync_with_stdio(0);cin.tie(0)
#define scanUnsigned(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#define printArr(a,l) cout<<#a<<": ";for(int i=0;i<(l);i++){cout<<a[i]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(int i=0;i<(r);i++){for(int j=0;j<(c);j++){cout<<a[i][j]<<" ";}cout<<endl;}
char _;
using namespace std;
void PRINT (int x, int y) { for (int i = y-1; i >= 0; i--) { cout << READ(x,i); } cout << endl; }

vector<string>vec_splitter(string s){s+=',';vector<string>res;while(!s.empty()){res.push_back(s.substr(0,s.find(',')));s=s.substr(s.find(',')+1);}
return res;}
void debug_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,__attribute__((unused))int LINE_NUM){cerr<<endl;}
template<typename Head,typename...Tail>void debug_out(vector<string>args,int idx,int LINE_NUM,Head H,Tail...T){if(idx>0)cerr<<", ";else cerr<<"Line("<<LINE_NUM<<") ";stringstream ss;ss<<H;cerr<<args[idx]<<" = "<<ss.str();debug_out(args,idx+1,LINE_NUM,T...);}
#ifdef LOCAL_DBG
#define dbg(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define dbg(...) 42
#endif

int main () {
	fastCin;
	int a;
	cin >> a;
	cout << a + a*a + a*a*a << "\n";
	return 0;
}

Measured memory_bytes: 3200
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        Console.WriteLine(Console.ReadLine().Split().Select(int.Parse).Sum() <= 21 ? "win" : "bust");
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <stdio.h>
#include <cstring>
using namespace std;
int field[12+2][12+2] ={0};


void island(int x,int y) {
  int dx[4] = {1,0,-1,0};
  int dy[4] = {0,-1,0,1};
  field[x][y] = 0;
  for(int i=0;i<4;i++) {
    if((field[x+dx[i]][y+dy[i]] == 1)&&(1 <= x)&&(x <= 12)&&(1 <= y)&&(y <= 12)){
      island(x+dx[i],y+dy[i]);
    }
  }
}

int main() {
  string str;
  int ans = 0;
  while(getline(cin,str)) {
    if(str.empty()) break;
    for(int i=0;i<12;i++) {
      for(int j=0;j<12;j++) {
        field[i+1][j+1] = atoi(str.substr(j,1).c_str());
      }
      getline(cin,str);
    }

    for(int i=0;i<12;i++) {
      for(int j=0;j<12;j++) {
        if(field[i+1][j+1] == 1) {
          island(i+1,j+1);
          ans++;
        }
      }
    }
    cout << ans << endl;
    ans = 0;
    // int field[12+2][12+2] ={0};
    memset(field,0,sizeof(field));
    /*     getline(cin,str);//erase \n
           if(cin.eof()) break;*/
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
#define PB push_back
#define POP pop_back()
#define PII pair<int,int>
#define FI first
#define SE second
#define ULL unsigned long long
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1),eps=1e-8;
const ll mod=998244353;
ll qpow(ll a,ll b){
	return b?qpow(a*a%mod,b/2)*(b%2?a:1)%mod:1;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n,m,k;
	cin>>n>>m>>k;
	ll ans=0,p=1;
	for(ll i=0;i<=k;i++){
		ans=(ans+(m*p%mod)*qpow(m-1,n-i-1)%mod)%mod;
		p=p*(n-i-1)%mod*qpow(i+1,mod-2)%mod;
	}
	cout<<ans<<endl;
 	return 0;
}







Measured memory_bytes: 3664
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>

using namespace std;
using LL = long long;

constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;

int main() {
	int n;
	cin >> n;
	for (int o = 0; o < n; o++) {
		int c, a, n;
		cin >> c >> a >> n;
		int ans = 0;
		while (1) {
			if (c&&a&&n) {
				c--; a--; n--;
			}
			else if (c >= 2 && a) {
				c -= 2; a--;
			}
			else if (c >= 3) {
				c -= 3;
			}
			else {
				break;
			}
			ans++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 3e5 + 5;

ll n,a[maxn],cnt[maxn],ans[maxn][3],pre[maxn],suf[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		cnt[a[i]]++;
	}
	ll sum=0;
	for(int i=1;i<=n;i++){
		ll k=cnt[i];
		// cout<<"k="<<k<<'\n';
		ans[i][1]=k*(k-1)/2;
		ans[i][2]=(k-1)*(k-2)/2;
		sum+=ans[i][1];
	}
	// cout<<sum<<'\n';
	// for(int i=1;i<=n;i++){
	// 	pre[i]=pre[i-1]+ans[i][1];
	// }
	// for(int i=n;i>=1;i--){
	// 	suf[i]=suf[i+1]+ans[i][1];
	// }
	for(int i=1;i<=n;i++){
		ll res=sum-ans[a[i]][1]+ans[a[i]][2];
		// cout<<pre[i-1]<<'\n';
		// cout<<suf[i+1]<<'\n';
		// cout<<ans[i][1]<<'\n';
		cout<<res<<'\n';
	}
	return 0;
}

Measured memory_bytes: 14848
while 1:
    line = input()
    words = line.split()
    x = words[0]
    y = words[1]
    if (x == '0') and (y == '0'):
        break
    elif int(x) > int(y):
        print(y + " " + x)
    else:
        print(x + " " + y)

Measured memory_bytes: 7568
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
short dp[4001][4001]={};
char str1[4005],str2[4005];
short ans=0;
int main(){ 
   while(scanf("%s",str1)!=EOF){    
    scanf("%s",str2);
int a=strlen(str1),b=strlen(str2);
 for(int i=0;i<a;i++){ 
   for(int j=0;j<b;j++){  
    if(str1[i]==str2[j]){   
      if(i==0 || j==0){ 
dp[i][j]=1;ans=max(ans,dp[i][j]);} 
         else{ dp[i][j]=1+dp[i-1][j-1];ans=max(ans,dp[i][j]);}
      }}} 
 printf("%d\n",ans); ans=0;memset(dp,0,sizeof(dp));}
return 0;}   

Measured memory_bytes: 32252
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	// N/K回またはN/K +1回の操作の最小値が答え
	fmt.Println(min(n%k, abs(n%k-k)))
}


Measured memory_bytes: 640
from collections import Counter

class UnionFind:
  def __init__(self, n):
    self.n = n
    self.par = [i for i in range(n)]
    self.rank = [0]*n
    
    
  def find(self, x):
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]
  
  
  def unite(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return
    if self.rank[x] < self.rank[y]:
      self.par[x] = y
    else:
      self.par[y] = x
      if self.rank[x] == self.rank[y]:
        self.rank[x] += 1
        
        
  def same(self, x, y):
    return self.find(x) == self.find(y)
  
  
  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]
  

n, k, l  = map(int, input().split())
pq = [list(map(int, input().split())) for i in range(k)]
rs = [list(map(int, input().split())) for i in range(l)]

uf_pq = UnionFind(n)
uf_rs = UnionFind(n)

for p in pq:
  x, y = p
  uf_pq.unite(x-1, y-1)
  
for r in rs:
  x, y = r
  uf_rs.unite(x-1, y-1)
  
pairs = []
for i in range(n):
  pairs.append((uf_pq.find(i), uf_rs.find(i)))
  
count = Counter(pairs)

ans = [count[pair] for pair in pairs]
print(*ans)

Measured memory_bytes: 94588
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        public static List<long> GeneratePrime(long max)
        {
            long prime;
            double sqrtMax = Math.Sqrt(max);
            var primeList = new List<long>();

            List<long> searchList = new List<long>();
            for (long i = 2; i <= max - 1; i++)
            {
                searchList.Add(i);
            }

            do
            {
                prime = searchList.First();
                primeList.Add(prime);
                searchList.RemoveAll(n => n % prime == 0);
            } while (prime < sqrtMax);

            primeList.AddRange(searchList);

            return primeList;
        }

        void Omame()
        {
            cin = new Scanner();
            long X = cin.nextLong();

            switch (X)
            {
                case 25:
                    Console.WriteLine("Christmas");
                    break;
                case 24:
                    Console.WriteLine("Christmas Eve");
                    break;
                case 23:
                    Console.WriteLine("Christmas Eve Eve");
                    break;
                case 22:
                    Console.WriteLine("Christmas Eve Eve Eve");
                    break;
            }
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>

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

using ll = long long;
using namespace std;

constexpr int INF = 2147483647; // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, t;
	cin >> x >> t;
	cout << (x - t < 0 ? 0 : x - t) << "\n";
	return 0;
}


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

class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] a = new double[n];
		double[] b = new double[n];
		HashMap<Double, Integer> ans = new HashMap<Double, Integer>();
		int[] count = new int[n];
		for(int i=0;i<n;i++){
			a[i] = sc.nextDouble();
			b[i] =  a[i];
		}		
		Arrays.sort(a);
		for(int i=0;i<n-1;i++){
			if(a[i]==a[i+1]){
				count[i] = Math.max(1,count[i]);
				count[i+1] = count[i]+1;
			}
		}
		for(int i=n-1;i>=0;i--){
			if(count[i]==0){
				ans.put(a[i], 3 * i);
			}
			else{
				ans.put(a[i], 3 * (i-count[i]+1) + (count[i]-1));
				i -= count[i] - 1;
			}
		}
		for(int i=0;i<n;i++){
			System.out.println(ans.get(b[i]));
		}
	}
}



Measured memory_bytes: 114396
object Main{
	def main(args:Array[String]){
		val s = new java.util.Scanner(System.in)
		val n,a = s.nextInt

		val r=(1 to (math.sqrt(a).toInt + 1))
				.filter(i=>a%i==0&&a/i>=n)
        		.map(i=>if(i>=n)math.max(i,a/i) else i)
				.max

		println(r)
	}
}

Measured memory_bytes: 25668
import Control.Applicative

main :: IO ()
main = solve <$> getLine >>= putStrLn

solve :: String -> String
solve ss = case az ss of
            [] -> "-1"
            s -> s

az :: String -> String
az ss
  | null ss = []
  | null xs = []
  | null ys = []
  | otherwise = 'A' : 'Z' : az (tail ys)
  where
    (_, xs) = break (== 'A') ss
    (_, ys) = break (== 'Z') (tail xs)



Measured memory_bytes: 3576
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

signed main()
{
	string t; cin >> t;
	rep(i, t.size()) {
		printf("%c", t[i] == '?' ? 'D' : t[i]);
	}
	puts("");
}




Measured memory_bytes: 3716
import Control.Monad
import Control.Applicative
import Data.List

main = do
  [n, m, o] <- map (read :: String -> Int) . words <$> getLine
  a <- (map ((map (read :: String -> Int)) . words)) <$> (replicateM n getLine)
  b <- (transpose . (map ((map (read :: String -> Int)) . words))) <$> (replicateM m getLine)
  putStr $ showm $ xn a b

nn :: [Int] -> [Int] -> Int
nn [] _ = 0
nn _ [] = 0
nn (x:xs) (y:ys) = x * y + (nn xs ys)

xn :: [[Int]] -> [[Int]] -> [[Int]]
xn [] _         = []
xn _ []         = []
xn (xs:xss) yss = map (nn xs) yss : (xn xss yss)

showm :: [[Int]] -> String
showm = unlines . map (unwords . map show)


Measured memory_bytes: 12304
import java.util.Scanner

object Main {
  def solve(n: Int, S: Array[String]): String = {
    val counts = S map (_.groupBy(identity).mapValues(_.length) withDefaultValue 0) // 文字列ごと、アルファベット毎に出現個数を調べる

    (for {
      c <- 'a' to 'z'
      cnt = counts.foldLeft(Integer.MAX_VALUE)((acc, cnt) => math.min(acc, cnt(c))) // 文字毎の最小出現回数分をaからzまで出力
      _ <- 0 until cnt
    } yield c).mkString
  }

  def main(args: Array[String]): Unit = {
    val in = io.Source.fromInputStream(System.in).getLines()
    val n = in.next().toInt
    val S = Array.ofDim[String](n)
    S.indices foreach (i => S(i) = in.next())
    println(solve(n, S))
  }
}


Measured memory_bytes: 25536
import heapq
import math

def solve():
    N, K = map(int, input().split())
    A = sorted(map(int, input().split()), reverse=True)
    l = 0
    r = A[0]
    # (l, r]
    #print(A)
    #print("K=",K)
    while r - l> 1:
        m = (r + l) // 2
        cuts = 0
        for a in A:
            cuts += (a-1) // m
        #print(l, m,r, cuts)
        if cuts <= K:
            r = m
        else:
            l = m
    print(r)

solve()

Measured memory_bytes: 104792
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; 
	scanf("%d",&n); 
	int a[n+2], sum[n+2], total, val;
	
	sum[0] = 0;
	for(int i=1;i<=n;i++){
		scanf("%d",&val);
		sum[i] = sum[i-1]+val;
	}
	total = sum[n];
	int minDif = INT_MAX, S1,S2;
	for(int i=1;i<n;i++) {
		S1 = sum[i], S2 = total-sum[i];
		minDif = min(minDif, abs(S1-S2));
		//printf("%d %d\n", sum[i], total-sum[i]);
	}
		
	printf("%d\n",minDif);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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 pair<int,int> P;

int main(){
  int h,n;
  cin >> h >> n;
  int a[n];
  rep(i,n)cin >> a[i];
  ll s=0;
  rep(i,n)s+=a[i];
  if(h<=s)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640
import math
N, H = map(int, input().split())
A, B = [], []
a_max = 0

# 何回でも使える攻撃を使うのは、最大値をとるものだけ
# あとは全員使い捨て

for _ in range(N):
	a, b = map(int, input().split())
	a_max = max(a_max, a)
	B.append(b)
B.sort(reverse = True)
for i in range(N):
	if B[i] <= a_max:
		B = B[0 : i]
		break
		
# 使い捨てだけで戦える時
if sum(B) >= H:
	ctr = 0
	for i in range(len(B)):
		ctr += B[i]
		if ctr >= H: break
	print(i + 1)
	
# 戦えないとき
else:
	rest = H - sum(B)
	print(math.ceil(rest / a_max) + len(B))

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

using namespace std;

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

	vector<string> name[5];
	int n;
	long long ans = 0;

	cin >> n;

	string in;
	for (int i = 0;i < n;i++){
		cin >> in;
		if (in[0] == 'M') name[0].push_back(in);
		if (in[0] == 'A') name[1].push_back(in);
		if (in[0] == 'R') name[2].push_back(in);
		if (in[0] == 'C') name[3].push_back(in);
		if (in[0] == 'H') name[4].push_back(in);
	}

	for (int i = 0;i <= 2;i++){
		for (int j = i+1;j <= 3;j++){
			for (int k = j+1;k <= 4;k++){
				ans += name[i].size() * name[j].size() * name[k].size();
			}
		}
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a, b;
  int aa=0, bb=0;
  int i;
  cin >> a >> b;
  
  for(i=0; i<b; i++){
    aa+=a*pow(10,i);
  }
  
  for(i=0; i<a; i++)
    bb+=b*pow(10,i);
  
  if(aa>bb)
    cout << aa << endl;
  else
    cout << bb << endl;
  
}

Measured memory_bytes: 256