akhauriyash/Code-Regression huggingface dataset:
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector<int> A(N);
	int MIN = INF;
	int MAX = 0;
	for(int i=0;i<N;++i){
		cin >> A[i];
		MIN = min(MIN,A[i]);
		MAX = max(MAX,A[i]);
	}
	if( MAX-MIN > 1 ){
		cout << "No" << endl;
		return;
	}
	if( MIN == MAX ){
		if( A[0] == N ){
			cout << "No" << endl;return;
		}
		if( A[0] == N-1 ){
			cout << "Yes" << endl;return;
		}
		if( A[0] <= N/2 ){
			cout << "Yes" << endl;return;
		}
		cout << "No" << endl;return;
	}
	else if( MIN != MAX ){
		int L = 0;
		int R = 0;
		for(int i=0;i<N;++i){
			if( MIN == A[i] ){
				++L;
			}else{
				++R;
			}
		}
		/*
		小さいほうがL個
		大きいほうがR個
		*/
		if( L >= MAX ){
			cout << "No" << endl;return;
		}
		if( L + (R/2) > N ){
			cout << "No" << endl;return;
		}
		if( MAX > L+(R/2) ){
			cout << "No" << endl;return;
		}

		cout << "Yes" << endl;return;
	}
	

}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
 
 
int main() {
    ll h=-1e9,cn=0,N;
    cin >> N;
    vector<pair<ll,ll>> arm(N);
    rep(i,N){
       	int x,l;
        cin >> x >> l;
        arm[i] = make_pair(x+l, x-l);
    }
    sort(arm.begin(),arm.end());
    rep(i,N){
        if(h <= arm[i].second) h = arm[i].first;
        else cn++;
    }
    cout << N-cn << endl;
    return 0;
}


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

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

#define fst first
#define snd second

using namespace std;

using ll = long long;
using PII = pair<int, int>;


int dp[2][5050][2];
int main(void){
	int N;
	int t[10010];
	cin >> N;
	REP(i, N-1){
		cin >> t[i+1];
	}
	REP(i, 2) REP(j, 5050) REP(k, 2) dp[i][j][k] = INF;
	dp[0][0][0] = 0;
	REP(i, N){
		REP(j, min(i, N/2)+1){
			dp[(i+1)&1][j+1][0] = min(dp[i&1][j][0], dp[i&1][j][1] + t[i]);
			dp[(i+1)&1][j][1] = min(dp[i&1][j][1], dp[i&1][j][0] + t[i]);
		}
		dp[(i+1)&1][0][0] = INF;
	}
	int res = min(dp[N&1][N/2][0], dp[N&1][N/2][1]);
	cout << res << endl;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a, b; cin >> a >> b;

    if(a % 2 == 0 or b % 2 == 0) cout << "No" << endl;
    else cout << "Yes" << endl;



}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <string>
#include <cmath>

#define MIN(a,b) (((a)<(b))?(a):(b))

using namespace std;

int dist(int i, int j, int X, int Y) {

	int Norm = abs(i - j);
	int a = abs(i - X);
	int b = abs(j - Y);
	int Cust = a + 1 + b;

	return MIN(Norm, Cust);

}

int main() {

	int N;
	cin >> N;
	int X;
	cin >> X;
	int Y;
	cin >> Y;

	int Sum = 0;

	vector<int> A(N - 1, 0);

	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			A[dist(i, j, X, Y) - 1]++;
		}
	}

	for (int k = 0; k < N - 1; k++) {
		cout << A[k] << "\n";
	}

}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define inputar(a,n) ll a[n];rep(i,0,n)cin>>a[i]
#define PI 3.14159265
const int MOD=1e9+7;
const int N=1e5+5;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()

#define test4(x,y,z,a) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cerr<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cerr<<"x is "<<x<<endl;

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

int main()
{
    IOS;
    ll a[5];
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
    }
    ll k;
    cin>>k;
    for(int i=0;i<4;i++)
    {
        for(int j=i;j<5;j++)
        {
            if(a[j]-a[i]>k)
            {
                cout<<":("<<endl;
                return 0;
            }
        }
    }
    cout<<"Yay!"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T> using vv=vector<vector<T>>;
typedef deque<int> di;
typedef deque<deque<int>> ddi;


int main() {
    int n,w;
    cin >> n >> w;
    i_i vw[101] = {};
    int dp[10001][101] = {};
    FOR(i,1,n+1) {
        cin >> vw[i].first >> vw[i].second;
    }
    FOR(i,1,w+1) {
        FOR(j,1,n+1) {
            if(i >= vw[j].second) {
                dp[i][j] = max((vw[j].first + dp[i-vw[j].second][j-1]),dp[i][j-1]);
            } else {
                dp[i][j] = dp[i][j-1];
            }
        }
    }
    cout <<  dp[w][n] << endl;
	return 0;
}

Measured memory_bytes: 7044
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	long int N, D;
	int count = 0;
	cin >> N >> D;
	for(int i = 0; i < N; i++){
		long int temp1, temp2;
		cin >> temp1 >> temp2;
		if(D * D >= temp1 * temp1 + temp2 * temp2)
			count++;
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}
int32_t main()
{
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	int ans=0;
		int x=min(a,k);
		ans+=x;
		k-=x;
		a-=x;
		if(k<=0)
		{
			cout << ans ;
			return 0;
		}
		
		int y=min(b,k);
		k-=y;
		b-=y;
		
		if(k<=0)
		{
			cout << ans ;
			return 0;
		}
		
		int z=min(c,k);
		k-=z;
		c-=z;
		ans-=z;
		
	cout << ans;
}


Measured memory_bytes: 3620
# include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
 
const int N = int(2e5) + 2; 
const int LG = 20;
const ll mod = 998244353;
const int INF = 2147483647;
const ll linf = 1e18;
const ld pi = acos(-1);
const ld EPS = 1e-10;

int n, a[N];
int main (){
	scanf ("%d", &n);
	for (int i = 1; i <= n; ++i) scanf ("%d", a + i);
	int ans = 0, cur = 0, last = -1;
	for (int i = 1; i <= n; ++i){
		if (last == -1) last = a[i];
		else {
			if (last >= a[i]){
				last = a[i];
				++cur;
			} else {
				last = a[i];
				ans = max(ans, cur);
				cur = 0;
			}
		}
	}
	ans = max(ans, cur);
	return !printf ("%d\n", ans);
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static int gcd(int a, int b) {
		int r = a % b;
		while ((r = a % b) != 0) {
			a = b;
			b = r;
		}
		return b;
	}

	public static void main(String[] args) {
		int n, X, min = 0;
		int x[];
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		X = sc.nextInt();
		x = new int[n];

		for (int i = 0; i < n; ++i) {
			x[i] = sc.nextInt();
			if (i > 0) {
				min = gcd(min, Math.abs(x[i] - X));
			} else {
				min = Math.abs(x[i] - X);
			}
		}

		System.out.println(min);
		sc.close();
	}

}


Measured memory_bytes: 50184
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();

		for(int i = a; i <= b; i++){
			if(i <= a + k - 1 || i >= b - (k - 1)){
				System.out.println(i);
			}
		}

	}
}


Measured memory_bytes: 23380
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<functional>
#include<string>
#include<vector>
#include<cstring>
#include<utility>
#include<set>
#include<map>

#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 2e9
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
const double PI = acos(-1);

using namespace std;
int P[200001];
int find(int a) {
	if (P[a] < 0) return a;
	else return P[a] = find(P[a]);
}
void merge(int a, int b) {
	a = find(a);
	b = find(b);
	if (a != b) {
		if (P[a] > P[b]) swap(a, b);
		P[a] += P[b];
		P[b] = a;
	}
}
int main(void) {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//	freopen("input.txt", "r", stdin);
	memset(P, -1, sizeof(P));
	int N, M; cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		int a, b; cin >> a >> b;
		merge(a, b);
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		ans = max(ans, -P[i]);
	}
	cout << ans;

}


Measured memory_bytes: 4432
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int L, count;
char str[100];
char ans[1000][100];

int judge(char *s){
	int i;
	for(i = 0; i < count; i++){
		if(strcmp(ans[i], s) == 0) return 0;
	}
	return 1;
}

void reverse(char *med, char *s){
	int i;
	for (i = 0; i < strlen(s); i++)
	{
		med[i] = s[strlen(s)-1-i];
	}
	med[i] = '\0';
	return;
}

int main()
{
	int i, k;
	char a[100], b[100], c[100], d[100], e[100], f[100];
	scanf("%d", &L);
	for (k = 0; k < L; k++)
	{
		count = 1;
		scanf("%s", str);
		strcpy(ans[0], str);
		reverse(c, str);
		if(judge(c)){
			strcpy(ans[count], c);
			count++;
		}
		for (i = 1; i < strlen(str); i++)//i??????????????§??????
		{
			strcpy(a, "\0");
			strcpy(b, "\0");
			strncat(a, str, i);
			strcat(b, &str[i]);
			reverse(c, a);
			strcat(c, b);
			if(judge(c)){
				strcpy(ans[count], c);
				count++;
			}
			reverse(d, c);
			if(judge(d)){
				strcpy(ans[count], d);
				count++;
			}

			strcpy(d, "\0");
			reverse(c, b);
			strcat(d, a);
			strcat(d, c);
			if(judge(d)){
				strcpy(ans[count], d);
				count++;
			}
			reverse(e, d);
			if(judge(e)){
				strcpy(ans[count], e);
				count++;
			}

			strcpy(e, "\0");
			reverse(c, a);
			reverse(d, b);
			strcat(e, c);
			strcat(e, d);
			if(judge(e)){
				strcpy(ans[count], e);
				count++;
			}
			reverse(f, e);
			if(judge(f)){
				strcpy(ans[count], f);
				count++;
			}
		}
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 676
//B - Judge Status Summary


#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int T;
	cin >> T;
	int ac = 0, wa = 0, tle = 0, re = 0;

	// cin.ignore(); must be there when using getline(cin, s)
	while (T--)
	{
		string s;
		cin >> s;
		if (s == "AC")
		{
			ac++;
		}
		else if (s == "WA")
		{
			wa++;
		}
		else if (s == "TLE")
		{
			tle++;
		}
		else
		{
			re++;
		}
	}
	cout << "AC " << "x " << ac << endl;
	cout << "WA " << "x " << wa << endl;

	cout << "TLE " << "x " << tle << endl;
	cout << "RE " << "x " << re << endl;



	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    string s;
    string need = "keyence";
    cin >> s;
    for (int j = 0; j < s.size(); j++) {
        for (int k = j - 1; k < s.size(); k++) {
            string t;
            for (int r = 0; r < s.size(); r++) {
                if (r >= j && r <= k) continue;
                t += s[r];
            }
            if (t == need) {
                cout << "YES";
                return 0;
            }
        }
    }
    cout << "NO";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;
const int MAXN = 305;
struct Edge {
    int v, w;
};
vector<Edge> adj[MAXN];
int n;
struct Item {
    int val;
    int u, v;
    bool operator < (const Item &item) const {
        return val < item.val;
    }
};
int dis[MAXN];
bool inque[MAXN];
void spfa(int s) {
    queue<int> que;
    dis[s] = 0;
    inque[s] = true;
    que.push(s);
    while(!que.empty()) {
        int u = que.front(); que.pop();
        inque[u] = false;
        for(int i = 0; i < adj[u].size(); i++) {
            if(dis[adj[u][i].v] > dis[u] + adj[u][i].w) {
                dis[adj[u][i].v] = dis[u] + adj[u][i].w;
                if(!inque[adj[u][i].v]) {
                    inque[adj[u][i].v] = true;
                    que.push(adj[u][i].v);
                }
            }
        }
    }
}
Item item[MAXN * MAXN];
int cnt_item;
int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) {
        int val; scanf("%d", &val);
        if(i < j) {
            item[cnt_item++] = (Item){val, i, j};
        }
    }
    sort(item, item + cnt_item);
    long long ans = 0;
    for(int i = 0; i < cnt_item; i++) {
        memset(dis, 0x3f, sizeof(dis));
        spfa(item[i].u);
        if(dis[item[i].v] < item[i].val) {
            printf("-1\n");
            return 0;
        }
        else if(dis[item[i].v] > item[i].val) {
            adj[item[i].u].push_back({item[i].v, item[i].val});
            adj[item[i].v].push_back({item[i].u, item[i].val});
            ans += item[i].val;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 768
import sys

N = int(raw_input())
A = [int(x)-(i+1) for i,x in enumerate(raw_input().strip().split())]
A.sort()
medians = []
if len(A)%2==1:
    medians.append(A[len(A)/2])
else:
    medians.append(A[len(A)/2])
    medians.append(A[len(A)/2 -1])

result = sys.maxint
for m in medians:
    temp = sum(abs(a-m) for a in A)
    result = min(result, temp)

print result

Measured memory_bytes: 21108
import java.util.Scanner;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    for(int i = 1;;i++){
      int x = sc.nextInt();
      if(x == 0){
        break;
      }
      System.out.printf("Case %d: %d\n",i,x);
    }
}
}


Measured memory_bytes: 66300
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b;
    cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;
   
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

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

int dp[87];

int luca(int n)
{
    if (n == 0)
    {
        return 2;
    }
    if (n == 1)
    {
        return 1;
    }
    if (dp[n] >= 0)
    {
        return dp[n];
    }
    return (dp[n] = luca(n - 1) + luca(n - 2));
}

signed main()
{
    int n;
    cin >> n;
    memset(dp, -1, sizeof(dp));
    cout << luca(n) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	ll T;

	ll ans=0;
	cin >>n>>T;
	vector<ll>t(n);
	rep(i,n){
		cin>>t[i];
		if(i!=0){
			ans+=min(T,t[i]-t[i-1]);
		}
	}
	cout<<ans+T<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>
#include<tuple>

using namespace std;

#define reep(i, s, n) for(int i=s;i<(int)n;i++)
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define all(v) v.begin(), v.end()
#define tyd typedef
#define vc vector
#define pb push_Back
#define eb emplace_back
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
const int IINF = 1<<28;

#define fs first
#define sc second


int main(){
	int n[6];
	while(1){
		int sum[3] = { 0 };
		bool isExit = true;
		rep(i, 6){
			cin >> n[i];
			if( n[i] != 0 ){
				isExit = false;
			}
		}

		if( isExit ){
			break;
		}

		rep(i, 3){
			sum[i] += n[i] + n[i+3];
		}

		int I = min(sum[0], min(sum[1], sum[2]));
		int ans = 0;
		for( int i = I; i >= max(I-12, 0); --i ){
			ans = max(ans, i + (sum[0]-i)/3 + (sum[1]-i)/3 + (sum[2]-i)/3);
		}

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

Measured memory_bytes: 1160
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
A = map(int, raw_input().split())

m_fact = {}
def fact(n):
    if n in m_fact:
        return m_fact[n]
    if n == 1:
        m_fact[n] = 1
        return 1
    m_fact[n] = (fact(n - 1) * n) % MOD
    return m_fact[n]

m_rev = {}
def rev_mod(n):
    if n in m_rev:
        return m_rev[n]
    p = MOD - 2
    ret = 1
    p_cur = n
    while p > 0:
        if p % 2:
            ret *= p_cur
            ret %= MOD
        p_cur *= p_cur
        p_cur %= MOD
        p /= 2
    m_rev[n] = ret
    return ret

S = [0] * (N + 2)
S2 = [0] * (N + 2)

for i in range(1, N):
    num = (fact(N) * rev_mod(i + 1)) % MOD
    S[0] += num
    S[0] %= MOD
    S[i] -= num
    S[i] %= MOD
    S[N] -= num
    S[N] %= MOD
    S[N - i] += num
    S[N - i] %= MOD

S[0] += fact(N)
S[0] %= MOD
S[N] -= fact(N)
S[N] %= MOD

for i in range(N):
    S[i + 1] += S[i]
    S[i + 1] %= MOD

for i in range(1, N - 1):
    num = (fact(N) * rev_mod(i + 1) * rev_mod(i + 2) * 2) % MOD
    wid = min(i, N - 1 - i)
    S2[1] += num
    S2[1] %= MOD
    S2[wid + 1] -= num
    S2[wid + 1] %= MOD
    S2[N - wid] -= num
    S2[N - wid] %= MOD

for i in range(N):
    S2[i + 1] += S2[i]
    S2[i + 1] %= MOD

for i in range(N):
    S2[i + 1] += S2[i]
    S2[i + 1] %= MOD

ans = 0
for i in range(N):
    ans += S[i] * A[i]
    ans += S2[i] * A[i]
    ans %= MOD

print ans

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int a, b;
    cin >> a >> b;
    int s = a - 1, t = b - 1;
    int ans = (t + s - 1) / s;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    int batas = N - K;
    long long int attack = 0;
    int Hi[N];

    for(int i = 0; i < N; i++){
        cin >> Hi[i];
    }
    sort(Hi, Hi + N);

    for(int i = 0; i < batas; i++){
        attack += Hi[i];
    }
    cout << attack << '\n';
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//struct area

//function area

//main area
int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    ll sum = 0;
    rep(i,n-1){
        if(a[i] > a[i+1]){
            sum += a[i]-a[i+1];
            a[i+1] = a[i];
        }
    }
    cout << sum << endl;
}
/*



*/

Measured memory_bytes: 4412
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

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

int sz;

void dfs(vector <set <int>> &g, vector <bool> &used, int v){
	sz++;
	used[v] = true;
	for(int i: g[v])
		if(!used[i])
			dfs(g, used, i);
}

int main(){
	int n, m;
	cin >> n >> m;
	
	vector <set <int>> g(n);
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		
		a--, b--;
		g[a].insert(b);
		g[b].insert(a);
	}
	
	int ans = 0;
	
	vector <bool> used(n, false);
	for(int i = 0; i < n; i++)
		if(!used[i]){
			sz = 0;
			dfs(g, used, i);
			
			ans = max(ans, sz);
		}
		
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 40608
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;
template<class T> inline bool chmax(T& a,T b){if (a < b) {a = b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if (a > b) {a = b;return 1;}return 0;}

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

}

Measured memory_bytes: 3636
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
 
    String s = sc.nextStr();
    String t = sc.nextStr();

    int ans = 0;
    for(int i = 0; i < s.length(); i++){
      if(s.charAt(i) != t.charAt(i)){
        ans++;
      }
    }
 
    System.out.println(ans);
 
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 29852
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int N,M;
    cin >> N >> M;
    lint A[N];
    rep(i,N) cin >> A[i];
    lint sum[N+1]={};
    rep(i,N) sum[i+1]=sum[i]+A[i];
    map<lint,lint> cnt;
    set<lint> appear;
    rep(i,N+1){
        appear.insert(sum[i]%M);
        cnt[sum[i]%M]++;
    }
    lint ans=0;
    while(!appear.empty()){
        auto itr=appear.begin();
        lint num=cnt[*itr];
        ans+=num*(num-1)/2;
        appear.erase(itr);
    }
    cout << ans << endl;
}

Measured memory_bytes: 8704
n, k = gets.split(' ').map(&:to_i)

x = gets.split(' ').map(&:to_i)
min = 10000000000
for i in 0...(n - k + 1)
	l = x[i].abs + (x[i + k - 1]-x[i]).abs;
	r = x[i + k - 1].abs + (x[i]-x[i + k - 1]).abs;
	min = l if min > l
	min = r if min > r
end

p min

Measured memory_bytes: 8452
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< int > vi;
typedef pair< int , int > pi;
typedef set< int > se;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define Fn 1.618033987
int main() 
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin>>N;
    int A[N];
    REP(i,0,N-1)
    {
        cin>>A[i];
    }
    sort(A,A+N,greater< int >());
    if(N==1)
    {
        cout<<0<<'\n';
    }
    else
    {
        ll ans=A[0];
        int t=0;
        int cap=0;
        REP(i,2,N-1)
        {
            ++t;
            ++cap;
            ans+=A[i-t];
            if(cap==2)
            {
                --t;
                cap=0;
            }
        }
        cout<<ans<<'\n';
    }
    return 0; 
}

Measured memory_bytes: 4444
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

struct PairHash {
  template <class K, class V> size_t operator()(const pair<K, V> &p) const
  {
    size_t h = 31 * hash<K> {}(p.first);
    h = 31 * (h + hash<V> {}(p.second));
    return h;
  }
};

int dda[][2] = { { 0, -1 }, { 1, 0 }, { 0, 1 }, { -1, 0 } };
int ddb[][2] = { { -2, -2 }, { -2, -1 }, { -2, 0 }, { -2, 1 }, { -2, 2 }, { -1, -2 }, { -1, -1 },
                 { -1, 1 },  { -1, 2 },  { 0, -2 }, { 0, 2 },  { 1, -2 }, { 1, -1 },  { 1, 1 },
                 { 1, 2 },   { 2, -2 },  { 2, -1 }, { 2, 0 },  { 2, 1 },  { 2, 2 } };

int main()
{
  int h, w, ch, cw, dh, dw;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  char ss[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> ss[i][j];
    }
  }
  pair<int, int> c(ch - 1, cw - 1);
  pair<int, int> d(dh - 1, dw - 1);

  unordered_map<pair<int, int>, int, PairHash> dist { { c, 0 } };
  queue<pair<int, int>> que;
  vector<pair<int, int>> tmp = { c };
  while (!tmp.empty() && dist.find(d) == dist.end()) {
    for (auto t : tmp)
      que.push(t);
    while (!que.empty()) {
      auto p = que.front();
      que.pop();
      for (int i = 0; i < 4; i++) {
        pair<int, int> next(p.first + dda[i][0], p.second + dda[i][1]);
        if (next.first < 0 || next.second < 0 || h <= next.first || w <= next.second
            || ss[next.first][next.second] == '#' || dist.find(next) != dist.end())
          continue;
        dist[next] = dist[p];
        que.push(next);
        tmp.push_back(next);
      }
    }
    for (auto t : tmp)
      que.push(t);
    tmp.clear();
    while (!que.empty()) {
      auto p = que.front();
      que.pop();
      for (int i = 0; i < 20; i++) {
        pair<int, int> next(p.first + ddb[i][0], p.second + ddb[i][1]);
        if (next.first < 0 || next.second < 0 || h <= next.first || w <= next.second
            || ss[next.first][next.second] == '#' || dist.find(next) != dist.end())
          continue;
        dist[next] = dist[p] + 1;
        tmp.push_back(next);
      }
    }
  }
  if (dist.find(d) == dist.end()) {
    cout << -1 << endl;
  } else {
    cout << dist[d] << endl;
  }
  return 0;
}


Measured memory_bytes: 27952
from sys import stdin
from collections import deque, Counter, defaultdict
# from fractions import gcd
from math import gcd
import heapq

MOD = 10 ** 9 + 7
input = stdin.readline

n = int(input())
zero = 0
A, B = [], []
# mp = defaultdict(lambda: [0, 0])
mp = {}
for i in range(n):
    ai, bi = map(int, input().split())
    if ai == 0 and bi == 0:
        zero += 1
        continue

    gi = gcd(ai, bi)
    ai = ai // gi
    bi = bi // gi

    if bi < 0:
        ai = -ai
        bi = -bi
    if bi == 0 and ai < 0:
        ai = -ai
    if ai <= 0:
        ai, bi = bi, -ai
        if (ai, bi) in mp:
            mp[(ai, bi)][0] += 1
        else:
            mp[(ai, bi)] = [1, 0]
    else:
        if (ai, bi) in mp:
            mp[(ai, bi)][1] += 1
        else:
            mp[(ai, bi)] = [0, 1]

ans = 1
for key in mp:
    s, t = mp[key]
    ans *= pow(2, s, MOD) + pow(2, t, MOD) - 1
    ans %= MOD
print((zero - 1 + ans) % MOD)

Measured memory_bytes: 125124
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)


struct Problem {

	struct Point {
		LL x, y;
		bool operator<(const Point &r) const {
			if (x * r.x > 0) return y * r.x < r.y * x;
			if (x * r.x < 0) return x > 0;
			if (r.x != 0) return !(r < *this);
			if (x == 0) return y < r.y;
			if (r.y > 0) return x > 0;
			return false;
		}
	};

	void Solve() {
		UL N; cin >> N;
		Point P[100];
		rep(i, N) cin >> P[i].x >> P[i].y;
		sort(P, P + N);

		LL ans = 0;
		for(UL s = 0; s < N; s++) {
			LL X = 0, Y = 0;
			for (UL t = 0; t < N; t++) {
            	UL tt = (s + t) % N;
				X -= P[tt].x; Y -= P[tt].y;
				ans = max(ans, X * X + Y * Y);
				//cout << X * X + Y * Y << endl;
			}
		}
		//cout << endl;
		cout << sqrt(double(ans)) << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 998244353;

    signed n;
    cin>>n;
    int ans=1;
    rep(i,n){
        int a;
        cin>>a;
        if(a==0){
            cout<<0<<endl;
            return 0;
        }
        if(ans==-1||a>1000000000000000000/ans){
            ans=-1;
        }
        else ans*=a;
    }
    cout<<ans<<endl;
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

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

template<class T>
void chmin(T& a,T b){
	a=min(a,b);
}

template<class T>
void ResetVector(vector<T>& v,int n,const T& t){
	v.clear();
	v.resize(n,t);
}

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

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

int r,c,n;
vector<vector<pii>> g;
vector<bool> vis;
vector<ll> ans;
void dfs(int v,ll w,ll& m1,ll& m2){
	if(vis[v]){
		if(ans[v]!=w)
			No();
		return;
	}
	vis[v]=true;
	ans[v]=w;
	if(v<r)
		chmin(m1,w);
	else
		chmin(m2,w);
	for(auto e:g[v])
		dfs(e.first,ll(e.second)-w,m1,m2);
}

int main(){
	r=read(),c=read(),n=read();
	g.resize(r+c);
	vis.resize(r+c,false);
	ans.resize(r+c);
	REP(i,n){
		int y=read()-1,x=read()-1,a=read();
		g[y].PB(MP(r+x,a));
		g[r+x].PB(MP(y,a));
	}
	REP(i,r+c)if(!vis[i]){
		ll m1=LLONG_MAX/2,m2=LLONG_MAX/2;
		dfs(i,0,m1,m2);
		if(m1+m2<0)
			No();
	}
	Yes();
}


Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A, B;
  int ans;
  cin >> A >> B;
  ans = A + B;
  if(A-B > ans) ans = A-B;
  if(A*B > ans) ans = A*B;
  cout << ans << endl;
  return 0;
}

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

using namespace std;


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

    long long a,b,c,d;
    cin>>a>>b>>c>>d;

    vector<long long> arr;
    arr.push_back(a*c);
    arr.push_back(a*d);
    arr.push_back(b*c);
    arr.push_back(b*d);
    

    cout<<*max_element(arr.begin(),arr.end());
    

    return 0;
}


Measured memory_bytes: 3616
import sys
def input():
	return sys.stdin.readline()[:-1]

from fractions import gcd
n, m = map(int, input().split())
a = list(map(int, input().split()))
m *= 2

if n == 1:
	print((m//a[0]+1)//2)
else:
	lcm = a[0]*a[1]//gcd(a[0], a[1])
	for i in range(2, n):
		lcm = lcm * a[i] // gcd(lcm, a[i])
		if lcm > m:
			print(0)
			sys.exit()

	divs = 0
	for x in a:
		divs += (lcm//x)%2
	if divs < n:
		print(0)
	else:
		print((m//lcm+1)//2)

Measured memory_bytes: 89580
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 2100
using namespace std;
struct edge{
    int from,to;
    ll cost;
    bool operator<(const edge& e)const{
        return cost<e.cost;
    };
};
edge E[N];
int n,m,state[N];
ll x;
int par[N],grade[N];
void init(int n){
    rep(i,n){
        par[i]=i;
        grade[i]=0;
    }
}
int root(int x){
    return par[x]==x?x:par[x]=root(par[x]);
}
bool same(int x,int y){
    return root(x)==root(y);
}
void unite(int x,int y){
    x=root(x); y=root(y);
    if(x==y)return;
    if(grade[x]<grade[y]){
        par[x]=y;
    }
    else{
        par[y]=x;
        if(grade[x]==grade[y]) grade[x]++;
    }
}
ll kruskal(int a){
    init(n+1);
    unite(E[a].from,E[a].to);
    ll t=E[a].cost;
    rep(i,m){
        int from=E[i].from,to=E[i].to;
        if(same(from,to))continue;
        unite(from,to);
        state[i]=1;
        t+=E[i].cost;
    }
    return t;
}
ll modpow(ll x,ll n){
    if(n==0) return 1;
    ll res=modpow(x*x%MOD,n/2);
    if(n&1) res=res*x%MOD;
    return res;
}
main(){
    cin>>n>>m>>x;
    rep(i,m){
        cin>>E[i].from>>E[i].to>>E[i].cost;
    }
    sort(E,E+m);
    init(n+1);
    ll temp=0;
    rep(i,m){
        int from=E[i].from,to=E[i].to;
        if(same(from,to))continue;
        unite(from,to);
        state[i]=1;
        temp+=E[i].cost;
    }
    if(temp==x){
        rep(i,m){
            if(state[i])continue;
            if(x==kruskal(i)){
                state[i]=1;
            }
        }
        int count=0;
        rep(i,m){
            count+=state[i];
        }
        cout<<((modpow(2,count)-2)*modpow(2,m-count)%MOD);
    }
    else{
        rep(i,m){
            if(state[i])continue;
            ll t=kruskal(i);
            if(t<x) state[i]=1;
            else if(t==x) state[i]=2;
        }
        int c1=0,c2=0;
        rep(i,m){
            if(state[i]==2) c1++;
            else if(state[i]==0) c2++;
        }
        cout<<(2*(modpow(2,c1)-1)*modpow(2,c2)%MOD);
    }
    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong X, Y, Z, K;
	vector<llong> A, B, C;

	cin >> X >> Y >> Z >> K;
	A.resize(X);
	B.resize(Y);
	C.resize(Z);
	for (int i = 0; i < X; ++i)
		cin >> A[i];
	for (int i = 0; i < Y; ++i)
		cin >> B[i];
	for (int i = 0; i < Z; ++i)
		cin >> C[i];

	priority_queue<llong, vector<llong>, greater<llong> > ab, abc;
	for (auto a : A) {
		for (auto b : B) {
			ab.push(a + b);
			if (ab.size() > K)
				ab.pop();
		}
	}

	while (ab.size()) {
		for (auto c : C) {
			abc.push(ab.top() + c);
			if (abc.size() > K)
				abc.pop();
		}
		ab.pop();
	}

	stack<llong> ans;
	while (abc.size()) {
		ans.push(abc.top());
		abc.pop();
	}

	while (ans.size()) {
		cout << ans.top() << endl;
		ans.pop();
	}

	return 0;
}

Measured memory_bytes: 384
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	int n;
	cin >> n;
	cout << 180 * (n - 2) << endl;
	return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

    std::vector<long long> x(n);
    for (int i = 0; i < n; i++) {
        std::cin >> x[i];
    }

    std::vector<long long> xn(x);
    std::sort(xn.begin(), xn.end(), std::greater<long long>());

    long long mid1 = xn[n / 2 - 1];
    long long mid2 = xn[n / 2];

    for (int i = 0; i < n; i++) {
        if((1.0*mid1 + 1.0*mid2) / 2 < x[i]) {
            std::cout << mid2 << "\n";
        } else {
            std::cout << mid1 << "\n";
        }
    }
}

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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

ll n, w, wt[101], v[101];
ll max(ll a, ll b)
{
	return (a>b)? a: b;
}
ll min(ll a, ll b)
{
	if(a == -1) return b;
	else if(b == -1) return a;
	return (a>b)? b : a;
}

int main()
{
	cin >> n >> w;
	for(int i=0;i<n;i++)
		cin >> wt[i] >> v[i];
	ll pos[n+1][100001];
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<100001;j++)
			pos[i][j] = -1;
	}
	int mval = 0;
	pos[0][0] = 0;
	ll m = 0;
	for(int i=1;i<=n;i++)
	{
		for(int val=0;val<=100000;val++)
		{
			// minimise the weight for certain value
			if(val - v[i-1] >=0 && pos[i-1][val - v[i-1]] != -1)
			{
				pos[i][val] = max(pos[i][val], pos[i-1][val -v[i-1]] + wt[i-1]);
			}
			pos[i][val] = min(pos[i][val], pos[i-1][val]);
			//debug(pos[i][val], val, i);
			if(w >= pos[i][val] && pos[i][val] > 0)
			{
				m = max(m, val);
				//debug(m);
			}
		}
	}
	cout << m << "\n";
	return 0;
}

Measured memory_bytes: 79104
def main():
    [N, K, Q] = [int(num) for num in input().split()]
    A = []
    for i in range(Q):
        A.append(int(input()))

    points = [K - Q] * N
    for a in A:
        points[a - 1] += 1
    for p in points:
        if p > 0:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 10448
N=int(input())
s=[]
for i in range(N):
     s.append(input())

A={}
U=0
for i in range(N):
    if ''.join(sorted(s[i])) in A.keys():
        A[''.join(sorted(s[i]))]=A[''.join(sorted(s[i]))]+1
        U+=A[''.join(sorted(s[i]))]
    else:
        A[''.join(sorted(s[i]))]=0
print(U)


Measured memory_bytes: 25020
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	scanf("%d", &n);
	vector<vector<int> > v(n, vector<int>(3));
	for (auto &x : v)
		for (auto &y : x)
			scanf("%d", &y);
	vector<vector<int> > dp(n + 1, vector<int>(3));
	for (int i = n - 1; i >= 0; --i)
		for (int l = 0; l < 3; ++l)
			for (int g = 0; g < 3; ++g)
				if (l != g)
					dp[i][l] = max(dp[i][l], dp[i + 1][g] + v[i][g]);
	printf("%d\n", max({ dp[0][0],dp[0][1],dp[0][2] }));
	return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[123][123456];
int N,W,price[123],wt[123];
int32_t main()
{
   cin >> N>>W;
   for(int i=0;i<N;i++)
   {
       cin>> wt[i] >> price[i];
   }
   
   for(int i=1;i<=N;i++)
   {
      for(int j=1;j<=W;j++)
      {
          if(wt[i-1]<=j)
          {
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-wt[i-1]]+price[i-1]);
          }
          else
          dp[i][j] = dp[i-1][j];
      }
   }
   
   cout<<dp[N][W]<<"\n";

}

Measured memory_bytes: 97408
N, A, B = map(int, input().split())
SUM = 0
for i in range(1, N+1):
    j = i
    s = 0
    while True:
        if j == 0:
            break
        s += j%10
        j = j//10
    if A <= s <= B:
        SUM += i
print(SUM)

Measured memory_bytes: 3060