akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll n,k;
    cin>>n>>k;
    ll a=n%k;
    if(n>k) a=min(a,abs(a-k));
    else a=min(n,k-n);
    cout<<a;
}

Measured memory_bytes: 3540
# import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
enu = enumerate
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

S = input()
cnt = 0
for s in S:
    cnt += int(s)
    cnt %= 9
if cnt:
    print("No")
else:
    print("Yes")



Measured memory_bytes: 68456
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

long long int sousu[100000];
int mod = 1000000007;

long long int rec(int x) {
	if (x < 0) {
		return 0;
	}
	else if (sousu[x] >= 0) {
		return sousu[x];
	}
	else if (x == 0) {
		sousu[x] = 1;
	}
	else if (x == 1) {
		if (sousu[x - 1] != 0) {
			sousu[x] = 2;
		}
		else {
			sousu[x] = 1;
		}
	}
	else {
		sousu[x] = (rec(x - 1) + rec(x - 2)) % mod;
	}
	return sousu[x];
}

int main() {
	int N, M, a, i;
	memset(sousu, -1, sizeof(sousu));
	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d", &a);
		sousu[a - 1] = 0;
	}
	printf("%lld\n", rec(N - 1));
	return 0;
}

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

using namespace std;

int n, W, wt[100001], v[100001];
long long dp[101][100001];

int main()
{
	cin >> n >> W;
	for (int i = 0; i < n; i++)
		cin >> wt[i] >> v[i];
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= W; j++)
		{
			if (i == 0 || j == 0)
				dp[i][j] = 0;
			else if (j >= wt[i - 1])
				dp[i][j] = max(v[i - 1] + dp[i - 1][j - wt[i - 1]], dp[i - 1][j]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	cout << dp[n][W] << endl;
	return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  int X, N, p;
  cin >> X >> N;
  int diff = 100000;
  int minN = 100000;
  
  map<int,int>m;
  for (int i = 0; i < N; i++) {
    cin >> p;
    m[p] = p;
  }

  for (int i = 101; i >= 0; i--) {
    if(i != m[i] || i == 0){
      if(diff >= abs(X-i)){
        diff = min(diff, abs(X-i));
        minN = i;
      }
    }
  }

  cout << minN << endl;

  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;




#define P pair<ll,ll>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define st std::string 
#define pb push_back 
#define ll long long 
#define pq(x) std::priority_queue<x> 
#define ultapq(x) priority_queue<x,vector<x>,greater<x>> cle
#define show_pq(x,n) for(ll i = 0; i < n; i++){cout<<x.top(); x.pop();} 
#define itrt(yo) for(auto x:yo){std::cout<<x<<" ";} 
#define vec(x) std::vector<x> 
#define inll(x)  ll x; cin>>x;
#define inint(x)  ll x; cin>>x;
#define nl '\n' 
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define ALL(x) x.begin(),x.end() 
#define BN(x) x.begin()
#define ED(x) x.end()
#define MAP_traverse(it,x)  for(auto it = BN(x); it!= ED(x); it++)
#define PI 3.14159265358979323846264338327950L


int main()
{
    IOS;
    
    st str,str1;
    getline(cin,str);
    getline(cin,str1);

    st temp = str1.substr(0,str.size());
    // cout<<temp;
    // cout<<str1.size()+1;
    if (temp==str && str.size()+1 == str1.size())
    {
        cout<<"Yes";
    }else
    {
        cout<<"No";
    }
    
    
    
    

  
     
}

Measured memory_bytes: 3620
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], M = I[1];
		var A = G;
		var sum = new long[N + 1];
		for (var i = 0; i < N; i++) sum[i + 1] = sum[i] + A[i];
		var c = new Dictionary<long, int>();
		foreach (var a in sum.Select(a => a % M))
			if (!c.ContainsKey(a)) c[a] = 1;
			else c[a]++;
		var ans = 0L;
		foreach (var v in c.Values) ans += v * (v - 1L) / 2;
		WriteLine(ans);
	}
}


Measured memory_bytes: 22752
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll a,b,c,d;
  cin >> a>>b>>c>>d;
  
  c=a%2019;
  d=b%2019;
  if(b-a<2019) {
    if(d<=c) d+=2019;
  }
  else d+=2019;
  
  ll ans = 50000;
  for(ll x=c;x<d;x++){
    for(ll y=x+1;y<=d;y++){
      ans=min(ans,(x*y)%2019);
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, ans;
std::vector<LL>s, b;

int main()
{
	in >> N;
	std::vector<LL>A(N);
	rep(i, N) in >> A[i];
	std::sort(A.begin(), A.end());
	if (N % 2 == 0)
	{
		rep(i, N / 2) s.push_back(A[i]);
		rep(i, s.size())
		{
			if (i < s.size() - 1) ans -= s[i] * 2;
			else ans -= s[i];
		}
		rep(i, N / 2) b.push_back(A[N - 1 - i]);
		rep(i, b.size())
		{
			if (i < b.size() - 1) ans += b[i] * 2;
			else ans += b[i];
		}
	}
	else
	{
		LL res1 = 0;
		rep(i, N / 2) s.push_back(A[i]);
		rep(i, s.size()) res1 -= s[i] * 2;
		rep(i, N / 2 + 1) b.push_back(A[N - 1 - i]);
		rep(i, b.size())
		{
			if (i < b.size() - 2) res1 += b[i] * 2;
			else res1 += b[i];
		}
		s.clear(); b.clear();
		LL res2 = 0;
		rep(i, N / 2 + 1) s.push_back(A[i]);
		rep(i, s.size())
		{
			if (i < s.size() - 2) res2 -= s[i] * 2;
			else res2 -= s[i];
		}
		rep(i, N / 2) b.push_back(A[N - 1 - i]);
		rep(i, b.size()) res2 += b[i] * 2;
		ans = std::max(res1, res2);
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 2168
#include <stdio.h>
#include <string.h>
int main(){
  char T[1000001],P[10001];
  int i,l,m;    
  scanf("%s",T);
  scanf("%s",P);
  l=strlen(T);
  m=strlen(P);
  for(i=0;i<l;i++){
    if(strncmp(&T[i],P,m)==0) printf("%d\n",i);
  }
  return 0; 
}  

Measured memory_bytes: 1548
#include <bits/stdc++.h>
#define ll long long
#define a first
#define b second

using namespace std;

const int MAXN = (int) 50;

pair <int, int> v[MAXN + 1];

int sef[MAXN + 1];

int myfind(int x) {
    if(sef[x] == 0)
        return x;
    return sef[x] = myfind(sef[x]);
}

int cnt = 0;

inline void myunion(int x, int y) {
    if(myfind(x) != myfind(y)) {
        sef[myfind(x)] = myfind(y);
        cnt++;
    }
}

int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int i, j, n, m;
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for(i = 1; i <= m; i++)
        cin >> v[i].a >> v[i].b;
    int ans = 0;
    for(i = 1; i <= m; i++) {
        memset(sef, 0, sizeof(sef));
        cnt = 0;
        for(j = 1; j <= m; j++)
            if(i != j)
               myunion(v[j].a, v[j].b);
        if(cnt < n - 1)
            ans++;
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>

int main(){
	double r;
	const double pi = 3.14159265358979323846;
	std::cin >> r;
	std::cout << std::fixed << std::setprecision(6) << r * r * pi << " ";
	std::cout << std::fixed << std::setprecision(6) << 2 * r * pi << "\n";
	return 0;
}


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

int main() {
  int L,R;
  cin >>L>>R;
  int ans = 2019;
  for(int i=L;i<min(R,L+2019);i++){
    for(int j=R;j>max(L,R-2019);j--){
      ans=min(ans,(i%2019)*(j%2019)%2019);
      
    }
  }
  
  cout <<ans<<endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    string S;
    cin >> S;
    
    sort(S.begin(),S.end());
    
    if(S[0] == S[2]){
        cout << "No" << endl;
        return 0;
        
    }else{
        
    if(S[0] == S[1] && S[2] == S[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long double

//template

//main
signed main(){
  int N,K;cin>>N>>K;
  int ans=0;
  for(int i=1;i<=N;i++){
    int j=i;
    int t=1;
    while(j<K){j*=2;t/=2;}
    ans+=t;
  }
  ans/=N;
  cout<<fixed<<setprecision(20)<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <random>
#include <ctime>
#include <queue>
using namespace std;
const int N = 2e5 + 5;
typedef long long ll;
int a[N];
int n;
int pref_xr[N];
ll pref[N];
int xr(int l, int r){
    if(l > 0){
        return pref_xr[r] ^ pref_xr[l - 1];
    }
    else{
        return pref_xr[r];
    }
}
ll sum(int l, int r){
    if(l > 0){
        return pref[r] - pref[l - 1];
    }
    else{
        return pref[r];
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        pref[i] = pref_xr[i] = a[i];
        if(i > 0){
            pref[i] += pref[i - 1];
            pref_xr[i] ^= pref_xr[i - 1];
            
        }
    }
    ll main_ans = 0;
    for(int i = 0; i < n; ++i){
        int l = i + 1;
        int r = n - 1;
        int ans = i;
        while(l <= r){
            int mid = (l + r) / 2;
            if(sum(i, mid) == xr(i, mid)){
                l = mid + 1;
                ans = mid;
            }
            else{
                r = mid - 1;
            }
        }
        main_ans += ans - i + 1;
    }
    cout << main_ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b;cin>>n>>a>>b;
	string s;cin>>s;
	rep(i,s.size()){
		if(s[i]=='a'){
			if(a>0){
				cout<<"Yes"<<endl;
				a--;
			}
			else if(b>0){
				cout<<"Yes"<<endl;
				b--;
			}
			else cout<<"No"<<endl;
		}
		else if(s[i]=='b'){
			if(b>0){
				cout<<"Yes"<<endl;
				b--;
			}
			else cout<<"No"<<endl;
		}
		else cout<<"No"<<endl;
	}

	return 0;
}



Measured memory_bytes: 848
from operator import itemgetter
n = int(input())
s = []
p = []
b = []
cnt = 1
while True:
  try:
    ts,tp = map(str,input().split())
    s.append(ts)
    p.append(int(tp))
    b.append((ts,int(tp),cnt))
    cnt +=1
  except:
    break

data = sorted(b, key=itemgetter(1), reverse=True)
data = sorted(data, key=itemgetter(0), reverse=False)

for i in data:
  print(i[2])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

// const int N = ;
int n, ans, scad, flag = 0;
string s;
int main() {
	ios_base::sync_with_stdio(false);

	cin>> s;

	cin >> n;
	if(s.size() == 1) return cout << n / 2 << '\n', 0;
	if(s == string(s.size(), s[0])) {
		cout << 1LL * s.size() * n / 2 << '\n';
		return 0;
	}
	int nr = 0;
	while(s[nr] == s[0])
		nr++;
	s += s[0];
	for(int i = 1; i < s.size(); i++)
		if(s[i] == s[i - 1]) {
			// dbg(i, s[i], s[i - 1], flag);
			if(i == 1) flag = 1;
			if(i == s.size() - 1) scad = 1;
			ans++, s[i] = '*';
		}

	// dbg(s, flag);
	if(flag && scad && nr % 2 == 0) ans--, scad = 0;
	cout << 1LL * ans * n - scad << '\n';
}	

	

Measured memory_bytes: 256
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

reader.on("close", function () {
  let input = Number(lines[0]);

  let tmp: number = 100;
  let count = 0;
  while (true) {
    count++;
    tmp = Math.floor(tmp * 1.01);
    if (tmp >= input) {
      console.log(count);
      return;
    }
  }
});


Measured memory_bytes: 30152
#include <iostream>
#include <queue>
#define REP(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;

signed main() {
    int n, m; cin >> n >> m;
    int a[n]; priority_queue<int> pq;
    REP(i, 0, n) {
        cin >> a[i];
        pq.push(a[i]);
    }
    REP(i, 0, m) {
        int x = pq.top(); pq.pop();
        pq.push(x / 2);
    }
    long long ans = 0;
    while (!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }
    cout << ans;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

//to calculate p1^x  *  p2^x2  *p3^x3 ----------
//i.e. prime factorization and store pi and xi in vector 
vector<pair<ll, ll>> pFactor;

void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        pFactor.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            pFactor.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        pFactor.pb({n,1}); 
} 



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
   ll x, k,d;
   cin>>x>>k>>d;
   x = abs(x);
   ll y = x/d;
   if(k<y){
       cout<<x-k*d<<endl;
   }else if(k==y){
       cout<<x%d<<endl;
   }else{
       ll rem= k-y;
       x = x%d;
       if(rem%2==0){
           cout<<x<<endl;
       }else{
           cout<<abs(x-d)<<endl;
       }
   }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           ((ll)x.size())
#define hell            (1000000007)
#define inf             ((ll)5e18 + 5)
#define PI              ((double)3.14159265358979323844)
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

const ll nax=2e5+5;

vi a[nax];
ll n, m;
bool vis[nax];
ll temp;

void dfs(ll node) {
    temp++;
    vis[node]=1;
    for(auto i:a[node]){
        if(!vis[i]){
            dfs(i);
        }
    }
}

void solve() {
    ll n, m;
    cin>>n>>m;
    memset(vis, 0, sizeof vis);
    rep(i, 0, m) {
        ll x, y;
        cin>>x>>y;
        a[x].pb(y);
        a[y].pb(x);
    }
    ll ans=0;
    rep(i, 1, n+1) {
        if (vis[i]==0) {
            temp=0;
            dfs(i);
            ans=max(ans, temp);
        }
    }
    cout<<ans<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 20920
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
power = [0] * (N+1)
for x in range(2, N+1):
    for p in range(2, x+1):
        while x % p == 0:
            power[p] += 1
            x //= p

def num(x):
    '''約数がx-1以上の数を返す'''
    return len(list(filter(lambda y: y >= x-1, power)))

answer = num(75) + num(25) * (num(3)-1) + num(15) * (num(5)-1)\
        + num(5) * (num(5)-1) * (num(3)-2) // 2
print(answer)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#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;

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

  vector<vector<int>> h(N, vector<int>(3, 0));
  rep(i, N) {
    int a, b, c;
    cin >> a >> b >> c;
    h.at(i) = {a, b, c};
  }

  // dp.at(i).at(j) -> i 日目に j で遊んだときの最大値
  vector<vector<int>> dp(N, vector<int>(3, 0));
  rep(i, 3) dp.at(0).at(i) = h.at(0).at(i);

  for (int i = 1; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      int k1 = (j + 1) % 3, k2 = (j + 2) % 3;
      int x = dp.at(i - 1).at(k1) + h.at(i).at(j);
      int y = dp.at(i - 1).at(k2) + h.at(i).at(j);
      dp.at(i).at(j) = max(x, y);
    }
  }
  cout << *max_element(dp.at(N - 1).begin(), dp.at(N - 1).end()) << endl;
  return 0;
}


Measured memory_bytes: 11136
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()
H = []
for i in range(1, N):
    H.append(h[i] - h[i - 1])
ans = sum(H[0:K - 1])
tmp = ans
for i in range(N - 1):
    if i + K < N:
        tmp = tmp + H[i + K - 1] - H[i]
        ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 11852
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
using vt = vector<T>;

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 n;
  cin >> n;
  bool ans = false;
  REP(i, 3) {
    int d = n%10;
    if (d==7) ans = true;
    n /= 10;
  }
  cout << (ans?"Yes":"No") << endl;

  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a,b;
    cin >> a >> b;

    // 出力
    if (((a * b) % 2) == 0)
    {
        cout << "Even";
    }
    else
    {
        cout << "Odd";
    }
    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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

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

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> cur(n+1),next(n+1);
    rep(i,n){
        cin >> cur[i];
    }
    rep(i,k){
        bool all=true;
        rep(j,n){
            ll pos1=max(j-cur[j],0LL);
            ll pos2=min(j+cur[j]+1,n);
            next[pos1]++;
            next[pos2]--;
        }
        rep(j,n+1){
            if(j){
                next[j]+=next[j-1];
            }
        }
        rep(j,n){
            if(cur[j]!=next[j]) all=false;
        }
        cur=next;
        next=vector<ll>(n);
        if(all) break;
    }
    rep(i,n){
        if(i) cout << " ";
        cout << cur[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 7936
N, P = gets.split.map(&:to_i)
S = gets.chomp.chars

if P == 2 || P == 5
  ans = 0

  S.reverse.each_with_index do |s, i|
    if s.to_i % P == 0
      ans += N - i
    end
  end

  puts ans

  exit
end

x = 1
D = []
S.reverse.each_with_index { |s, i|  
  D << (s.to_i * x) % P
  x = x * 10 % P
}

ans = 0
rui = 0
counter = Hash.new(0)

D.each do |d|
  rui += d
  mod = rui % P
  ans += counter[mod]
  counter[mod] += 1
end

ans += counter[0]

puts ans


Measured memory_bytes: 16504
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		String taro,hanako;
		int n = sc.nextInt();
		int taroscore = 0;
		int hanakoscore = 0;
		for(int i = 0; i < n; i++){
			taro = sc.next();
			hanako = sc.next();
			if(taro.compareTo(hanako) == 0){
				taroscore++;
				hanakoscore++;
			}else if(taro.compareTo(hanako) > 0){
				taroscore = taroscore + 3;
			}else if(taro.compareTo(hanako) < 0){
				hanakoscore = hanakoscore + 3;
			}
		}
		
		System.out.println(taroscore + " " + hanakoscore);
	}
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> board(H);
  vector<vector<int>> count(H, vector<int>(W));

  for(int i = 0; i < H; i++) {
    string line;
    cin >> line;
    int hPrev = i - 1;
    int hNext = i + 1;
    bool hPrevf = hPrev > -1;
    bool hNextf = hNext < H;
    for(int j = 0; j < W; j++) {
      if(line.at(j) != '#') {
        continue;
      }
      
      count.at(i).at(j) = -1;
      int prev = j - 1;
      int next = j + 1;
      bool prevf = prev > -1;
      bool nextf = next < W;
      if(prevf && count.at(i).at(prev) != -1) count.at(i).at(prev)++;
      if(nextf && count.at(i).at(next) != -1) count.at(i).at(next)++;
      if(hPrevf && count.at(hPrev).at(j) != -1) count.at(hPrev).at(j)++;
      if(hNextf && count.at(hNext).at(j) != -1) count.at(hNext).at(j)++;
      if(prevf && hPrevf && count.at(hPrev).at(prev) != -1) count.at(hPrev).at(prev)++;
      if(prevf && hNextf && count.at(hNext).at(prev) != -1) count.at(hNext).at(prev)++;
      if(nextf && hPrevf && count.at(hPrev).at(next) != -1) count.at(hPrev).at(next)++;
      if(nextf && hNextf && count.at(hNext).at(next) != -1) count.at(hNext).at(next)++;
    }
  }
  
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      int a = count.at(i).at(j);

      if(a == -1) cout << '#';
      else cout << a;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3636
N, A, B, C, D = map(int, input().split())
S = input()
mx = max(C,D)
r_count = [len(s) for s in S[A-1:mx].split('.') if len(s) > 1]
if r_count != []:
    print('No')
    exit()
if C < D:
    print('Yes')
    exit()

count = [len(s) for s in S[B-2:D+1].split('#') if len(s) > 2]
print('Yes' if len(count) > 0 else 'No')


Measured memory_bytes: 4660
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>
#include <functional>
#include <iterator>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end())
#define PSort(x) sort(begin(x), end(x), pairCompare)
#define ll long long
#define INF 2000000000
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, 0, n)cin >> v[i];
	int m;
	cin >> m;
	vector<int> vv(m);
	rep(i, 0, m)cin >> vv[i];

	int ans = 0;
	rep(i, 0, m) {
		rep(j, 0, n) {
			if (vv[i] == v[j]) {
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define Rep(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) Rep(i,0,n)
#define stop char nyaa;cin>>nyaa;
using ll = long long;
const int inf = 1e9 + 7;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;

using P = pair<int, int>;

void solve() {
	int n; cin >> n;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll s = 1;
	ll ans = 0;
	rep(i, 60) {
		ll k = (ll)1 << i;
		ll cnt = 0;
		rep(j, n) {
			if (k&a[j])cnt++;
		}
		cnt = cnt * (n - cnt) % mod;
		ans += s * cnt%mod;
		s = s * 2 % mod;
	}
	cout << ans % mod << endl;
}


signed main() {
	solve();
	stop
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<stdio.h>

using namespace std;

int main()
{
  int H,W;
  cin >> H >> W;
  string str[50];

  for(int i=0;i<H;i++){
    cin >> str[i];
  }

  for(int i=0;i<H;i++){
    for(int w=0;w<W;w++){
      if(str[i][w] == '#')continue;
      int bomb = 0;

      if(i-1 > -1 && str[i-1][w] == '#')bomb++;
      if(i+1 < 50 && str[i+1][w] == '#')bomb++;
      if(w-1 > -1 && str[i][w-1] == '#')bomb++;
      if(i-1 > -1 && w-1 > -1 && str[i-1][w-1] == '#')bomb++;
      if(i+1 < 50 && w-1 > -1 && str[i+1][w-1] == '#')bomb++;
      if(w+1 < 50 && str[i][w+1] == '#')bomb++;
      if(i-1 > -1 && w+1 < 50 && str[i-1][w+1] == '#')bomb++;
      if(i+1 < 50 && w+1 < 50 && str[i+1][w+1] == '#')bomb++;
      str[i][w] = '0' + bomb;
    }
  }

  //output
  for(int i=0;i<H;i++){
    cout << str[i] << endl;
  }
}


Measured memory_bytes: 256
def solve():
    maxCycle = 10**20

    T1, T2 = map(int, input().split())
    A1, A2 = map(int, input().split())
    B1, B2 = map(int, input().split())

    C1, C2 = B1-A1, B2-A2
    if C1 > 0:
        C1, C2 = -C1, -C2

    dist = C1*T1 + C2*T2

    def binarySearch(isOK):
        ng, ok = -1, maxCycle
        while abs(ok-ng) > 1:
            mid = (ng+ok) // 2
            if isOK(mid):
                ok = mid
            else:
                ng = mid
        return ok

    def isOK1(c):
        return dist*(c+1) >= 0
    cycle1 = binarySearch(isOK1)
    if cycle1 == maxCycle:
        return 0

    def isOK2(c):
        return dist*c > 0
    cycle2 = binarySearch(isOK2)
    if cycle2 == maxCycle:
        return 'infinity'

    def isOK3(c):
        return dist*c + C1*T1 >= 0
    cycle3 = binarySearch(isOK3)

    def isOK4(c):
        return dist*c + C1*T1 > 0
    cycle4 = binarySearch(isOK4)

    ans = 1*(cycle2-cycle1) + 2*(cycle3-cycle2) + 1*(cycle4-cycle3)
    return ans


print(solve())


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

using namespace std;
using ll = long long;

int co(char c) {
  return c - '0';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string es; cin >> es;
  int f = co(es[0]) * 10 + co(es[1]);
  int s = co(es[2]) * 10 + co(es[3]);
//  if((f > 12 && s > 12)) {
//    cout << "NA\n";
//  } else if (f <= 12 && s <= 12 && f >= 1 && s >= 1) {
//    cout << "AMBIGUOUS\n";
//  } else if (f > 12 && s <= 12 && s >= 1) {
//    cout << "YYMM\n";
//  } else if(s > 12 && f <= 12 && f >= 1){
//    cout << "MMYY\n"; 
//  } else {
//    cout << "NA\n";
//  }
  if(f <= 12 && f >= 1) {
    if(s <= 12 && s >= 1) {
      cout << "AMBIGUOUS\n";
    } else {
      cout << "MMYY\n";
    }
  } else if (s <= 12 && s >= 1) {
    if(f <= 12 && f >= 1) {
      cout << "AMBIGUOUS\n";
    } else {
      cout << "YYMM\n";
    }
  } else {
    cout << "NA\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

ll mod_pow(ll x, ll p, ll MOD) {
    ll a = 1;
    while (p) {
        if (p%2) a = a*x%MOD;
        x = x*x%MOD;
        p/=2;
    }
    return a;
}

// mod_inverse
ll mod_inverse(ll a, ll m) {
    return mod_pow(a, m-2, m);
}

const int MOD = 1e9+7;

const int MAX = 333333;
ll fact[MAX], rfact[MAX];

ll nCr(int n, int r) {
    return fact[n]*rfact[r]%MOD*rfact[n-r]%MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    fact[0] = rfact[0] = 1;
    for (int i = 1; i < MAX; i++) {
        fact[i] = (fact[i-1]*i)%MOD;
        rfact[i] = mod_inverse(fact[i], MOD);
    }
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    ll ans = 0;
    for (int i = B+1; i <= W; i++) {
        int h = H-A-1, w = i-1;
        ll tmp = nCr(h+w, h);
        h = A-1, w = W-i;
        tmp *= nCr(h+w, w);
        ans += tmp%MOD;
    }
    cout << ans%MOD << endl;
    return 0;
}


Measured memory_bytes: 5504
def main(N, K):
    def sumN(x):
        return int(x * (x + 1) * 0.5)
    ans = sum([sumN(N) - sumN(N - k) - sumN(k - 1) + 1 for k in range(K, N + 2)])
    print(ans%(10**9+7))



if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    main(N, K)


Measured memory_bytes: 19952
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	long long n,ans=1;
	const long long MOD=1e9+7;
	cin>>n;
	loop(i,1,n+1){
		ans*=i;
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;
typedef long long ll;

int main(){

    int num;
    cin >> num;

    int head=0;
    int tail=0;

    head = num / 100;
    tail = num % 100;

    if(head == 0 && (tail >= 13 || tail == 0) || tail == 0 && (head >= 13 || head == 0) || (head >= 13 && tail >= 13)){
        cout << "NA" << endl;
        return 0;
    }
    if(head >= 1 && head <= 12 && tail >= 1 && tail <= 12){
        cout << "AMBIGUOUS" << endl;
        return 0;
    }

    if(head >= 1 && head <= 12 && !(tail >= 1 && tail <= 12)){
        cout << "MMYY" << endl;
        return 0;
    }

    if(!(head >= 1 && head <= 12) && tail >= 1 && tail <= 12){
        cout << "YYMM" << endl;
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())
    BC = [None] * Q
    for i in range(Q):
        BC[i] = map(int, input().split())

    c = Counter(A)
    d = dict(c.items())
    S = sum(k * v for k, v in c.items())
    for B, C in BC:
        if B in d:
            v = d[B]
            if C in d:
                d[C] += v
            else:
                d[C] = v
            d[B] = 0
            S = S + (C - B) * v
        print(S)


if __name__ == "__main__":
    main()


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

int main()
{
	while (true)
	{
		string s;
		cin >> s;
		if (s == "-")
		{
			return 0;
		}
		int n;
		cin >> n;
		for (int i = 0; i < n; i++)
		{
			int j;
			cin >> j;
			s = s.substr(j) + s.substr(0, j);
		}
		cout << s << endl;
	}
	return 0;
}

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

int main()
{
	int n;
	
	cin >> n;
	
	lli a[n+5], b[n+5];
	for(int i = 1; i <= n+1; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];
	
	lli sum = 0, d;
	
	for(int i = 1; i <= n; i++){
		if(b[i] <= a[i]) sum += b[i];
		else{
			sum += a[i];
			d = b[i] - a[i];
			sum += min(a[i+1], d);
			a[i+1] -= min(a[i+1], d);
		}
	}
	
	cout << sum << "\n";
	
	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		Console.WriteLine("{0}",n*n);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n, l,r;
	cin >> n;
	REP(i, n){
		cin >> l >> r;
		ans += r- l +1;
	}
	cout << ans << endl;
}

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

using namespace std;

int  main(){
  int x , a, b;
  cin >> x >> a >> b;

  int A = x - a;
  int B = x - b;

  int absA = abs(A);
  int absB = abs(B);

  if(absA < absB)
    cout << "A" << endl;

  else
    cout << "B" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,M; cin>>N>>M;
	if(N%2) {
		int i=1, j=N-1;
		while(M--)
			cout<<i<<" "<<j<<"\n", i++, j--;
	} else {
		int i=1, j=N;
		while(M--) {
			int cur=abs(i-j);
			if(cur<=N-cur) break;
			cout<<i<<" "<<j<<"\n";
			i++, j--;
		}
		M++;
		j--;
		while(M--) {
			cout<<i<<" "<<j<<"\n";
			i++, j--;
		}
	}
	return 0;
}

Measured memory_bytes: 3644
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String S = br.readLine();
        int len = S.length();

        String temp1 = new StringBuilder(S).reverse().toString();
        String sub1 = S.substring(0,(len-1)/2);
        String temp2 = new StringBuffer(sub1).reverse().toString();
        String sub2 = S.substring(((len+3)/2)-1, len);
        String temp3 = new StringBuffer(sub2).reverse().toString();

        if(S.equals(temp1) && sub1.equals(temp2) && sub2.equals(temp3)) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1001001001;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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 N,K; cin >> N >> K;
    int R,S,P; cin >> R >> S >> P;
    string T; cin >> T;
    vector <int> ok(T.length(),0);
    
    ll ans=0;
    rep(i,T.length()){
        
        if (T[i]=='s'){
            if (i-K<0){
                ok[i]=1;
                ans+=R;
            }else{
                if (ok[i-K]!=1){
                    ok[i]=1;
                    ans+=R;
                }
            }
        }
        if (T[i]=='p'){
            if (i-K<0){
                ok[i]=2;
                ans+=S;
            }else{
                if (ok[i-K]!=2){
                    ok[i]=2;
                    ans+=S;
                }
            }
        }
        if (T[i]=='r'){
            if (i-K<0){
                ok[i]=3;
                ans+=P;
            }else{
                if (ok[i-K]!=3){
                    ok[i]=3;
                    ans+=P;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>

int main(void)
{
    char S[101];
    int len;
    int i;
    int ctr = 0;
    
    
    scanf("%s", S);
    len = strlen(S);
    
    
    for(i=0; i<len/2; i++)
    {
        if(S[i] != S[len-1-i])
            ctr++;
    }
    
    printf("%d\n", ctr);
    
    
    //system("pause");
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

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

    int sum = 0;
    vector<int> time(n);
    for (int i = 0; i < n; i++) {
        cin >> time[i];
        sum += time[i];
    }

    vector<double> limit(sum * 2 + 1, 1145141919);
    int now = 0;
    for (int i = 0; i < n; i++) {
        double speed;
        cin >> speed;
        for (int j = 0; j <= time[i] * 2; j++) {
            limit[now] = min(limit[now], speed);
            now++;
        }
        now--;
    }

    vector<double> lmax(sum * 2 + 1);
    for (int i = 1; i <= sum * 2; i++) lmax[i] = min(lmax[i - 1] + 0.5, limit[i]);
    vector<double> rmax(sum * 2 + 1);
    for (int i = sum * 2 - 1; i >= 0; i--)rmax[i] = min(rmax[i + 1] + 0.5, limit[i]);

    double ret = 0;
    for (int i = 1; i <= sum * 2; i++) {
        ret += (min(lmax[i - 1], rmax[i - 1]) + min(lmax[i], rmax[i])) / 2 * 0.5;
    }

    cout << fixed << setprecision(10) << ret << endl;
    return 0;
}

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

#define INF (1<<18)



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

    ll ans = 1;
    rep2(i,1,n+1){
        ans *= i;
        if(ans > 100000007) ans %= 1000000007;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    string a,b,c;
    cin >> a >> b >> c;
    if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    
}


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

int main(void) {
    int a, b;
    cin >> a >> b;
    if (a > 0 && b > 0) {
        cout << "Positive" << endl;
    }
    else if (a < 0 && b < 0) {
        int cnt = abs(a) - abs(b) + 1;
        if (cnt % 2 == 0) {
            cout << "Positive" << endl;
        }
        else {
            cout << "Negative" << endl;
        }
    }
    else {
        cout << "Zero" << endl;
    }
    return 0;
}

Measured memory_bytes: 3544
/*input

*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	int a,b,c;
  cin>>a>>b>>c;
  cout<<min(b/a,c);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define lli long long int
#define all(x) x.begin(),x.end()
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
lli dp[100005];
lli h[100005];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	lli n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
	}
	dp[n-1]=0;
	for(int i=n-2;i>=0;i--)
	{
		dp[i]=LLONG_MAX;
		for(int j=i+1;j-i<=k && j<n;j++)
		{
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
		}
	}
	cout<<dp[0];

}



Measured memory_bytes: 1792
#include<iostream>

int main(void) {
  int a, b;
  std::cin >> a >> b;
  if (a < b) {
    std::cout << "a < b" << std::endl;
  } else if (a > b) {
    std::cout << "a > b" << std::endl;
  } else {
    std::cout << "a == b" << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3092