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

using namespace std;
using ll = long long;

int K;

template<class T>
struct Vector {
  vector<T> v;
  Vector(int sz) : v(sz, 0) {}
  Vector() : v(0) {}
  Vector(vector<T> t) : v(t) {}
  inline auto& operator[](size_t pos) {
    return v[pos];
  }
  inline auto begin() {
    return v.begin();
  }
  inline auto end() {
    return v.end();
  }
  inline auto size() {
    return v.size();
  }
  inline auto push_back(T t) {
    v.push_back(t);
  }
  inline auto pop_back() {
    v.pop_back();
  }
  inline auto& back() {
    return v.back();
  }
  friend auto& operator>>(istream& lhs, Vector& rhs) {
    for (int i = 0; i < rhs.size(); i++) lhs >> rhs[i];
    return lhs;
  }
  friend auto& operator<<(ostream& lhs, Vector& rhs) {
    for (int i = 0; i + 1 < rhs.size(); i++) lhs << rhs[i] << endl;
    if (rhs.size()) lhs << rhs.back();
    return lhs;
  }
};

Vector<ll> calc(Vector<ll>& x, Vector<ll>& y)
{
  Vector<ll> res;
  for (ll X : x) {
    for (ll Y : y) {
      res.push_back(X + Y);
    }
  }
  sort(res.begin(), res.end(), greater<ll>());
  while (res.size() > K) res.pop_back();
  return res;
}

int main()
{
  int x, y, z;
  cin >> x >> y >> z >> K;
  Vector<ll> a(x), b(y), c(z);
  cin >> a >> b >> c;
  auto v = calc(a, b);
  v = calc(v, c);
  cout << v << endl;
}


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

namespace abc086_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(x[0] % 2 == 1 && x[1] % 2 == 1 ? "Odd" : "Even");
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
 
#define endl '\n'
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define loope(i, m, n) for (ll i = m; i <= n; i++)
#define epool(i, m, n) for (ll i = m; i >= n; i--)
#define mod 1000000007
#define mod2 998244353
#define vi vector<ll>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x,0;
#define all(v) v.begin(),v.end()
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll>,greater<ll>>
const ll INF=1e18;
const double PI=4*atan(1);

#define SpeedForce                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;

ll mpow(ll base,ll exp);
ll POW(ll base,ll exp);
ll gcd(ll a,ll b);
ll modInverse(ll n);
ll nCr(ll n, ll r);

void solve(){
    ll n;
    cin  >> n;
    ll cur=n/1000;
    if(n%1000!=0) cur++;
    cout << cur*1000-n << endl;

}

int32_t main(){
    SpeedForce
    ll i = 0,j = 0;


    int t;
    t=1;
    //cin >> t;
    //ll cnt=1;
    while (t--){
        //cout << "Case #" << cnt << ": ";
        //cout << fixed << setprecision(10);
        solve();
        //cout << endl;
        //cnt++;
    }
}

ll POW(ll base,ll exp){
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base);
        base = ((ll)base * base);
        exp >>= 1;
    }
    return result;
}

ll mpow(ll base, ll exp){
    base %= mod;
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

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

ll modInverse(ll n) { 
    return mpow(n, mod-2); 
}
 
ll nCr(ll n, ll r){ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%mod; 
    return ((fac[n]* modInverse(fac[r]) % mod * 
            modInverse(fac[n-r]) % mod)%mod)%mod; 
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int a = N / 1000;
  int b = N / 100;
  int c = N / 10;
  int d = N;
  if (a == b - a * 10 && b - a * 10 == c - b * 10) {
    cout << "Yes" << endl;
  }
  else if (b - a * 10 == c - b * 10 && c - b * 10 == d - c * 10) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
typedef long long ll;
int main(){
  cin >> n;
  vector<string> s(n);
  map<string, ll> ma;
  for(int i=0 ; i<n ; i++){
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  for(int i=0 ; i<n ; i++){
    if(ma.count(s[i])==0){
      ma[s[i]] = 1;
    }else{
      ma[s[i]]++;
    }
  }
  ll sum = 0;
  for(auto ite=ma.begin() ; ite!=ma.end() ; ite++){
    ll it = ite->second;//firstはkeyを指す,secondはvalueを指す
    if(it > 1){
      sum += (it * (it - 1))/2;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 18176
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s = input()
# flagで複数条件の管理をした方が頭がバグらない
flag = 1
if s[0] != "A": flag = 0

if s[2:-1].count("C") != 1: flag = 0

for i in range(len(s)):
    if s[i] in "AC": pass
    elif 97 <= ord(s[i]) <= 122: pass
    else: flag = 0
print("AC" if flag else "WA")

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
using namespace std;


int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a*b > c*d){
        cout << a*b;
    }
    else{
        cout << c*d;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long int n,i,j=0,p,q;
    scanf("%ld",&n);

    p=(n*(n-1))/2;
    /*q=n;
    for(i=1; i<=n; i++)
    {
        if(i==n)
        {
            p=i%n;
            j=j+p;
        }
        else
        {
            p=i%(q+1);
            j=j+p;
            q++;
        }

    }

    printf("%d\n",j);*/
    printf("%ld\n",p);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y){
	if(y==0)
		return 1;
	ll res=power(x,y/2);
	res=(res*res);
	if(y&1)
		res=(res*x);
	return res;
}
 
ll powermod(ll x,ll y,ll mod){
	if(y==0)
		return 1;
	ll res=powermod(x,y/2,mod);
	res=(res*res)%mod;
	if(y&1)
		res=(res*x)%mod;
	return res;
}
/*ll binarysearch(ll va)
{
	ll n=1;
	ll l=va+1,u=n;
	ll st=num.order_of_key(va);
	while(l+1<u)
	{
		m=(l+u)/2;
		ll in=num.order_of_key(m);
		if(in-st==m-va)
		{
			l=m;
		}
		else
		{
            u=m;
		}
	}
	if(num1.find(l)==num1.end())
		return l;
	return u;
}*/
void solve(){
	int n;
	cin>>n;
	string s,s2;
	cin>>s;
	s2.pb(s[0]);
	for(int i=1;i<s.length();i++){
		if(s[i]!=s[i-1]) s2.pb(s[i]);
	}
	cout<<s2.length()<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
 
    for(int i=1;i<=t;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}

Measured memory_bytes: 3700
import numpy as np
N = int(input())

x = N / 1.08
c = int(np.ceil(x))
f = int(np.floor(x))
if int(c * 1.08) == N:
  print(c)
elif int(f * 1.08) == N:
  print(f)
else:
  print(':(')


Measured memory_bytes: 12484
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=50+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
ll x;
ll fun(ll b){
	ll sum=0;
	while(x>=b){
		sum+=x%b;
		x/=b;
	}
	sum+=x;
	return sum;
}
int main(){
	ll n,s;
	cin>>n>>s;
	if(s==n) printf("%lld\n",n+1),exit(0);
	if(s>n) return puts("-1"),0;
	for(ll i=2;i*i<=n;i++){
		x=n;
		if(fun(i)==s){
			printf("%lld\n",i);
			return 0;
		}
	}
	for(ll i=sqrt(n-s);i>=1;i--){
		x=n;
		 if((n-s)%i==0){
		 	ll b=(n-s)/i+1;
		 	if(b>=2&&fun(b)==s) {
			 printf("%lld\n", b);
			 return 0;
			}
		 }
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 3748
#include<iostream>
using namespace std;
int main(){
	int w,h,x,y,r;
	while(cin>>w>>h>>x>>y>>r){
		if(x+r<=w&&x-r>=0&&y+r<=h&&y-r>=0){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3104
#include <iostream>

 using namespace std;
 typedef long long ll;

 int main(void){
 ll H,W;
 cin >> H >> W;

 if(H == 1 || W == 1){
 cout << 1 << endl;
 } else {
 cout << (H * W + 1) / 2 << endl;
 }

 return 0;
 }


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int start0 = 0, start1 = 0;
    char cur0 = '0', cur1 = '1';
    for(int i=0; i<s.size(); i++)
    {
        if(s[i] != cur0)
            start0++;
        if(s[i] != cur1)
            start1++;
        
        cur0 = cur0 == '0' ? '1' : '0';
        cur1 = cur1 == '1' ? '0' : '1';
    }
    cout<<min(start0,start1);
}

Measured memory_bytes: 512
#include <stdio.h>
int main ()
{
  int a,b,d,r;
  double f;

  scanf("%d %d",&a,&b);

  d=a/b;
  r=a%b;
  f=(double)a/b;

  printf("%d %d %f\n",d,r,f);

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;

int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	int a;
	string s;
	cin >> a >> s;
	if(a>=3200) cout << s;
	else cout << "red"; 
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
 
mn = 10 ** 9
mx = 0
 
for i in range(n):
  if a[i] < mn:
    mn = a[i]
    
  if a[i] > mx:
    mx = a[i]
  
print(mx - mn)

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

int root(int x, vector<int> &par){
        return par.at(x)==x ? x : par.at(x) = root(par.at(x),par);
}

int unite(int x, int y, vector<int> &par, vector<int> &pop){
        x = root(x,par);
        y = root(y,par);
        if(x==y) return 0;
        else{
                par.at(y) = x;
                pop.at(x) += pop.at(y);
                return pop.at(x);
        }
}

int main(){
        int n,m,i,a,b,ans=1;
        cin >> n >> m;
        vector<int> par(n);
        for(i=0;i<n;++i) par.at(i) = i;
        vector<int> pop(n,1);
        for(i=0;i<m;++i){
                cin >> a >> b;
                --a; --b;
                ans = max(ans, unite(a,b,par,pop));
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 4824
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,a,b] <- getIntList
    let ans | a > b || (n == 1 && a /= b) = 0 
            | otherwise = (b*(n-1) + a) - (b + a*(n-1)) + 1
    print ans

Measured memory_bytes: 380
K=int(input())

i=1
d=7

m=d % K
ML = [0 for i in range(1000000)]
while m != 0:
    ML[m]=1
    i+=1
    d=m*10+7
    m = d % K
    if ML[m] != 0:
        break

if m != 0:
    ans = -1
else:
    ans = i

print(ans)


Measured memory_bytes: 16952
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(e => long.Parse(e)).ToArray();
        long sum = 0;
        for (int i = 1; i < n; i++)
        {
            long diff = a[i - 1] - a[i];
            if (diff <= 0)
            {
                continue;
            }
            a[i] += diff;
            sum += diff;
        }
        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 47668
S = input()
T = list(S)
Tlength = len(S)
N = int((len(S)-1)/2)
halfN1=int(N/2)
halfN2=int((Tlength+N)/2)
check=0
#print(T[Tlength-2])
#print(N)
#print(halfN1)
#print(halfN2)
for i in range(0,N):
    if T[i]!=T[Tlength-1-i]:
        check=1
        break
for i in range(0,halfN1):
    if T[i]!=T[N-1-i]:
        check=1
        break
for i in range(0,halfN1):
    if T[N+1+i]!=T[Tlength-1-i]:
        check=1
if check==1:
    print('No')
else:
    print('Yes')
    

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int N;
	map<vi, ll> s;
	cin >> N;
	rep(i, N) {
		string si;
		cin >> si;
		vi slist(26, 0);
		rep(i, 10) {
			int j = (int)si[i] - 97;
			slist[j]++;
		}
		s[slist]++;
	}
	ll ans = 0;
	for(auto si : s) {
		ll anstmp = si.second * (si.second - 1) / 2;
		ans += anstmp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 18944
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 1e5;

int n;
int a[MaxN + 5];
int cnt[MaxN + 5];

int main()
{
	while(scanf("%d", &n) != EOF)
	{
		for(int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			cnt[a[i]]++;
		}
		int ans = 0;
		for(int i = 1; i <= n; i++) {
			if(a[i] == 0) {
				if(cnt[a[i]] + cnt[a[i] + 1] > ans) {
					ans = cnt[a[i]] + cnt[a[i] + 1];
				}
			}
			else if(a[i] == MaxN - 1) {
				if(cnt[a[i]] + cnt[a[i] - 1] > ans) {
					ans = cnt[a[i]] + cnt[a[i] - 1];
				}
			}
			else {
				if(cnt[a[i]] + cnt[a[i] - 1] + cnt[a[i] + 1] > ans) {
					ans = cnt[a[i]] + cnt[a[i] - 1] + cnt[a[i] + 1];
				}
			}
		}
		printf("%d\n", ans);
		memset(cnt, 0, sizeof(cnt));
	}
	return 0;
}

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

int main() {
    int a [] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
    int x,y;
    cin >> x >> y;
    cout << (a[x] == a[y] ? " Yes " : " No ") << endl ;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int a[100005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, x;
    cin >> n >> x;
    for (int i=0; i<n; i++)
        cin >> a[i];

    long long ret = 0;
    int change = max(a[0] - x, 0);
    a[0] -= change;
    ret += change;
    change = max(a[n-1] - x, 0);
    a[n-1] -= change;
    ret += change;

    for (int i=1; i<n-1; i++) {
        change = max(a[i-1] + a[i] - x, 0);
        a[i] -= change;
        ret += change;
    }
    change = max(a[n-2] + a[n-1] - x, 0);
    ret += change;
    cout << ret << "\n";

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define ZERO(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vint vector<int>

int link[100010];

void solve(int n) {
    ZERO(link);
    ll ans = 0;
    rep(i,n) {
        int a; scanf("%d",&a);
        --a;
        link[i] = a;
    }

    rep(i,n) {
        if(link[link[i]] == i) ++ans;
    }
    cout<<ans / 2<<"\n";
}

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

    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#define MAx 100000
typedef long long llong;

int n, k;
int T[MAx];
using namespace std;

int check(llong P)
{
  int i = 0;
  for(int j = 0; j<k; j++)
  {
    llong s = 0;
    while(s + T[i] <= P)
    {
      s += T[i];
      i++;
      if(i == n) return n;
    }
  }
  return i;
}

llong solve()
{
  llong left = 0;
  llong right = 100000 * 10000;
  llong mid;
  while(right - left > 1)
  {
    mid = (left + right) / 2;
    int v = check(mid);
    if( v>= n) right = mid;
    else left = mid;
  }
  return right;
}

int main()
{

  scanf("%d%d", &n, &k);
  for(int i=0; i<n; i++)
  {
    scanf("%d", &T[i]);
  }
  llong ans = solve();
  printf("%d\n", ans);

  return 0;
}



Measured memory_bytes: 3584
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>

const int INF = 0x3f3f3f3f;
const int kN = 2000 + 5;
int n;
int pos[2][kN];
int inv[2][kN][kN];
int dp[kN][kN];

inline void update(int &a, int b) {
  if (a > b) a = b;
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n + n; ++ i) {
    char s[2];
    int a;
    scanf("%s%d", s, &a);
    pos[s[0] == 'W'][a] = i;
  }
  for (int c = 0; c < 2; ++ c) {
    for (int i = 1; i <= n; ++ i) {
      for (int j = 1; j <= n; ++ j) {
        inv[c][i][j] = inv[c][i][j - 1] + (pos[c][i] < pos[c ^ 1][j]);
      }
    }
  }
  memset(dp, INF, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 0; i <= n; ++ i) {
    for (int j = 0; j <= n; ++ j) {
      if (i < n)
        update(dp[i + 1][j], dp[i][j] + inv[0][i + 1][j]);
      if (j < n)
        update(dp[i][j + 1], dp[i][j] + inv[1][j + 1][i]);
    }
  }
  int result = dp[n][n];
  for (int c = 0; c < 2; ++ c) {
    for (int i = 1; i <= n; ++ i) {
      for (int j = 1; j < i; ++ j)
        result += pos[c][i] < pos[c][j];
    }
  }
  printf("%d\n", result);
}


Measured memory_bytes: 47232
import numpy as np
h,w = map(int, input().split())
mat = np.array([list(map(int,input().replace(".","0").replace("#","1"))) for i in range(h)])
mat = np.concatenate([np.zeros((1,w),int),mat,np.zeros((1,w),int)])
mat = np.concatenate([np.zeros((h+2,1),int),mat,np.zeros((h+2,1),int)], axis = 1)
import copy
nmat = copy.deepcopy(mat)
for i in range(1,h+1):
  for j in range(1, w+1):
    if mat[i,j] == 0:
      nmat[i,j] = mat[i+1,j]+mat[i-1,j]+mat[i,j+1]+mat[i,j-1]+mat[i-1,j-1]+mat[i-1,j+1]+mat[i+1,j-1]+mat[i+1,j+1]
nmat = np.array(nmat, dtype = "str")
nmat[np.where(mat == 1)] = "#"
for i in range(h):
  print("".join(nmat[1:h+1,1:w+1].tolist()[i]))


Measured memory_bytes: 12772
N, K = map(int, input().split())
d = []
A = []

s = set([i for i in range(1, N+1)])
rs = set()

for i in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

for i in range(K):
    for a in A:
        for j in a:
            rs.add(j)

for i in rs:
    s.remove(i)

print(len(s))

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

using namespace std;

int a[2001][2001];
int r[2001][2001];
int dr[2001][2001];
int fr[2001][2001];

 main () {
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	int n, m, q;
	cin >> n >> m >> q;
	for (int i = 1;i <= n;i ++) {
		for (int j = 1;j <= m;j ++) {
			char te;
			cin >> te;
			if (te == '1') a[i][j] = 1;
			else a[i][j] = 0;
			dr[i][j] = dr[i - 1][j] + dr[i][j - 1] - dr[i - 1][j - 1];
			fr[i][j] = fr[i - 1][j] + fr[i][j - 1] - fr[i - 1][j - 1];
			if (a[i][j] && a[i][j - 1]) dr[i][j] += 1;
			if (a[i][j] && a[i - 1][j]) fr[i][j] += 1;
			r[i][j] = r[i - 1][j] + r[i][j - 1] - r[i - 1][j - 1] + a[i][j];
		}
	}
	while (q --) {
		int x, y, x1, y1;
		cin >> x >> y >> x1 >> y1;
		int cur = r[x1][y1] - r[x1][y - 1] - r[x - 1][y1] + r[x - 1][y - 1];
		int jkl = dr[x1][y1] - dr[x1][y] - dr[x - 1][y1] + dr[x - 1][y];
		int lkj = fr[x1][y1] - fr[x1][y - 1] - fr[x][y1] + fr[x][y - 1];
		cout << cur - jkl - lkj << endl;
	}
	return 0;
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

int d(string &s, string &t){
    int n = s.size();
    int ret = 0;
    REP(i,n){
        if(s[i] != t[i]) ret++;
    }
    return ret;
}

void Main(){
    string S,T; cin >> S >> T;
    int n = INF;
    int s = S.size(), t = T.size();
    REP(i,s-t+1){
        string u = S.substr(i,t);
        chmin(n, d(T,u));
    }
    int ans = n;
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3644
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

inline void setmin(int &x, int y) { if (y < x) x = y; }
inline void setmax(int &x, int y) { if (y > x) x = y; }
inline void setmin(ll &x, ll y) { if (y < x) x = y; }
inline void setmax(ll &x, ll y) { if (y > x) x = y; }

const int N = 200000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 52;

ll f2(ll x) {
    if (x == 0) {
        return 2;
    } else if (x % 2 == 1) {
        return 1;
    } else {
        return 0;
    }
}

ll a[N], dpL[N], dpR[N];
ll pref[N], suff[N];

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    rep(i, 0, n) {
        cin >> a[i];
    }
    rep(i, 0, n) {
        pref[i] = a[i];
        if (i > 0) {
            pref[i] += pref[i - 1];
        }
    }
    repb(i, n - 1, -1) {
        suff[i] = a[i];
        if (i < n - 1) {
            suff[i] += suff[i + 1];
        }
    }
    rep(i, 0, n) {
        dpL[i] = min(pref[i], f2(a[i]) + (i > 0 ? dpL[i - 1] : 0));
    }
    repb(i, n - 1, -1) {
        dpR[i] = min(suff[i], f2(a[i]) + (i < n - 1 ? dpR[i + 1] : 0));
    }
    /*rep(i, 0, n) {
        cout << dpL[i] << " ";
    }
    cout << "\n";
    rep(i, 0, n) {
        cout << dpR[i] << " ";
    }
    cout << "\n";*/
    ll ans = big, cur = 0;
    repb(i, n - 1, -1) {
        setmin(ans, dpL[i] + cur);
        if (a[i] % 2 == 0) {
            cur++;
        }
        setmin(cur, dpR[i]);
    }
    setmin(ans, cur);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 8064
import fractions

A, B, K_ban = map(int, input().split())

gc = fractions.gcd(A, B)
ctr = 1

while (gc > 0):

    if (A % gc == 0 and B % gc == 0):
        
        if (ctr == K_ban):
            print(gc)
            break
        else:
            ctr += 1
    
    gc -= 1


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

int main(){
    int n;
    cin >> n;
    set<int> s;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        if(s.count(a)){
            cout << "NO" << endl;
            return 0;
        }
        s.insert(a);
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 12948
import math
n, a, b = map(int, input().split())
p = 10 ** 9 + 7
#ans = 2 ** n - 1 - N C a - N C b

def modpow(a, n, MOD):
  res = 1
  while (n > 0):
    if (n & 1):
      res = res * a % MOD
    a = a * a % MOD
    n >>= 1
  return res

def cmb(n, r, p):
  A = 1
  for i in range(r):
    A *= (n - i)
    A *= modpow(i + 1, p - 2, p)
    A %= p
  return A

ans = (modpow(2, n, p) - 1) % p
ans -= cmb(n, a, p) + cmb(n, b, p)

print(ans % p)







Measured memory_bytes: 73524
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;


const long long MOD = 1000000007;

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

	int n;
	cin >> n;
	map<string, int> s;
	rep(i, n) {
		string p;
		cin >> p;
		int q = s[p];
		++q;
		s[p] = q;
	}

	priority_queue<string, vector<string>, greater<string>> ans;
	int num = 0;
	for (auto i = s.begin(); i != s.end(); ++i) num = max(num, (*i).second);
	for (auto i = s.begin(); i != s.end(); ++i) {
		if ((*i).second == num) ans.push((*i).first);
	}

	while (!ans.empty()) {
		cout << ans.top() << "\n";
		ans.pop();
	}

	return 0;
}


Measured memory_bytes: 25584
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        sc.close();
        if(X == 2 || X == 3) System.out.println(X);
        else System.out.println(getPrimeNumber(X));
    }

    public static int getPrimeNumber(int x) {
        int ptr = 0; // 素数の個数
        int[] prime = new int[(x / 2) + 1];// 素数を格納

        prime[ptr++] = 2; // 2は素数
        prime[ptr++] = 3; // 3は素数

        boolean flg = false;
        int r = x;
        for(int n = 5; n <= Math.pow(10, 5) + 3; n+=2) { // 対象は奇数のみ(偶数は2で割り切れるため)
            boolean f = false;
            for(int i = 1; prime[i] * prime[i] <= n; i++) { // prime[i]の2乗がn以下であるか
                if(n % prime[i] == 0) {
                    f = true;
                    break; // 割り切れると素数ではないため繰り返し処理を抜ける
                }
            }
            if(!f) {
                prime[ptr++] = n; // 素数をとして配列に設定
                if(!flg && n >= x) {
                    r = n;
                    break;
                }
            }
        }
        return r;
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define int long long

using namespace std;

const int mo=998244353;

int n,a,b,ans=0,jie[1000001],inv[1000001],k;

int C(int o,int p) {return 1ll*jie[o]*inv[p]%mo*inv[o-p]%mo;}

int mi(int o,int p)
{
	int u=1;
	while(p>0)
	{
		if(p&1) u=1ll*u*o%mo;
		o=1ll*o*o%mo;
		p>>=1;
	}
	return u;
}

signed main()
{
	jie[0]=inv[0]=1;
	for(int i=1;i<=1000000;i++) jie[i]=1ll*jie[i-1]*i%mo;
	for(int i=1;i<=1000000;i++) inv[i]=mi(jie[i],mo-2);
	scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
	for(int i=0;(i<=n)&&(i*a<=k);i++)
	{
		if((k-i*a)%b!=0) continue;
		if(((k-i*a)/b)>n) continue;
		ans=(ans+1ll*C(n,i)*C(n,(k-i*a)/b)%mo)%mo;
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;

struct UnionFind {
private:
    vector<int> par,sizes;
public:
    UnionFind (int n) {
        par.resize(n);
        sizes = vector<int>(n,1);
        for (int i = 0;i < n;++i) par[i] = i;
    }
 
    int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
 
    void unite(int x,int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x,y);
        par[y] = x;
        sizes[x] += sizes[y];
    }
 
    bool same(int x,int y) {
        return find(x) == find(y);
    }
 
    int size(int x) {
        return sizes[find(x)];
    }
};
 
int main() {
    int n,m;
    cin >> n >> m;
    ll s = (ll)n*(n-1)/2;
    vector<ll> ans(m);
    vector<int> a(m),b(m);
    UnionFind bridge(n);
    for (int i = 0;i < m;++i) {
        int u,v;
        cin >> u >> v;
        u--;v--;
        a[i] = u;
        b[i] = v;
    }
    for (int i = m-1;i >= 0;--i) {
        ans[i] = s;
        if (!bridge.same(a[i],b[i])) s -= (ll)bridge.size(a[i])*bridge.size(b[i]);
        bridge.unite(a[i],b[i]);
    }
    for (int i = 0;i < m;++i) cout << ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 3712
import sys
import collections
from collections import Counter
from collections import deque
from collections import defaultdict
import itertools
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from itertools import takewhile
from itertools import compress
import functools
from functools import reduce
import math
####from math import gcd
####from math import inf
from math import ceil
from math import floor
##from math import log10
##from math import log2
##from math import log
from math import factorial
import re
from functools import lru_cache

# @lru_cache(maxsize=1000)

# MOD = 10 ** 9 + 7

# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]

# N, K = [int(x) for x in input().split()]
# A = [int(x) for x in input().split()]


N, K = [int(x) for x in input().split()]
S = input()

c = ""
if S[K - 1] == 'A':
    c = 'a'
elif S[K - 1] == 'B':
    c = 'b'
else:
    c = 'c'
S = list(S)
S[K-1] = c

print("".join(S))




Measured memory_bytes: 38384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string S = Console.ReadLine ();
            string T = Console.ReadLine ();

            char[] s = S.ToCharArray ();
            char[] t = T.ToCharArray ();

            int ans = 0;

            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] != t[i]) ans += 1;
            }

            Console.Write (ans);
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 28108
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int cnt=0;  //用来标记
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='C')
        {
            cnt=1;
        }
        if(a[i]=='F'&&cnt==1)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
N, T = [int(x) for x in input().strip().split(' ')]
import sys
mincost = -1
for line in sys.stdin:
    c, t = [int(x) for x in line.strip().split(' ')]
    if t <= T:
        if mincost == -1:
            mincost = c
        else:
            mincost = min(mincost, c)
    else:
        continue
if mincost == -1:
    print("TLE")
else:
    print(mincost)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <set>
using namespace std;
using ll = long long;

ll BASE_NUM = 1000000007;

int main()
{
    // 整数の入力
    ll N;
    cin >> N;
    if (N == 2){
        cout << 1 << endl;
        return 0;
    }
    // for(int i = 2;i <= N;i++){
    //     ll ans = N;
    //     while(ans >= i){
    //         if (ans % i == 0){
    //             ans = ans/i;
    //         }else{
    //             ans = ans % i;
    //         }
    //     }
    //     if (ans == 1){
    //         cout << i << endl;
    //     }
    // }
    ll counter = 2;
    set<ll> answers;
    answers.insert(N);
    answers.insert(N-1);
    for(ll i = 2;i * i <= N;i++){
        if( N % i == 0){
            ll ans = N;
            while(ans >= i){
                if (ans % i == 0){
                    ans = ans/i;
                }else{
                    ans = ans % i;
                }
            }
            if (ans == 1){
                // cout << i << endl;
                answers.insert(i);
            }
        }
    }

    for(ll i = 2;i * i <= N - 1;i++){
        if( (N - 1) % i == 0){
            // cout << i << endl;
            // cout << (N-1)/i << endl;
            answers.insert(i);
            answers.insert((N-1)/i);
        }
    }
    cout << answers.size() << endl;
    return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
li = list(map(int,input().split()))
q = int(input())
num_li=[list(map(int,input().split())) for i in range(q)]

c = collections.Counter(li)

li_sum = sum(li)

for i,j in num_li:
    s = 0
    if i in c:
        cnt = c.pop(i)
        c[j] += cnt
        li_sum = li_sum - (i*cnt) + (j*cnt)
    print(li_sum)

Measured memory_bytes: 37488
#include<queue>
#include<set>
#include<map>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#define ll long long
#define maxn 400010
#define For(i,x,y)  for(ll i=x;i<=y;++i)
#define FOr(i,x,y)  for(ll i=x;i>=y;--i)
using namespace std;
inline ll read(){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  return x*f; } 
inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  } 
inline void writeln(ll x){ write(x);   puts("");   }
const ll N=100010;
ll a[N],w[N],q[N],answ[N],L,T,n,tot;
ll get(ll x){	return x==1?1:-1;	}
int main(){
//	freopen("ants.in","r",stdin);
//	freopen("ants.out","w",stdout);
	n=read();	L=read();	T=read();
	For(i,1,n){
		a[i]=read();	w[i]=read()==1?1:-1;
		q[i]=(a[i]+w[i]*T%L+L)%L;
	}sort(q+1,q+n+1);
	if (q[1]==q[n]){
		For(i,1,n)	writeln(q[i]);
		return 0;
	}
	ll pos=1;
	For(i,2,n){
		if (w[1]==w[i])	continue;
		ll cang=T*2;
		if (w[1]==1){
			ll tt=a[i]-a[1];
			if (tt<=cang)	pos+=((cang-tt)/L+1)*w[1];
		}else{
			ll tt=L-(a[i]-a[1]);
			if (tt<=cang)	pos+=((cang-tt)/L+1)*w[1];
		}
	}
	pos%=n;
	pos+=n;
	pos%=n;
	if (!pos)	pos++;
	ll v_pos=lower_bound(q+1,q+n+1,(a[1]+w[1]*T%L+L)%L)-q;
	if (w[1]==1)
	while (q[v_pos+1]==q[v_pos])	v_pos=v_pos+1;
	For(i,1,n){
		answ[pos]=v_pos;
		pos=pos%n+1;
		if (!pos)pos++;
		v_pos=v_pos%n+1;
		if (!v_pos)v_pos++;
	}
	For(i,1,n)	writeln(q[answ[i]]);
}
/*
3 8 3
0 1
3 2
6 1
*/

Measured memory_bytes: 4224
import math
n = int(input())

ini = 1 if n%2 else 2
div = []
for i in range(ini, int(math.sqrt(n)+1),2):
  if n%i==0:
    div.append([i,n//i])
print(max(len(str(div[-1][0])),len(str(div[-1][1]))))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
using namespace std;
int used[26];
int main(){
  string s,t;
  cin >> s;
for(int i=0;i<s.size();i++) used[s[i]-'a']++;
if(s.size()!=26){
  for(int i=0;i<26;i++){
  if(!used[i]){
   cout << s<<(char)(i+'a')<<endl;
   return 0;
  }
}
}
else{
for(int i=s.size()-1;i>=0;i--){//後ろから調べる
   bool flag=false;
   for(int j=s[i]-'a'+1;j<26;j++){//ターゲットより辞書順で後ろの文字を順に調べる
     if(!used[j]){
       s[i]='a'+j;flag=true;
       break;
     }
   }
   if(flag){
     s.erase(i+1);//最初から数えてi+1個以外は全消し
     cout << s<<endl;
     return 0;
   }
   used[s[i]-'a']=0;
}
cout << -1<<endl;
}
}


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

const int INF = 100000000;
typedef pair<int, int> P;

int R, C;
int sy, sx, gy, gx;
char maze[50][50];
int dis[50][50];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int bfs() {
    queue<P> que;
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) dis[i][j] = INF;
    }
    que.push(P(sy - 1, sx - 1));
    dis[sy - 1][sx - 1] = 0;

    while (que.size() > 0) {
        P p = que.front();
        que.pop();
        if (p.first == gy - 1 && p.second == gx - 1) break;

        for (int i = 0; i < 4; i++) {
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] != '#' && dis[ny][nx] == INF) {
                que.push(P(ny, nx));
                dis[ny][nx] = dis[p.first][p.second] + 1;
            }
        }
    }
    return dis[gy - 1][gx - 1];
}
int main() {
    cin >> R >> C;
    sy = 1;
    sx = 1;
    gy = R;
    gx = C;

    int B = 0;
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            cin >> maze[i][j];
            if (maze[i][j] == '#') B++;
        }
    }
    if (bfs() == INF) cout << "-1" << endl;
    else cout << R * C - bfs() - B - 1 << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - Weather Prediction
https://atcoder.jp/contests/abc141/tasks/abc141_a

"""
import sys


def solve(S):
    return {'Sunny': 'Cloudy', 'Cloudy': 'Rainy', 'Rainy': 'Sunny'}[S]


def main(args):
    S = input()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int ans,N,L,mini=1e9,a;

int main(){
    cin>>N>>L;
    rep(i,N){
        ans+=L+i;
        if(mini>abs(L+i)){
            a=L+i;
            mini=abs(L+i);
        }
    }
    out(ans-a);
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define N 100000
#define MAX (1<<31)-1
using namespace std;
long long A[N], T[4*N], lazy[4*N];

void build(int l, int r, int k) {
    if (l == r) {
        T[k] = A[l];
        return;
    }
    int mid = (l + r) / 2;
    build(l, mid, k * 2);
    build(mid + 1, r, k * 2 + 1);
    T[k] = T[2 * k] + T[2 * k + 1];
}
void pushdown(int k, int l, int r, int mid) {
    if (lazy[k] != MAX) {
        lazy[2*k] = lazy[k];
        lazy[2*k+1] = lazy[k];
        T[2*k] = lazy[k]*(mid-l+1);
        T[2*k+1] = lazy[k]*(r-mid);
        lazy[k] = MAX;
    }
}
void updata(int L, int R, int data ,int l, int r ,int k) {
    if (L <= l && r <= R) {
        T[k] = data*(r-l+1);
        lazy[k] = data;
        return;
    }
    int mid = (l + r) / 2;
    pushdown(k, l, r, mid);
    if (mid >= L) updata(L, R, data, l, mid, 2*k);
    if (mid < R) updata(L, R, data, mid+1, r, 2*k+1);
    T[k] = T[2 * k] + T[2 * k + 1];
}
long long find(int L, int R, int l, int r, int k) {
    if (L <= l && r <= R) return T[k];
    int mid = (l + r) / 2;
    pushdown(k, l, r, mid);
    long long ans = 0;
    if (mid >= L) ans = ans + find(L, R, l, mid, k * 2);
    if (mid < R) ans = ans + find(L, R, mid + 1, r, k * 2 + 1);
    return ans;
}
int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    for (int i = 0; i < n; i++)
        A[i] = 0;
    for (int i = 0; i < 4*n; i++)
        lazy[i] = MAX;
    build(0, n - 1, 1);
    int com, s, t, x, y;
    while (q--) {
        scanf("%d", &com);
        if (com == 0) {
            scanf("%d%d%d", &s, &t, &x);
            updata(s, t, x, 0, n - 1, 1);
        }
        else {
            scanf("%d%d", &s, &t);
            printf("%ld\n", find(s, t, 0, n - 1, 1));
        }
    }
    return 0;
}


Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int n;
int a[maxn]; 
set<int> st;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		st.insert(a[i]);
	}
	if(st.size()!=n)
	{
		puts("NO");
	}
	else
	{
		puts("YES");
	}
	return 0;
}

Measured memory_bytes: 11392
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

//1番目の値でソート 
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

//2番目の値でソート 
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
  int N,a,b,c,d;
  int used[N]={};
  cin>>N;
  vector<pair<int,int>> pairs_red(N);
  vector<pair<int,int>> pairs_blue(N);
  for(int i=0;i<N;++i){
    cin>>a>>b;
    pairs_red[i]=make_pair(a,b);
  }
  for(int i=0;i<N;++i){
    cin>>c>>d;
    pairs_blue[i]=make_pair(c,d);
  }
  sort(pairs_red.begin(),pairs_red.end(),compare_by_b);
  sort(pairs_blue.begin(),pairs_blue.end(),compare_by_a); 
  int red_x,red_y,blue_x,blue_y;
  int ans=0;
  for(int i=N-1;i>=0;--i){
    red_x=pairs_red[i].first;
    red_y=pairs_red[i].second;
    for(int j=0;j<N;++j){
      blue_x=pairs_blue[j].first;
      blue_y=pairs_blue[j].second;
      if(red_x<blue_x && red_y<blue_y && used[j]==0){
        ans+=1;
        used[j]=1;
        break;
      }
    }
  } 
  cout<<ans<<"\n";
return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define loop for(;;)
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;
#define inf (1e9)
#define eps (1e-9)

template<class T> inline
ostream& operator<<(ostream&os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

inline
int num_empty(vector<int>&v) {
  int ret = 0;
  for (int x: v) if (x == 0) ++ret;
  return ret;
}

inline
bool is_draw(vector<int>&v) {
  return num_empty(v) == 0;
}

inline
int is_goal(vector<int>&v) {
  for (int t=1; t<3; ++t) {
    rep (k, 3) {
      if ( v[3 * k + 0] == t
       and v[3 * k + 1] == t
       and v[3 * k + 2] == t ) return t;
      if ( v[k + 0] == t
       and v[k + 3] == t
       and v[k + 6] == t ) return t;
    }
    if (v[0] == t
      and v[4] == t
      and v[8] == t ) return t;
    if (v[2] == t
        and v[4] == t
        and v[6] == t ) return t;
  }
  return 0;
}

vector<int> empties(vector<int>&v) {
  vector<int> r;
  rep (i, 9) if (v[i] == 0) r.push_back(i);
  return r;
}

map<vector<int>, int> memo;

int search(vector<int> v, bool b) {
  if (memo.count(v) > 0) return memo[v];
  if (is_goal(v)) return memo[v] = is_goal(v);
  if (is_draw(v)) return memo[v] = 0;
  auto es = empties(v);
  int t = b ? 1 : 2;
  bool drawable = false;
  for (int e: es) {
    v[e] = t;
    int r = search(v, (not b));
    if (r == t) return memo[v] = t;
    if (r == 0) drawable = true;
    v[e] = 0;
  }
  if (drawable) return memo[v] = 0;
  return memo[v] = (3 - t);
}

int solve(string s) {
  vector<int> f(9); rep (i, 9) f[i] = s[i] == 's' ? 0 : s[i] == 'o' ? 1 : 2;
  bool b = num_empty(f) % 2 == 1; // is o's turn?
  return search(f, b);
}

int main() {
  string s;
  while (getline(cin, s)) {
    int res = solve(s);
    cout << ((res == 0) ? 'd' : (res == 1) ? 'o' : 'x') << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  int n;
  ll ans = 0;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    if ((i%3 == 0) || (i%5 == 0)) continue;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> a(N);
  vector<ll> b(N);
  vector<ll> c(N);

  for (ll i = 0; i < N; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }

  ll ans = 0;
  for (ll bit = 0; bit < (1LL<<3); bit++) {
    vector<ll> cakes;
    for (ll i = 0; i < N; i++) {
      ll tmp = 0;
      for (ll j = 0; j < 3; j++) {
        if (bit & (1LL<<j)) {
          if (j == 0) {
            tmp += -a[i];
          } else if (j == 1) {
            tmp += -b[i];
          } else {
            tmp += -c[i];
          }
        } else {
          if (j == 0) {
            tmp += a[i];
          } else if (j == 1) {
            tmp += b[i];
          } else {
            tmp += c[i];
          }
        }
      }
      cakes.push_back(tmp);
    }
    sort(cakes.begin(), cakes.end(), greater<ll>());
    ll sum = 0;
    for (ll i = 0; i < M; i++) {
      sum += cakes[i];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
  string s;
  int k;
  cin>>s>>k;
  int n=sz(s);
  vector<int> vec;
  int cnt=0;
  int now=s[0];
  for(char c:s) {
    if(c==now) cnt++;
    else {
      vec.push_back(cnt);
      now=c;
      cnt=1;
    }
  }
  vec.push_back(cnt);
  
  
  
  
  ll ans=0;
  if(s[0]!=s[n-1]) {
    for(int x:vec) ans+=(ll)x/2*k;
  }
  else {
    int m=sz(vec);
    FOR(i,1,m-2) ans+=(ll)(vec[i]/2)*k;
    ans+=(ll)((vec[0]+vec[m-1])/2)*(k-1);
    ans+=(ll)vec[0]/2+vec[m-1]/2;
    if(m==1) ans=(ll)n*k/2;
  }
  
  cout<<ans<<endl;
  //for(int x:vec) cout<<x<<endl;
}

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

int main() {
    int n;
    scanf("%d", &n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int l, r;
        scanf("%d%d", &l, &r);
        sum += r - l + 1;
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 256